Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards: stm32n6: Add serial boot variant #84869

Merged
merged 12 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions boards/st/common/scripts/board_power_reset.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erwango Sorry for the late review, shouldn't this script be in Python for the sake of portability?

Original file line number Diff line number Diff line change
@@ -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
14 changes: 10 additions & 4 deletions boards/st/nucleo_n657x0_q/board.cmake
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 3 additions & 1 deletion boards/st/nucleo_n657x0_q/board.yml
Original file line number Diff line number Diff line change
@@ -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
134 changes: 102 additions & 32 deletions boards/st/nucleo_n657x0_q/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
==================

Expand Down Expand Up @@ -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:
----------------------------------
Expand All @@ -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 <stm32cubeprog-flash-host-tools>` is required.
Flashing or loading
===================

The board is configured to be programmed using west `STM32CubeProgrammer`_ runner,
so its :ref:`installation <stm32cubeprog-flash-host-tools>` 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 <ZEPHYR_PATH>/build/zephyr/zephyr.elf

* Go to File > Import and select C/C++ > STM32 Cortex-M Executable.
* In Executable field, browse to your <ZEPHYR_PATH>/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: <path_to_zephyr>/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

Expand Down
115 changes: 2 additions & 113 deletions boards/st/nucleo_n657x0_q/nucleo_n657x0_q.dts
Original file line number Diff line number Diff line change
@@ -1,124 +1,13 @@
/*
* Copyright (c) 2024 STMicroelectronics
* Copyright (c) 2025 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;
#include <st/n6/stm32n657X0.dtsi>
#include <st/n6/stm32n657x0hxq-pinctrl.dtsi>
#include <zephyr/dt-bindings/input/input-event-codes.h>
#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 = <INPUT_KEY_0>;
};
};

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 = <DT_FREQ_M(600)>;
status = "okay";
};

&rcc {
/* ic2, ic6 & ic11 must all be enabled to set ic2 as SYSCLK */
clocks = <&ic2>;
clock-frequency = <DT_FREQ_M(400)>;
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";
};
Loading
Loading