Skip to content

Commit e581c5c

Browse files
thernstigfpistm
authored andcommitted
feat: Generic variant C071RBTx support
Fixes #2536 Signed-off-by: thernstig <[email protected]>
1 parent c43d779 commit e581c5c

File tree

4 files changed

+231
-2
lines changed

4 files changed

+231
-2
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
214214
| :green_heart: | STM32C011J4<br>STM32C011J6 | Generic Board | *2.8.0* | |
215215
| :green_heart: | STM32C031C4<br>STM32C031C6 | Generic Board | *2.5.0* | |
216216
| :green_heart: | STM32C031F4<br>STM32C031F6 | Generic Board | *2.6.0* | |
217+
| :yellow_heart: | STM32C071R8<br>STM32C071RB | Generic Board | **2.9.0** | |
217218

218219
### Generic STM32F0 boards
219220

Diff for: boards.txt

+16
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,22 @@ GenC0.menu.pnum.GENERIC_C031F6PX.build.product_line=STM32C031xx
16681668
GenC0.menu.pnum.GENERIC_C031F6PX.build.variant=STM32C0xx/C011D6Y_C011F(4-6)(P-U)_C031F(4-6)P
16691669
GenC0.menu.pnum.GENERIC_C031F6PX.debug.svd_file={runtime.tools.STM32_SVD.path}/svd/STM32C0xx/STM32C031.svd
16701670

1671+
# Generic C071R8Tx
1672+
GenC0.menu.pnum.GENERIC_C071R8TX=Generic C071R8Tx
1673+
GenC0.menu.pnum.GENERIC_C071R8TX.upload.maximum_size=65536
1674+
GenC0.menu.pnum.GENERIC_C071R8TX.upload.maximum_data_size=24576
1675+
GenC0.menu.pnum.GENERIC_C071R8TX.build.board=GENERIC_C071R8TX
1676+
GenC0.menu.pnum.GENERIC_C071R8TX.build.product_line=STM32C071xx
1677+
GenC0.menu.pnum.GENERIC_C071R8TX.build.variant=STM32C0xx/C071R(8-B)T
1678+
1679+
# Generic C071RBTx
1680+
GenC0.menu.pnum.GENERIC_C071RBTX=Generic C071RBTx
1681+
GenC0.menu.pnum.GENERIC_C071RBTX.upload.maximum_size=131072
1682+
GenC0.menu.pnum.GENERIC_C071RBTX.upload.maximum_data_size=24576
1683+
GenC0.menu.pnum.GENERIC_C071RBTX.build.board=GENERIC_C071RBTX
1684+
GenC0.menu.pnum.GENERIC_C071RBTX.build.product_line=STM32C071xx
1685+
GenC0.menu.pnum.GENERIC_C071RBTX.build.variant=STM32C0xx/C071R(8-B)T
1686+
16711687
# Upload menu
16721688
GenC0.menu.upload_method.swdMethod=STM32CubeProgrammer (SWD)
16731689
GenC0.menu.upload_method.swdMethod.upload.protocol=swd

Diff for: variants/STM32C0xx/C071R(8-B)T/generic_clock.c

+27-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
#if defined(ARDUINO_GENERIC_C071R8TX) || defined(ARDUINO_GENERIC_C071RBTX)
1414
#include "pins_arduino.h"
15+
#include "stm32yyxx_ll_utils.h"
1516

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

2752
#endif /* ARDUINO_GENERIC_* */

