Skip to content

Commit 3d1c207

Browse files
committed
variant: f0: add F042K(4-6)T generic support
Signed-off-by: Frederic Pillon <[email protected]>
1 parent ecd67a9 commit 3d1c207

File tree

4 files changed

+238
-2
lines changed

4 files changed

+238
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
174174
| :green_heart: | STM32F030R8 | Generic Board | *2.0.0* | |
175175
| :green_heart: | STM32F031K6T | Generic Board | *2.0.0* | |
176176
| :green_heart: | STM32F042C4<br>STM32F042C6 | Generic Board | *2.0.0* | |
177+
| :yellow_heart: | STM32F042K4T<br>STM32F042K6T | Generic Board | **2.0.1** | |
177178
| :green_heart: | STM32F051K6U<br>STM32F051K8U | Generic Board | *2.0.0* | |
178179
| :green_heart: | STM32F070CB | Generic Board | *2.0.0* | |
179180
| :green_heart: | STM32F070RB | Generic Board | *2.0.0* | |

boards.txt

+16
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,22 @@ GenF0.menu.pnum.GENERIC_F042C6UX.build.board=GENERIC_F042C6UX
10321032
GenF0.menu.pnum.GENERIC_F042C6UX.build.product_line=STM32F042x6
10331033
GenF0.menu.pnum.GENERIC_F042C6UX.build.variant=STM32F0xx/F042C(4-6)(T-U)
10341034

1035+
# Generic F042K4Tx
1036+
GenF0.menu.pnum.GENERIC_F042K4TX=Generic F042K4Tx
1037+
GenF0.menu.pnum.GENERIC_F042K4TX.upload.maximum_size=16384
1038+
GenF0.menu.pnum.GENERIC_F042K4TX.upload.maximum_data_size=6144
1039+
GenF0.menu.pnum.GENERIC_F042K4TX.build.board=GENERIC_F042K4TX
1040+
GenF0.menu.pnum.GENERIC_F042K4TX.build.product_line=STM32F042x6
1041+
GenF0.menu.pnum.GENERIC_F042K4TX.build.variant=STM32F0xx/F042K(4-6)T
1042+
1043+
# Generic F042K6Tx
1044+
GenF0.menu.pnum.GENERIC_F042K6TX=Generic F042K6Tx
1045+
GenF0.menu.pnum.GENERIC_F042K6TX.upload.maximum_size=32768
1046+
GenF0.menu.pnum.GENERIC_F042K6TX.upload.maximum_data_size=6144
1047+
GenF0.menu.pnum.GENERIC_F042K6TX.build.board=GENERIC_F042K6TX
1048+
GenF0.menu.pnum.GENERIC_F042K6TX.build.product_line=STM32F042x6
1049+
GenF0.menu.pnum.GENERIC_F042K6TX.build.variant=STM32F0xx/F042K(4-6)T
1050+
10351051
# Generic F051K6Ux
10361052
GenF0.menu.pnum.GENERIC_F051K6UX=Generic F051K6Ux
10371053
GenF0.menu.pnum.GENERIC_F051K6UX.upload.maximum_size=32768

variants/STM32F0xx/F042K(4-6)T/generic_clock.c

+35-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,41 @@
2020
*/
2121
WEAK void SystemClock_Config(void)
2222
{
23-
/* SystemClock_Config can be generated by STM32CubeMX */
24-
#warning "SystemClock_Config() is empty. Default clock at reset is used."
23+
RCC_OscInitTypeDef RCC_OscInitStruct = {};
24+
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
25+
RCC_PeriphCLKInitTypeDef PeriphClkInit = {};
26+
27+
/** Initializes the RCC Oscillators according to the specified parameters
28+
* in the RCC_OscInitTypeDef structure.
29+
*/
30+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI14 | RCC_OSCILLATORTYPE_HSI48;
31+
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
32+
RCC_OscInitStruct.HSI14State = RCC_HSI14_ON;
33+
RCC_OscInitStruct.HSI14CalibrationValue = 16;
34+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
35+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
36+
Error_Handler();
37+
}
38+
/** Initializes the CPU, AHB and APB buses clocks
39+
*/
40+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
41+
| RCC_CLOCKTYPE_PCLK1;
42+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI48;
43+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
44+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
45+
46+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
47+
Error_Handler();
48+
}
49+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB | RCC_PERIPHCLK_USART1
50+
| RCC_PERIPHCLK_I2C1;
51+
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK1;
52+
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_SYSCLK;
53+
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
54+
55+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
56+
Error_Handler();
57+
}
2558
}
2659

