Skip to content

Commit 03959a2

Browse files
nagelklcarlescufi
authored andcommitted
boards: st: nucleo_g431kb: add support for nucleo g431kb
Add support for the nucleo g431kb Board. Signed-off-by: Klaus Nagel <[email protected]>
1 parent ec2dd19 commit 03959a2

File tree

9 files changed

+368
-0
lines changed

9 files changed

+368
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024 Klaus Nagel <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_NUCLEO_G431KB
5+
select SOC_STM32G431XX

boards/st/nucleo_g431kb/board.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
# keep first
4+
board_runner_args(stm32cubeprogrammer "--port=swd" "--reset-mode=hw")
5+
board_runner_args(pyocd "--target=stm32g431kbtx")
6+
7+
# keep first
8+
include(${ZEPHYR_BASE}/boards/common/stm32cubeprogrammer.board.cmake)
9+
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
10+
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)

boards/st/nucleo_g431kb/board.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: nucleo_g431kb
3+
full_name: Nucleo G431KB
4+
vendor: st
5+
socs:
6+
- name: stm32g431xx
Binary file not shown.

boards/st/nucleo_g431kb/doc/index.rst

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
.. _nucleo_g431kb_board:
2+
3+
ST Nucleo G431KB
4+
################
5+
6+
Overview
7+
********
8+
9+
The Nucleo G431KB board features an ARM Cortex-M4 based STM32G431KB MCU
10+
with a wide range of connectivity support and configurations.
11+
Here are some highlights of the Nucleo G431KB board:
12+
13+
- STM32 microcontroller in LQFP32 package
14+
- Arduino Nano V3 connectivity
15+
- On-board ST-LINK/V3E debugger/programmer
16+
- Flexible board power supply:
17+
18+
- USB VBUS or external source(3.3 V, 5 V, 7 - 12 V)
19+
- Power management access point
20+
21+
- Three LEDs: USB communication (LD1), power LED (LD3), user LED (LD2)
22+
- One push-button for RESET
23+
24+
.. image:: img/nucleo_g431kb.webp
25+
:align: center
26+
:alt: Nucleo G431kB
27+
28+
More information about the board can be found at the `Nucleo G431KB website`_.
29+
30+
- Development support: serial wire debug (SWD), JTAG, Embedded Trace Macrocell.
31+
32+
More information about STM32G431KB can be found here:
33+
34+
- `STM32G431KB on www.st.com`_
35+
- `STM32G4 reference manual`_
36+
37+
Supported Features
38+
==================
39+
40+
The Zephyr ``nucleo_g431kb`` board target supports the following hardware features:
41+
42+
+-----------+------------+-------------------------------------+
43+
| Interface | Controller | Driver/Component |
44+
+===========+============+=====================================+
45+
| NVIC | on-chip | nested vector interrupt controller |
46+
+-----------+------------+-------------------------------------+
47+
| UART | on-chip | serial port-polling; |
48+
| | | serial port-interrupt |
49+
+-----------+------------+-------------------------------------+
50+
| PINMUX | on-chip | pinmux |
51+
+-----------+------------+-------------------------------------+
52+
| GPIO | on-chip | gpio |
53+
+-----------+------------+-------------------------------------+
54+
| PWM | on-chip | pwm |
55+
+-----------+------------+-------------------------------------+
56+
| I2C | on-chip | i2c |
57+
+-----------+------------+-------------------------------------+
58+
59+
Other hardware features are not yet supported on this Zephyr port.
60+
61+
The default configuration can be found in the defconfig file:
62+
:zephyr_file:`boards/st/nucleo_g431kb/nucleo_g431kb_defconfig`
63+
64+
65+
Connections and IOs
66+
===================
67+
68+
Nucleo G431KB Board has 6 GPIO controllers. These controllers are responsible for pin muxing,
69+
input/output, pull-up, etc.
70+
71+
For more details please refer to `STM32G4 Nucleo-32 board User Manual`_.
72+
73+
Default Zephyr Peripheral Mapping:
74+
----------------------------------
75+
76+
.. rst-class:: rst-columns
77+
78+
- LPUART_1_TX : PA2
79+
- LPUART_1_RX : PA3
80+
- LD2 : PB8
81+
- PWM_4_CH_3 : PB8
82+
- I2C_2_SCL : PA9
83+
- I2C_2_SDA : PA8
84+
85+
System Clock
86+
------------
87+
88+
The Nucleo G431KB System Clock could be driven by internal or external oscillator,
89+
as well as main PLL clock. By default the external oscillator is not connected to the board. Therefore only the internal
90+
High Speed oscillator is supported. By default System clock is driven by PLL clock at 170 MHz,
91+
the PLL is driven by the 16 MHz high speed internal oscillator.
92+
93+
Serial Port
94+
-----------
95+
96+
Nucleo G431KB board has 1 U(S)ARTs and one LPUART. The Zephyr console output is assigned to LPUART1.
97+
Default settings are 115200 8N1.
98+
99+
Please note that LPUART1 baudrate is limited to 9600 if the MCU is clocked by LSE (32.768 kHz) in
100+
low power mode.
101+
102+
Programming and Debugging
103+
*************************
104+
105+
Nucleo G431KB Board includes an ST-Link/V3 embedded debug tool interface.
106+
107+
Applications for the ``nucleo_g431kb`` board target can be built and
108+
flashed in the usual way (see :ref:`build_an_application` and
109+
:ref:`application_run` for more details).
110+
111+
Flashing
112+
========
113+
114+
The board is configured to be flashed using west `STM32CubeProgrammer`_ runner,
115+
so its :ref:`installation <stm32cubeprog-flash-host-tools>` is required.
116+
117+
Alternatively, OpenOCD, or pyOCD can also be used to flash the board using
118+
the ``--runner`` (or ``-r``) option:
119+
120+
.. code-block:: console
121+
122+
$ west flash --runner openocd
123+
$ west flash --runner pyocd
124+
125+
To enable support of the STM32G431KB SoC in pyOCD, its pack has to be installed first:
126+
127+
.. code-block:: console
128+
129+
$ pyocd pack --update
130+
$ pyocd pack --install stm32g431kb
131+
132+
Flashing an application to Nucleo G431KB
133+
----------------------------------------
134+
135+
Connect the Nucleo G431KB to your host computer using the USB port,
136+
then run a serial host program to connect with your Nucleo board.
137+
138+
.. code-block:: console
139+
140+
$ minicom -D /dev/ttyACM0
141+
142+
Now build and flash an application. Here is an example for
143+
:zephyr:code-sample:`hello_world`.
144+
145+
.. zephyr-app-commands::
146+
:zephyr-app: samples/hello_world
147+
:board: nucleo_g431kb
148+
:goals: build flash
149+
150+
You should see the following message on the console:
151+
152+
.. code-block:: console
153+
154+
$ Hello World! nucleo_g431kb/stm32g431xx
155+
156+
Debugging
157+
=========
158+
159+
You can debug an application in the usual way. Here is an example for the
160+
:zephyr:code-sample:`hello_world` application.
161+
162+
.. zephyr-app-commands::
163+
:zephyr-app: samples/hello_world
164+
:board: nucleo_g431kb
165+
:maybe-skip-config:
166+
:goals: debug
167+
168+
References
169+
**********
170+
171+
.. target-notes::
172+
173+
.. _Nucleo G431KB website:
174+
https://www.st.com/en/evaluation-tools/nucleo-g431kb.html
175+
176+
.. _STM32G4 Nucleo-32 board User Manual:
177+
https://www.st.com/resource/en/user_manual/um2397-stm32g4-nucleo32-board-mb1430-stmicroelectronics.pdf
178+
179+
.. _STM32g431kb Nucleo-32 board schematic:
180+
https://www.st.com/resource/en/schematic_pack/mb1430-g431kbt6-a02_schematic_internal.pdf
181+
182+
.. _STM32G431KB on www.st.com:
183+
https://www.st.com/en/microcontrollers-microprocessors/stm32g431kb.html
184+
185+
.. _STM32G4 reference manual:
186+
https://www.st.com/resource/en/reference_manual/rm0440-stm32g4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf
187+
188+
.. _STM32CubeProgrammer:
189+
https://www.st.com/en/development-tools/stm32cubeprog.html
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Copyright (c) 2024 Klaus Nagel, <[email protected]>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/dts-v1/;
8+
#include <st/g4/stm32g431Xb.dtsi>
9+
#include <st/g4/stm32g431k(6-8-b)tx-pinctrl.dtsi>
10+
11+
/ {
12+
model = "STMicroelectronics STM32G431KB-NUCLEO board";
13+
compatible = "st,stm32g431kb-nucleo";
14+
15+
chosen {
16+
zephyr,console = &lpuart1;
17+
zephyr,shell-uart = &lpuart1;
18+
zephyr,sram = &sram0;
19+
zephyr,flash = &flash0;
20+
};
21+
22+
leds: leds {
23+
compatible = "gpio-leds";
24+
green_led: led_0 {
25+
gpios = <&gpiob 8 GPIO_ACTIVE_HIGH>;
26+
label = "User LD2";
27+
};
28+
29+
};
30+
31+
pwmleds {
32+
compatible = "pwm-leds";
33+
34+
green_pwm_led: green_pwm_led {
35+
pwms = <&pwm4 3 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
36+
};
37+
};
38+
39+
40+
aliases {
41+
led0 = &green_led;
42+
pwm-led0 = &green_pwm_led;
43+
watchdog0 = &iwdg;
44+
};
45+
};
46+
47+
&clk_hsi {
48+
status = "okay";
49+
};
50+
51+
&clk_lsi {
52+
status = "okay";
53+
};
54+
55+
stm32_lp_tick_source: &lptim1 {
56+
clocks = <&rcc STM32_CLOCK_BUS_APB1 0x80000000>,
57+
<&rcc STM32_SRC_LSI LPTIM1_SEL(3)>;
58+
status = "okay";
59+
};
60+
61+
/* Adjust the pll for a SYSTEM Clock of 170MHz */
62+
&pll {
63+
div-m = <4>;
64+
mul-n = <85>;
65+
div-p = <7>;
66+
div-q = <2>;
67+
div-r = <2>;
68+
clocks = <&clk_hsi>;
69+
status = "okay";
70+
};
71+
72+
&rcc {
73+
clocks = <&pll>;
74+
clock-frequency = <DT_FREQ_M(170)>;
75+
ahb-prescaler = <1>;
76+
apb1-prescaler = <1>;
77+
apb2-prescaler = <1>;
78+
};
79+
80+
&lpuart1 {
81+
pinctrl-0 = <&lpuart1_tx_pa2 &lpuart1_rx_pa3>;
82+
pinctrl-names = "default";
83+
current-speed = <115200>;
84+
status = "okay";
85+
};
86+
87+
&timers4 {
88+
st,prescaler = <10000>;
89+
status = "okay";
90+
91+
pwm4: pwm {
92+
status = "okay";
93+
pinctrl-0 = <&tim4_ch3_pb8>;
94+
pinctrl-names = "default";
95+
};
96+
};
97+
98+
&i2c2 {
99+
pinctrl-0 = <&i2c2_scl_pa9 &i2c2_sda_pa8>;
100+
pinctrl-names = "default";
101+
status = "okay";
102+
};
103+
104+
&flash0 {
105+
106+
partitions {
107+
compatible = "fixed-partitions";
108+
#address-cells = <1>;
109+
#size-cells = <1>;
110+
111+
/* Set 4Kb of storage at the end of the 128Kb of flash */
112+
storage_partition: partition@1f000 {
113+
label = "storage";
114+
reg = <0x0001f000 DT_SIZE_K(4)>;
115+
};
116+
};
117+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
identifier: nucleo_g431kb
2+
name: ST Nucleo G431KB
3+
type: mcu
4+
arch: arm
5+
toolchain:
6+
- zephyr
7+
- gnuarmemb
8+
- xtools
9+
ram: 32
10+
flash: 128
11+
supported:
12+
- gpio
13+
- pwm
14+
- counter
15+
- i2c
16+
vendor: st
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
# Serial drivers
4+
CONFIG_SERIAL=y
5+
CONFIG_UART_INTERRUPT_DRIVEN=y
6+
7+
# enable GPIO
8+
CONFIG_GPIO=y
9+
10+
# Console
11+
CONFIG_CONSOLE=y
12+
CONFIG_UART_CONSOLE=y
13+
14+
# Enable MPU
15+
CONFIG_ARM_MPU=y
16+
17+
# Enable HW stack protection
18+
CONFIG_HW_STACK_PROTECTION=y
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source [find interface/stlink.cfg]
2+
3+
transport select hla_swd
4+
5+
source [find target/stm32g4x.cfg]
6+
7+
reset_config srst_only

0 commit comments

Comments
 (0)