Skip to content

Commit b43d643

Browse files
ademurifpistm
authored andcommitted
Define generic boards for STM32L051K(6-8) T and U variants.
1 parent 6b7e4a0 commit b43d643

File tree

6 files changed

+489
-4
lines changed

6 files changed

+489
-4
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
617617
| :green_heart: | STM32L041G6 | Generic Board | *2.4.0* | |
618618
| :green_heart: | STM32L041K6T | Generic Board | *2.0.0* | |
619619
| :green_heart: | STM32L051C6<br>STM32L051C8 | Generic Board | *2.0.0* | |
620+
| :yellow_heart: | STM32L051K6<br>STM32L051K8 | Generic Board | **2.8.0** | |
620621
| :green_heart: | STM32L052C6<br>STM32L052C8 | Generic Board | *2.4.0* | |
621622
| :green_heart: | STM32L052K6<br>STM32L052K8 | Generic Board | *2.4.0* | |
622623
| :green_heart: | STM32L052R6<br>STM32L052R8 | Generic Board | *2.4.0* | |

Diff for: boards.txt

+32
Original file line numberDiff line numberDiff line change
@@ -8562,6 +8562,38 @@ GenL0.menu.pnum.GENERIC_L051C8UX.build.board=GENERIC_L051C8UX
85628562
GenL0.menu.pnum.GENERIC_L051C8UX.build.product_line=STM32L051xx
85638563
GenL0.menu.pnum.GENERIC_L051C8UX.build.variant=STM32L0xx/L051C(6-8)(T-U)
85648564

8565+
# Generic L051K6Tx
8566+
GenL0.menu.pnum.GENERIC_L051K6TX=Generic L051K6Tx
8567+
GenL0.menu.pnum.GENERIC_L051K6TX.upload.maximum_size=32768
8568+
GenL0.menu.pnum.GENERIC_L051K6TX.upload.maximum_data_size=8192
8569+
GenL0.menu.pnum.GENERIC_L051K6TX.build.board=GENERIC_L051K6TX
8570+
GenL0.menu.pnum.GENERIC_L051K6TX.build.product_line=STM32L051xx
8571+
GenL0.menu.pnum.GENERIC_L051K6TX.build.variant=STM32L0xx/L051K(6-8)T
8572+
8573+
# Generic L051K6Ux
8574+
GenL0.menu.pnum.GENERIC_L051K6UX=Generic L051K6Ux
8575+
GenL0.menu.pnum.GENERIC_L051K6UX.upload.maximum_size=32768
8576+
GenL0.menu.pnum.GENERIC_L051K6UX.upload.maximum_data_size=8192
8577+
GenL0.menu.pnum.GENERIC_L051K6UX.build.board=GENERIC_L051K6UX
8578+
GenL0.menu.pnum.GENERIC_L051K6UX.build.product_line=STM32L051xx
8579+
GenL0.menu.pnum.GENERIC_L051K6UX.build.variant=STM32L0xx/L051K(6-8)U
8580+
8581+
# Generic L051K8Tx
8582+
GenL0.menu.pnum.GENERIC_L051K8TX=Generic L051K8Tx
8583+
GenL0.menu.pnum.GENERIC_L051K8TX.upload.maximum_size=65536
8584+
GenL0.menu.pnum.GENERIC_L051K8TX.upload.maximum_data_size=8192
8585+
GenL0.menu.pnum.GENERIC_L051K8TX.build.board=GENERIC_L051K8TX
8586+
GenL0.menu.pnum.GENERIC_L051K8TX.build.product_line=STM32L051xx
8587+
GenL0.menu.pnum.GENERIC_L051K8TX.build.variant=STM32L0xx/L051K(6-8)T
8588+
8589+
# Generic L051K8Ux
8590+
GenL0.menu.pnum.GENERIC_L051K8UX=Generic L051K8Ux
8591+
GenL0.menu.pnum.GENERIC_L051K8UX.upload.maximum_size=65536
8592+
GenL0.menu.pnum.GENERIC_L051K8UX.upload.maximum_data_size=8192
8593+
GenL0.menu.pnum.GENERIC_L051K8UX.build.board=GENERIC_L051K8UX
8594+
GenL0.menu.pnum.GENERIC_L051K8UX.build.product_line=STM32L051xx
8595+
GenL0.menu.pnum.GENERIC_L051K8UX.build.variant=STM32L0xx/L051K(6-8)U
8596+
85658597
# Generic L052C6Tx
85668598
GenL0.menu.pnum.GENERIC_L052C6TX=Generic L052C6Tx
85678599
GenL0.menu.pnum.GENERIC_L052C6TX.upload.maximum_size=32768

Diff for: variants/STM32L0xx/L051K(6-8)T/generic_clock.c

+40-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,46 @@
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+
/** Configure the main internal regulator output voltage
28+
*/
29+
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
30+
31+
/** Initializes the RCC Oscillators according to the specified parameters
32+
* in the RCC_OscInitTypeDef structure.
33+
*/
34+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
35+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
36+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
37+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
38+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
39+
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_4;
40+
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_2;
41+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
42+
Error_Handler();
43+
}
44+
45+
/** Initializes the CPU, AHB and APB buses clocks
46+
*/
47+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
48+
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
49+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
50+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
51+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
52+
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
53+
54+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
55+
Error_Handler();
56+
}
57+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_I2C1;
58+
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
59+
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
60+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
61+
Error_Handler();
62+
}
2563
}
2664

2765
#endif /* ARDUINO_GENERIC_* */

Diff for: variants/STM32L0xx/L051K(6-8)T/ldscript.ld

+188
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 STM32L051K8Tx Device from STM32L0 series
9+
** 64KBytes FLASH
10+
** 8KBytes 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+
}
188+

Diff for: variants/STM32L0xx/L051K(6-8)U/generic_clock.c

+40-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,46 @@
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+
/** Configure the main internal regulator output voltage
28+
*/
29+
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
30+
31+
/** Initializes the RCC Oscillators according to the specified parameters
32+
* in the RCC_OscInitTypeDef structure.
33+
*/
34+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
35+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
36+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
37+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
38+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
39+
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_4;
40+
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_2;
41+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
42+
Error_Handler();
43+
}
44+
45+
/** Initializes the CPU, AHB and APB buses clocks
46+
*/
47+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
48+
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
49+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
50+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
51+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
52+
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
53+
54+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
55+
Error_Handler();
56+
}
57+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_I2C1;
58+
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
59+
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
60+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
61+
Error_Handler();
62+
}
2563
}
2664

2765
#endif /* ARDUINO_GENERIC_* */

0 commit comments

Comments
 (0)