Skip to content

Commit c1ee060

Browse files
authored
Merge pull request #2791 from nessotrin/main
Fix build for STM32C051xx boards
2 parents 07e97a5 + a27d6c8 commit c1ee060

File tree

5 files changed

+261
-5
lines changed

5 files changed

+261
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
229229
| :green_heart: | STM32C011J4<br>STM32C011J6 | Generic Board | *2.8.0* | |
230230
| :green_heart: | STM32C031C4<br>STM32C031C6 | Generic Board | *2.5.0* | |
231231
| :green_heart: | STM32C031F4<br>STM32C031F6 | Generic Board | *2.6.0* | |
232+
| :yellow_heart: | STM32C051C6<br>STM32C051C8 | Generic Board | **2.12.0** | |
232233
| :green_heart: | STM32C071G8<br>STM32C071GB | Generic Board | *2.11.0* | |
233234
| :green_heart: | STM32C071R8<br>STM32C071RB | Generic Board | *2.9.0* | |
234235
| :yellow_heart: | STM32C092CB<br>STM32C092CC| Generic Board | **2.12.0** | STM32C092CBT since 2.11.0 |

boards.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,6 +1882,42 @@ GenC0.menu.pnum.GENERIC_C031F6PX.build.product_line=STM32C031xx
18821882
GenC0.menu.pnum.GENERIC_C031F6PX.build.variant=STM32C0xx/C031F(4-6)P
18831883
GenC0.menu.pnum.GENERIC_C031F6PX.debug.svd_file={runtime.tools.STM32_SVD.path}/svd/STM32C0xx/STM32C031.svd
18841884

1885+
# Generic C051C6Tx
1886+
GenC0.menu.pnum.GENERIC_C051C6TX=Generic C051C6Tx
1887+
GenC0.menu.pnum.GENERIC_C051C6TX.upload.maximum_size=32768
1888+
GenC0.menu.pnum.GENERIC_C051C6TX.upload.maximum_data_size=12288
1889+
GenC0.menu.pnum.GENERIC_C051C6TX.build.board=GENERIC_C051C6TX
1890+
GenC0.menu.pnum.GENERIC_C051C6TX.build.product_line=STM32C051xx
1891+
GenC0.menu.pnum.GENERIC_C051C6TX.build.variant=STM32C0xx/C051C(6-8)(T-U)
1892+
GenC0.menu.pnum.GENERIC_C051C6TX.debug.svd_file={runtime.tools.STM32_SVD.path}/svd/STM32C0xx/STM32C051.svd
1893+
1894+
# Generic C051C6Ux
1895+
GenC0.menu.pnum.GENERIC_C051C6UX=Generic C051C6Ux
1896+
GenC0.menu.pnum.GENERIC_C051C6UX.upload.maximum_size=32768
1897+
GenC0.menu.pnum.GENERIC_C051C6UX.upload.maximum_data_size=12288
1898+
GenC0.menu.pnum.GENERIC_C051C6UX.build.board=GENERIC_C051C6UX
1899+
GenC0.menu.pnum.GENERIC_C051C6UX.build.product_line=STM32C051xx
1900+
GenC0.menu.pnum.GENERIC_C051C6UX.build.variant=STM32C0xx/C051C(6-8)(T-U)
1901+
GenC0.menu.pnum.GENERIC_C051C6UX.debug.svd_file={runtime.tools.STM32_SVD.path}/svd/STM32C0xx/STM32C051.svd
1902+
1903+
# Generic C051C8Tx
1904+
GenC0.menu.pnum.GENERIC_C051C8TX=Generic C051C8Tx
1905+
GenC0.menu.pnum.GENERIC_C051C8TX.upload.maximum_size=65536
1906+
GenC0.menu.pnum.GENERIC_C051C8TX.upload.maximum_data_size=12288
1907+
GenC0.menu.pnum.GENERIC_C051C8TX.build.board=GENERIC_C051C8TX
1908+
GenC0.menu.pnum.GENERIC_C051C8TX.build.product_line=STM32C051xx
1909+
GenC0.menu.pnum.GENERIC_C051C8TX.build.variant=STM32C0xx/C051C(6-8)(T-U)
1910+
GenC0.menu.pnum.GENERIC_C051C8TX.debug.svd_file={runtime.tools.STM32_SVD.path}/svd/STM32C0xx/STM32C051.svd
1911+
1912+
# Generic C051C8Ux
1913+
GenC0.menu.pnum.GENERIC_C051C8UX=Generic C051C8Ux
1914+
GenC0.menu.pnum.GENERIC_C051C8UX.upload.maximum_size=65536
1915+
GenC0.menu.pnum.GENERIC_C051C8UX.upload.maximum_data_size=12288
1916+
GenC0.menu.pnum.GENERIC_C051C8UX.build.board=GENERIC_C051C8UX
1917+
GenC0.menu.pnum.GENERIC_C051C8UX.build.product_line=STM32C051xx
1918+
GenC0.menu.pnum.GENERIC_C051C8UX.build.variant=STM32C0xx/C051C(6-8)(T-U)
1919+
GenC0.menu.pnum.GENERIC_C051C8UX.debug.svd_file={runtime.tools.STM32_SVD.path}/svd/STM32C0xx/STM32C051.svd
1920+
18851921
# Generic C071G8Ux
18861922
GenC0.menu.pnum.GENERIC_C071G8UX=Generic C071G8Ux
18871923
GenC0.menu.pnum.GENERIC_C071G8UX.upload.maximum_size=65536

