Skip to content

Commit 17ce259

Browse files
committed
variant(C0): add C031C(4-6)(T-U) generic support
Note: SystemClock_Config() is based on LL to spare a maximum memory Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent 6426bf4 commit 17ce259

File tree

4 files changed

+303
-2
lines changed

4 files changed

+303
-2
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
5656
- [Discovery boards](#discovery-boards)
5757
- [Eval boards](#eval-boards)
5858
- [STM32MP1 series coprocessor boards](#stm32mp1-series-coprocessor-boards)
59+
- [Generic STM32C0 boards](#generic-stm32c0-boards)
5960
- [Generic STM32F0 boards](#generic-stm32f0-boards)
6061
- [Generic STM32F1 boards](#generic-stm32f1-boards)
6162
- [Generic STM32F2 boards](#generic-stm32f2-boards)
@@ -176,6 +177,12 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
176177
| :green_heart: | STM32MP157A | [STM32MP157A-DK1](https://www.st.com/en/evaluation-tools/stm32mp157a-dk1.html) | *1.8.0* | See [the documentation](https://github.com/stm32duino/Arduino_Core_STM32/tree/main/variants/STM32MP157_DK/README.md) to use this board|
177178
| :green_heart: | STM32MP157C | [STM32MP157C-DK2](https://www.st.com/en/evaluation-tools/stm32mp157c-dk2.html) | *1.8.0* | See [the documentation](https://github.com/stm32duino/Arduino_Core_STM32/tree/main/variants/STM32MP157_DK/README.md) to use this board|
178179

180+
### Generic STM32C0 boards
181+
182+
| Status | Device(s) | Name | Release | Notes |
183+
| :----: | :-------: | ---- | :-----: | :---- |
184+
| :yellow_heart: | STM32C031C4<br>STM32C031C6 | Generic Board | **2.5.0** | |
185+
179186
### Generic STM32F0 boards
180187

181188
| Status | Device(s) | Name | Release | Notes |

boards.txt

+92
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,60 @@ STM32MP1.menu.upload_method.MassStorage=Generate run_arduino.sh (You need to cop
10901090
STM32MP1.menu.upload_method.MassStorage.upload.protocol=
10911091
STM32MP1.menu.upload_method.MassStorage.upload.tool=remoteproc_gen
10921092

1093+
###############################
1094+
# Generic C0
1095+
GenC0.name=Generic STM32C0 series
1096+
1097+
GenC0.build.core=arduino
1098+
GenC0.build.board=GenC0
1099+
GenC0.build.mcu=cortex-m0plus
1100+
GenC0.build.series=STM32C0xx
1101+
GenC0.build.cmsis_lib_gcc=arm_cortexM0l_math
1102+
GenC0.build.extra_flags=-D{build.product_line} {build.xSerial} -D__CORTEX_SC=0
1103+
1104+
# Generic C031C4Tx
1105+
GenC0.menu.pnum.GENERIC_C031C4TX=Generic C031C4Tx
1106+
GenC0.menu.pnum.GENERIC_C031C4TX.upload.maximum_size=16384
1107+
GenC0.menu.pnum.GENERIC_C031C4TX.upload.maximum_data_size=12288
1108+
GenC0.menu.pnum.GENERIC_C031C4TX.build.board=GENERIC_C031C4TX
1109+
GenC0.menu.pnum.GENERIC_C031C4TX.build.product_line=STM32C031xx
1110+
GenC0.menu.pnum.GENERIC_C031C4TX.build.variant=STM32C0xx/C031C(4-6)(T-U)
1111+
1112+
# Generic C031C6Tx
1113+
GenC0.menu.pnum.GENERIC_C031C6TX=Generic C031C6Tx
1114+
GenC0.menu.pnum.GENERIC_C031C6TX.upload.maximum_size=32768
1115+
GenC0.menu.pnum.GENERIC_C031C6TX.upload.maximum_data_size=12288
1116+
GenC0.menu.pnum.GENERIC_C031C6TX.build.board=GENERIC_C031C6TX
1117+
GenC0.menu.pnum.GENERIC_C031C6TX.build.product_line=STM32C031xx
1118+
GenC0.menu.pnum.GENERIC_C031C6TX.build.variant=STM32C0xx/C031C(4-6)(T-U)
1119+
1120+
# Generic C031C4Ux
1121+
GenC0.menu.pnum.GENERIC_C031C4UX=Generic C031C4Ux
1122+
GenC0.menu.pnum.GENERIC_C031C4UX.upload.maximum_size=16384
1123+
GenC0.menu.pnum.GENERIC_C031C4UX.upload.maximum_data_size=12288
1124+
GenC0.menu.pnum.GENERIC_C031C4UX.build.board=GENERIC_C031C4UX
1125+
GenC0.menu.pnum.GENERIC_C031C4UX.build.product_line=STM32C031xx
1126+
GenC0.menu.pnum.GENERIC_C031C4UX.build.variant=STM32C0xx/C031C(4-6)(T-U)
1127+
1128+
# Generic C031C6Ux
1129+
GenC0.menu.pnum.GENERIC_C031C6UX=Generic C031C6Ux
1130+
GenC0.menu.pnum.GENERIC_C031C6UX.upload.maximum_size=32768
1131+
GenC0.menu.pnum.GENERIC_C031C6UX.upload.maximum_data_size=12288
1132+
GenC0.menu.pnum.GENERIC_C031C6UX.build.board=GENERIC_C031C6UX
1133+
GenC0.menu.pnum.GENERIC_C031C6UX.build.product_line=STM32C031xx
1134+
GenC0.menu.pnum.GENERIC_C031C6UX.build.variant=STM32C0xx/C031C(4-6)(T-U)
1135+
1136+
# Upload menu
1137+
GenC0.menu.upload_method.swdMethod=STM32CubeProgrammer (SWD)
1138+
GenC0.menu.upload_method.swdMethod.upload.protocol=0
1139+
GenC0.menu.upload_method.swdMethod.upload.options=-g
1140+
GenC0.menu.upload_method.swdMethod.upload.tool=stm32CubeProg
1141+
1142+
GenC0.menu.upload_method.serialMethod=STM32CubeProgrammer (Serial)
1143+
GenC0.menu.upload_method.serialMethod.upload.protocol=1
1144+
GenC0.menu.upload_method.serialMethod.upload.options={serial.port.file} -s
1145+
GenC0.menu.upload_method.serialMethod.upload.tool=stm32CubeProg
1146+
10931147
###############################
10941148
# Generic F0
10951149
GenF0.name=Generic STM32F0 series
@@ -10500,6 +10554,12 @@ STM32MP1.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NO
1050010554
STM32MP1.menu.xserial.disabled=Disabled (no Serial support)
1050110555
STM32MP1.menu.xserial.disabled.build.xSerial=
1050210556

10557+
GenC0.menu.xserial.generic=Enabled (generic 'Serial')
10558+
GenC0.menu.xserial.none=Enabled (no generic 'Serial')
10559+
GenC0.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE
10560+
GenC0.menu.xserial.disabled=Disabled (no Serial support)
10561+
GenC0.menu.xserial.disabled.build.xSerial=
10562+
1050310563
GenF0.menu.xserial.generic=Enabled (generic 'Serial')
1050410564
GenF0.menu.xserial.none=Enabled (no generic 'Serial')
1050510565
GenF0.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE
@@ -11088,6 +11148,24 @@ STM32MP1.menu.opt.ogstd.build.flags.optimize=-Og
1108811148
STM32MP1.menu.opt.o0std=No Optimization (-O0)
1108911149
STM32MP1.menu.opt.o0std.build.flags.optimize=-O0
1109011150

11151+
GenC0.menu.opt.osstd=Smallest (-Os default)
11152+
GenC0.menu.opt.oslto=Smallest (-Os) with LTO
11153+
GenC0.menu.opt.oslto.build.flags.optimize=-Os -flto
11154+
GenC0.menu.opt.o1std=Fast (-O1)
11155+
GenC0.menu.opt.o1std.build.flags.optimize=-O1
11156+
GenC0.menu.opt.o1lto=Fast (-O1) with LTO
11157+
GenC0.menu.opt.o1lto.build.flags.optimize=-O1 -flto
11158+
GenC0.menu.opt.o2std=Faster (-O2)
11159+
GenC0.menu.opt.o2std.build.flags.optimize=-O2
11160+
GenC0.menu.opt.o2lto=Faster (-O2) with LTO
11161+
GenC0.menu.opt.o2lto.build.flags.optimize=-O2 -flto
11162+
GenC0.menu.opt.o3std=Fastest (-O3)
11163+
GenC0.menu.opt.o3std.build.flags.optimize=-O3
11164+
GenC0.menu.opt.o3lto=Fastest (-O3) with LTO
11165+
GenC0.menu.opt.o3lto.build.flags.optimize=-O3 -flto
11166+
GenC0.menu.opt.ogstd=Debug (-Og)
11167+
GenC0.menu.opt.ogstd.build.flags.optimize=-Og
11168+
1109111169
GenF0.menu.opt.osstd=Smallest (-Os default)
1109211170
GenF0.menu.opt.oslto=Smallest (-Os) with LTO
1109311171
GenF0.menu.opt.oslto.build.flags.optimize=-Os -flto
@@ -11618,6 +11696,10 @@ STM32MP1.menu.dbg.enable_log.build.flags.debug=
1161811696
STM32MP1.menu.dbg.enable_all=Core Logs and Symbols Enabled (-g)
1161911697
STM32MP1.menu.dbg.enable_all.build.flags.debug=-g
1162011698

11699+
GenC0.menu.dbg.none=None
11700+
GenC0.menu.dbg.enable=Enabled (-g)
11701+
GenC0.menu.dbg.enable.build.flags.debug=-g
11702+
1162111703
GenF0.menu.dbg.none=None
1162211704
GenF0.menu.dbg.enable_sym=Symbols Enabled (-g)
1162311705
GenF0.menu.dbg.enable_sym.build.flags.debug=-g -DNDEBUG
@@ -11863,6 +11945,16 @@ STM32MP1.menu.rtlib.nanofps.build.flags.ldspecs=--specs=nano.specs -u _printf_fl
1186311945
STM32MP1.menu.rtlib.full=Newlib Standard
1186411946
STM32MP1.menu.rtlib.full.build.flags.ldspecs=
1186511947

11948+
GenC0.menu.rtlib.nano=Newlib Nano (default)
11949+
GenC0.menu.rtlib.nanofp=Newlib Nano + Float Printf
11950+
GenC0.menu.rtlib.nanofp.build.flags.ldspecs=--specs=nano.specs -u _printf_float
11951+
GenC0.menu.rtlib.nanofs=Newlib Nano + Float Scanf
11952+
GenC0.menu.rtlib.nanofs.build.flags.ldspecs=--specs=nano.specs -u _scanf_float
11953+
GenC0.menu.rtlib.nanofps=Newlib Nano + Float Printf/Scanf
11954+
GenC0.menu.rtlib.nanofps.build.flags.ldspecs=--specs=nano.specs -u _printf_float -u _scanf_float
11955+
GenC0.menu.rtlib.full=Newlib Standard
11956+
GenC0.menu.rtlib.full.build.flags.ldspecs=
11957+
1186611958
GenF0.menu.rtlib.nano=Newlib Nano (default)
1186711959
GenF0.menu.rtlib.nanofp=Newlib Nano + Float Printf
1186811960
GenF0.menu.rtlib.nanofp.build.flags.ldspecs=--specs=nano.specs -u _printf_float

variants/STM32C0xx/C031C(4-6)(T-U)/generic_clock.c

+27-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#if defined(ARDUINO_GENERIC_C031C4TX) || defined(ARDUINO_GENERIC_C031C4UX) ||\
1414
defined(ARDUINO_GENERIC_C031C6TX) || defined(ARDUINO_GENERIC_C031C6UX)
1515
#include "pins_arduino.h"
16+
#include "stm32yyxx_ll_utils.h"
1617

1718
/**
1819
* @brief System Clock Configuration
@@ -21,8 +22,32 @@
2122
*/
2223
WEAK void SystemClock_Config(void)
2324
{
24-
/* SystemClock_Config can be generated by STM32CubeMX */
25-
#warning "SystemClock_Config() is empty. Default clock at reset is used."
25+
LL_FLASH_SetLatency(LL_FLASH_LATENCY_1);
26+
27+
/* HSI configuration and activation */
28+
LL_RCC_HSI_Enable();
29+
while (LL_RCC_HSI_IsReady() != 1) {
30+
}
31+
32+
LL_RCC_HSI_SetCalibTrimming(64);
33+
LL_RCC_SetHSIDiv(LL_RCC_HSI_DIV_1);
34+
/* Set AHB prescaler*/
35+
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
36+
37+
/* Sysclk activation on the HSI */
38+
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI);
39+
while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI) {
40+
}
41+
42+
/* Set APB1 prescaler*/
43+
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
44+
/* Update CMSIS variable (which can be updated also through SystemCoreClockUpdate function) */
45+
LL_SetSystemCoreClock(48000000);
46+
47+
/* Update the time base */
48+
if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) {
49+
Error_Handler();
50+
}
2651
}
2752

2853
#endif /* ARDUINO_GENERIC_* */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
/**
2+
******************************************************************************
3+
* @file LinkerScript.ld
4+
* @author Auto-generated by STM32CubeIDE
5+
* Abstract : Linker script for STM32C031CxTx Device from stm32c0 series
6+
* 32Kbytes FLASH
7+
* 12Kbytes RAM
8+
*
9+
* Set heap size, stack size and stack location according
10+
* to application requirements.
11+
*
12+
* Set memory bank area and size if external memory is used
13+
******************************************************************************
14+
* @attention
15+
*
16+
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
17+
* All rights reserved.</center></h2>
18+
*
19+
* This software component is licensed by ST under BSD 3-Clause license,
20+
* the "License"; You may not use this file except in compliance with the
21+
* License. You may obtain a copy of the License at:
22+
* opensource.org/licenses/BSD-3-Clause
23+
*
24+
******************************************************************************
25+
*/
26+
27+
/* Entry Point */
28+
ENTRY(Reset_Handler)
29+
30+
/* Highest address of the user mode stack */
31+
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
32+
33+
_Min_Heap_Size = 0x200; /* required amount of heap */
34+
_Min_Stack_Size = 0x400; /* required amount of stack */
35+
36+
/* Memories definition */
37+
MEMORY
38+
{
39+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE
40+
FLASH (rx) : ORIGIN = 0x8000000+ LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
41+
}
42+
43+
/* Sections */
44+
SECTIONS
45+
{
46+
/* The startup code into "FLASH" Rom type memory */
47+
.isr_vector :
48+
{
49+
. = ALIGN(4);
50+
KEEP(*(.isr_vector)) /* Startup code */
51+
. = ALIGN(4);
52+
} >FLASH
53+
54+
/* The program code and other data into "FLASH" Rom type memory */
55+
.text :
56+
{
57+
. = ALIGN(4);
58+
*(.text) /* .text sections (code) */
59+
*(.text*) /* .text* sections (code) */
60+
*(.glue_7) /* glue arm to thumb code */
61+
*(.glue_7t) /* glue thumb to arm code */
62+
*(.eh_frame)
63+
64+
KEEP (*(.init))
65+
KEEP (*(.fini))
66+
67+
. = ALIGN(4);
68+
_etext = .; /* define a global symbols at end of code */
69+
} >FLASH
70+
71+
/* Constant data into "FLASH" Rom type memory */
72+
.rodata :
73+
{
74+
. = ALIGN(4);
75+
*(.rodata) /* .rodata sections (constants, strings, etc.) */
76+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
77+
. = ALIGN(4);
78+
} >FLASH
79+
80+
.ARM.extab : {
81+
. = ALIGN(4);
82+
*(.ARM.extab* .gnu.linkonce.armextab.*)
83+
. = ALIGN(4);
84+
} >FLASH
85+
86+
.ARM : {
87+
. = ALIGN(4);
88+
__exidx_start = .;
89+
*(.ARM.exidx*)
90+
__exidx_end = .;
91+
. = ALIGN(4);
92+
} >FLASH
93+
94+
.preinit_array :
95+
{
96+
. = ALIGN(4);
97+
PROVIDE_HIDDEN (__preinit_array_start = .);
98+
KEEP (*(.preinit_array*))
99+
PROVIDE_HIDDEN (__preinit_array_end = .);
100+
. = ALIGN(4);
101+
} >FLASH
102+
103+
.init_array :
104+
{
105+
. = ALIGN(4);
106+
PROVIDE_HIDDEN (__init_array_start = .);
107+
KEEP (*(SORT(.init_array.*)))
108+
KEEP (*(.init_array*))
109+
PROVIDE_HIDDEN (__init_array_end = .);
110+
. = ALIGN(4);
111+
} >FLASH
112+
113+
.fini_array :
114+
{
115+
. = ALIGN(4);
116+
PROVIDE_HIDDEN (__fini_array_start = .);
117+
KEEP (*(SORT(.fini_array.*)))
118+
KEEP (*(.fini_array*))
119+
PROVIDE_HIDDEN (__fini_array_end = .);
120+
. = ALIGN(4);
121+
} >FLASH
122+
123+
/* Used by the startup to initialize data */
124+
_sidata = LOADADDR(.data);
125+
126+
/* Initialized data sections into "RAM" Ram type memory */
127+
.data :
128+
{
129+
. = ALIGN(4);
130+
_sdata = .; /* create a global symbol at data start */
131+
*(.data) /* .data sections */
132+
*(.data*) /* .data* sections */
133+
*(.RamFunc) /* .RamFunc sections */
134+
*(.RamFunc*) /* .RamFunc* sections */
135+
136+
. = ALIGN(4);
137+
_edata = .; /* define a global symbol at data end */
138+
139+
} >RAM AT> FLASH
140+
141+
/* Uninitialized data section into "RAM" Ram type memory */
142+
. = ALIGN(4);
143+
.bss :
144+
{
145+
/* This is used by the startup in order to initialize the .bss section */
146+
_sbss = .; /* define a global symbol at bss start */
147+
__bss_start__ = _sbss;
148+
*(.bss)
149+
*(.bss*)
150+
*(COMMON)
151+
152+
. = ALIGN(4);
153+
_ebss = .; /* define a global symbol at bss end */
154+
__bss_end__ = _ebss;
155+
} >RAM
156+
157+
/* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
158+
._user_heap_stack :
159+
{
160+
. = ALIGN(8);
161+
PROVIDE ( end = . );
162+
PROVIDE ( _end = . );
163+
. = . + _Min_Heap_Size;
164+
. = . + _Min_Stack_Size;
165+
. = ALIGN(8);
166+
} >RAM
167+
168+
/* Remove information from the compiler libraries */
169+
/DISCARD/ :
170+
{
171+
libc.a ( * )
172+
libm.a ( * )
173+
libgcc.a ( * )
174+
}
175+
176+
.ARM.attributes 0 : { *(.ARM.attributes) }
177+
}

0 commit comments

Comments
 (0)