|
62 | 62 | #define FLASH_SIZE_MAX_G0B_C (512U * 1024U) // 512kiB |
63 | 63 | #define FLASH_SIZE_MAX_C01 (32U * 1024U) // 32kiB |
64 | 64 | #define FLASH_SIZE_MAX_C03 (32U * 1024U) // 32kiB |
| 65 | +#define FLASH_SIZE_MAX_C05 (64U * 1024U) // 64kiB |
| 66 | +#define FLASH_SIZE_MAX_C07 (128U * 1024U) // 128kiB |
| 67 | +#define FLASH_SIZE_MAX_C09 (256U * 1024U) // 256kiB |
65 | 68 |
|
66 | 69 | #define STM32G0_FLASH_PAGE_SIZE 0x800U |
67 | 70 | #define STM32G0_FLASH_BANK2_START_PAGE 256U |
|
128 | 131 | #define STM32G0_FPEC_OPTION_KEY2 0x4c5d6e7fU |
129 | 132 | #define STM32G0_FPEC_OPTION_RDP_MASK 0xffU |
130 | 133 | #define STM32G0x1_FPEC_OPTION_DEFAULT 0xfffffeaaU |
131 | | -#define STM32C0x1_FPEC_OPTION_DEFAULT 0xffffffaaU |
| 134 | +#define STM32C0x1_FPEC_OPTION_DEFAULT 0x3fffffaaU |
132 | 135 |
|
133 | 136 | #define STM32G0_SRAM_BASE 0x20000000U |
134 | 137 | #define STM32G03_4_SRAM_SIZE (8U * 1024U) // 8kiB |
135 | 138 | #define STM32G05_6_SRAM_SIZE (18U * 1024U) // 18kiB |
136 | 139 | #define STM32G07_8_SRAM_SIZE (36U * 1024U) // 36kiB |
137 | 140 | #define STM32G0B_C_SRAM_SIZE (144U * 1024U) // 144kiB |
138 | 141 |
|
139 | | -#define STM32C01_SRAM_SIZE (6U * 1024U) // 6kiB |
140 | | -#define STM32C03_SRAM_SIZE (12U * 1024U) // 12kiB |
| 142 | +#define STM32C01_SRAM_SIZE (6U * 1024U) // 6kiB |
| 143 | +#define STM32C03_SRAM_SIZE (12U * 1024U) // 12kiB |
| 144 | +#define STM32C05_SRAM_SIZE (12U * 1024U) // 12kiB |
| 145 | +#define STM32C07_SRAM_SIZE (24U * 1024U) // 24kiB |
| 146 | +#define STM32C091_SRAM_SIZE (36U * 1024U) // 36kiB |
| 147 | +#define STM32C092_SRAM_SIZE (30U * 1024U) // 30kiB |
141 | 148 |
|
142 | 149 | #define STM32U031_SRAM_SIZE (12U * 1024U) // 12kiB |
143 | 150 | #define STM32U0x3_SRAM_SIZE (40U * 1024U) // 40kiB |
|
166 | 173 | * The underscores in these definitions represent /'s, this means |
167 | 174 | * that STM32G03_4 is supposed to refer to the G03/4 aka the G03 and G04. |
168 | 175 | */ |
| 176 | +/* RM0490 §30.10.1 p1009 */ |
169 | 177 | #define ID_STM32C011 0x443U |
170 | 178 | #define ID_STM32C031 0x453U |
| 179 | +#define ID_STM32C051 0x44CU |
| 180 | +#define ID_STM32C071 0x493U |
| 181 | +#define ID_STM32C09x 0x44DU /* STM32C091/092 */ |
171 | 182 | #define ID_STM32G03_4 0x466U |
172 | 183 | #define ID_STM32G05_6 0x456U |
173 | 184 | #define ID_STM32G07_8 0x460U |
@@ -207,7 +218,7 @@ typedef struct stm32g0_option_register { |
207 | 218 | * 1101 1111 1111 1111 1110 0001 1010 1010 |
208 | 219 | * *IRHEN * ****BOREN |
209 | 220 | * C0x1: OPTR = FFFFFFAA |
210 | | - * 1111 1111 1111 1111 1111 1111 1010 1010 |
| 221 | + * 0011 1111 1111 1111 1111 1111 1010 1010 |
211 | 222 | * *BOREN |
212 | 223 | * IRH and BOR are reserved on G0x0, it is safe to apply G0x1 options on G0x0. |
213 | 224 | * The same for PCROP and SECR. |
@@ -328,6 +339,25 @@ bool stm32g0_probe(target_s *const target) |
328 | 339 | } |
329 | 340 | target->part_id = dev_id; |
330 | 341 | break; |
| 342 | + case ID_STM32C051: |
| 343 | + /* SRAM 12kiB, Flash up to 64kiB */ |
| 344 | + ram_size = STM32C05_SRAM_SIZE; |
| 345 | + flash_size = FLASH_SIZE_MAX_C05; |
| 346 | + target->driver = "STM32C051"; |
| 347 | + break; |
| 348 | + case ID_STM32C071: |
| 349 | + /* SRAM 24kiB, Flash up to 128kiB */ |
| 350 | + ram_size = STM32C07_SRAM_SIZE; |
| 351 | + flash_size = FLASH_SIZE_MAX_C07; |
| 352 | + target->driver = "STM32C071"; |
| 353 | + break; |
| 354 | + case ID_STM32C09x: |
| 355 | + /* TODO: determine how to tell C091 and C092 apart here */ |
| 356 | + /* SRAM 30/36kiB, Flash up to 256kiB */ |
| 357 | + ram_size = STM32C091_SRAM_SIZE; |
| 358 | + flash_size = FLASH_SIZE_MAX_C09; |
| 359 | + target->driver = "STM32C09x"; |
| 360 | + break; |
331 | 361 | case ID_STM32G05_6: |
332 | 362 | /* SRAM 18kiB, Flash up to 64kiB */ |
333 | 363 | ram_size = STM32G05_6_SRAM_SIZE; |
@@ -701,7 +731,8 @@ static bool stm32g0_cmd_option(target_s *const target, const int argc, const cha |
701 | 731 | stm32g0_option_register_s options_req[OPT_REG_COUNT] = {{0}}; |
702 | 732 |
|
703 | 733 | if (argc == 2 && strcasecmp(argv[1], "erase") == 0) { |
704 | | - if (target->part_id == ID_STM32C011 || target->part_id == ID_STM32C031) |
| 734 | + if (target->part_id == ID_STM32C011 || target->part_id == ID_STM32C031 || target->part_id == ID_STM32C051 || |
| 735 | + target->part_id == ID_STM32C071 || target->part_id == ID_STM32C09x) |
705 | 736 | stm32g0_options_def[OPT_REG_OPTR].val = STM32C0x1_FPEC_OPTION_DEFAULT; |
706 | 737 | if (!stm32g0_option_write(target, stm32g0_options_def)) |
707 | 738 | goto exit_error; |
@@ -737,6 +768,9 @@ static bool stm32g0_cmd_uid(target_s *const target, const int argc, const char * |
737 | 768 | switch (target->part_id) { |
738 | 769 | case ID_STM32C011: |
739 | 770 | case ID_STM32C031: |
| 771 | + case ID_STM32C051: |
| 772 | + case ID_STM32C071: |
| 773 | + case ID_STM32C09x: |
740 | 774 | uid_base = STM32C0_UID_BASE; |
741 | 775 | break; |
742 | 776 | case ID_STM32U031: |
|
0 commit comments