Skip to content

Commit 451a6b2

Browse files
committed
[G4] Add Nucleo-G431RB support
Signed-off-by: Frederic.Pillon <[email protected]>
1 parent 8ebe376 commit 451a6b2

File tree

7 files changed

+860
-0
lines changed

7 files changed

+860
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
6262
| :green_heart: | [Nucleo F411RE](http://www.st.com/en/evaluation-tools/nucleo-f411re.html) | *0.2.1* | |
6363
| :green_heart: | [Nucleo F446RE](http://www.st.com/en/evaluation-tools/nucleo-f446re.html) | *1.1.1* | |
6464
| :green_heart: | [Nucleo-G071RB](https://www.st.com/en/evaluation-tools/nucleo-g071rb.html) | *1.6.0* | |
65+
| :yellow_heart: | [Nucleo-G431RB](https://www.st.com/en/evaluation-tools/nucleo-g431rb.html) | **1.7.0** | |
6566
| :yellow_heart: | [Nucleo-G474RE](https://www.st.com/en/evaluation-tools/nucleo-g474re.html) | **1.7.0** | |
6667
| :green_heart: | [Nucleo L053R8](http://www.st.com/en/evaluation-tools/nucleo-l053r8.html) | *0.1.0* | |
6768
| :green_heart: | [Nucleo L073RZ](http://www.st.com/en/evaluation-tools/nucleo-l073rz.html) | *1.4.0* | |

boards.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,18 @@ Nucleo_64.menu.pnum.NUCLEO_G071RB.build.variant=NUCLEO_G071RB
268268
Nucleo_64.menu.pnum.NUCLEO_G071RB.build.cmsis_lib_gcc=arm_cortexM0l_math
269269
Nucleo_64.menu.pnum.NUCLEO_G071RB.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} -D__CORTEX_SC=0
270270

271+
# NUCLEO_G431RB board
272+
Nucleo_64.menu.pnum.NUCLEO_G431RB=Nucleo G431RB
273+
Nucleo_64.menu.pnum.NUCLEO_G431RB.node=NODE_G431RB
274+
Nucleo_64.menu.pnum.NUCLEO_G431RB.upload.maximum_size=131072
275+
Nucleo_64.menu.pnum.NUCLEO_G431RB.upload.maximum_data_size=32768
276+
Nucleo_64.menu.pnum.NUCLEO_G431RB.build.mcu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
277+
Nucleo_64.menu.pnum.NUCLEO_G431RB.build.board=NUCLEO_G431RB
278+
Nucleo_64.menu.pnum.NUCLEO_G431RB.build.series=STM32G4xx
279+
Nucleo_64.menu.pnum.NUCLEO_G431RB.build.product_line=STM32G431xx
280+
Nucleo_64.menu.pnum.NUCLEO_G431RB.build.variant=NUCLEO_G431RB
281+
Nucleo_64.menu.pnum.NUCLEO_G431RB.build.cmsis_lib_gcc=arm_cortexM4l_math
282+
271283
# NUCLEO_G474RE board
272284
Nucleo_64.menu.pnum.NUCLEO_G474RE=Nucleo G474RE
273285
Nucleo_64.menu.pnum.NUCLEO_G474RE.node=NODE_G474RE

variants/NUCLEO_G431RB/PeripheralPins.c

Lines changed: 342 additions & 0 deletions
Large diffs are not rendered by default.

variants/NUCLEO_G431RB/PinNamesVar.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* SYS_WKUP */
2+
#ifdef PWR_WAKEUP_PIN1
3+
SYS_WKUP1 = PA_0,
4+
#endif
5+
#ifdef PWR_WAKEUP_PIN2
6+
SYS_WKUP2 = PC_13,
7+
#endif
8+
#ifdef PWR_WAKEUP_PIN3
9+
SYS_WKUP3 = PE_6,
10+
#endif
11+
#ifdef PWR_WAKEUP_PIN4
12+
SYS_WKUP4 = PA_2,
13+
#endif
14+
#ifdef PWR_WAKEUP_PIN5
15+
SYS_WKUP5 = PC_5,
16+
#endif
17+
#ifdef PWR_WAKEUP_PIN6
18+
SYS_WKUP6 = NC,
19+
#endif
20+
#ifdef PWR_WAKEUP_PIN7
21+
SYS_WKUP7 = NC,
22+
#endif
23+
#ifdef PWR_WAKEUP_PIN8
24+
SYS_WKUP8 = NC,
25+
#endif
26+
/* USB */
27+
#ifdef USBCON
28+
USB_DM = PA_11,
29+
USB_DP = PA_12,
30+
#endif

variants/NUCLEO_G431RB/ldscript.ld

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
/*
2+
******************************************************************************
3+
**
4+
5+
** File : LinkerScript.ld
6+
**
7+
** Author : Auto-generated by Ac6 System Workbench
8+
**
9+
** Abstract : Linker script for STM32G431RBTx series
10+
** 128Kbytes FLASH and 32Kbytes 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) 2014 Ac6</center></h2>
26+
**
27+
** Redistribution and use in source and binary forms, with or without modification,
28+
** are permitted provided that the following conditions are met:
29+
** 1. Redistributions of source code must retain the above copyright notice,
30+
** this list of conditions and the following disclaimer.
31+
** 2. Redistributions in binary form must reproduce the above copyright notice,
32+
** this list of conditions and the following disclaimer in the documentation
33+
** and/or other materials provided with the distribution.
34+
** 3. Neither the name of Ac6 nor the names of its contributors
35+
** may be used to endorse or promote products derived from this software
36+
** without specific prior written permission.
37+
**
38+
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39+
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40+
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41+
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
42+
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
44+
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
45+
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46+
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47+
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48+
**
49+
*****************************************************************************
50+
*/
51+
52+
/* Entry Point */
53+
ENTRY(Reset_Handler)
54+
55+
/* Highest address of the user mode stack */
56+
_estack = 0x20008000; /* end of RAM */
57+
/* Generate a link error if heap and stack don't fit into RAM */
58+
_Min_Heap_Size = 0x200; /* required amount of heap */
59+
_Min_Stack_Size = 0x400; /* required amount of stack */
60+
61+
/* Specify the memory areas */
62+
MEMORY
63+
{
64+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
65+
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
66+
}
67+
68+
/* Define output sections */
69+
SECTIONS
70+
{
71+
/* The startup code goes first into FLASH */
72+
.isr_vector :
73+
{
74+
. = ALIGN(4);
75+
KEEP(*(.isr_vector)) /* Startup code */
76+
. = ALIGN(4);
77+
} >FLASH
78+
79+
/* The program code and other data goes into FLASH */
80+
.text :
81+
{
82+
. = ALIGN(4);
83+
*(.text) /* .text sections (code) */
84+
*(.text*) /* .text* sections (code) */
85+
*(.glue_7) /* glue arm to thumb code */
86+
*(.glue_7t) /* glue thumb to arm code */
87+
*(.eh_frame)
88+
89+
KEEP (*(.init))
90+
KEEP (*(.fini))
91+
92+
. = ALIGN(4);
93+
_etext = .; /* define a global symbols at end of code */
94+
} >FLASH
95+
96+
/* Constant data goes into FLASH */
97+
.rodata :
98+
{
99+
. = ALIGN(4);
100+
*(.rodata) /* .rodata sections (constants, strings, etc.) */
101+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
102+
. = ALIGN(4);
103+
} >FLASH
104+
105+
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
106+
.ARM : {
107+
__exidx_start = .;
108+
*(.ARM.exidx*)
109+
__exidx_end = .;
110+
} >FLASH
111+
112+
.preinit_array :
113+
{
114+
PROVIDE_HIDDEN (__preinit_array_start = .);
115+
KEEP (*(.preinit_array*))
116+
PROVIDE_HIDDEN (__preinit_array_end = .);
117+
} >FLASH
118+
.init_array :
119+
{
120+
PROVIDE_HIDDEN (__init_array_start = .);
121+
KEEP (*(SORT(.init_array.*)))
122+
KEEP (*(.init_array*))
123+
PROVIDE_HIDDEN (__init_array_end = .);
124+
} >FLASH
125+
.fini_array :
126+
{
127+
PROVIDE_HIDDEN (__fini_array_start = .);
128+
KEEP (*(SORT(.fini_array.*)))
129+
KEEP (*(.fini_array*))
130+
PROVIDE_HIDDEN (__fini_array_end = .);
131+
} >FLASH
132+
133+
/* used by the startup to initialize data */
134+
_sidata = LOADADDR(.data);
135+
136+
/* Initialized data sections goes into RAM, load LMA copy after code */
137+
.data :
138+
{
139+
. = ALIGN(4);
140+
_sdata = .; /* create a global symbol at data start */
141+
*(.data) /* .data sections */
142+
*(.data*) /* .data* sections */
143+
144+
. = ALIGN(4);
145+
_edata = .; /* define a global symbol at data end */
146+
} >RAM AT> FLASH
147+
148+
149+
/* Uninitialized data section */
150+
. = ALIGN(4);
151+
.bss :
152+
{
153+
/* This is used by the startup in order to initialize the .bss secion */
154+
_sbss = .; /* define a global symbol at bss start */
155+
__bss_start__ = _sbss;
156+
*(.bss)
157+
*(.bss*)
158+
*(COMMON)
159+
160+
. = ALIGN(4);
161+
_ebss = .; /* define a global symbol at bss end */
162+
__bss_end__ = _ebss;
163+
} >RAM
164+
165+
/* User_heap_stack section, used to check that there is enough RAM left */
166+
._user_heap_stack :
167+
{
168+
. = ALIGN(8);
169+
PROVIDE ( end = . );
170+
PROVIDE ( _end = . );
171+
. = . + _Min_Heap_Size;
172+
. = . + _Min_Stack_Size;
173+
. = ALIGN(8);
174+
} >RAM
175+
176+
177+
178+
/* Remove information from the standard libraries */
179+
/DISCARD/ :
180+
{
181+
libc.a ( * )
182+
libm.a ( * )
183+
libgcc.a ( * )
184+
}
185+
186+
.ARM.attributes 0 : { *(.ARM.attributes) }
187+
}
188+
189+

variants/NUCLEO_G431RB/variant.cpp

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2019, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* This software component is licensed by ST under BSD 3-Clause license,
7+
* the "License"; You may not use this file except in compliance with the
8+
* License. You may obtain a copy of the License at:
9+
* opensource.org/licenses/BSD-3-Clause
10+
*
11+
*******************************************************************************
12+
*/
13+
14+
#include "pins_arduino.h"
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif
19+
20+
// Pin number
21+
const PinName digitalPin[] = {
22+
// CN9
23+
PC_5, //D0
24+
PC_4, //D1
25+
PA_10, //D2
26+
PB_3, //D3
27+
PB_5, //D4
28+
PB_4, //D5
29+
PB_10, //D6
30+
PA_8, //D7
31+
// CN5
32+
PA_9, //D8
33+
PC_7, //D9
34+
PB_6, //D10
35+
PA_7, //D11
36+
PA_6, //D12
37+
PA_5, //D13/LED
38+
PB_9, //D14
39+
PB_8, //D15
40+
// CN7 Left Side
41+
PC_10, //D16
42+
PC_12, //D17
43+
PA_13, //D18/SWDIO
44+
PA_14, //D19/SWCLK
45+
PA_15, //D20
46+
PB_7, //D21
47+
PC_13, //D22
48+
PC_14, //D23
49+
PC_15, //D24
50+
PF_0, //D25
51+
PF_1, //D26
52+
PC_2, //D27
53+
PC_3, //D28
54+
// CN7 Right Side
55+
PD_2, //D29
56+
PC_11, //D30
57+
// CN10 Left Side
58+
PC_9, //D31
59+
// CN8
60+
PA_0, //D32/A0
61+
PA_1, //D33/A1
62+
PA_4, //D34/A2
63+
PB_0, //D35/A3
64+
PC_1, //D36/A4
65+
PC_0, //D37/A5
66+
// CN10 Right side
67+
PB_14, //D38/A6
68+
PB_15, //D39/A7
69+
PB_1, //D40/A8
70+
PB_2, //D41/A9
71+
PB_11, //D42/A10
72+
PB_12, //D43/A11
73+
PB_13, //D44
74+
PA_11, //D45
75+
PA_12, //D46
76+
PC_6, //D47
77+
PC_8, //D48
78+
PA_2, //D49
79+
PA_3 //D50
80+
};
81+
82+
#ifdef __cplusplus
83+
}
84+
#endif
85+
86+
// ----------------------------------------------------------------------------
87+
88+
#ifdef __cplusplus
89+
extern "C" {
90+
#endif
91+
92+
/**
93+
* @brief System Clock Configuration
94+
*/
95+
WEAK void SystemClock_Config(void)
96+
{
97+
RCC_OscInitTypeDef RCC_OscInitStruct = {};
98+
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
99+
#ifdef USBCON
100+
RCC_PeriphCLKInitTypeDef PeriphClkInit = {};
101+
#endif
102+
103+
/* Configure the main internal regulator output voltage */
104+
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST);
105+
/* Initializes the CPU, AHB and APB busses clocks */
106+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48;
107+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
108+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
109+
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
110+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
111+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
112+
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4;
113+
RCC_OscInitStruct.PLL.PLLN = 85;
114+
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
115+
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
116+
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
117+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
118+
Error_Handler();
119+
}
120+
/* Initializes the CPU, AHB and APB busses clocks */
121+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
122+
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
123+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
124+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
125+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
126+
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
127+
128+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_8) != HAL_OK) {
129+
Error_Handler();
130+
}
131+
132+
#ifdef USBCON
133+
/* Initializes the peripherals clocks */
134+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
135+
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
136+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
137+
Error_Handler();
138+
}
139+
#endif
140+
}
141+
142+
#ifdef __cplusplus
143+
}
144+
#endif

0 commit comments

Comments
 (0)