Diff for: variants/STM32C0xx/C071R(8-B)T/ldscript.ld

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
/*
2+
******************************************************************************
3+
**
4+
** @file : LinkerScript.ld
5+
**
6+
** @author : Auto-generated by STM32CubeIDE
7+
**
8+
** @brief : Linker script for STM32C071RBTx Device from STM32C0 series
9+
** 128KBytes FLASH
10+
** 24KBytes 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) 2024 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+
/* The startup code into "FLASH" Rom type memory */
55+
.isr_vector :
56+
{
57+
. = ALIGN(4);
58+
KEEP(*(.isr_vector)) /* Startup code */
59+
. = ALIGN(4);
60+
} >FLASH
61+
62+
/* The program code and other data into "FLASH" Rom type memory */
63+
.text :
64+
{
65+
. = ALIGN(4);
66+
*(.text) /* .text sections (code) */
67+
*(.text*) /* .text* sections (code) */
68+
*(.glue_7) /* glue arm to thumb code */
69+
*(.glue_7t) /* glue thumb to arm code */
70+
*(.eh_frame)
71+
72+
KEEP (*(.init))
73+
KEEP (*(.fini))
74+
75+
. = ALIGN(4);
76+
_etext = .; /* define a global symbols at end of code */
77+
} >FLASH
78+
79+
/* Constant data into "FLASH" Rom type memory */
80+
.rodata :
81+
{
82+
. = ALIGN(4);
83+
*(.rodata) /* .rodata sections (constants, strings, etc.) */
84+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
85+
. = ALIGN(4);
86+
} >FLASH
87+
88+
.ARM.extab (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
89+
{
90+
. = ALIGN(4);
91+
*(.ARM.extab* .gnu.linkonce.armextab.*)
92+
. = ALIGN(4);
93+
} >FLASH
94+
95+
.ARM (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
96+
{
97+
. = ALIGN(4);
98+
__exidx_start = .;
99+
*(.ARM.exidx*)
100+
__exidx_end = .;
101+
. = ALIGN(4);
102+
} >FLASH
103+
104+
.preinit_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
105+
{
106+
. = ALIGN(4);
107+
PROVIDE_HIDDEN (__preinit_array_start = .);
108+
KEEP (*(.preinit_array*))
109+
PROVIDE_HIDDEN (__preinit_array_end = .);
110+
. = ALIGN(4);
111+
} >FLASH
112+
113+
.init_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
114+
{
115+
. = ALIGN(4);
116+
PROVIDE_HIDDEN (__init_array_start = .);
117+
KEEP (*(SORT(.init_array.*)))
118+
KEEP (*(.init_array*))
119+
PROVIDE_HIDDEN (__init_array_end = .);
120+
. = ALIGN(4);
121+
} >FLASH
122+
123+
.fini_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
124+
{
125+
. = ALIGN(4);
126+
PROVIDE_HIDDEN (__fini_array_start = .);
127+
KEEP (*(SORT(.fini_array.*)))
128+
KEEP (*(.fini_array*))
129+
PROVIDE_HIDDEN (__fini_array_end = .);
130+
. = ALIGN(4);
131+
} >FLASH
132+
133+
/* Used by the startup to initialize data */
134+
_sidata = LOADADDR(.data);
135+
136+
/* Initialized data sections into "RAM" Ram type memory */
137+
.data :
138+
{
139+
. = ALIGN(4);
140+
_sdata = .; /* create a global symbol at data start */
141+
*(.data) /* .data sections */
142+
*(.data*) /* .data* sections */
143+
*(.RamFunc) /* .RamFunc sections */
144+
*(.RamFunc*) /* .RamFunc* sections */
145+
146+
. = ALIGN(4);
147+
_edata = .; /* define a global symbol at data end */
148+
149+
} >RAM AT> FLASH
150+
151+
/* Uninitialized data section into "RAM" Ram type memory */
152+
. = ALIGN(4);
153+
.bss :
154+
{
155+
/* This is used by the startup in order to initialize the .bss section */
156+
_sbss = .; /* define a global symbol at bss start */
157+
__bss_start__ = _sbss;
158+
*(.bss)
159+
*(.bss*)
160+
*(COMMON)
161+
162+
. = ALIGN(4);
163+
_ebss = .; /* define a global symbol at bss end */
164+
__bss_end__ = _ebss;
165+
} >RAM
166+
167+
/* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
168+
._user_heap_stack :
169+
{
170+
. = ALIGN(8);
171+
PROVIDE ( end = . );
172+
PROVIDE ( _end = . );
173+
. = . + _Min_Heap_Size;
174+
. = . + _Min_Stack_Size;
175+
. = ALIGN(8);
176+
} >RAM
177+
178+
/* Remove information from the compiler libraries */
179+
/DISCARD/ :
180+
{
181+
libc.a ( * )
182+
libm.a ( * )
183+
libgcc.a ( * )
184+
}
185+
186+
.ARM.attributes 0 : { *(.ARM.attributes) }
187+
}

0 commit comments

Comments
 (0)