diff --git a/boards/st/common/scripts/board_power_reset.sh b/boards/st/common/scripts/board_power_reset.sh new file mode 100755 index 000000000000..47227f7de054 --- /dev/null +++ b/boards/st/common/scripts/board_power_reset.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2025 STMicroelectronics +# +# SPDX-License-Identifier: Apache-2.0 + +STM32_Programmer_CLI -c port=swd mode=UR --power off index=0 --power on index=0 > /dev/null + +sleep 1 diff --git a/boards/st/nucleo_n657x0_q/board.cmake b/boards/st/nucleo_n657x0_q/board.cmake index a285b0deabd1..a469036845ca 100644 --- a/boards/st/nucleo_n657x0_q/board.cmake +++ b/boards/st/nucleo_n657x0_q/board.cmake @@ -1,9 +1,15 @@ # SPDX-License-Identifier: Apache-2.0 # Copyright (c) 2024 STMicroelectronics -board_runner_args(stm32cubeprogrammer "--port=swd") -board_runner_args(stm32cubeprogrammer "--tool-opt= mode=HOTPLUG ap=1") -board_runner_args(stm32cubeprogrammer "--extload=MX25UM51245G_STM32N6570-NUCLEO.stldr") -board_runner_args(stm32cubeprogrammer "--download-address=0x70000000") +if(CONFIG_STM32N6_BOOT_SERIAL) + board_runner_args(stm32cubeprogrammer "--port=usb1") + board_runner_args(stm32cubeprogrammer "--download-modifiers=0x1") + board_runner_args(stm32cubeprogrammer "--start-modifiers=noack") +else() + board_runner_args(stm32cubeprogrammer "--port=swd") + board_runner_args(stm32cubeprogrammer "--tool-opt= mode=HOTPLUG ap=1") + board_runner_args(stm32cubeprogrammer "--extload=MX25UM51245G_STM32N6570-NUCLEO.stldr") + board_runner_args(stm32cubeprogrammer "--download-address=0x70000000") +endif() include(${ZEPHYR_BASE}/boards/common/stm32cubeprogrammer.board.cmake) diff --git a/boards/st/nucleo_n657x0_q/board.yml b/boards/st/nucleo_n657x0_q/board.yml index 57f19a7e1fab..4261dec1e7bd 100644 --- a/boards/st/nucleo_n657x0_q/board.yml +++ b/boards/st/nucleo_n657x0_q/board.yml @@ -1,6 +1,8 @@ board: name: nucleo_n657x0_q - full_name: Nucleo N657x0-Q + full_name: Nucleo N657X0-Q vendor: st socs: - name: stm32n657xx + variants: + - name: sb diff --git a/boards/st/nucleo_n657x0_q/doc/index.rst b/boards/st/nucleo_n657x0_q/doc/index.rst index 3ea57ffadd38..89d28cb60248 100644 --- a/boards/st/nucleo_n657x0_q/doc/index.rst +++ b/boards/st/nucleo_n657x0_q/doc/index.rst @@ -3,7 +3,7 @@ Overview ******** -The STM32 Nucleo-144 board provides an affordable and flexible way for users to try out +The NUCLEO-N657X0-Q 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. For the compatible boards, the internal or external SMPS significantly reduces power consumption in Run mode. @@ -12,7 +12,7 @@ The ST Zio connector, which extends the ARDUINO® Uno V3 connectivity, and the S provide an easy means of expanding the functionality of the Nucleo open development platform with a wide choice of specialized shields. -The STM32 Nucleo-144 board does not require any separate probe as it integrates the ST-LINK +The NUCLEO-N657X0-Q board does not require any separate probe as it integrates the ST-LINK debugger/programmer. The STM32 Nucleo-144 board comes with the STM32 comprehensive free software libraries and @@ -51,6 +51,12 @@ Hardware - On-board ST-LINK (STLINK/V2-1, STLINK-V3E, or STLINK-V3EC) debugger/programmer with USB re-enumeration capability: mass storage, Virtual COM port, and debug port +For more details, please refer to: + +* `NUCLEO-N657X0-Q website`_ +* `STM32N657X0 on www.st.com`_ +* `STM32N657 reference manual`_ + Supported Features ================== @@ -79,10 +85,10 @@ The default configuration can be found in the defconfig file: Connections and IOs =================== -NUCLEO_N657X0_Q Board has 12 GPIO controllers. These controllers are responsible +NUCLEO-N657X0-Q Board has 12 GPIO controllers. These controllers are responsible for pin muxing, input/output, pull-up, etc. -For more details please refer to `NUCLEO_N657X0_Q User Manual`_. +For more details please refer to `NUCLEO-N657X0-Q User Manual`_. Default Zephyr Peripheral Mapping: ---------------------------------- @@ -95,83 +101,147 @@ Default Zephyr Peripheral Mapping: System Clock ------------ -NUCLEO_N657X0_Q System Clock could be driven by internal or external oscillator, +NUCLEO-N657X0-Q System Clock could be driven by internal or external oscillator, as well as main PLL clock. By default System clock is driven by PLL clock at 400MHz, driven by 64MHz high speed internal oscillator. Serial Port ----------- -NUCLEO_N657X0_Q board has 10 U(S)ARTs. The Zephyr console output is assigned to +NUCLEO-N657X0-Q board has 10 U(S)ARTs. The Zephyr console output is assigned to USART1. Default settings are 115200 8N1. Programming and Debugging ************************* -NUCLEO_N657X0_Q board includes an ST-LINK/V3 embedded debug tool interface. -This probe allows to flash the board using various tools. +NUCLEO-N657X0-Q board includes an ST-LINK/V3 embedded debug tool interface. +This probe allows to flash and debug the board using various tools. + -Flashing -======== -The board is configured to be flashed using west `STM32CubeProgrammer`_ runner, -so its :ref:`installation ` is required. +Flashing or loading +=================== + +The board is configured to be programmed using west `STM32CubeProgrammer`_ runner, +so its :ref:`installation ` is needed. Version 2.18.0 or later of `STM32CubeProgrammer`_ is required. -Flashing an application to NUCLEO_N657X0_Q ------------------------------------------- +To program the board, there are two options: + +- Program the firmware in external flash. At boot, it will then be loaded on RAM + and executed from there. +- Optionally, it can also be taken advantage from the serial boot interface provided + by the boot ROM. In that case, firmware is directly loaded in RAM and executed from + there. It is not retained. + +Programming an application to NUCLEO-N657X0-Q +--------------------------------------------- + +Here is an example to build and run :zephyr:code-sample:`hello_world` application. + +First, connect the NUCLEO-N657X0-Q to your host computer using the ST-Link USB port. -Connect the NUCLEO_N657X0_Q to your host computer using the USB port. -Then build and flash an application. + .. tabs:: + + .. group-tab:: ST-Link + + Build and flash an application using ``nucleo_n657x0_q`` target. + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: nucleo_n657x0_q + :goals: build flash .. note:: - For flashing, BOOT0 pin should be set to 0 and BOOT1 to 1 before powering on - the board. + For flashing, before powering the board, set the boot pins in the following configuration: + + * BOOT0: 0 + * BOOT1: 1 - To run the application after flashing, BOOT1 should be set to 0 and the board - should be powered off and on again. + After flashing, to run the application, set the boot pins in the following configuration: -Here is an example for the :zephyr:code-sample:`hello_world` application. + * BOOT1: 0 -Run a serial host program to connect with your Nucleo board: + Power off and on the board again. + + Run a serial host program to connect to your board: .. code-block:: console $ minicom -D /dev/ttyACM0 -Then build and flash the application. + .. group-tab:: Serial Boot Loader (USB) + + Additionally, connect the NUCLEO-N657X0-Q to your host computer using the USB port. + In this configuration, ST-Link is used to power the board and for serial communication + over the Virtual COM Port. + + .. note:: + Before powering the board, set the boot pins in the following configuration: + + * BOOT0: 1 + * BOOT1: 0 + + Build and load an application using ``nucleo_n657x0_q/stm32n657xx/sb`` target (you + can also use the shortened form: ``nucleo_n657x0_q//sb``) .. zephyr-app-commands:: :zephyr-app: samples/hello_world :board: nucleo_n657x0_q :goals: build flash + +Run a serial host program to connect to your board: + +.. code-block:: console + + $ minicom -D /dev/ttyACM0 + You should see the following message on the console: .. code-block:: console Hello World! nucleo_n657x0_q/stm32n657xx + Debugging ========= For now debugging is only available through STM32CubeIDE: -* Go to File > Import and select C/C++ > STM32 Cortex-M Executable -* In Executable field, browse to your /build/zephyr/zephyr.elf + +* Go to File > Import and select C/C++ > STM32 Cortex-M Executable. +* In Executable field, browse to your /build/zephyr/zephyr.elf. * In MCU field, select STM32N657X0HxQ. -* Click on Finish -* Then click on Debug to start the debugging session +* Click on Finish. +* Finally, click on Debug to start the debugging session. .. note:: - For debugging, BOOT0 pin should be set to 0 and BOOT1 to 1 before powering on the - board. + For debugging, before powering on the board, set the boot pins in the following configuration: + + * BOOT0: 0 + * BOOT1: 1 + + +Running tests with twister +========================== -.. _NUCLEO_N657X0_Q website: +Due to the BOOT switches manipulation required when flashing the board using ``nucleo_n657x0_q`` +board target, it is only possible to run twister tests campaign on ``nucleo_n657x0_q/stm32n657xx/sb`` +board target which doesn't require BOOT pins changes to load and execute binaries. +To do so, it is advised to use Twister's hardware map feature with the following settings: + +.. code-block:: yaml + + - platform: nucleo_n657x0_q/stm32n657xx/sb + product: BOOT-SERIAL + pre_script: /boards/st/common/scripts/board_power_reset.sh + runner: stm32cubeprogrammer + +.. _NUCLEO-N657X0-Q website: https://www.st.com/en/evaluation-tools/nucleo-n657x0-q.html -.. _NUCLEO_N657X0_Q User Manual: +.. _NUCLEO-N657X0-Q User Manual: https://www.st.com/resource/en/user_manual/um3417-stm32n6-nucleo144-board-mb1940-stmicroelectronics.pdf - .. _STM32N657X0 on www.st.com: https://www.st.com/en/microcontrollers-microprocessors/stm32n657x0.html diff --git a/boards/st/nucleo_n657x0_q/nucleo_n657x0_q.dts b/boards/st/nucleo_n657x0_q/nucleo_n657x0_q.dts index 92943cbfd52f..1e6d99ed6324 100644 --- a/boards/st/nucleo_n657x0_q/nucleo_n657x0_q.dts +++ b/boards/st/nucleo_n657x0_q/nucleo_n657x0_q.dts @@ -1,124 +1,13 @@ /* - * Copyright (c) 2024 STMicroelectronics + * Copyright (c) 2025 STMicroelectronics * * SPDX-License-Identifier: Apache-2.0 */ /dts-v1/; -#include -#include -#include +#include "nucleo_n657x0_q_common.dtsi" / { model = "STMicroelectronics STM32N657X0-Q-NUCLEO board"; compatible = "st,stm32n657x0-q-nucleo"; - - chosen { - zephyr,console = &usart1; - zephyr,shell-uart = &usart1; - zephyr,sram = &axisram2; - }; - - leds: leds { - compatible = "gpio-leds"; - - green_led: led_1 { - gpios = <&gpiog 0 GPIO_ACTIVE_HIGH>; - label = "User LD6"; - }; - - blue_led: led_2 { - gpios = <&gpiog 8 GPIO_ACTIVE_HIGH>; - label = "User LD7"; - }; - - red_led: led_3 { - gpios = <&gpiog 10 GPIO_ACTIVE_HIGH>; - label = "User LD5"; - }; - }; - - gpio_keys { - compatible = "gpio-keys"; - - user_button: button_0 { - gpios = <&gpioc 13 GPIO_ACTIVE_HIGH>; - label = "User SB1"; - zephyr,code = ; - }; - }; - - aliases { - led0 = &green_led; - sw0 = &user_button; - }; -}; - -&clk_hsi { - hsi-div = <1>; - status = "okay"; -}; - -&pll1 { - clocks = <&clk_hsi>; - div-m = <4>; - mul-n = <75>; - div-p1 = <1>; - div-p2 = <1>; - status = "okay"; -}; - -&ic1 { - pll-src = <1>; - ic-div = <2>; - status = "okay"; -}; - -&ic2 { - pll-src = <1>; - ic-div = <3>; - status = "okay"; -}; - -&ic6 { - pll-src = <1>; - ic-div = <2>; - status = "okay"; -}; - -&ic11 { - pll-src = <1>; - ic-div = <3>; - status = "okay"; -}; - -&perck { - clocks = <&rcc STM32_SRC_HSI PER_SEL(0)>; - status = "okay"; -}; - -&cpusw { - clocks = <&rcc STM32_SRC_IC1 CPU_SEL(3)>; - clock-frequency = ; - status = "okay"; -}; - -&rcc { - /* ic2, ic6 & ic11 must all be enabled to set ic2 as SYSCLK */ - clocks = <&ic2>; - clock-frequency = ; - ahb-prescaler = <2>; - apb1-prescaler = <1>; - apb2-prescaler = <1>; - apb4-prescaler = <1>; - apb5-prescaler = <1>; -}; - -&usart1 { - clocks = <&rcc STM32_CLOCK(APB2, 4)>, - <&rcc STM32_SRC_CKPER USART1_SEL(1)>; - pinctrl-0 = <&usart1_tx_pe5 &usart1_rx_pe6>; - pinctrl-names = "default"; - current-speed = <115200>; - status = "okay"; }; diff --git a/boards/st/nucleo_n657x0_q/nucleo_n657x0_q.yaml b/boards/st/nucleo_n657x0_q/nucleo_n657x0_q.yaml deleted file mode 100644 index 7e398f0d7fe9..000000000000 --- a/boards/st/nucleo_n657x0_q/nucleo_n657x0_q.yaml +++ /dev/null @@ -1,14 +0,0 @@ -identifier: nucleo_n657x0_q -name: ST Nucleo N657X0-Q -type: mcu -arch: arm -toolchain: - - zephyr - - gnuarmemb - - xtools -ram: 1024 -flash: 0 -supported: - - gpio - - uart -vendor: st diff --git a/boards/st/nucleo_n657x0_q/nucleo_n657x0_q_common.dtsi b/boards/st/nucleo_n657x0_q/nucleo_n657x0_q_common.dtsi new file mode 100644 index 000000000000..3dffbe335e73 --- /dev/null +++ b/boards/st/nucleo_n657x0_q/nucleo_n657x0_q_common.dtsi @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +/ { + chosen { + zephyr,console = &usart1; + zephyr,shell-uart = &usart1; + zephyr,sram = &axisram2; + }; + + leds: leds { + compatible = "gpio-leds"; + + green_led: led_1 { + gpios = <&gpiog 0 GPIO_ACTIVE_HIGH>; + label = "User LD6"; + }; + + blue_led: led_2 { + gpios = <&gpiog 8 GPIO_ACTIVE_HIGH>; + label = "User LD7"; + }; + + red_led: led_3 { + gpios = <&gpiog 10 GPIO_ACTIVE_HIGH>; + label = "User LD5"; + }; + }; + + gpio_keys { + compatible = "gpio-keys"; + + user_button: button_0 { + gpios = <&gpioc 13 GPIO_ACTIVE_HIGH>; + label = "User SB1"; + zephyr,code = ; + }; + }; + + aliases { + led0 = &green_led; + sw0 = &user_button; + }; +}; + +&clk_hsi { + hsi-div = <1>; + status = "okay"; +}; + +&pll1 { + clocks = <&clk_hsi>; + div-m = <4>; + mul-n = <75>; + div-p1 = <1>; + div-p2 = <1>; + status = "okay"; +}; + +&ic1 { + pll-src = <1>; + ic-div = <2>; + status = "okay"; +}; + +&ic2 { + pll-src = <1>; + ic-div = <3>; + status = "okay"; +}; + +&ic6 { + pll-src = <1>; + ic-div = <2>; + status = "okay"; +}; + +&ic11 { + pll-src = <1>; + ic-div = <3>; + status = "okay"; +}; + +&perck { + clocks = <&rcc STM32_SRC_HSI PER_SEL(0)>; + status = "okay"; +}; + +&cpusw { + clocks = <&rcc STM32_SRC_IC1 CPU_SEL(3)>; + clock-frequency = ; + status = "okay"; +}; + +&rcc { + /* ic2, ic6 & ic11 must all be enabled to set ic2 as SYSCLK */ + clocks = <&ic2>; + clock-frequency = ; + ahb-prescaler = <2>; + apb1-prescaler = <1>; + apb2-prescaler = <1>; + apb4-prescaler = <1>; + apb5-prescaler = <1>; +}; + +&usart1 { + clocks = <&rcc STM32_CLOCK(APB2, 4)>, + <&rcc STM32_SRC_CKPER USART1_SEL(1)>; + pinctrl-0 = <&usart1_tx_pe5 &usart1_rx_pe6>; + pinctrl-names = "default"; + current-speed = <115200>; + status = "okay"; +}; diff --git a/boards/st/nucleo_n657x0_q/nucleo_n657x0_q_stm32n657xx_sb.dts b/boards/st/nucleo_n657x0_q/nucleo_n657x0_q_stm32n657xx_sb.dts new file mode 100644 index 000000000000..e7d5f3473043 --- /dev/null +++ b/boards/st/nucleo_n657x0_q/nucleo_n657x0_q_stm32n657xx_sb.dts @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include "nucleo_n657x0_q_common.dtsi" + +/ { + model = "STMicroelectronics STM32N657X0-Q-NUCLEO board"; + compatible = "st,stm32n657x0-q-nucleo-sb"; +}; diff --git a/boards/st/nucleo_n657x0_q/nucleo_n657x0_q_stm32n657xx_sb_defconfig b/boards/st/nucleo_n657x0_q/nucleo_n657x0_q_stm32n657xx_sb_defconfig new file mode 100644 index 000000000000..4cb7201f9f9b --- /dev/null +++ b/boards/st/nucleo_n657x0_q/nucleo_n657x0_q_stm32n657xx_sb_defconfig @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2024 STMicroelectronics + +# Enable UART driver +CONFIG_SERIAL=y + +# Enable GPIO +CONFIG_GPIO=y + +# Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +# No internal Flash +CONFIG_XIP=n + +# Use serial boot (USB) +CONFIG_STM32N6_BOOT_SERIAL=y diff --git a/boards/st/nucleo_n657x0_q/twister.yaml b/boards/st/nucleo_n657x0_q/twister.yaml new file mode 100644 index 000000000000..9fe4ce0680eb --- /dev/null +++ b/boards/st/nucleo_n657x0_q/twister.yaml @@ -0,0 +1,16 @@ +name: ST Nucleo N657X0-Q +type: mcu +arch: arm +ram: 1024 +flash: 1024 +supported: + - gpio + - uart +vendor: st +variants: + nucleo_n657x0_q/stm32n657xx: + twister: false + nucleo_n657x0_q/stm32n657xx/sb: + toolchain: + - zephyr + - gnuarmemb diff --git a/boards/st/stm32n6570_dk/board.cmake b/boards/st/stm32n6570_dk/board.cmake index fbbb050642a7..becac84524af 100644 --- a/boards/st/stm32n6570_dk/board.cmake +++ b/boards/st/stm32n6570_dk/board.cmake @@ -1,9 +1,15 @@ # SPDX-License-Identifier: Apache-2.0 # Copyright (c) 2024 STMicroelectronics -board_runner_args(stm32cubeprogrammer "--port=swd") -board_runner_args(stm32cubeprogrammer "--tool-opt= mode=HOTPLUG ap=1") -board_runner_args(stm32cubeprogrammer "--extload=MX66UW1G45G_STM32N6570-DK.stldr") -board_runner_args(stm32cubeprogrammer "--download-address=0x70000000") +if(CONFIG_STM32N6_BOOT_SERIAL) + board_runner_args(stm32cubeprogrammer "--port=usb1") + board_runner_args(stm32cubeprogrammer "--download-modifiers=0x1") + board_runner_args(stm32cubeprogrammer "--start-modifiers=noack") +else() + board_runner_args(stm32cubeprogrammer "--port=swd") + board_runner_args(stm32cubeprogrammer "--tool-opt= mode=HOTPLUG ap=1") + board_runner_args(stm32cubeprogrammer "--extload=MX66UW1G45G_STM32N6570-DK.stldr") + board_runner_args(stm32cubeprogrammer "--download-address=0x70000000") +endif() include(${ZEPHYR_BASE}/boards/common/stm32cubeprogrammer.board.cmake) diff --git a/boards/st/stm32n6570_dk/board.yml b/boards/st/stm32n6570_dk/board.yml index 04d7a92c5b05..2bdf8abd80e2 100644 --- a/boards/st/stm32n6570_dk/board.yml +++ b/boards/st/stm32n6570_dk/board.yml @@ -4,3 +4,5 @@ board: vendor: st socs: - name: stm32n657xx + variants: + - name: sb diff --git a/boards/st/stm32n6570_dk/doc/index.rst b/boards/st/stm32n6570_dk/doc/index.rst index 7b4218d2c8f0..7ffd7667004f 100644 --- a/boards/st/stm32n6570_dk/doc/index.rst +++ b/boards/st/stm32n6570_dk/doc/index.rst @@ -55,6 +55,11 @@ Hardware - On-board STLINK-V3EC debugger/programmer with USB re-enumeration capability: Virtual COM port, and debug port +For more details, please refer to: + +* `STM32N6570_DK website`_ +* `STM32N657X0 on www.st.com`_ +* `STM32N657 reference manual`_ Supported Features ================== @@ -114,29 +119,80 @@ Programming and Debugging ************************* STM32N6570_DK board includes an ST-LINK/V3 embedded debug tool interface. -This probe allows to flash the board using various tools. +This probe allows to flash and debug the board using various tools. + -Flashing -======== +Flashing or loading +=================== -The board is configured to be flashed using west `STM32CubeProgrammer`_ runner, -so its :ref:`installation ` is required. +The board is configured to be programmed using west `STM32CubeProgrammer`_ runner, +so its :ref:`installation ` is needed. Version 2.18.0 or later of `STM32CubeProgrammer`_ is required. -Flashing an application to STM32N6570_DK ------------------------------------------- +To program the board, there are two options: -Connect the STM32N6570_DK to your host computer using the USB port. -Then build and flash an application. +- Program the firmware in external flash. At boot, it will then be loaded on RAM + and executed from there. +- Optionally, it can also be taken advantage from the serial boot interface provided + by the boot ROM. In that case, firmware is directly loaded in RAM and executed from + there. It is not retained. -.. note:: - For flashing, BOOT0 pin should be set to 0 and BOOT1 to 1 before powering on - the board. +Programming an application to STM32N6570_DK +------------------------------------------- + +Here is an example to build and run :zephyr:code-sample:`hello_world` application. + +First, connect the STM32N6570_DK to your host computer using the ST-Link USB port. + + .. tabs:: + + .. group-tab:: ST-Link + + Build and flash an application using ``stm32n6570_dk`` target. + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: stm32n6570_dk + :goals: build flash + + .. note:: + For flashing, before powering the board, set the boot pins in the following configuration: + + * BOOT0: 0 + * BOOT1: 1 + + After flashing, to run the application, set the boot pins in the following configuration: + + * BOOT1: 0 + + Power off and on the board again. + + Run a serial host program to connect to your board: - To run the application after flashing, BOOT1 should be set to 0 and the board - should be powered off and on again. + .. code-block:: console + + $ minicom -D /dev/ttyACM0 + + .. group-tab:: Serial Boot Loader (USB) + + Additionally, connect the STM32N6570_DK to your host computer using the USB port. + In this configuration, ST-Link is used to power the board and for serial communication + over the Virtual COM Port. + + .. note:: + Before powering the board, set the boot pins in the following configuration: + + * BOOT0: 1 + * BOOT1: 0 + + Build and load an application using ``stm32n6570_dk/stm32n657xx/sb`` target (you + can also use the shortened form: ``stm32n6570_dk//sb``) + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: stm32n6570_dk//sb + :goals: build flash -Here is an example for the :zephyr:code-sample:`hello_world` application. Run a serial host program to connect with your Disco board: @@ -144,13 +200,6 @@ Run a serial host program to connect with your Disco board: $ minicom -D /dev/ttyACM0 -Then build and flash the application. - -.. zephyr-app-commands:: - :zephyr-app: samples/hello_world - :board: stm32n6570_dk - :goals: build flash - You should see the following message on the console: .. code-block:: console @@ -162,15 +211,34 @@ Debugging ========= For now debugging is only available through STM32CubeIDE: -* Go to File > Import and select C/C++ > STM32 Cortex-M Executable -* In Executable field, browse to your /build/zephyr/zephyr.elf + +* Go to File > Import and select C/C++ > STM32 Cortex-M Executable. +* In Executable field, browse to your /build/zephyr/zephyr.elf. * In MCU field, select STM32N657X0HxQ. -* Click on Finish -* Then click on Debug to start the debugging session +* Click on Finish. +* Finally, click on Debug to start the debugging session. .. note:: - For debugging, BOOT0 pin should be set to 0 and BOOT1 to 1 before powering on the - board. + For debugging, before powering on the board, set the boot pins in the following configuration: + + * BOOT0: 0 + * BOOT1: 1 + + +Running tests with twister +========================== + +Due to the BOOT switches manipulation required when flashing the board using ``stm32n6570_dk`` +board target, it is only possible to run twister tests campaign on ``stm32n6570_dk/stm32n657xx/sb`` +board target which doesn't require BOOT pins changes to load and execute binaries. +To do so, it is advised to use Twister's hardware map feature with the following settings: + +.. code-block:: yaml + + - platform: stm32n6570_dk/stm32n657xx/sb + product: BOOT-SERIAL + pre_script: /boards/st/common/scripts/board_power_reset.sh + runner: stm32cubeprogrammer .. _STM32N6570_DK website: https://www.st.com/en/evaluation-tools/stm32n6570-dk.html diff --git a/boards/st/stm32n6570_dk/stm32n6570_dk.dts b/boards/st/stm32n6570_dk/stm32n6570_dk.dts index 94cd6ac702b0..82bb8b72dde7 100644 --- a/boards/st/stm32n6570_dk/stm32n6570_dk.dts +++ b/boards/st/stm32n6570_dk/stm32n6570_dk.dts @@ -1,108 +1,13 @@ /* - * Copyright (c) 2024 STMicroelectronics + * Copyright (c) 2025 STMicroelectronics * * SPDX-License-Identifier: Apache-2.0 */ /dts-v1/; -#include -#include -#include +#include "stm32n6570_dk_common.dtsi" / { model = "STMicroelectronics STM32N6570 Discovery Kit board"; compatible = "st,stm32n6570-dk"; - - chosen { - zephyr,console = &usart1; - zephyr,shell-uart = &usart1; - zephyr,sram = &axisram2; - }; - - aliases { - led0 = &green_led_1; - }; - - leds: leds { - compatible = "gpio-leds"; - - green_led_1: led_1 { - gpios = <&gpioo 1 GPIO_ACTIVE_HIGH>; - label = "User LD1"; - }; - - red_led_1: led_2 { - gpios = <&gpiog 10 GPIO_ACTIVE_HIGH>; - label = "User LD2"; - }; - }; -}; - -&clk_hsi { - hsi-div = <1>; - status = "okay"; -}; - -&pll1 { - clocks = <&clk_hsi>; - div-m = <4>; - mul-n = <75>; - div-p1 = <1>; - div-p2 = <1>; - status = "okay"; -}; - -&ic1 { - pll-src = <1>; - ic-div = <2>; - status = "okay"; -}; - -&ic2 { - pll-src = <1>; - ic-div = <3>; - status = "okay"; -}; - -&ic6 { - pll-src = <1>; - ic-div = <2>; - status = "okay"; -}; - -&ic11 { - pll-src = <1>; - ic-div = <3>; - status = "okay"; -}; - -&perck { - clocks = <&rcc STM32_SRC_HSI PER_SEL(0)>; - status = "okay"; -}; - -&cpusw { - clocks = <&rcc STM32_SRC_IC1 CPU_SEL(3)>; - clock-frequency = ; - status = "okay"; -}; - -&rcc { - /* ic2, ic6 & ic11 must all be enabled to set ic2 as SYSCLK */ - clocks = <&ic2>; - clock-frequency = ; - ahb-prescaler = <2>; - apb1-prescaler = <1>; - apb2-prescaler = <1>; - apb4-prescaler = <1>; - apb5-prescaler = <1>; -}; - -&usart1 { - clocks = <&rcc STM32_CLOCK(APB2, 4)>, - <&rcc STM32_SRC_CKPER USART1_SEL(1)>; - pinctrl-0 = <&usart1_tx_pe5 &usart1_rx_pe6>; - pinctrl-names = "default"; - current-speed = <115200>; - status = "okay"; }; diff --git a/boards/st/stm32n6570_dk/stm32n6570_dk.yaml b/boards/st/stm32n6570_dk/stm32n6570_dk.yaml deleted file mode 100644 index 390fd67caa93..000000000000 --- a/boards/st/stm32n6570_dk/stm32n6570_dk.yaml +++ /dev/null @@ -1,14 +0,0 @@ -identifier: stm32n6570_dk -name: STM32N6570 Discovery Kit -type: mcu -arch: arm -toolchain: - - zephyr - - gnuarmemb - - xtools -ram: 1024 -flash: 0 -supported: - - gpio - - uart -vendor: st diff --git a/boards/st/stm32n6570_dk/stm32n6570_dk_common.dtsi b/boards/st/stm32n6570_dk/stm32n6570_dk_common.dtsi new file mode 100644 index 000000000000..ba29343eda0a --- /dev/null +++ b/boards/st/stm32n6570_dk/stm32n6570_dk_common.dtsi @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +/ { + chosen { + zephyr,console = &usart1; + zephyr,shell-uart = &usart1; + zephyr,sram = &axisram2; + }; + + aliases { + led0 = &green_led_1; + }; + + leds: leds { + compatible = "gpio-leds"; + + green_led_1: led_1 { + gpios = <&gpioo 1 GPIO_ACTIVE_HIGH>; + label = "User LD1"; + }; + + red_led_1: led_2 { + gpios = <&gpiog 10 GPIO_ACTIVE_HIGH>; + label = "User LD2"; + }; + }; +}; + +&clk_hsi { + hsi-div = <1>; + status = "okay"; +}; + +&pll1 { + clocks = <&clk_hsi>; + div-m = <4>; + mul-n = <75>; + div-p1 = <1>; + div-p2 = <1>; + status = "okay"; +}; + +&ic1 { + pll-src = <1>; + ic-div = <2>; + status = "okay"; +}; + +&ic2 { + pll-src = <1>; + ic-div = <3>; + status = "okay"; +}; + +&ic6 { + pll-src = <1>; + ic-div = <2>; + status = "okay"; +}; + +&ic11 { + pll-src = <1>; + ic-div = <3>; + status = "okay"; +}; + +&perck { + clocks = <&rcc STM32_SRC_HSI PER_SEL(0)>; + status = "okay"; +}; + +&cpusw { + clocks = <&rcc STM32_SRC_IC1 CPU_SEL(3)>; + clock-frequency = ; + status = "okay"; +}; + +&rcc { + /* ic2, ic6 & ic11 must all be enabled to set ic2 as SYSCLK */ + clocks = <&ic2>; + clock-frequency = ; + ahb-prescaler = <2>; + apb1-prescaler = <1>; + apb2-prescaler = <1>; + apb4-prescaler = <1>; + apb5-prescaler = <1>; +}; + +&usart1 { + clocks = <&rcc STM32_CLOCK(APB2, 4)>, + <&rcc STM32_SRC_CKPER USART1_SEL(1)>; + pinctrl-0 = <&usart1_tx_pe5 &usart1_rx_pe6>; + pinctrl-names = "default"; + current-speed = <115200>; + status = "okay"; +}; diff --git a/boards/st/stm32n6570_dk/stm32n6570_dk_stm32n657xx_sb.dts b/boards/st/stm32n6570_dk/stm32n6570_dk_stm32n657xx_sb.dts new file mode 100644 index 000000000000..967209c2fcc4 --- /dev/null +++ b/boards/st/stm32n6570_dk/stm32n6570_dk_stm32n657xx_sb.dts @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include "stm32n6570_dk_common.dtsi" + +/ { + model = "STMicroelectronics STM32N6570 Discovery Kit board"; + compatible = "st,stm32n6570-dk-serial-boot"; +}; diff --git a/boards/st/stm32n6570_dk/stm32n6570_dk_stm32n657xx_sb_defconfig b/boards/st/stm32n6570_dk/stm32n6570_dk_stm32n657xx_sb_defconfig new file mode 100644 index 000000000000..4cb7201f9f9b --- /dev/null +++ b/boards/st/stm32n6570_dk/stm32n6570_dk_stm32n657xx_sb_defconfig @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2024 STMicroelectronics + +# Enable UART driver +CONFIG_SERIAL=y + +# Enable GPIO +CONFIG_GPIO=y + +# Console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +# No internal Flash +CONFIG_XIP=n + +# Use serial boot (USB) +CONFIG_STM32N6_BOOT_SERIAL=y diff --git a/boards/st/stm32n6570_dk/twister.yaml b/boards/st/stm32n6570_dk/twister.yaml new file mode 100644 index 000000000000..3ed79107db03 --- /dev/null +++ b/boards/st/stm32n6570_dk/twister.yaml @@ -0,0 +1,16 @@ +name: STM32N6570 Discovery Kit +type: mcu +arch: arm +ram: 1024 +flash: 1024 +vendor: st +supported: + - gpio + - uart +variants: + stm32n6570_dk/stm32n657xx: + twister: false + stm32n6570_dk/stm32n657xx/sb: + toolchain: + - zephyr + - gnuarmemb diff --git a/scripts/pylib/twister/twisterlib/handlers.py b/scripts/pylib/twister/twisterlib/handlers.py index eb7d90ddd3eb..5b3922f9de79 100755 --- a/scripts/pylib/twister/twisterlib/handlers.py +++ b/scripts/pylib/twister/twisterlib/handlers.py @@ -595,7 +595,7 @@ def _create_command(self, runner, hardware): # --probe=# select by probe index # --probe= select by probe serial number command.append(f"--probe={board_id}") - elif runner == "stm32cubeprogrammer": + elif runner == "stm32cubeprogrammer" and product != "BOOT-SERIAL": command.append(f"--tool-opt=sn={board_id}") # Receive parameters from runner_params field. diff --git a/scripts/west_commands/runners/stm32cubeprogrammer.py b/scripts/west_commands/runners/stm32cubeprogrammer.py index a124e32d168f..032e40837bf8 100644 --- a/scripts/west_commands/runners/stm32cubeprogrammer.py +++ b/scripts/west_commands/runners/stm32cubeprogrammer.py @@ -35,7 +35,9 @@ def __init__( frequency: int | None, reset_mode: str | None, download_address: int | None, + download_modifiers: list[str], start_address: int | None, + start_modifiers: list[str], conn_modifiers: str | None, cli: Path | None, use_elf: bool, @@ -47,8 +49,17 @@ def __init__( self._port = port self._frequency = frequency + self._download_address = download_address + self._download_modifiers: list[str] = list() + for opts in [shlex.split(opt) for opt in download_modifiers]: + self._download_modifiers += opts + self._start_address = start_address + self._start_modifiers: list[str] = list() + for opts in [shlex.split(opt) for opt in start_modifiers]: + self._start_modifiers += opts + self._reset_mode = reset_mode self._conn_modifiers = conn_modifiers self._cli = ( @@ -160,6 +171,13 @@ def do_add_parser(cls, parser): required=False, help="Address where flashing should be done" ) + parser.add_argument( + "--download-modifiers", + default=[], + required=False, + action='append', + help="Additional options for the --download argument" + ) parser.add_argument( "--start-address", # To accept arguments in hex format, a wrapper lambda around int() must be used. @@ -169,6 +187,13 @@ def do_add_parser(cls, parser): required=False, help="Address where execution should begin after flashing" ) + parser.add_argument( + "--start-modifiers", + default=[], + required=False, + action='append', + help="Additional options for the --start argument" + ) parser.add_argument( "--conn-modifiers", type=str, @@ -206,7 +231,9 @@ def do_create( frequency=args.frequency, reset_mode=args.reset_mode, download_address=args.download_address, + download_modifiers=args.download_modifiers, start_address=args.start_address, + start_modifiers=args.start_modifiers, conn_modifiers=args.conn_modifiers, cli=args.cli, use_elf=args.use_elf, @@ -261,6 +288,7 @@ def flash(self, **kwargs) -> None: flash_and_run_args = ["--download", dl_file] if self._download_address is not None: flash_and_run_args.append(f"0x{self._download_address:X}") + flash_and_run_args += self._download_modifiers # '--start' is needed to start execution after flash. # The default start address is the beggining of the flash, @@ -268,5 +296,6 @@ def flash(self, **kwargs) -> None: flash_and_run_args.append("--start") if self._start_address is not None: flash_and_run_args.append(f"0x{self._start_address:X}") + flash_and_run_args += self._start_modifiers self.check_call(cmd + flash_and_run_args) diff --git a/scripts/west_commands/tests/test_stm32cubeprogrammer.py b/scripts/west_commands/tests/test_stm32cubeprogrammer.py index 216e9233b55a..917a0099b45e 100644 --- a/scripts/west_commands/tests/test_stm32cubeprogrammer.py +++ b/scripts/west_commands/tests/test_stm32cubeprogrammer.py @@ -67,6 +67,8 @@ "download_address": None, "start_address": None, "conn_modifiers": None, + "start_modifiers": [], + "download_modifiers": [], "cli": CLI_PATH, "use_elf": False, "erase": False, @@ -92,6 +94,8 @@ "download_address": None, "start_address": 0x8001000, "conn_modifiers": None, + "start_modifiers": [], + "download_modifiers": [], "cli": CLI_PATH, "use_elf": False, "erase": False, @@ -118,6 +122,8 @@ "download_address": None, "start_address": None, "conn_modifiers": None, + "start_modifiers": [], + "download_modifiers": [], "cli": CLI_PATH, "use_elf": False, "erase": False, @@ -143,6 +149,8 @@ "download_address": None, "start_address": None, "conn_modifiers": None, + "start_modifiers": [], + "download_modifiers": [], "cli": CLI_PATH, "use_elf": False, "erase": False, @@ -168,6 +176,8 @@ "download_address": None, "start_address": None, "conn_modifiers": None, + "start_modifiers": [], + "download_modifiers": [], "cli": CLI_PATH, "use_elf": False, "erase": False, @@ -193,6 +203,8 @@ "download_address": None, "start_address": None, "conn_modifiers": None, + "start_modifiers": [], + "download_modifiers": [], "cli": CLI_PATH, "use_elf": False, "erase": False, @@ -218,6 +230,8 @@ "download_address": None, "start_address": None, "conn_modifiers": "br=115200 sn=TEST", + "start_modifiers": [], + "download_modifiers": [], "cli": CLI_PATH, "use_elf": False, "erase": False, @@ -243,6 +257,8 @@ "download_address": None, "start_address": None, "conn_modifiers": None, + "start_modifiers": [], + "download_modifiers": [], "cli": CLI_PATH, "use_elf": True, "erase": False, @@ -268,6 +284,8 @@ "download_address": None, "start_address": None, "conn_modifiers": None, + "start_modifiers": [], + "download_modifiers": [], "cli": CLI_PATH, "use_elf": False, "erase": True, @@ -294,6 +312,8 @@ "download_address": None, "start_address": None, "conn_modifiers": None, + "start_modifiers": [], + "download_modifiers": [], "cli": CLI_PATH, "use_elf": False, "erase": False, @@ -320,6 +340,8 @@ "download_address": None, "start_address": None, "conn_modifiers": None, + "start_modifiers": [], + "download_modifiers": [], "cli": None, "use_elf": False, "erase": False, @@ -345,6 +367,8 @@ "download_address": None, "start_address": None, "conn_modifiers": None, + "start_modifiers": [], + "download_modifiers": [], "cli": None, "use_elf": False, "erase": False, @@ -370,6 +394,8 @@ "download_address": None, "start_address": None, "conn_modifiers": None, + "start_modifiers": [], + "download_modifiers": [], "cli": None, "use_elf": False, "erase": False, @@ -395,6 +421,8 @@ "download_address": 0x80000000, "start_address": None, "conn_modifiers": None, + "start_modifiers": ["noack"], + "download_modifiers": ["0x1"], "cli": CLI_PATH, "use_elf": False, "erase": False, @@ -410,7 +438,9 @@ "--download", RC_KERNEL_HEX, "0x80000000", + "0x1", "--start", + "noack", ], ], }, @@ -440,7 +470,9 @@ def test_stm32cubeprogrammer_init( frequency=tc["frequency"], reset_mode=tc["reset_mode"], download_address=tc["download_address"], + download_modifiers=tc["download_modifiers"], start_address=tc["start_address"], + start_modifiers=tc["start_modifiers"], conn_modifiers=tc["conn_modifiers"], cli=tc["cli"], use_elf=tc["use_elf"], @@ -492,6 +524,10 @@ def test_stm32cubeprogrammer_create( args.extend(["--extload", tc["extload"]]) if tc["tool_opt"]: args.extend(["--tool-opt", " " + tc["tool_opt"][0]]) + if tc["download_modifiers"]: + args.extend(["--download-modifiers", " " + tc["download_modifiers"][0]]) + if tc["start_modifiers"]: + args.extend(["--start-modifiers", " " + tc["start_modifiers"][0]]) parser = argparse.ArgumentParser(allow_abbrev=False) STM32CubeProgrammerBinaryRunner.add_parser(parser) diff --git a/soc/st/stm32/stm32n6x/CMakeLists.txt b/soc/st/stm32/stm32n6x/CMakeLists.txt index 008bb9440cd2..d8ded3541e4f 100644 --- a/soc/st/stm32/stm32n6x/CMakeLists.txt +++ b/soc/st/stm32/stm32n6x/CMakeLists.txt @@ -15,13 +15,25 @@ else() set(SIGNING_TOOL STM32_SigningTool_CLI) endif() -set_property(GLOBAL APPEND PROPERTY extra_post_build_commands - COMMAND ${SIGNING_TOOL} - -in ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.bin - -nk -t fsbl -hv 2.3 - -o ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.signed.bin - -dump ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.signed.bin - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} -) - -set_property(TARGET runners_yaml_props_target PROPERTY bin_file ${CONFIG_KERNEL_BIN_NAME}.signed.bin) +find_file(SIGNING_TOOL_FIND ${SIGNING_TOOL}) +if(SIGNING_TOOL_FIND STREQUAL SIGNING_TOOL_FIND-NOTFOUND) + message(WARNING " + Signing Image tool (${SIGNING_TOOL}) is not available. + Signed image will not be generated. + You won't be able to run image on board.") +endif() + +if(NOT SIGNING_TOOL_FIND STREQUAL SIGNING_TOOL_FIND-NOTFOUND) + + set_property(GLOBAL APPEND PROPERTY extra_post_build_commands + COMMAND ${SIGNING_TOOL} + -in ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.bin + -nk -t fsbl -hv 2.3 + -o ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.signed.bin + -dump ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.signed.bin + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + ) + + set_property(TARGET runners_yaml_props_target PROPERTY bin_file ${CONFIG_KERNEL_BIN_NAME}.signed.bin) + +endif() diff --git a/soc/st/stm32/stm32n6x/Kconfig b/soc/st/stm32/stm32n6x/Kconfig index e8711ce26fd0..61b5a7f29a7d 100644 --- a/soc/st/stm32/stm32n6x/Kconfig +++ b/soc/st/stm32/stm32n6x/Kconfig @@ -17,3 +17,6 @@ config SOC_SERIES_STM32N6X select SOC_RESET_HOOK select TRUSTED_EXECUTION_SECURE select BUILD_OUTPUT_BIN + +config STM32N6_BOOT_SERIAL + bool "Serial boot target (USB)" diff --git a/tests/drivers/uart/uart_async_api/boards/nucleo_n657x0_q_stm32n657xx_sb.conf b/tests/drivers/uart/uart_async_api/boards/nucleo_n657x0_q_stm32n657xx_sb.conf new file mode 100644 index 000000000000..24be02d577c4 --- /dev/null +++ b/tests/drivers/uart/uart_async_api/boards/nucleo_n657x0_q_stm32n657xx_sb.conf @@ -0,0 +1 @@ +CONFIG_DCACHE=n diff --git a/tests/drivers/uart/uart_async_api/boards/stm32n6570_dk_stm32n657xx_sb.conf b/tests/drivers/uart/uart_async_api/boards/stm32n6570_dk_stm32n657xx_sb.conf new file mode 100644 index 000000000000..24be02d577c4 --- /dev/null +++ b/tests/drivers/uart/uart_async_api/boards/stm32n6570_dk_stm32n657xx_sb.conf @@ -0,0 +1 @@ +CONFIG_DCACHE=n