diff --git a/boards/arm/nucleo_f410rb/Kconfig.board b/boards/arm/nucleo_f410rb/Kconfig.board new file mode 100644 index 00000000000..8dcfa890169 --- /dev/null +++ b/boards/arm/nucleo_f410rb/Kconfig.board @@ -0,0 +1,8 @@ +# STM32F410RB Nucleo board configuration + +# Copyright (c) 2020 Hans Unzner +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_NUCLEO_F410RB + bool "Nucleo F410RB Development Board" + depends on SOC_STM32F410RX diff --git a/boards/arm/nucleo_f410rb/Kconfig.defconfig b/boards/arm/nucleo_f410rb/Kconfig.defconfig new file mode 100644 index 00000000000..df64f4ca9d3 --- /dev/null +++ b/boards/arm/nucleo_f410rb/Kconfig.defconfig @@ -0,0 +1,15 @@ +# STM32F410RB Nucleo board configuration + +# Copyright (c) 2020 Hans Unzner +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_NUCLEO_F410RB + +config BOARD + default "nucleo_f410rb" + +config SPI_STM32_INTERRUPT + default y + depends on SPI + +endif # BOARD_NUCLEO_F410RB diff --git a/boards/arm/nucleo_f410rb/arduino_r3_connector.dtsi b/boards/arm/nucleo_f410rb/arduino_r3_connector.dtsi new file mode 100644 index 00000000000..94c46e664d7 --- /dev/null +++ b/boards/arm/nucleo_f410rb/arduino_r3_connector.dtsi @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2020 Hans Unzner + * + * 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/arm/nucleo_f410rb/board.cmake b/boards/arm/nucleo_f410rb/board.cmake new file mode 100644 index 00000000000..2cc7742cc2d --- /dev/null +++ b/boards/arm/nucleo_f410rb/board.cmake @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(jlink "--device=STM32F410RB" "--speed=4000") + +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb.png b/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb.png new file mode 100644 index 00000000000..01e8af58170 Binary files /dev/null and b/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb.png differ diff --git a/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb_arduino_top_left.png b/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb_arduino_top_left.png new file mode 100644 index 00000000000..06c6d04a5dc Binary files /dev/null and b/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb_arduino_top_left.png differ diff --git a/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb_arduino_top_right.png b/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb_arduino_top_right.png new file mode 100644 index 00000000000..da44a370fc0 Binary files /dev/null and b/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb_arduino_top_right.png differ diff --git a/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb_morpho_top_left.png b/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb_morpho_top_left.png new file mode 100644 index 00000000000..6b6bc52cfd9 Binary files /dev/null and b/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb_morpho_top_left.png differ diff --git a/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb_morpho_top_right.png b/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb_morpho_top_right.png new file mode 100644 index 00000000000..02e959a39e5 Binary files /dev/null and b/boards/arm/nucleo_f410rb/doc/img/nucleo_f410rb_morpho_top_right.png differ diff --git a/boards/arm/nucleo_f410rb/doc/index.rst b/boards/arm/nucleo_f410rb/doc/index.rst new file mode 100644 index 00000000000..68f1fa46dd8 --- /dev/null +++ b/boards/arm/nucleo_f410rb/doc/index.rst @@ -0,0 +1,222 @@ +.. _nucleo_f410rb_board: + +ST Nucleo F410RB +################ + +Overview +******** + +The Nucleo F410RB board features an ARM Cortex-M4 based STM32F410RB MCU +with a wide range of connectivity support and configurations. Here are +some highlights of the Nucleo F410RB board: + +- 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 +- 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 + +.. image:: img/nucleo_f410rb.png + :width: 720px + :align: center + :height: 720px + :alt: Nucleo F410RB + +More information about the board can be found at the `Nucleo F410RB website`_. + +Hardware +******** + +Nucleo F410RB provides the following hardware components: + +- STM32F410RBT6 in LQFP64 package +- ARM |reg| 32-bit Cortex |reg|-M4 CPU with FPU +- Adaptive real-time accelerator (ART Accelerator) +- 100 MHz max CPU frequency +- VDD from 1.7 V to 3.6 V +- 128 KB Flash +- 32 KB SRAM +- General purpose timer (4) +- Low-power timer (1) +- Advanced-control timer (1) +- Random number generator (TRNG for HW entropy) +- SPI/I2S (3) +- I2C (3) +- USART (3) +- GPIO (50) with external interrupt capability +- 12-bit ADC with 16 channels +- 12-bit DAC with 1 channel +- RTC + + +More information about STM32F410RB can be found here: + +- `STM32F410RB on www.st.com`_ +- `STM32F410 reference manual`_ + +Supported Features +================== + +The Zephyr nucleo_f410rb board configuration supports the following hardware features: + ++-----------+------------+-------------------------------------+ +| Interface | Controller | Driver/Component | ++===========+============+=====================================+ +| NVIC | on-chip | nested vector interrupt controller | ++-----------+------------+-------------------------------------+ +| UART | on-chip | serial port | ++-----------+------------+-------------------------------------+ +| PINMUX | on-chip | pinmux | ++-----------+------------+-------------------------------------+ +| GPIO | on-chip | gpio | ++-----------+------------+-------------------------------------+ +| PWM | on-chip | pwm | ++-----------+------------+-------------------------------------+ +| I2C | on-chip | i2c | ++-----------+------------+-------------------------------------+ +| I2S | on-chip | i2s | ++-----------+------------+-------------------------------------+ +| SPI | on-chip | spi | ++-----------+------------+-------------------------------------+ +| ADC | on-chip | ADC Controller | ++-----------+------------+-------------------------------------+ +| DAC | on-chip | DAC Controller | ++-----------+------------+-------------------------------------+ +| WATCHDOG | on-chip | window & independent | ++-----------+------------+-------------------------------------+ + + +Other hardware features are not yet supported on this Zephyr port. + +The default configuration can be found in the defconfig file: +``boards/arm/nucleo_f410rb/nucleo_f410rb_defconfig`` + + +Connections and IOs +=================== + +Nucleo F410RB Board has 8 GPIO controllers. These controllers are responsible for pin muxing, +input/output, pull-up, etc. + +Available pins: +--------------- +.. image:: img/nucleo_f410rb_arduino_top_left.png + :width: 720px + :align: center + :height: 540px + :alt: Nucleo F410RB Arduino connectors (top left) +.. image:: img/nucleo_f410rb_arduino_top_right.png + :width: 720px + :align: center + :height: 540px + :alt: Nucleo F410RB Arduino connectors (top right) +.. image:: img/nucleo_f410rb_morpho_top_left.png + :width: 720px + :align: center + :height: 540px + :alt: Nucleo F410RB Morpho connectors (top left) +.. image:: img/nucleo_f410rb_morpho_top_right.png + :width: 720px + :align: center + :height: 540px + :alt: Nucleo F410RB Morpho connectors (top right) + +For mode details please refer to `STM32 Nucleo-64 board User Manual`_. + +Default Zephyr Peripheral Mapping: +---------------------------------- + +- UART_1_TX : PB6 +- UART_1_RX : PB7 +- UART_2_TX : PA2 +- UART_2_RX : PA3 +- USER_PB : PC13 +- LD2 : PA5 +- I2C1_SDA : PB9 +- I2C1_SCL : PB8 +- I2C2_SDA : PB3 +- I2C2_SCL : PB10 + +System Clock +------------ + +Nucleo F410RB System Clock could be driven by an internal or external oscillator, +as well as the main PLL clock. By default, the System clock is driven by the PLL clock at 84MHz, +driven by an 8MHz high-speed external clock. + +Serial Port +----------- + +Nucleo F410RB board has 3 USARTs. The Zephyr console output is assigned to UART2. +Default settings are 115200 8N1. + + +Programming and Debugging +************************* + +Applications for the ``nucleo_f410rb`` 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 F410RB 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 F410RB +---------------------------------------- + +Here is an example for the :ref:`hello_world` application. + +Run a serial host program to connect with your Nucleo board. + +.. code-block:: console + + $ minicom -b 115200 -D /dev/ttyACM0 + +Build and flash the application: + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: nucleo_f410rb + :goals: build flash + +You should see the following message on the console: + +.. code-block:: console + + $ Hello World! arm + +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_f410rb + :maybe-skip-config: + :goals: debug + +.. _Nucleo F410RB website: + http://www.st.com/en/evaluation-tools/nucleo-F410RB.html + +.. _STM32 Nucleo-64 board User Manual: + http://www.st.com/resource/en/user_manual/dm00105823.pdf + +.. _STM32F410RB on www.st.com: + http://www.st.com/en/microcontrollers/stm32f410rb.html + +.. _STM32F410 reference manual: + https://www.st.com/resource/en/reference_manual/dm00180366.pdf diff --git a/boards/arm/nucleo_f410rb/nucleo_f410rb.dts b/boards/arm/nucleo_f410rb/nucleo_f410rb.dts new file mode 100644 index 00000000000..ba6cfafb843 --- /dev/null +++ b/boards/arm/nucleo_f410rb/nucleo_f410rb.dts @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2020 Hans Unzner + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include +#include "arduino_r3_connector.dtsi" + +/ { + model = "STMicroelectronics STM32F410RB-NUCLEO board"; + compatible = "st,stm32f410rb-nucleo"; + + chosen { + zephyr,console = &usart2; + zephyr,shell-uart = &usart2; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + + 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>; + }; + }; + + aliases { + led0 = &green_led_2; + sw0 = &user_button; + }; +}; + +&usart1 { + pinctrl-0 = <&usart1_tx_pb6 &usart1_rx_pb7>; + current-speed = <115200>; + status = "okay"; +}; + +&usart2 { + pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>; + current-speed = <115200>; + status = "okay"; +}; + +&i2c1 { + pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>; + status = "okay"; + clock-frequency = ; +}; + +&i2c2 { + pinctrl-0 = <&i2c2_scl_pb10 &i2c2_sda_pb3>; + status = "okay"; + clock-frequency = ; +}; + +&spi1 { + pinctrl-0 = <&spi1_nss_pa4 &spi1_sck_pa5 + &spi1_miso_pa6 &spi1_mosi_pa7>; + status = "okay"; +}; + +&rtc { + status = "okay"; +}; + +&dac1 { + status = "okay"; + pinctrl-0 = <&dac_out1_pa5>; +}; + +&flash0 { + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x00000000 0x00010000>; + read-only; + }; + + /* + * The flash starting at 0x00010000 and ending at + * 0x0001ffff (sectors 16-31) is reserved for use + * by the application. + */ + storage_partition: partition@10000 { + label = "storage"; + reg = <0x00010000 0x00010000>; + }; + + slot0_partition: partition@20000 { + label = "image-0"; + reg = <0x00020000 0x00020000>; + }; + slot1_partition: partition@40000 { + label = "image-1"; + reg = <0x00040000 0x00020000>; + }; + scratch_partition: partition@60000 { + label = "image-scratch"; + reg = <0x00060000 0x00020000>; + }; + }; +}; diff --git a/boards/arm/nucleo_f410rb/nucleo_f410rb.yaml b/boards/arm/nucleo_f410rb/nucleo_f410rb.yaml new file mode 100644 index 00000000000..a1ce4005e07 --- /dev/null +++ b/boards/arm/nucleo_f410rb/nucleo_f410rb.yaml @@ -0,0 +1,18 @@ +identifier: nucleo_f410rb +name: ST Nucleo F410RB +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - arduino_gpio + - arduino_i2c + - arduino_spi + - counter + - gpio + - spi + - i2c +ram: 32 +flash: 128 diff --git a/boards/arm/nucleo_f410rb/nucleo_f410rb_defconfig b/boards/arm/nucleo_f410rb/nucleo_f410rb_defconfig new file mode 100644 index 00000000000..52695730511 --- /dev/null +++ b/boards/arm/nucleo_f410rb/nucleo_f410rb_defconfig @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_SOC_SERIES_STM32F4X=y +CONFIG_SOC_STM32F410RX=y +# 96MHz system clock (highest value to get a precise USB clock) +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=96000000 + +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable HW stack protection +CONFIG_HW_STACK_PROTECTION=y + +CONFIG_SERIAL=y + +# console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +# enable pinmux +CONFIG_PINMUX=y + +# enable GPIO +CONFIG_GPIO=y + +# clock configuration +CONFIG_CLOCK_CONTROL=y + +# Clock configuration for Cube Clock control driver +CONFIG_CLOCK_STM32_HSE_CLOCK=8000000 +CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y +# use HSE as PLL input +CONFIG_CLOCK_STM32_PLL_SRC_HSE=y +# however, the board does not have an external oscillator, so just use +# the 8MHz clock signal coming from integrated STLink +CONFIG_CLOCK_STM32_HSE_BYPASS=y + +# produce 96MHz clock at PLL output +CONFIG_CLOCK_STM32_PLL_M_DIVISOR=8 +CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=384 +CONFIG_CLOCK_STM32_PLL_P_DIVISOR=4 +CONFIG_CLOCK_STM32_PLL_Q_DIVISOR=8 +CONFIG_CLOCK_STM32_AHB_PRESCALER=1 + +# APB1 clock must not exceed 50MHz limit +CONFIG_CLOCK_STM32_APB1_PRESCALER=2 +CONFIG_CLOCK_STM32_APB2_PRESCALER=1 diff --git a/boards/arm/nucleo_f410rb/support/openocd.cfg b/boards/arm/nucleo_f410rb/support/openocd.cfg new file mode 100644 index 00000000000..9073ee6db09 --- /dev/null +++ b/boards/arm/nucleo_f410rb/support/openocd.cfg @@ -0,0 +1,12 @@ +source [find board/st_nucleo_f4.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 +}