diff --git a/boards/st/nucleo_f072rb/Kconfig.defconfig b/boards/st/nucleo_f072rb/Kconfig.defconfig new file mode 100644 index 00000000000..1031692291f --- /dev/null +++ b/boards/st/nucleo_f072rb/Kconfig.defconfig @@ -0,0 +1,12 @@ +# NUCLEO_F072RB board configuration + +# Copyright (c) 2025 Alex Fabre +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_NUCLEO_F072RB + +config SPI_STM32_INTERRUPT + default y + depends on SPI + +endif # BOARD_NUCLEO_F072RB diff --git a/boards/st/nucleo_f072rb/Kconfig.nucleo_f072rb b/boards/st/nucleo_f072rb/Kconfig.nucleo_f072rb new file mode 100644 index 00000000000..165ba6c2902 --- /dev/null +++ b/boards/st/nucleo_f072rb/Kconfig.nucleo_f072rb @@ -0,0 +1,5 @@ +# Copyright (c) 2025 Alex Fabre +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_NUCLEO_F072RB + select SOC_STM32F072XB diff --git a/boards/st/nucleo_f072rb/arduino_r3_connector.dtsi b/boards/st/nucleo_f072rb/arduino_r3_connector.dtsi new file mode 100644 index 00000000000..6ed2b49ad15 --- /dev/null +++ b/boards/st/nucleo_f072rb/arduino_r3_connector.dtsi @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Alex Fabre + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + arduino_header: connector { + compatible = "arduino-header-r3"; + #gpio-cells = <2>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0 0x3f>; + gpio-map = <0 0 &gpioa 0 0>, /* A0 */ + <1 0 &gpioa 1 0>, /* A1 */ + <2 0 &gpioa 4 0>, /* A2 */ + <3 0 &gpiob 0 0>, /* A3 */ + <4 0 &gpioc 1 0>, /* A4 */ + <5 0 &gpioc 0 0>, /* A5 */ + <6 0 &gpioa 3 0>, /* D0 */ + <7 0 &gpioa 2 0>, /* D1 */ + <8 0 &gpioa 10 0>, /* D2 */ + <9 0 &gpiob 3 0>, /* D3 */ + <10 0 &gpiob 5 0>, /* D4 */ + <11 0 &gpiob 4 0>, /* D5 */ + <12 0 &gpiob 10 0>, /* D6 */ + <13 0 &gpioa 8 0>, /* D7 */ + <14 0 &gpioa 9 0>, /* D8 */ + <15 0 &gpioc 7 0>, /* D9 */ + <16 0 &gpiob 6 0>, /* D10 */ + <17 0 &gpioa 7 0>, /* D11 */ + <18 0 &gpioa 6 0>, /* D12 */ + <19 0 &gpioa 5 0>, /* D13 */ + <20 0 &gpiob 9 0>, /* D14 */ + <21 0 &gpiob 8 0>; /* D15 */ + }; +}; + +arduino_i2c: &i2c1 {}; +arduino_spi: &spi1 {}; diff --git a/boards/st/nucleo_f072rb/board.cmake b/boards/st/nucleo_f072rb/board.cmake new file mode 100644 index 00000000000..136bd345f6a --- /dev/null +++ b/boards/st/nucleo_f072rb/board.cmake @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 + +# keep first +board_runner_args(stm32cubeprogrammer "--port=swd" "--reset-mode=hw") +board_runner_args(jlink "--device=STM32F072RB" "--speed=4000") + +# keep first +include(${ZEPHYR_BASE}/boards/common/stm32cubeprogrammer.board.cmake) +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/boards/st/nucleo_f072rb/board.yml b/boards/st/nucleo_f072rb/board.yml new file mode 100644 index 00000000000..96a4c251439 --- /dev/null +++ b/boards/st/nucleo_f072rb/board.yml @@ -0,0 +1,6 @@ +board: + name: nucleo_f072rb + full_name: Nucleo F072RB + vendor: st + socs: + - name: stm32f072xb diff --git a/boards/st/nucleo_f072rb/doc/img/nucleo_f072rb.webp b/boards/st/nucleo_f072rb/doc/img/nucleo_f072rb.webp new file mode 100644 index 00000000000..36ee2ce83aa Binary files /dev/null and b/boards/st/nucleo_f072rb/doc/img/nucleo_f072rb.webp differ diff --git a/boards/st/nucleo_f072rb/doc/img/nucleo_f072rb_connectors.webp b/boards/st/nucleo_f072rb/doc/img/nucleo_f072rb_connectors.webp new file mode 100644 index 00000000000..db83da75dab Binary files /dev/null and b/boards/st/nucleo_f072rb/doc/img/nucleo_f072rb_connectors.webp differ diff --git a/boards/st/nucleo_f072rb/doc/index.rst b/boards/st/nucleo_f072rb/doc/index.rst new file mode 100644 index 00000000000..154497de014 --- /dev/null +++ b/boards/st/nucleo_f072rb/doc/index.rst @@ -0,0 +1,181 @@ +.. zephyr:board:: nucleo_f072rb + +Overview +******** +The STM32 Nucleo-64 development board with STM32F072RB MCU, supports Arduino and ST morpho connectivity. + +The STM32 Nucleo board provides an affordable, and flexible way for users to try out new concepts, +and build prototypes with the STM32 microcontroller, choosing from the various +combinations of performance, power consumption, and features. + +The Arduino* Uno V3 connectivity support and the ST morpho headers allow easy functionality +expansion of the STM32 Nucleo open development platform with a wide choice of +specialized shields. + +The STM32 Nucleo board integrates the ST-LINK/V2-1 debugger and programmer. + +The STM32 Nucleo board comes with the STM32 comprehensive software HAL library together +with various packaged software examples. + +More information about the board can be found at the `Nucleo F072RB website`_. + +Hardware +******** +Nucleo F072RB provides the following hardware components: + +- STM32 microcontroller in QFP64 package +- Two types of extension resources: + + - Arduino* Uno V3 connectivity + - ST morpho extension pin headers for full access to all STM32 I/Os + +- On-board ST-LINK/V2-1 debugger/programmer with SWD connector: + + - Selection-mode switch to use the kit as a standalone ST-LINK/V2-1 + +- Flexible board power supply: + + - USB VBUS or external source (3.3V, 5V, 7 - 12V) + - Power management access point + +- Three LEDs: + + - USB communication (LD1), user LED (LD2), power LED (LD3) + +- Two push-buttons: USER and RESET +- USB re-enumeration capability. Three different interfaces supported on USB: + + - Virtual COM port + - Mass storage + - Debug port + +More information about STM32F072RB can be found in +the `STM32F072 reference manual`_ . + + +Supported Features +================== + +The Zephyr ``nucleo_f072rb`` board 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 | ++-----------+------------+-------------------------------------+ +| FLASH | on-chip | flash memory | ++-----------+------------+-------------------------------------+ +| WATCHDOG | on-chip | independent watchdog | ++-----------+------------+-------------------------------------+ +| I2C | on-chip | i2c controller | ++-----------+------------+-------------------------------------+ +| SPI | on-chip | SPI controller | ++-----------+------------+-------------------------------------+ +| RTC | on-chip | rtc | ++-----------+------------+-------------------------------------+ + +Other hardware features are not yet supported in this Zephyr port. + +The default configuration can be found in +:zephyr_file:`boards/st/nucleo_f072rb/nucleo_f072rb_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. + +Board connectors: +----------------- +.. image:: img/nucleo_f072rb_connectors.webp + :align: center + :alt: Nucleo F072RB connectors + +Default Zephyr Peripheral Mapping: +---------------------------------- + +- UART_1 TX/RX : PA9/PA10 +- UART_2 TX/RX : PA2/PA3 (ST-Link Virtual COM Port) +- I2C1 SCL/SDA : PB8/PB9 (Arduino I2C) +- I2C2 SCL/SDA : PB10/PB11 +- SPI1 NSS/SCK/MISO/MOSI : PB6/PA5/PA6/PA7 (Arduino SPI) +- SPI2 SCK/MISO/MOSI : PB13/PB14/PB15 +- USER_PB : PC13 +- LD1 : PA5 + +For more details please refer to `STM32 Nucleo-64 board User Manual`_. + +Programming and Debugging +************************* + +Nucleo F072RB board includes an ST-LINK/V2-1 embedded debug tool interface. + +Applications for the ``nucleo_f072rb`` board configuration can be built and +flashed in the usual way (see :ref:`build_an_application` and +:ref:`application_run` for more details). + +Flashing +======== + +The board is configured to be flashed using west `STM32CubeProgrammer`_ runner, +so its :ref:`installation ` is required. + +Alternatively, OpenOCD or JLink can also be used to flash the board using +the ``--runner`` (or ``-r``) option: + +.. code-block:: console + + $ west flash --runner openocd + $ west flash --runner jlink + +Flashing an application to Nucleo F072RB +---------------------------------------- + +Here is an example for the :zephyr:code-sample:`blinky` application. + +.. zephyr-app-commands:: + :zephyr-app: samples/basic/blinky + :board: nucleo_f072rb + :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 +:zephyr:code-sample:`hello_world` application. + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: nucleo_f072rb + :maybe-skip-config: + :goals: debug + +References +********** + +.. target-notes:: + +.. _Nucleo F072RB website: + https://www.st.com/en/evaluation-tools/nucleo-f072rb.html + +.. _STM32F072 reference manual: + https://www.st.com/resource/en/reference_manual/dm00031936.pdf + +.. _STM32 Nucleo-64 board User Manual: + https://www.st.com/resource/en/user_manual/dm00105823.pdf + +.. _STM32CubeProgrammer: + https://www.st.com/en/development-tools/stm32cubeprog.html diff --git a/boards/st/nucleo_f072rb/nucleo_f072rb.dts b/boards/st/nucleo_f072rb/nucleo_f072rb.dts new file mode 100644 index 00000000000..207639f73b1 --- /dev/null +++ b/boards/st/nucleo_f072rb/nucleo_f072rb.dts @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2025 Alex Fabre + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include +#include "arduino_r3_connector.dtsi" +#include "st_morpho_connector.dtsi" +#include + +/ { + model = "STMicroelectronics NUCLEO-F072RB board"; + compatible = "st,stm32f072rb-nucleo"; + + chosen { + zephyr,console = &usart2; + zephyr,shell-uart = &usart2; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + + leds: leds { + compatible = "gpio-leds"; + green_led_2: led_2 { + gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>; + label = "User LD2"; + }; + }; + + gpio_keys { + compatible = "gpio-keys"; + user_button: button { + label = "User"; + gpios = <&gpioc 13 GPIO_ACTIVE_LOW>; + zephyr,code = ; + }; + }; + + aliases { + led0 = &green_led_2; + sw0 = &user_button; + watchdog0 = &iwdg; + die-temp0 = &die_temp; + volt-sensor0 = &vref; + }; +}; + +&clk_lse { + status = "okay"; +}; + +&clk_hse { + hse-bypass; + clock-frequency = ; /* STLink 8MHz clock */ + status = "okay"; +}; + +&pll { + clocks = <&clk_hse>; + prediv = <1>; + mul = <6>; + status = "okay"; +}; + +&rcc { + clocks = <&pll>; + clock-frequency = ; + ahb-prescaler = <1>; + apb1-prescaler = <2>; +}; + +&usart1 { + pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>; + pinctrl-names = "default"; + current-speed = <115200>; + status = "okay"; +}; + +&usart2 { + pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>; + pinctrl-names = "default"; + current-speed = <115200>; + status = "okay"; +}; + +&i2c1 { + pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>; + pinctrl-names = "default"; + status = "okay"; + clock-frequency = ; +}; + +&i2c2 { + pinctrl-0 = <&i2c2_scl_pb10 &i2c2_sda_pb11>; + pinctrl-names = "default"; + status = "okay"; + clock-frequency = ; +}; + +&spi1 { + pinctrl-0 = <&spi1_sck_pa5 &spi1_miso_pa6 &spi1_mosi_pa7>; + pinctrl-names = "default"; + cs-gpios = <&gpiob 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + status = "okay"; +}; + +&spi2 { + pinctrl-0 = <&spi2_sck_pb13 &spi2_miso_pb14 &spi2_mosi_pb15>; + pinctrl-names = "default"; + status = "okay"; +}; + +&iwdg { + status = "okay"; +}; + +&adc1 { + pinctrl-0 = <&adc_in0_pa0>; + pinctrl-names = "default"; + st,adc-clock-source = "SYNC"; + st,adc-prescaler = <4>; + status = "okay"; +}; + +&rtc { + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x10000000>, + <&rcc STM32_SRC_LSE RTC_SEL(1)>; + status = "okay"; +}; + +&die_temp { + status = "okay"; +}; + +&vref { + status = "okay"; +}; diff --git a/boards/st/nucleo_f072rb/nucleo_f072rb.yaml b/boards/st/nucleo_f072rb/nucleo_f072rb.yaml new file mode 100644 index 00000000000..ddebe84fcab --- /dev/null +++ b/boards/st/nucleo_f072rb/nucleo_f072rb.yaml @@ -0,0 +1,25 @@ +identifier: nucleo_f070rb +name: ST Nucleo F072RB +type: mcu +arch: arm +ram: 16 +flash: 128 +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - adc + - arduino_gpio + - arduino_i2c + - arduino_spi + - gpio + - i2c + - spi + - watchdog + - rtc +testing: + ignore_tags: + - net + - bluetooth +vendor: st diff --git a/boards/st/nucleo_f072rb/nucleo_f072rb_defconfig b/boards/st/nucleo_f072rb/nucleo_f072rb_defconfig new file mode 100644 index 00000000000..c60dfffbc3b --- /dev/null +++ b/boards/st/nucleo_f072rb/nucleo_f072rb_defconfig @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Serial Drivers +CONFIG_SERIAL=y +CONFIG_UART_INTERRUPT_DRIVEN=y + +# Enable console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +# GPIO Controller +CONFIG_GPIO=y diff --git a/boards/st/nucleo_f072rb/st_morpho_connector.dtsi b/boards/st/nucleo_f072rb/st_morpho_connector.dtsi new file mode 100644 index 00000000000..397f3192dac --- /dev/null +++ b/boards/st/nucleo_f072rb/st_morpho_connector.dtsi @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2024 Alex Fabre + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +/ { + st_morpho_header: st-morpho-header { + compatible = "st-morpho-header"; + #gpio-cells = <2>; + gpio-map-mask = ; + gpio-map-pass-thru = <0x0 GPIO_DT_FLAGS_MASK>; + gpio-map = , + , + , + , + , + , + , + , + , + , + , + , /* SB49=ON */ + , /* SB48=ON */ + , + , /* SB55=ON */ + , + , /* SB54=ON */ + , + , + , + , /* SB56=ON, SB46=OFF */ + , + , /* SB51=ON, SB52=OFF */ + , + , + , + , + , + , + , + , /* SB42=ON, SB29=OFF */ + , + , /* SB41=ON, SB24=OFF */ + , + , /* SB40=ON, SB20=OFF */ + , + , + , + , + , + , + , + , + , + , /* SB25=ON, SB36=OFF */ + , + , /* SB28=ON, SB39=OFF */ + , + , /* SB35=ON, SB44=OFF */ + , + , + , + , + , + , + ; + }; +}; diff --git a/boards/st/nucleo_f072rb/support/openocd.cfg b/boards/st/nucleo_f072rb/support/openocd.cfg new file mode 100644 index 00000000000..f0d0b22a310 --- /dev/null +++ b/boards/st/nucleo_f072rb/support/openocd.cfg @@ -0,0 +1,12 @@ +source [find board/st_nucleo_f0.cfg] + +$_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 +}