Skip to content

Commit 35ed185

Browse files
committed
variant(c0): add generic C031K4, and C031K6
Fixes #3087. Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 175df77 commit 35ed185

4 files changed

Lines changed: 252 additions & 2 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
238238
| :green_heart: | STM32C011J4<br>STM32C011J6 | Generic Board | *2.8.0* | |
239239
| :green_heart: | STM32C031C4<br>STM32C031C6 | Generic Board | *2.5.0* | |
240240
| :green_heart: | STM32C031F4<br>STM32C031F6 | Generic Board | *2.6.0* | |
241+
| :yellow_heart: | STM32C031K4<br>STM32C031K6 | Generic Board | **3.0.1** | |
241242
| :green_heart: | STM32C051C6<br>STM32C051C8 | Generic Board | *2.12.0* | |
242243
| :green_heart: | STM32C071G8<br>STM32C071GB | Generic Board | *2.11.0* | |
243244
| :green_heart: | STM32C071R8<br>STM32C071RB | Generic Board | *2.9.0* | |

‎boards.txt‎

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

2031+
# Generic C031K4Tx
2032+
GenC0.menu.pnum.GENERIC_C031K4TX=Generic C031K4Tx
2033+
GenC0.menu.pnum.GENERIC_C031K4TX.upload.maximum_size=16384
2034+
GenC0.menu.pnum.GENERIC_C031K4TX.upload.maximum_data_size=12288
2035+
GenC0.menu.pnum.GENERIC_C031K4TX.build.board=GENERIC_C031K4TX
2036+
GenC0.menu.pnum.GENERIC_C031K4TX.build.product_line=STM32C031xx
2037+
GenC0.menu.pnum.GENERIC_C031K4TX.build.variant=STM32C0xx/C031K(4-6)(T-U)
2038+
GenC0.menu.pnum.GENERIC_C031K4TX.debug.svd_file={runtime.tools.STM32_SVD.path}/svd/STM32C0xx/STM32C031.svd
2039+
2040+
# Generic C031K6Tx
2041+
GenC0.menu.pnum.GENERIC_C031K6TX=Generic C031K6Tx
2042+
GenC0.menu.pnum.GENERIC_C031K6TX.upload.maximum_size=32768
2043+
GenC0.menu.pnum.GENERIC_C031K6TX.upload.maximum_data_size=12288
2044+
GenC0.menu.pnum.GENERIC_C031K6TX.build.board=GENERIC_C031K6TX
2045+
GenC0.menu.pnum.GENERIC_C031K6TX.build.product_line=STM32C031xx
2046+
GenC0.menu.pnum.GENERIC_C031K6TX.build.variant=STM32C0xx/C031K(4-6)(T-U)
2047+
GenC0.menu.pnum.GENERIC_C031K6TX.debug.svd_file={runtime.tools.STM32_SVD.path}/svd/STM32C0xx/STM32C031.svd
2048+
2049+
# Generic C031K4Ux
2050+
GenC0.menu.pnum.GENERIC_C031K4UX=Generic C031K4Ux
2051+
GenC0.menu.pnum.GENERIC_C031K4UX.upload.maximum_size=16384
2052+
GenC0.menu.pnum.GENERIC_C031K4UX.upload.maximum_data_size=12288
2053+
GenC0.menu.pnum.GENERIC_C031K4UX.build.board=GENERIC_C031K4UX
2054+
GenC0.menu.pnum.GENERIC_C031K4UX.build.product_line=STM32C031xx
2055+
GenC0.menu.pnum.GENERIC_C031K4UX.build.variant=STM32C0xx/C031K(4-6)(T-U)
2056+
GenC0.menu.pnum.GENERIC_C031K4UX.debug.svd_file={runtime.tools.STM32_SVD.path}/svd/STM32C0xx/STM32C031.svd
2057+
2058+
# Generic C031K6Ux
2059+
GenC0.menu.pnum.GENERIC_C031K6UX=Generic C031K6Ux
2060+
GenC0.menu.pnum.GENERIC_C031K6UX.upload.maximum_size=32768
2061+
GenC0.menu.pnum.GENERIC_C031K6UX.upload.maximum_data_size=12288
2062+
GenC0.menu.pnum.GENERIC_C031K6UX.build.board=GENERIC_C031K6UX
2063+
GenC0.menu.pnum.GENERIC_C031K6UX.build.product_line=STM32C031xx
2064+
GenC0.menu.pnum.GENERIC_C031K6UX.build.variant=STM32C0xx/C031K(4-6)(T-U)
2065+
GenC0.menu.pnum.GENERIC_C031K6UX.debug.svd_file={runtime.tools.STM32_SVD.path}/svd/STM32C0xx/STM32C031.svd
2066+
20312067
# Generic C051C6Tx
20322068
GenC0.menu.pnum.GENERIC_C051C6TX=Generic C051C6Tx
20332069
GenC0.menu.pnum.GENERIC_C051C6TX.upload.maximum_size=32768

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#if defined(ARDUINO_GENERIC_C031K4TX) || defined(ARDUINO_GENERIC_C031K4UX) ||\
1414
defined(ARDUINO_GENERIC_C031K6TX) || defined(ARDUINO_GENERIC_C031K6UX)
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_HCLK_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_* */
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 STM32C031K6Tx Device from STM32C0 series
9+
** 32KBytes 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) 2026 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 = LD_MAX_DATA_SIZE
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)