2760
#endif /* ARDUINO_GENERIC_* */
+186
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
/*
2+
******************************************************************************
3+
**
4+
** @file : LinkerScript.ld
5+
**
6+
** @author : Auto-generated by STM32CubeIDE
7+
**
8+
** Abstract : Linker script for NUCLEO-F042K6 Board embedding STM32F042K6Tx Device from stm32f0 series
9+
** 32Kbytes FLASH
10+
** 6Kbytes 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+
** <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
26+
** All rights reserved.</center></h2>
27+
**
28+
** This software component is licensed by ST under BSD 3-Clause license,
29+
** the "License"; You may not use this file except in compliance with the
30+
** License. You may obtain a copy of the License at:
31+
** opensource.org/licenses/BSD-3-Clause
32+
**
33+
******************************************************************************
34+
*/
35+
36+
/* Entry Point */
37+
ENTRY(Reset_Handler)
38+
39+
/* Highest address of the user mode stack */
40+
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
41+
42+
_Min_Heap_Size = 0x200; /* required amount of heap */
43+
_Min_Stack_Size = 0x400; /* required amount of stack */
44+
45+
/* Memories definition */
46+
MEMORY
47+
{
48+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE
49+
FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
50+
}
51+
52+
/* Sections */
53+
SECTIONS
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 : {
90+
. = ALIGN(4);
91+
*(.ARM.extab* .gnu.linkonce.armextab.*)
92+
. = ALIGN(4);
93+
} >FLASH
94+
95+
.ARM : {
96+
. = ALIGN(4);
97+
__exidx_start = .;
98+
*(.ARM.exidx*)
99+
__exidx_end = .;
100+
. = ALIGN(4);
101+
} >FLASH
102+
103+
.preinit_array :
104+
{
105+
. = ALIGN(4);
106+
PROVIDE_HIDDEN (__preinit_array_start = .);
107+
KEEP (*(.preinit_array*))
108+
PROVIDE_HIDDEN (__preinit_array_end = .);
109+
. = ALIGN(4);
110+
} >FLASH
111+
112+
.init_array :
113+
{
114+
. = ALIGN(4);
115+
PROVIDE_HIDDEN (__init_array_start = .);
116+
KEEP (*(SORT(.init_array.*)))
117+
KEEP (*(.init_array*))
118+
PROVIDE_HIDDEN (__init_array_end = .);
119+
. = ALIGN(4);
120+
} >FLASH
121+
122+
.fini_array :
123+
{
124+
. = ALIGN(4);
125+
PROVIDE_HIDDEN (__fini_array_start = .);
126+
KEEP (*(SORT(.fini_array.*)))
127+
KEEP (*(.fini_array*))
128+
PROVIDE_HIDDEN (__fini_array_end = .);
129+
. = ALIGN(4);
130+
} >FLASH
131+
132+
/* Used by the startup to initialize data */
133+
_sidata = LOADADDR(.data);
134+
135+
/* Initialized data sections into "RAM" Ram type memory */
136+
.data :
137+
{
138+
. = ALIGN(4);
139+
_sdata = .; /* create a global symbol at data start */
140+
*(.data) /* .data sections */
141+
*(.data*) /* .data* sections */
142+
*(.RamFunc) /* .RamFunc sections */
143+
*(.RamFunc*) /* .RamFunc* sections */
144+
145+
. = ALIGN(4);
146+
_edata = .; /* define a global symbol at data end */
147+
148+
} >RAM AT> FLASH
149+
150+
/* Uninitialized data section into "RAM" Ram type memory */
151+
. = ALIGN(4);
152+
.bss :
153+
{
154+
/* This is used by the startup in order to initialize the .bss section */
155+
_sbss = .; /* define a global symbol at bss start */
156+
__bss_start__ = _sbss;
157+
*(.bss)
158+
*(.bss*)
159+
*(COMMON)
160+
161+
. = ALIGN(4);
162+
_ebss = .; /* define a global symbol at bss end */
163+
__bss_end__ = _ebss;
164+
} >RAM
165+
166+
/* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
167+
._user_heap_stack :
168+
{
169+
. = ALIGN(8);
170+
PROVIDE ( end = . );
171+
PROVIDE ( _end = . );
172+
. = . + _Min_Heap_Size;
173+
. = . + _Min_Stack_Size;
174+
. = ALIGN(8);
175+
} >RAM
176+
177+
/* Remove information from the compiler libraries */
178+
/DISCARD/ :
179+
{
180+
libc.a ( * )
181+
libm.a ( * )
182+
libgcc.a ( * )
183+
}
184+
185+
.ARM.attributes 0 : { *(.ARM.attributes) }
186+
}

0 commit comments

Comments
 (0)