libraries/SrcWrapper/inc/stm32_def.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,14 @@ __STATIC_INLINE void LL_RTC_SetBinMixBCDU(RTC_TypeDef *RTCx, uint32_t BinMixBcdU
222222
#define GPIO_AF1_SPI1 STM_PIN_AFNUM_MASK
223223
#endif
224224

225-
#if defined(STM32C0xx) && defined(USART3) && !defined(GPIO_AF7_USART3)
226-
#define GPIO_AF7_USART3 ((uint8_t)0x07)
227-
#endif // STM32C0xx && !defined(USART3)
225+
#if defined(STM32C0xx)
226+
#if defined(USART3) && !defined(GPIO_AF7_USART3)
227+
#define GPIO_AF7_USART3 ((uint8_t)0x07)
228+
#endif /* USART3 & !GPIO_AF7_USART3*/
229+
#if defined(STM32C051xx) && !defined(GPIO_AF0_USART2)
230+
#define GPIO_AF0_USART2 ((uint8_t)0x00)
231+
#endif
232+
#endif // STM32C0xx
228233

229234
#if defined(STM32WBAxx) && defined(USB_OTG_HS) && !defined(GPIO_AF4_USB_OTG_HS)
230235
#define GPIO_AF4_USB_OTG_HS GPIO_AF4_OTG_HS

variants/STM32C0xx/C051C(6-8)(T-U)/generic_clock.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,34 @@
2121
*/
2222
WEAK void SystemClock_Config(void)
2323
{
24-
/* SystemClock_Config can be generated by STM32CubeMX */
25-
#warning "SystemClock_Config() is empty. Default clock at reset is used."
24+
RCC_OscInitTypeDef RCC_OscInitStruct = {};
25+
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
26+
27+
__HAL_FLASH_SET_LATENCY(FLASH_LATENCY_1);
28+
29+
/** Initializes the RCC Oscillators according to the specified parameters
30+
* in the RCC_OscInitTypeDef structure.
31+
*/
32+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
33+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
34+
RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1;
35+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
36+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
37+
Error_Handler();
38+
}
39+
40+
/** Initializes the CPU, AHB and APB buses clocks
41+
*/
42+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
43+
| RCC_CLOCKTYPE_PCLK1;
44+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
45+
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
46+
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1;
47+
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV1;
48+
49+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
50+
Error_Handler();
51+
}
2652
}
2753

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

0 commit comments

Comments
 (0)