diff --git a/boards/arm/nucleo_g031k8/Kconfig.board b/boards/arm/nucleo_g031k8/Kconfig.board new file mode 100644 index 00000000000..02133d33257 --- /dev/null +++ b/boards/arm/nucleo_g031k8/Kconfig.board @@ -0,0 +1,8 @@ +# STM32 Nucleo-32 development board with STM32G031K8 MCU configuration + +# Copyright (c) 2022 Joylab AG +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_NUCLEO_G031K8 + bool "NUCLEO-32 G031K8 Development Board" + depends on SOC_STM32G031XX diff --git a/boards/arm/nucleo_g031k8/Kconfig.defconfig b/boards/arm/nucleo_g031k8/Kconfig.defconfig new file mode 100644 index 00000000000..b448461f39e --- /dev/null +++ b/boards/arm/nucleo_g031k8/Kconfig.defconfig @@ -0,0 +1,15 @@ +# STM32 Nucleo-32 development board with STM32G031K8 MCU + +# Copyright (c) 2022 Joylab AG +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_NUCLEO_G031K8 + +config BOARD + default "nucleo_g031k8" + +config SPI_STM32_INTERRUPT + default y + depends on SPI + +endif # BOARD_NUCLEO_G031K8 diff --git a/boards/arm/nucleo_g031k8/board.cmake b/boards/arm/nucleo_g031k8/board.cmake new file mode 100644 index 00000000000..8b8ec50a6b6 --- /dev/null +++ b/boards/arm/nucleo_g031k8/board.cmake @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(jlink "--device=STM32G031K8" "--speed=4000") + +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/boards/arm/nucleo_g031k8/doc/img/nucleo_g031k8.jpg b/boards/arm/nucleo_g031k8/doc/img/nucleo_g031k8.jpg new file mode 100644 index 00000000000..9d1a48567ac Binary files /dev/null and b/boards/arm/nucleo_g031k8/doc/img/nucleo_g031k8.jpg differ diff --git a/boards/arm/nucleo_g031k8/doc/index.rst b/boards/arm/nucleo_g031k8/doc/index.rst new file mode 100644 index 00000000000..d416fcfee7a --- /dev/null +++ b/boards/arm/nucleo_g031k8/doc/index.rst @@ -0,0 +1,170 @@ +.. _nucleo_g031k8_board: + +ST Nucleo G031K8 +################ + +Overview +******** +The STM32 Nucleo-32 board provides an affordable and flexible way for users to try +out new concepts and build prototypes by choosing from the various combinations of +performance and power consumption features, provided by the STM32 +microcontroller. + +The Arduinoâ„¢ Nano V3 connectivity support allows the easy expansion of the +functionality of the STM32 Nucleo open development platform with a wide choice of +specialized shields. + +The STM32 Nucleo-32 board does not require any separate probe as it integrates the +ST-LINK debugger/programmer. + +The STM32 Nucleo-32 board comes with the STM32 comprehensive free software +libraries and examples available with the STM32Cube MCU Package. + + +.. image:: img/nucleo_g031k8.jpg + :width: 426px + :height: 653px + :align: center + :alt: Nucleo G031K8 + +More information about the board can be found at the `Nucleo G031K8 website`_. + +Hardware +******** +Nucleo G031K8 provides the following hardware components: + +- STM32 microcontroller in 32-pin package featuring 64 Kbytes of Flash memory + and 8 Kbytes of SRAM. +- Extension resource: + + - Arduino* Nano V3 connectivity + +- On-board ST-LINK/V2-1 debugger/programmer with SWD connector: + +- Flexible board power supply: + + - USB VBUS or external source (3.3V, 5V, 7 - 12V) + - Current consumption measurement (IDD) + +- Four LEDs: + + - USB communication (LD1), power LED (LD2), user LED (LD3), + USB power fault LED (LD4) + +- One push-button: RESET + +- USB re-enumeration capability. Three different interfaces supported on USB: + + - Virtual COM port + - Mass storage + - Debug port + +More information about STM32G031K8 can be found in the +`STM32G0x1 reference manual`_ + +Supported Features +================== + +The Zephyr nucleo_g031k8 board configuration supports the following hardware features: + ++-----------+------------+-------------------------------------+ +| Interface | Controller | Driver/Component | ++===========+============+=====================================+ +| NVIC | on-chip | nested vector interrupt controller | ++-----------+------------+-------------------------------------+ +| UART | on-chip | serial port-polling; | +| | | serial port-interrupt | ++-----------+------------+-------------------------------------+ +| PINMUX | on-chip | pinmux | ++-----------+------------+-------------------------------------+ +| GPIO | on-chip | gpio | ++-----------+------------+-------------------------------------+ +| CLOCK | on-chip | reset and clock control | ++-----------+------------+-------------------------------------+ +| I2C | on-chip | i2c controller | ++-----------+------------+-------------------------------------+ +| SPI | on-chip | spi controller | ++-----------+------------+-------------------------------------+ + +Other hardware features are not yet supported in this Zephyr port. + +The default configuration can be found in the defconfig file: +``boards/arm/nucleo_g031k8/nucleo_g031k8_defconfig`` + +Connections and IOs +=================== + +Each of the GPIO pins can be configured by software as output (push-pull or open-drain), as +input (with or without pull-up or pull-down), or as peripheral alternate function. Most of the +GPIO pins are shared with digital or analog alternate functions. All GPIOs are high current +capable except for analog inputs. + +Default Zephyr Peripheral Mapping: +---------------------------------- + +- UART_2 TX/RX : PA2/PA3 (ST-Link Virtual Port Com) +- I2C2 SCL/SDA : PA9/PA10 (Arduino I2C) +- SPI1 SCK/MISO/MOSI : PB3/PB4/PB5 (Arduino SPI) +- LD3 : PC6 + +For mode details please refer to `STM32 Nucleo-32 board User Manual`_. + +Programming and Debugging +************************* + +Applications for the ``nucleo_g031k8`` board configuration can be built and +flashed in the usual way (see :ref:`build_an_application` and +:ref:`application_run` for more details). + +Flashing +======== + +Nucleo G031K8 board includes an ST-LINK/V2-1 embedded debug tool interface. +This interface is supported by the openocd version included in the Zephyr SDK. + +Flashing an application to Nucleo G031K8 +---------------------------------------- + +Here is an example for the :ref:`blinky-sample` application. + +.. zephyr-app-commands:: + :zephyr-app: samples/basic/blinky + :board: nucleo_g031k8 + :goals: build flash + +You will see the LED blinking every second. + +Debugging +========= + +You can debug an application in the usual way. Here is an example for the +:ref:`hello_world` application. + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: nucleo_g031k8 + :maybe-skip-config: + :goals: debug + +Restriction +*********** + +On some boards, the board reset line is not used by the controller. +Therefore the reset button, reset-pin and the ST-Link reset have no effect. +To enable those functionalities, the option byte NRST_mode in the User +Configuration needs to be changed from 2 to 1 or 3 - depending on the +requirements. + +References +********** + +.. target-notes:: + +.. _Nucleo G031K8 website: + http://www.st.com/en/evaluation-tools/nucleo-g031k8.html + +.. _STM32G0x1 reference manual: + https://www.st.com/resource/en/reference_manual/rm0444-stm32g0x1-advanced-armbased-32bit-mcus-stmicroelectronics.pdf + +.. _STM32 Nucleo-32 board User Manual: + https://www.st.com/resource/en/user_manual/um2591-stm32g0-nucleo32-board-mb1455-stmicroelectronics.pdf diff --git a/boards/arm/nucleo_g031k8/nucleo_g031k8.dts b/boards/arm/nucleo_g031k8/nucleo_g031k8.dts new file mode 100644 index 00000000000..cfb35ed595f --- /dev/null +++ b/boards/arm/nucleo_g031k8/nucleo_g031k8.dts @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2022 Joylab AG + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include + +/ { + model = "STMicroelectronics STM32G031K8-NUCLEO board"; + compatible = "st,stm32g031k8-nucleo"; + + chosen { + zephyr,console = &usart2; + zephyr,shell-uart = &usart2; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + + leds { + compatible = "gpio-leds"; + green_led_3: led_3 { + gpios = <&gpioc 6 GPIO_ACTIVE_HIGH>; + label = "User LD3"; + }; + }; + + aliases { + led0 = &green_led_3; + }; +}; + +&clk_hsi { + status = "okay"; +}; + +&pll { + div-m = <1>; + mul-n = <8>; + div-r = <2>; + clocks = <&clk_hsi>; + status = "okay"; +}; + +&rcc { + clocks = <&pll>; + clock-frequency = ; + ahb-prescaler = <1>; + apb1-prescaler = <1>; +}; + +&usart1 { + pinctrl-0 = <&usart1_tx_pb6 &usart1_rx_pb7>; + pinctrl-names = "default"; + current-speed = <115200>; +}; + +&usart2 { + pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>; + pinctrl-names = "default"; + current-speed = <115200>; + status = "okay"; +}; + +&i2c1 { + pinctrl-0 = <&i2c1_scl_pa9 &i2c1_sda_pa10>; + pinctrl-names = "default"; + clock-frequency = ; + status = "okay"; +}; + +&i2c2 { + pinctrl-0 = <&i2c2_scl_pa11 &i2c2_sda_pa12>; + pinctrl-names = "default"; + clock-frequency = ; + status = "okay"; +}; + +&spi1 { + pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>; + pinctrl-names = "default"; + status = "okay"; +}; diff --git a/boards/arm/nucleo_g031k8/nucleo_g031k8.yaml b/boards/arm/nucleo_g031k8/nucleo_g031k8.yaml new file mode 100644 index 00000000000..9a19f3e6338 --- /dev/null +++ b/boards/arm/nucleo_g031k8/nucleo_g031k8.yaml @@ -0,0 +1,14 @@ +identifier: nucleo_g031k8 +name: ST Nucleo G031K8 +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - gpio + - i2c + - spi +ram: 8 +flash: 64 diff --git a/boards/arm/nucleo_g031k8/nucleo_g031k8_defconfig b/boards/arm/nucleo_g031k8/nucleo_g031k8_defconfig new file mode 100644 index 00000000000..e4a8706b596 --- /dev/null +++ b/boards/arm/nucleo_g031k8/nucleo_g031k8_defconfig @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Zephyr Kernel Configuration +CONFIG_SOC_SERIES_STM32G0X=y + +# Platform Configuration +CONFIG_SOC_STM32G031XX=y + +# Kernel Options due to Low Memory (8k) +CONFIG_MAIN_STACK_SIZE=640 +CONFIG_IDLE_STACK_SIZE=200 +CONFIG_ISR_STACK_SIZE=512 + +# Serial Drivers +CONFIG_SERIAL=y +CONFIG_UART_INTERRUPT_DRIVEN=y +# enable console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +# GPIO Controller +CONFIG_GPIO=y + +# Enable Clocks +CONFIG_CLOCK_CONTROL=y + +# enable pin controller +CONFIG_PINCTRL=y diff --git a/boards/arm/nucleo_g031k8/support/openocd.cfg b/boards/arm/nucleo_g031k8/support/openocd.cfg new file mode 100644 index 00000000000..6bb5b17874f --- /dev/null +++ b/boards/arm/nucleo_g031k8/support/openocd.cfg @@ -0,0 +1,22 @@ +# This is an ST NUCLEO-G031K8 board with single STM32G031K8 chip. +# http://www.st.com/en/evaluation-tools/nucleo-g031k8.html + +source [find interface/stlink-dap.cfg] + +transport select dapdirect_swd + +source [find target/stm32g0x.cfg] + +# There is only system reset line and JTAG/SWD command can be issued when SRST +reset_config srst_only + +$_TARGETNAME configure -event gdb-attach { + echo "Debugger attaching: halting execution" + reset halt + gdb_breakpoint_override hard +} + +$_TARGETNAME configure -event gdb-detach { + echo "Debugger detaching: resuming execution" + resume +}