You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2026/10/06 18:34:22 UTC

(nuttx) branch master updated (9199e5aa286 -> 38d6c3b8bb8)

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


    from 9199e5aa286 sensors/adxl367: add I2C accelerometer support
     new acc296ef092 arm/stm32n6: configure board clocks after ROM boot
     new 97a8da4fd92 arm/stm32n6: allow debugger access after flash boot
     new 38d6c3b8bb8 boards/arm/stm32n6: add initial STM32N6570-DK support

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../arm/stm32n6/boards/stm32n6570-dk/index.rst     | 108 +++++++++++
 .../boards/stm32n6570-dk/stm32n6570-dk-back.jpg    | Bin 0 -> 107955 bytes
 .../boards/stm32n6570-dk/stm32n6570-dk-front.jpg   | Bin 0 -> 75456 bytes
 Documentation/platforms/arm/stm32n6/index.rst      |   4 -
 arch/arm/src/stm32n6/Kconfig                       |  10 +
 .../hardware/stm32n6xxx_bsec.h}                    |  40 ++--
 arch/arm/src/stm32n6/stm32_start.c                 |  18 ++
 arch/arm/src/stm32n6/stm32n6xx_rcc.c               |  38 ++--
 boards/Kconfig                                     |  12 ++
 .../stm32n6570-dk}/CMakeLists.txt                  |  24 ++-
 .../t3-gem-o1 => stm32n6/stm32n6570-dk}/Kconfig    |   2 +-
 .../configs/nsh/defconfig                          |  12 +-
 .../include/board.h                                |  65 +++----
 .../scripts/Make.defs                              |  13 +-
 boards/arm/stm32n6/stm32n6570-dk/scripts/flash.cfg | 148 ++++++++++++++
 .../scripts/flash.ld                               | 212 +++++++++++----------
 .../src/CMakeLists.txt                             |   2 +-
 .../src/Make.defs                                  |   2 +-
 .../stm32n6570-dk}/src/stm32_autoleds.c            |  63 +++---
 .../src/stm32_boot.c                               |   4 +-
 .../src/stm32_bringup.c                            |  20 +-
 .../stm32n6570-dk}/src/stm32_userleds.c            |  15 +-
 .../src/stm32n6570-dk.h}                           |  26 +--
 23 files changed, 573 insertions(+), 265 deletions(-)
 create mode 100644 Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst
 create mode 100644 Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/stm32n6570-dk-back.jpg
 create mode 100644 Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/stm32n6570-dk-front.jpg
 copy arch/arm/src/{stm32l4/hardware/stm32l4_rng.h => stm32n6/hardware/stm32n6xxx_bsec.h} (56%)
 copy boards/arm/{csk6/csk6011a-nano => stm32n6/stm32n6570-dk}/CMakeLists.txt (64%)
 copy boards/arm/{am67/t3-gem-o1 => stm32n6/stm32n6570-dk}/Kconfig (83%)
 copy boards/arm/stm32n6/{nucleo-n657x0-q => stm32n6570-dk}/configs/nsh/defconfig (79%)
 copy boards/arm/stm32n6/{nucleo-n657x0-q => stm32n6570-dk}/include/board.h (67%)
 copy boards/arm/stm32n6/{nucleo-n657x0-q => stm32n6570-dk}/scripts/Make.defs (83%)
 create mode 100644 boards/arm/stm32n6/stm32n6570-dk/scripts/flash.cfg
 copy boards/arm/stm32n6/{nucleo-n657x0-q => stm32n6570-dk}/scripts/flash.ld (82%)
 copy boards/arm/stm32n6/{nucleo-n657x0-q => stm32n6570-dk}/src/CMakeLists.txt (95%)
 copy boards/arm/stm32n6/{nucleo-n657x0-q => stm32n6570-dk}/src/Make.defs (96%)
 copy boards/arm/{stm32f4/nucleo-f412zg => stm32n6/stm32n6570-dk}/src/stm32_autoleds.c (79%)
 copy boards/arm/stm32n6/{nucleo-n657x0-q => stm32n6570-dk}/src/stm32_boot.c (97%)
 copy boards/arm/stm32n6/{nucleo-n657x0-q => stm32n6570-dk}/src/stm32_bringup.c (83%)
 copy boards/arm/{stm32h5/nucleo-h563zi => stm32n6/stm32n6570-dk}/src/stm32_userleds.c (91%)
 copy boards/arm/stm32n6/{nucleo-n657x0-q/src/nucleo-n657x0-q.h => stm32n6570-dk/src/stm32n6570-dk.h} (76%)


(nuttx) 03/03: boards/arm/stm32n6: add initial STM32N6570-DK support

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 38d6c3b8bb83a9960ef446dae03738898bed405b
Author: raiden00pl <ra...@railab.me>
AuthorDate: Sat Sep 19 11:04:20 2026 +0200

    boards/arm/stm32n6: add initial STM32N6570-DK support
    
    add initial STM32N6570-DK support
    
    Assisted-by: Codex:GPT-6
    Signed-off-by: raiden00pl <ra...@railab.me>
---
 .../arm/stm32n6/boards/stm32n6570-dk/index.rst     | 108 ++++++++++++++
 .../boards/stm32n6570-dk/stm32n6570-dk-back.jpg    | Bin 0 -> 107955 bytes
 .../boards/stm32n6570-dk/stm32n6570-dk-front.jpg   | Bin 0 -> 75456 bytes
 Documentation/platforms/arm/stm32n6/index.rst      |   4 -
 boards/Kconfig                                     |  12 ++
 boards/arm/stm32n6/stm32n6570-dk/CMakeLists.txt    |  42 ++++++
 boards/arm/stm32n6/stm32n6570-dk/Kconfig           |   8 +
 .../stm32n6/stm32n6570-dk/configs/nsh/defconfig    |  37 +++++
 boards/arm/stm32n6/stm32n6570-dk/include/board.h   | 165 +++++++++++++++++++++
 boards/arm/stm32n6/stm32n6570-dk/scripts/Make.defs |  47 ++++++
 boards/arm/stm32n6/stm32n6570-dk/scripts/flash.cfg | 148 ++++++++++++++++++
 boards/arm/stm32n6/stm32n6570-dk/scripts/flash.ld  | 109 ++++++++++++++
 .../arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt   |  33 +++++
 boards/arm/stm32n6/stm32n6570-dk/src/Make.defs     |  36 +++++
 .../arm/stm32n6/stm32n6570-dk/src/stm32_autoleds.c | 103 +++++++++++++
 boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c  |  83 +++++++++++
 .../arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c  |  87 +++++++++++
 .../arm/stm32n6/stm32n6570-dk/src/stm32_userleds.c | 127 ++++++++++++++++
 .../arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h  |  80 ++++++++++
 19 files changed, 1225 insertions(+), 4 deletions(-)

diff --git a/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst b/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst
new file mode 100644
index 00000000000..6e2fdd53391
--- /dev/null
+++ b/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst
@@ -0,0 +1,108 @@
+================
+ST STM32N6570-DK
+================
+
+.. tags:: chip:stm32, chip:stm32n6, chip:stm32n657
+
+.. figure:: stm32n6570-dk-front.jpg
+   :align: center
+   :alt: STM32N6570-DK Front
+
+   STM32N6570-DK Front
+
+.. figure:: stm32n6570-dk-back.jpg
+   :align: center
+   :alt: STM32N6570-DK Back
+
+   STM32N6570-DK Back
+
+The STM32N6570-DK Discovery kit is based on the STM32N657X0H3Q
+Arm Cortex-M55 microcontroller.
+
+Loading and running
+===================
+
+Use SRAM loading for routine debugging and external flash for persistent
+boot, reset testing and standalone operation.  The console is the ST-LINK
+Virtual COM Port at 115200 8N1.
+
+Persistent flash
+----------------
+
+OpenOCD adds the STM32N6 ROM header to ``nuttx.bin`` and programs the
+on-board NOR flash with its ``stmqspi`` driver.  Use an OpenOCD version
+that provides ``target/stm32n6x.cfg``.
+
+Build and program the persistent boot image with:
+
+.. code:: console
+
+   $ make flash
+
+This erases the affected flash sectors, programs and verifies the image,
+and resets the board.  ``OPENOCD`` and ``OPENOCD_TARGET`` can override the
+OpenOCD executable and target script.  The board's ``scripts/flash.cfg``
+configures the NOR pins, clocks and geometry for the native flash driver.
+
+For a CMake build configured in ``build``:
+
+.. code:: console
+
+   $ cmake --build build --target flash
+
+Both targets build ``nuttx.bin`` before flashing.  With CMake, ``OPENOCD``
+and ``OPENOCD_TARGET`` are cache variables set with ``-D`` at configuration.
+
+The boot ROM loads NuttX from flash and starts it without a debugger or
+separate FSBL.
+The header and padding occupy the first 1 KiB at ``0x34180000``; NuttX is
+linked at ``0x34180400``.  The ROM download buffer limits the binary to
+511 KiB.  The generated image is unauthenticated and requires a device
+that permits unauthenticated boot.
+
+SRAM debugging
+--------------
+
+Build with ``make`` or ``cmake --build build``.  Start OpenOCD using its
+standard ST-LINK and STM32N6 scripts:
+
+.. code:: console
+
+   $ openocd -f interface/stlink.cfg -c 'transport select swd' \
+         -f target/stm32n6x.cfg -c 'reset_config srst_only srst_nogate'
+
+In another terminal, open the ELF with GDB.  Use ``build/nuttx`` instead of
+``nuttx`` for CMake:
+
+.. code:: console
+
+   $ arm-none-eabi-gdb nuttx
+   (gdb) target extended-remote :3333
+   (gdb) monitor reset halt
+   (gdb) load
+   (gdb) set $msp = *(unsigned int *)0x34180400
+   (gdb) set $pc = *(unsigned int *)0x34180404
+   (gdb) hbreak nx_start
+   (gdb) continue
+
+``load`` writes the ELF sections into SRAM without programming external
+flash.  The next two commands initialize the stack pointer and entry point
+from the vector table.  Continue again after reaching ``nx_start`` to run
+NSH.  Reset before each reload; resetting after ``load`` boots the image
+stored in flash instead.  The SRAM image is lost on power-off.
+
+To inspect an already running image, attach with its matching ELF and omit
+the reset, load and register-setting commands.
+
+NSH enables ``CONFIG_STM32N6_DEBUG`` to reopen debug access after ROM boot
+and includes debug symbols.  These debugging steps require an installed
+image that enables debug access.  Stop GDB and OpenOCD before running either
+flash target.
+
+Configurations
+==============
+
+nsh
+---
+
+Minimal NuttShell configuration.
diff --git a/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/stm32n6570-dk-back.jpg b/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/stm32n6570-dk-back.jpg
new file mode 100644
index 00000000000..de32714d373
Binary files /dev/null and b/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/stm32n6570-dk-back.jpg differ
diff --git a/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/stm32n6570-dk-front.jpg b/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/stm32n6570-dk-front.jpg
new file mode 100644
index 00000000000..ec4da9bec4a
Binary files /dev/null and b/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/stm32n6570-dk-front.jpg differ
diff --git a/Documentation/platforms/arm/stm32n6/index.rst b/Documentation/platforms/arm/stm32n6/index.rst
index 241cca916c3..fdc1fd004e5 100644
--- a/Documentation/platforms/arm/stm32n6/index.rst
+++ b/Documentation/platforms/arm/stm32n6/index.rst
@@ -5,10 +5,6 @@ ST STM32N6
 This is a port of NuttX to the STM32N6 family.
 The STM32N6 is a chip based on the Arm Cortex-M55.
 
-Development is performed on the Nucleo-N657X0-Q.  At this time only the
-STM32N657X0 is supported.  Kconfig will need updates to support other
-MCUs in the family.
-
 Supported MCUs
 ==============
 
diff --git a/boards/Kconfig b/boards/Kconfig
index 17f3873221b..bd03388b768 100644
--- a/boards/Kconfig
+++ b/boards/Kconfig
@@ -3498,6 +3498,14 @@ config ARCH_BOARD_NUCLEO_N657X0_Q
 		code directly into SRAM via the on-board ST-Link V3EC, with
 		the NSH console on USART1 (ST-Link Virtual COM Port).
 
+config ARCH_BOARD_STM32N6570_DK
+	bool "STM32N6570-DK"
+	depends on ARCH_CHIP_STM32N657X0
+	select ARCH_HAVE_LEDS
+	---help---
+		STMicro STM32N6570-DK Discovery kit based on the STM32N657X0
+		MCU (Cortex-M55).
+
 config ARCH_BOARD_STM32L562E_DK
 	bool "STM32L562E-DK"
 	depends on ARCH_CHIP_STM32L562QE
@@ -4302,6 +4310,7 @@ config ARCH_BOARD
 	default "nucleo-h533re"                if ARCH_BOARD_NUCLEO_H533RE
 	default "nucleo-h563zi"                if ARCH_BOARD_NUCLEO_H563ZI
 	default "nucleo-n657x0-q"              if ARCH_BOARD_NUCLEO_N657X0_Q
+	default "stm32n6570-dk"                if ARCH_BOARD_STM32N6570_DK
 	default "nucleo-u5a5zj-q"              if ARCH_BOARD_NUCLEO_U5A5ZJ_Q
 	default "nucleo-u3c5zi-q"              if ARCH_BOARD_NUCLEO_U3C5ZI_Q
 	default "nucleo-c562re"                if ARCH_BOARD_NUCLEO_C562RE
@@ -5029,6 +5038,9 @@ endif
 if ARCH_BOARD_NUCLEO_N657X0_Q
 source "boards/arm/stm32n6/nucleo-n657x0-q/Kconfig"
 endif
+if ARCH_BOARD_STM32N6570_DK
+source "boards/arm/stm32n6/stm32n6570-dk/Kconfig"
+endif
 if ARCH_BOARD_STM32L562E_DK
 source "boards/arm/stm32l5/stm32l562e-dk/Kconfig"
 endif
diff --git a/boards/arm/stm32n6/stm32n6570-dk/CMakeLists.txt b/boards/arm/stm32n6/stm32n6570-dk/CMakeLists.txt
new file mode 100644
index 00000000000..e2233dd6aa1
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/CMakeLists.txt
@@ -0,0 +1,42 @@
+# ##############################################################################
+# boards/arm/stm32n6/stm32n6570-dk/CMakeLists.txt
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements.  See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership.  The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License.  You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# ##############################################################################
+
+add_subdirectory(src)
+
+if(CONFIG_RAW_BINARY)
+  set(OPENOCD
+      openocd
+      CACHE STRING "OpenOCD executable")
+  set(OPENOCD_TARGET
+      target/stm32n6x.cfg
+      CACHE STRING "OpenOCD target script")
+
+  add_custom_target(
+    flash
+    COMMAND
+      ${OPENOCD} -f interface/stlink.cfg -c "transport select swd" -f
+      ${OPENOCD_TARGET} -f ${CMAKE_CURRENT_LIST_DIR}/scripts/flash.cfg -c
+      "stm32n6_program nuttx.bin"
+    WORKING_DIRECTORY ${NUTTX_BINARY_DIR}
+    USES_TERMINAL VERBATIM)
+  add_dependencies(flash nuttx-bin)
+endif()
diff --git a/boards/arm/stm32n6/stm32n6570-dk/Kconfig b/boards/arm/stm32n6/stm32n6570-dk/Kconfig
new file mode 100644
index 00000000000..dfcb5c354a4
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/Kconfig
@@ -0,0 +1,8 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+if ARCH_BOARD_STM32N6570_DK
+
+endif
diff --git a/boards/arm/stm32n6/stm32n6570-dk/configs/nsh/defconfig b/boards/arm/stm32n6/stm32n6570-dk/configs/nsh/defconfig
new file mode 100644
index 00000000000..eb07976447c
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/configs/nsh/defconfig
@@ -0,0 +1,37 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed .config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that includes your
+# modifications.
+#
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="stm32n6570-dk"
+CONFIG_ARCH_BOARD_STM32N6570_DK=y
+CONFIG_ARCH_CHIP="stm32n6"
+CONFIG_ARCH_CHIP_STM32=y
+CONFIG_ARCH_CHIP_STM32N657X0=y
+CONFIG_ARCH_CHIP_STM32N6=y
+CONFIG_ARCH_INTERRUPTSTACK=4096
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARD_LOOPSPERMSEC=21000
+CONFIG_BUILTIN=y
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_FS_PROCFS=y
+CONFIG_HAVE_CXX=y
+CONFIG_HAVE_CXXINITIALIZE=y
+CONFIG_IDLETHREAD_STACKSIZE=4096
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_READLINE=y
+CONFIG_RAM_SIZE=2620416
+CONFIG_RAM_START=0x34180400
+CONFIG_RAW_BINARY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_WAITPID=y
+CONFIG_STM32N6_DEBUG=y
+CONFIG_STM32_USART1=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_USART1_SERIAL_CONSOLE=y
diff --git a/boards/arm/stm32n6/stm32n6570-dk/include/board.h b/boards/arm/stm32n6/stm32n6570-dk/include/board.h
new file mode 100644
index 00000000000..bcd57f8d0ee
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/include/board.h
@@ -0,0 +1,165 @@
+/****************************************************************************
+ * boards/arm/stm32n6/stm32n6570-dk/include/board.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __BOARDS_ARM_STM32N6_STM32N6570_DK_INCLUDE_BOARD_H
+#define __BOARDS_ARM_STM32N6_STM32N6570_DK_INCLUDE_BOARD_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#ifndef __ASSEMBLY__
+#  include <stdint.h>
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Clocking *****************************************************************/
+
+/* Clock tree (single PLL1 fed from the internal HSI):
+ *
+ *   HSI 64 MHz / M=4 * N=50 = 800 MHz VCO
+ *     IC1  /4 = 200 MHz  -> CPU clock (CPUSW)
+ *     IC2  /8 = 100 MHz  \
+ *     IC6 /12 = 66.7 MHz  > SYSCLK components (SYSSW IC2_IC6_IC11)
+ *     IC11 /8 = 100 MHz  /
+ *   HPRE /2  = 50 MHz   -> HCLK
+ *   PPRE1 /1 = 50 MHz   -> PCLK1
+ *   PPRE2 /1 = 50 MHz   -> PCLK2
+ *
+ * Works with the default VOS SCALE1, no SMPS overdrive required.  Higher
+ * CPU frequencies (600/800 MHz) are deferred to a follow-up.
+ */
+
+#define STM32_HSI_FREQUENCY     64000000ul
+
+#define STM32_PLL1_M            4
+#define STM32_PLL1_N            50
+#define STM32_PLL1_IC1_DIV      4
+
+#define STM32_CPUCLK_FREQUENCY  200000000ul
+#define STM32_SYSCLK_FREQUENCY  (STM32_CPUCLK_FREQUENCY / 2)
+#define STM32_HCLK_FREQUENCY    (STM32_CPUCLK_FREQUENCY / 4)
+#define STM32_PCLK1_FREQUENCY   STM32_HCLK_FREQUENCY
+#define STM32_PCLK2_FREQUENCY   STM32_HCLK_FREQUENCY
+
+/* Timer input clock = SYSCLK (TIMPRE=0 default) */
+
+#define STM32_APB1_TIM_FREQUENCY STM32_SYSCLK_FREQUENCY
+#define STM32_APB2_TIM_FREQUENCY STM32_SYSCLK_FREQUENCY
+
+/* I/O voltage domains ******************************************************/
+
+/* VDDIO2 and VDDIO3 are supplied at 1.8 V on the Discovery kit.
+ * Mark both supplies valid and select their 1.8 V range before the
+ * common STM32N6 startup configures I/O compensation.
+ */
+
+#define BOARD_PWR_VDDIO  (PWR_SVMCR3_VDDIO2SV    | PWR_SVMCR3_VDDIO3SV | \
+                          PWR_SVMCR3_VDDIO2VRSEL | PWR_SVMCR3_VDDIO3VRSEL)
+
+/* LED definitions **********************************************************/
+
+/* LD1 (green, PO1) is active high; LD2 (red, PG10) is active low. */
+
+/* LED index values for use with board_userled() */
+
+#define BOARD_LED1        0
+#define BOARD_LED2        1
+#define BOARD_NLEDS       2
+
+#define BOARD_LED_GREEN   BOARD_LED1
+#define BOARD_LED_RED     BOARD_LED2
+
+/* LED bits for use with board_userled_all() */
+
+#define BOARD_LED1_BIT    (1 << BOARD_LED1)
+#define BOARD_LED2_BIT    (1 << BOARD_LED2)
+
+/* OS event indications when CONFIG_ARCH_LEDS is enabled:
+ *
+ *   SYMBOL                 Meaning                  Green  Red
+ *   ---------------------  -----------------------  -----  -----
+ */
+
+#define LED_STARTED        0 /* NuttX has started     OFF    OFF   */
+#define LED_HEAPALLOCATE   0 /* Heap allocated        OFF    OFF   */
+#define LED_IRQSENABLED    0 /* Interrupts enabled    OFF    OFF   */
+#define LED_STACKCREATED   1 /* Idle stack created    ON     OFF   */
+#define LED_INIRQ          2 /* In an interrupt       N/C    N/C   */
+#define LED_SIGNAL         2 /* In a signal handler   N/C    N/C   */
+#define LED_ASSERTION      2 /* An assertion failed   N/C    N/C   */
+#define LED_PANIC          3 /* The system crashed    OFF    Blink */
+
+/* Alternate function pin selections ****************************************/
+
+/* USART1 GPIOs *************************************************************/
+
+/* USART1 (ST-LINK Virtual COM Port): PE5=TX (AF7), PE6=RX (AF7)
+ * Connected to the on-board ST-Link to provide a Virtual COM Port.
+ */
+
+#define GPIO_USART1_TX   GPIO_USART1_TX_1
+#define GPIO_USART1_RX   GPIO_USART1_RX_1
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_board_initialize
+ *
+ * Description:
+ *   All STM32N6 architectures must provide the following entry point.
+ *   This entry point is called early in the initialization -- after all
+ *   memory has been configured and mapped but before any devices
+ *   have been initialized.
+ *
+ ****************************************************************************/
+
+void stm32_board_initialize(void);
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __BOARDS_ARM_STM32N6_STM32N6570_DK_INCLUDE_BOARD_H */
diff --git a/boards/arm/stm32n6/stm32n6570-dk/scripts/Make.defs b/boards/arm/stm32n6/stm32n6570-dk/scripts/Make.defs
new file mode 100644
index 00000000000..8c64959b07a
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/scripts/Make.defs
@@ -0,0 +1,47 @@
+##############################################################################
+# boards/arm/stm32n6/stm32n6570-dk/scripts/Make.defs
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+##############################################################################
+
+include ${TOPDIR}/.config
+include ${TOPDIR}/tools/Config.mk
+include ${TOPDIR}/arch/arm/src/armv8-m/Toolchain.defs
+
+ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld
+
+CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
+CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
+CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
+AFLAGS := $(CFLAGS) -D__ASSEMBLY__
+
+NXFLATLDFLAGS1 = -r -d -warn-common
+NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections
+LDNXFLATFLAGS = -e main -s 2048
+
+OPENOCD ?= openocd
+OPENOCD_TARGET ?= target/stm32n6x.cfg
+
+ifeq ($(CONFIG_RAW_BINARY),y)
+define FLASH
+	$(Q) $(OPENOCD) -f interface/stlink.cfg -c 'transport select swd' \
+		-f $(OPENOCD_TARGET) -f $(BOARD_DIR)/scripts/flash.cfg \
+		-c 'stm32n6_program nuttx.bin'
+endef
+endif
diff --git a/boards/arm/stm32n6/stm32n6570-dk/scripts/flash.cfg b/boards/arm/stm32n6/stm32n6570-dk/scripts/flash.cfg
new file mode 100644
index 00000000000..5134077c371
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/scripts/flash.cfg
@@ -0,0 +1,148 @@
+##############################################################################
+# boards/arm/stm32n6/stm32n6570-dk/scripts/flash.cfg
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+##############################################################################
+
+# Load interface/stlink.cfg and target/stm32n6x.cfg before this file.
+
+reset_config srst_only srst_nogate
+flash bank stm32n6570_dk.nor stmqspi 0x70000000 0 0 0 $_TARGETNAME 0x5802a000
+proc stm32n6570_dk_flash_init {} {
+    # Stop inherited interrupts and instruction caching while OpenOCD runs
+    # SRAM algorithms.  The boot ROM also leaves stack limits set.
+
+    mww 0xe000e010 0
+    mww 0xe000ed04 0x0a000000
+    mmw 0xe000ed14 0 0x20000
+    mww 0xe000ef50 0
+    reg msplim_s 0
+    reg psplim_s 0
+    reg primask_s 1
+
+    # PWR, GPION and all XSPIM clocks.  Reset both XSPI controllers before
+    # restoring the direct XSPI2-to-port-2 mapping left changed by ROM.
+
+    mww 0x56028a5c 0x42000
+    mww 0x56028a60 0x3020
+    mww 0x56028a20 0x3020
+    mww 0x56029220 0x3020
+
+    # HCLK kernel source and conservative /8 prescaler.
+
+    mmw 0x56028158 0 0x30
+
+    # The DK NOR uses the 1.8 V VDDIO3 domain.
+
+    mmw 0x5602483c 0x04000200 0
+
+    # PN1 NCS, PN2 MOSI, PN3 MISO, PN6 CLK, AF9.
+
+    mmw 0x56023400 0x20a8 0x30fc
+    mmw 0x56023408 0x30fc 0
+    mmw 0x5602340c 0x504 0x3ffc
+    mmw 0x56023420 0x09009990 0x0f00fff0
+
+    # Map XSPI2 to port 2 and configure single-lane, 32-bit-address reads.
+
+    mww 0x5802b400 0
+    mww 0x5802a008 0x001a0700
+    mww 0x5802a00c 7
+    mww 0x5802a108 0
+    mww 0x5802a100 0x01003101
+    mww 0x5802a110 0x13
+    mww 0x5802a000 0x30000001
+
+    # MX66UW1G45G geometry and standard 4-byte read/program/erase commands.
+    # This part is absent from some OpenOCD JEDEC ID tables.
+
+    stmqspi set stm32n6570_dk.nor MX66UW1G45G 0x8000000 256 \
+        0x13 0 0x12 0x60 0x10000 0xdc
+}
+
+# Add the unauthenticated ROM header v2.3 (UM3234) as part of programming.
+# The vector table follows the header and padding at offset 0x400.
+
+proc stm32n6_program {image} {
+    set input [open $image rb]
+    set data [read $input]
+    close $input
+
+    # Jim Tcl strings can contain UTF-8; use the binary byte count.
+
+    set size [string bytelength $data]
+    if {$size < 8 || $size > 0x7fc00} {
+        error "NuttX binary must contain vectors and fit in 511 KiB"
+    }
+
+    binary scan $data ii stack entry
+    if {$stack < 0x34180400 || $stack > 0x34400000 || ($stack & 3)} {
+        error "Initial SP must be word-aligned and inside AXISRAM"
+    }
+    if {!($entry & 1) || ($entry & ~1) < 0x34180400 ||
+        ($entry & ~1) >= 0x34180400 + $size} {
+        error "Reset vector must point into the payload at 0x34180400"
+    }
+
+    set checksum 0
+    binary scan $data c* bytes
+    foreach byte $bytes {
+        set checksum [expr {($checksum + ($byte & 0xff)) & 0xffffffff}]
+    }
+    set padding [expr {(-$size) & 31}]
+    set length [expr {0x1c0 + $size + $padding}]
+    set header [lrepeat 256 0]
+    foreach {offset value} [list \
+        0x00 0x324d5453 \
+        0x64 $checksum \
+        0x68 0x00020300 \
+        0x6c $length \
+        0x70 $entry \
+        0x78 0xffffffff \
+        0x84 0x80000000 \
+        0x88 0x1a0 \
+        0x8c 0x10 \
+        0xa0 0xffff5453 \
+        0xa4 0x1a0] {
+        lset header [expr {$offset / 4}] $value
+    }
+
+    set boot [file rootname $image]-boot.bin
+    set output [open $boot wb]
+    puts -nonewline $output [binary format i* $header]
+    puts -nonewline $output $data
+    puts -nonewline $output [binary format x$padding]
+    close $output
+
+    # Reject a truncated or incorrectly encoded image before touching flash.
+
+    if {[file size $boot] != 0x400 + $size + $padding} {
+        error "Boot image size does not match the ROM header"
+    }
+
+    # Keep the current debug access until the replacement image is verified.
+
+    init
+    halt
+    stm32n6570_dk_flash_init
+    echo [flash write_image erase $boot 0x70000000 bin]
+    echo [verify_image $boot 0x70000000 bin]
+    reset run
+    shutdown
+}
diff --git a/boards/arm/stm32n6/stm32n6570-dk/scripts/flash.ld b/boards/arm/stm32n6/stm32n6570-dk/scripts/flash.ld
new file mode 100644
index 00000000000..54fb1d8846e
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/scripts/flash.ld
@@ -0,0 +1,109 @@
+/****************************************************************************
+ * boards/arm/stm32n6/stm32n6570-dk/scripts/flash.ld
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/* The STM32N657X0 boot ROM copies the image from external flash into
+ * AXISRAM2.  The STM32 image header occupies 0x34180000-0x341803ff;
+ * the vector table and payload start at 0x34180400.  The ROM download
+ * buffer ends at 0x34200000, limiting the payload to 511 KiB.
+ * After boot, the remaining contiguous AXISRAM is available for data
+ * and the heap through 0x34400000.
+ */
+
+MEMORY
+{
+    sram (rwx) : ORIGIN = 0x34180400, LENGTH = 2620416
+}
+
+OUTPUT_ARCH(arm)
+ENTRY(_stext)
+SECTIONS
+{
+    .text : {
+        _stext = ABSOLUTE(.);
+        *(.vectors)
+        *(.text .text.*)
+        *(.fixup)
+        *(.gnu.warning)
+        *(.rodata .rodata.*)
+        *(.gnu.linkonce.t.*)
+        *(.glue_7)
+        *(.glue_7t)
+        *(.got)
+        *(.gcc_except_table)
+        *(.gnu.linkonce.r.*)
+        _etext = ABSOLUTE(.);
+    } > sram
+
+    .init_section : {
+        _sinit = ABSOLUTE(.);
+        KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
+        KEEP(*(.init_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o) .ctors))
+        _einit = ABSOLUTE(.);
+    } > sram
+
+    .ARM.extab : {
+        *(.ARM.extab*)
+    } > sram
+
+    __exidx_start = ABSOLUTE(.);
+    .ARM.exidx : {
+        *(.ARM.exidx*)
+    } > sram
+    __exidx_end = ABSOLUTE(.);
+
+    .data : {
+        _eronly = ABSOLUTE(.);
+        _sdata = ABSOLUTE(.);
+        *(.data .data.*)
+        *(.gnu.linkonce.d.*)
+        CONSTRUCTORS
+        . = ALIGN(4);
+        _edata = ABSOLUTE(.);
+    } > sram
+
+    ASSERT(_edata <= 0x34200000,
+           "STM32N6 boot ROM payload exceeds 511 KiB")
+
+    .bss : {
+        _sbss = ABSOLUTE(.);
+        *(.bss .bss.*)
+        *(.gnu.linkonce.b.*)
+        *(COMMON)
+        . = ALIGN(4);
+        _ebss = ABSOLUTE(.);
+    } > sram
+
+    /* Stabs debugging sections. */
+
+    .stab 0 : { *(.stab) }
+    .stabstr 0 : { *(.stabstr) }
+    .stab.excl 0 : { *(.stab.excl) }
+    .stab.exclstr 0 : { *(.stab.exclstr) }
+    .stab.index 0 : { *(.stab.index) }
+    .stab.indexstr 0 : { *(.stab.indexstr) }
+    .comment 0 : { *(.comment) }
+    .debug_abbrev 0 : { *(.debug_abbrev) }
+    .debug_info 0 : { *(.debug_info) }
+    .debug_line 0 : { *(.debug_line) }
+    .debug_pubnames 0 : { *(.debug_pubnames) }
+    .debug_aranges 0 : { *(.debug_aranges) }
+}
diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt b/boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt
new file mode 100644
index 00000000000..9304da05ae5
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt
@@ -0,0 +1,33 @@
+# ##############################################################################
+# boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements.  See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership.  The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License.  You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# ##############################################################################
+
+set(SRCS stm32_boot.c stm32_bringup.c)
+
+if(CONFIG_ARCH_LEDS)
+  list(APPEND SRCS stm32_autoleds.c)
+else()
+  list(APPEND SRCS stm32_userleds.c)
+endif()
+
+target_sources(board PRIVATE ${SRCS})
+
+set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/flash.ld")
diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/Make.defs b/boards/arm/stm32n6/stm32n6570-dk/src/Make.defs
new file mode 100644
index 00000000000..0714c5c2dcc
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/src/Make.defs
@@ -0,0 +1,36 @@
+##############################################################################
+# boards/arm/stm32n6/stm32n6570-dk/src/Make.defs
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+##############################################################################
+
+-include $(TOPDIR)/Make.defs
+
+ASRCS =
+CSRCS = stm32_boot.c stm32_bringup.c
+
+ifeq ($(CONFIG_ARCH_LEDS),y)
+CSRCS += stm32_autoleds.c
+else
+CSRCS += stm32_userleds.c
+endif
+
+DEPPATH += --dep-path board
+VPATH += :board
+CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board
diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_autoleds.c b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_autoleds.c
new file mode 100644
index 00000000000..aa42aa4d869
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_autoleds.c
@@ -0,0 +1,103 @@
+/****************************************************************************
+ * boards/arm/stm32n6/stm32n6570-dk/src/stm32_autoleds.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/board.h>
+#include <arch/board/board.h>
+
+#include "stm32_gpio.h"
+#include "stm32n6570-dk.h"
+
+#ifdef CONFIG_ARCH_LEDS
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_autoled_initialize
+ *
+ * Description:
+ *   Configure both user LEDs as outputs, initially off.
+ *
+ ****************************************************************************/
+
+void board_autoled_initialize(void)
+{
+  stm32_configgpio(GPIO_LD1);
+  stm32_configgpio(GPIO_LD2);
+}
+
+/****************************************************************************
+ * Name: board_autoled_on
+ *
+ * Description:
+ *   Indicate successful startup with the green LED and panic with red.
+ *   Interrupt and signal events leave the LEDs unchanged.
+ *
+ ****************************************************************************/
+
+void board_autoled_on(int led)
+{
+  switch (led)
+    {
+      case LED_STARTED:
+        stm32_gpiowrite(GPIO_LD1, false);
+        stm32_gpiowrite(GPIO_LD2, true);
+        break;
+
+      case LED_STACKCREATED:
+        stm32_gpiowrite(GPIO_LD1, true);
+        break;
+
+      case LED_PANIC:
+        stm32_gpiowrite(GPIO_LD1, false);
+        stm32_gpiowrite(GPIO_LD2, false);
+        break;
+
+      default:
+        break;
+    }
+}
+
+/****************************************************************************
+ * Name: board_autoled_off
+ *
+ * Description:
+ *   Turn off the red LED between panic indications.
+ *
+ ****************************************************************************/
+
+void board_autoled_off(int led)
+{
+  if (led == LED_PANIC)
+    {
+      stm32_gpiowrite(GPIO_LD2, true);
+    }
+}
+
+#endif /* CONFIG_ARCH_LEDS */
diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c
new file mode 100644
index 00000000000..b84940016a4
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c
@@ -0,0 +1,83 @@
+/****************************************************************************
+ * boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <debug.h>
+
+#include <nuttx/board.h>
+
+#include "arm_internal.h"
+#include "stm32n6570-dk.h"
+
+#include <arch/board/board.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_board_initialize
+ *
+ * Description:
+ *   All STM32 architectures must provide the following entry point.  This
+ *   entry point is called early in the initialization -- after all memory
+ *   has been configured and mapped but before any devices have been
+ *   initialized.
+ *
+ ****************************************************************************/
+
+void stm32_board_initialize(void)
+{
+#ifdef CONFIG_ARCH_LEDS
+  /* Configure on-board LEDs if LED support has been selected. */
+
+  board_autoled_initialize();
+#endif
+}
+
+/****************************************************************************
+ * Name: board_late_initialize
+ *
+ * Description:
+ *   If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional
+ *   initialization call will be performed in the boot-up sequence to a
+ *   function called board_late_initialize().  board_late_initialize() will
+ *   be called immediately after up_initialize() is called and just before
+ *   the initial application is started.  This additional initialization
+ *   phase may be used, for example, to initialize board-specific device
+ *   drivers.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_BOARD_LATE_INITIALIZE
+void board_late_initialize(void)
+{
+  /* Perform board-specific initialization here if so configured */
+
+  stm32_bringup();
+}
+#endif
diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c
new file mode 100644
index 00000000000..82212af087b
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c
@@ -0,0 +1,87 @@
+/****************************************************************************
+ * boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/mount.h>
+#include <sys/types.h>
+#include <syslog.h>
+#include <debug.h>
+
+#include <nuttx/board.h>
+#include <nuttx/leds/userled.h>
+
+#include "stm32n6570-dk.h"
+
+#include <arch/board/board.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_bringup
+ *
+ * Description:
+ *   Perform architecture-specific initialization
+ *
+ *   CONFIG_BOARD_LATE_INITIALIZE=y :
+ *     Called from board_late_initialize().
+ *
+ *   CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y :
+ *     Called from the NSH library
+ *
+ ****************************************************************************/
+
+int stm32_bringup(void)
+{
+#if defined(CONFIG_FS_PROCFS) || \
+    (!defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER))
+  int ret;
+#endif
+
+#ifdef CONFIG_FS_PROCFS
+  /* Mount the procfs file system. */
+
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
+    }
+#endif
+
+#if !defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER)
+  /* Register the LED driver */
+
+  ret = userled_lower_initialize("/dev/userleds");
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
+    }
+#endif
+
+  return OK;
+}
diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_userleds.c b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_userleds.c
new file mode 100644
index 00000000000..4c748429405
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_userleds.c
@@ -0,0 +1,127 @@
+/****************************************************************************
+ * boards/arm/stm32n6/stm32n6570-dk/src/stm32_userleds.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdbool.h>
+#include <nuttx/debug.h>
+
+#include <sys/param.h>
+
+#include <nuttx/board.h>
+#include <arch/board/board.h>
+
+#include "stm32_gpio.h"
+#include "stm32n6570-dk.h"
+
+#ifndef CONFIG_ARCH_LEDS
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* This array maps an LED number to GPIO pin configuration and is indexed by
+ * BOARD_LED_<color>
+ */
+
+static const uint32_t g_ledcfg[BOARD_NLEDS] =
+{
+  GPIO_LD1,
+  GPIO_LD2,
+};
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_userled_initialize
+ *
+ * Description:
+ *   If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board
+ *   LEDs.  If CONFIG_ARCH_LEDS is not defined, then the
+ *   board_userled_initialize() is available to initialize the LEDs from user
+ *   application logic.
+ *
+ ****************************************************************************/
+
+uint32_t board_userled_initialize(void)
+{
+  int i;
+
+  /* Configure LD1 and LD2 GPIOs for output */
+
+  for (i = 0; i < nitems(g_ledcfg); i++)
+    {
+      stm32_configgpio(g_ledcfg[i]);
+    }
+
+  return BOARD_NLEDS;
+}
+
+/****************************************************************************
+ * Name: board_userled
+ *
+ * Description:
+ *   If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board
+ *   LEDs.  If CONFIG_ARCH_LEDS is not defined, then the board_userled() is
+ *   available to control the LEDs from user application logic.
+ *
+ ****************************************************************************/
+
+void board_userled(int led, bool ledon)
+{
+  if ((unsigned)led < nitems(g_ledcfg))
+    {
+      /* LD1 is active high; LD2 is active low. */
+
+      stm32_gpiowrite(g_ledcfg[led], led == BOARD_LED_RED ? !ledon : ledon);
+    }
+}
+
+/****************************************************************************
+ * Name: board_userled_all
+ *
+ * Description:
+ *   If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board
+ *   LEDs.  If CONFIG_ARCH_LEDS is not defined, then the board_userled_all()
+ *   is available to control the LED from user application logic.
+ *
+ ****************************************************************************/
+
+void board_userled_all(uint32_t ledset)
+{
+  int i;
+
+  /* Apply the polarity of each LED. */
+
+  for (i = 0; i < nitems(g_ledcfg); i++)
+    {
+      board_userled(i, (ledset & (1 << i)) != 0);
+    }
+}
+
+#endif /* !CONFIG_ARCH_LEDS */
diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h b/boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h
new file mode 100644
index 00000000000..586aeb3ee3f
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+ * boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __BOARDS_ARM_STM32N6_STM32N6570_DK_SRC_STM32N6570_DK_H
+#define __BOARDS_ARM_STM32N6_STM32N6570_DK_SRC_STM32N6570_DK_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+#include <stdint.h>
+
+#include "stm32_gpio.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* LED definitions **********************************************************/
+
+/* LD1 is active high; LD2 is active low.  Start with both LEDs off. */
+
+#define GPIO_LD1       (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHZ | \
+                        GPIO_OUTPUT_CLEAR | GPIO_PORTO | GPIO_PIN1)
+#define GPIO_LD2       (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHZ | \
+                        GPIO_OUTPUT_SET | GPIO_PORTG | GPIO_PIN10)
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_bringup
+ *
+ * Description:
+ *   Perform architecture-specific initialization
+ *
+ *   CONFIG_BOARD_LATE_INITIALIZE=y :
+ *     Called from board_late_initialize().
+ *
+ *   CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y :
+ *     Called from the NSH library
+ *
+ ****************************************************************************/
+
+int stm32_bringup(void);
+
+#endif /* __ASSEMBLY__ */
+#endif /* __BOARDS_ARM_STM32N6_STM32N6570_DK_SRC_STM32N6570_DK_H */


(nuttx) 01/03: arm/stm32n6: configure board clocks after ROM boot

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit acc296ef092b29e48b5d7e844e7fb31a2ad4abee
Author: raiden00pl <ra...@railab.me>
AuthorDate: Sat Sep 19 11:40:13 2026 +0200

    arm/stm32n6: configure board clocks after ROM boot
    
    In the nominal ROM clock configuration, flash boot leaves PLL1 driving
    the CPU at 400 MHz. Skipping clock setup when PLL1 is already selected
    makes SysTick run twice as fast as the board's 200 MHz configuration
    expects.
    
    Switch CPU and system clocks to HSI before reconfiguring PLL1, then apply
    the board clock tree.
    
    Remove the incorrect comments claiming CFGR1 and CFGR2 lock after the first
    clock switch.
    
    Assisted-by: Codex:GPT-6
    Signed-off-by: raiden00pl <ra...@railab.me>
---
 arch/arm/src/stm32n6/stm32n6xx_rcc.c | 38 +++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/arch/arm/src/stm32n6/stm32n6xx_rcc.c b/arch/arm/src/stm32n6/stm32n6xx_rcc.c
index e6ec3cad067..a121aa0548e 100644
--- a/arch/arm/src/stm32n6/stm32n6xx_rcc.c
+++ b/arch/arm/src/stm32n6/stm32n6xx_rcc.c
@@ -135,9 +135,8 @@ void stm32_rcc_enableperipherals(void)
  *   clock tree is laid out in the board header; see board.h for the full
  *   diagram.
  *
- *   IMPORTANT: CFGR1 locks after the first write -- CPUSW and SYSSW must
- *   be written together in a single putreg32().  CFGR2 (bus prescalers)
- *   also locks after CFGR1 is written, so it must be set first.
+ *   Switch CPU and system clocks to HSI before changing PLL1, since the
+ *   boot ROM may already be using PLL1 with a different clock tree.
  *
  ****************************************************************************/
 
@@ -146,22 +145,30 @@ void stm32_stdclockconfig(void)
   volatile int32_t timeout;
   uint32_t regval;
 
-  /* If clocks are already configured (e.g. FSBL set up PLL1 and switched
-   * CPUSW to IC1), skip PLL1/CFGR1 reconfiguration.  CFGR1 locks after
-   * the first write - a second write crashes the system (SRAM goes
-   * offline).
-   */
+  /* Keep HSI running while PLL1 and the IC dividers are reconfigured. */
 
-  regval = getreg32(STM32_RCC_CFGR1);
-  if ((regval & RCC_CFGR1_CPUSWS_MASK) == RCC_CFGR1_CPUSWS_IC1 &&
-      (regval & RCC_CFGR1_SYSSWS_MASK) == RCC_CFGR1_SYSSWS_IC2_IC6_IC11)
+  putreg32(RCC_CR_HSION, STM32_RCC_CSR);
+
+  for (timeout = HSIRDY_TIMEOUT; timeout > 0; timeout--)
     {
-      return;
+      if ((getreg32(STM32_RCC_SR) & RCC_SR_HSIRDY) != 0)
+        {
+          break;
+        }
     }
 
+  /* The flash boot ROM leaves CPUCLK at 400 MHz.  Move both CPU and
+   * system clocks off PLL1 before disabling it, then establish the
+   * board clock tree instead of inheriting the ROM's configuration.
+   */
+
+  modifyreg32(STM32_RCC_CFGR1,
+              RCC_CFGR1_CPUSW_MASK | RCC_CFGR1_SYSSW_MASK, 0);
+
   for (timeout = HSIRDY_TIMEOUT; timeout > 0; timeout--)
     {
-      if ((getreg32(STM32_RCC_SR) & RCC_SR_HSIRDY) != 0)
+      if ((getreg32(STM32_RCC_CFGR1) &
+           (RCC_CFGR1_CPUSWS_MASK | RCC_CFGR1_SYSSWS_MASK)) == 0)
         {
           break;
         }
@@ -229,9 +236,8 @@ void stm32_stdclockconfig(void)
          | RCC_DIVENR_IC6EN | RCC_DIVENR_IC11EN,
            STM32_RCC_DIVENSR);
 
-  /* CFGR2 (bus prescalers) and CFGR1 (clock-source switch) both lock
-   * after CFGR1 is written, so CFGR2 must be set first and CFGR1 must
-   * be written exactly once with both CPUSW and SYSSW in place.
+  /* Set the bus prescalers before switching CPU and system clocks to
+   * the configured PLL1 outputs.
    */
 
   putreg32(RCC_CFGR2_HPRE_SYSCLKd2, STM32_RCC_CFGR2);


(nuttx) 02/03: arm/stm32n6: allow debugger access after flash boot

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 97a8da4fd924dd71a228457f0d74c90a09105986
Author: raiden00pl <ra...@railab.me>
AuthorDate: Sat Sep 19 15:55:56 2026 +0200

    arm/stm32n6: allow debugger access after flash boot
    
    Add an opt-in STM32N6_DEBUG setting to reopen the debug access port and
    secure/non-secure debug at the current BSEC protection level.  Enable the
    BSEC clock and configure access before clock and memory initialization so
    a debugger can attach to a flash-booted development image.
    
    Assisted-by: Codex:GPT-6
    Signed-off-by: raiden00pl <ra...@railab.me>
---
 arch/arm/src/stm32n6/Kconfig                    | 10 +++++
 arch/arm/src/stm32n6/hardware/stm32n6xxx_bsec.h | 56 +++++++++++++++++++++++++
 arch/arm/src/stm32n6/stm32_start.c              | 18 ++++++++
 3 files changed, 84 insertions(+)

diff --git a/arch/arm/src/stm32n6/Kconfig b/arch/arm/src/stm32n6/Kconfig
index b90a6b0663c..68d8a1b051e 100644
--- a/arch/arm/src/stm32n6/Kconfig
+++ b/arch/arm/src/stm32n6/Kconfig
@@ -27,4 +27,14 @@ config ARCH_CHIP_STM32N657X0
 
 endchoice
 
+config STM32N6_DEBUG
+	bool "Enable debugger access after boot"
+	default n
+	---help---
+		Reopen secure and non-secure debugger access at the current hardware
+		protection level early in startup.  The boot ROM can close this access
+		when booting from external flash.  Enable this option for development
+		to attach without switching to DEV boot mode.  This changes runtime
+		BSEC registers only, not OTP fuses.
+
 endif # ARCH_CHIP_STM32N6
diff --git a/arch/arm/src/stm32n6/hardware/stm32n6xxx_bsec.h b/arch/arm/src/stm32n6/hardware/stm32n6xxx_bsec.h
new file mode 100644
index 00000000000..b39a02d534f
--- /dev/null
+++ b/arch/arm/src/stm32n6/hardware/stm32n6xxx_bsec.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+ * arch/arm/src/stm32n6/hardware/stm32n6xxx_bsec.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_STM32N6_HARDWARE_STM32N6XXX_BSEC_H
+#define __ARCH_ARM_SRC_STM32N6_HARDWARE_STM32N6XXX_BSEC_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "hardware/stm32n6xxx_memorymap.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Register Offsets *********************************************************/
+
+#define STM32_BSEC_DBGCR_OFFSET      0xe8c /* Debug control register */
+#define STM32_BSEC_AP_UNLOCK_OFFSET  0xe90 /* Debug access port unlock register */
+#define STM32_BSEC_HDPLSR_OFFSET     0xe94 /* Hide protection level status register */
+
+/* Register Addresses *******************************************************/
+
+#define STM32_BSEC_DBGCR      (STM32_BSEC_BASE + STM32_BSEC_DBGCR_OFFSET)
+#define STM32_BSEC_AP_UNLOCK  (STM32_BSEC_BASE + STM32_BSEC_AP_UNLOCK_OFFSET)
+#define STM32_BSEC_HDPLSR     (STM32_BSEC_BASE + STM32_BSEC_HDPLSR_OFFSET)
+
+/* Register Bitfield Definitions ********************************************/
+
+#define BSEC_DBGCR_UNLOCK          (0xb4 << 8)   /* Non-secure debug authorization */
+#define BSEC_DBGCR_AUTH_HDPL_SHIFT (16)          /* Bits 16-23: Debug protection level */
+#define BSEC_DBGCR_AUTH_SEC        (0xb4u << 24) /* Secure debug authorization */
+#define BSEC_AP_UNLOCK_UNLOCK      0xb4          /* Unlock the debug access port */
+#define BSEC_HDPLSR_HDPL_MASK      0xff          /* Bits 0-7: Current protection level */
+
+#endif /* __ARCH_ARM_SRC_STM32N6_HARDWARE_STM32N6XXX_BSEC_H */
diff --git a/arch/arm/src/stm32n6/stm32_start.c b/arch/arm/src/stm32n6/stm32_start.c
index c0f29e74371..7c7c50bd238 100644
--- a/arch/arm/src/stm32n6/stm32_start.c
+++ b/arch/arm/src/stm32n6/stm32_start.c
@@ -41,6 +41,7 @@
 #include "stm32_gpio.h"
 #include "stm32_pwr.h"
 #include "stm32_start.h"
+#include "hardware/stm32n6xxx_bsec.h"
 #include "hardware/stm32n6xxx_syscfg.h"
 
 /****************************************************************************
@@ -146,6 +147,23 @@ void __start_c(void)
   putreg32(0, NVIC_SYSTICK_CTRL);
   putreg32(NVIC_INTCTRL_PENDSTCLR, NVIC_INTCTRL);
 
+#ifdef CONFIG_STM32N6_DEBUG
+  /* Enable BSEC before accessing its debug control registers. */
+
+  putreg32(RCC_APB4HENR_BSECEN, STM32_RCC_APB4HENSR);
+  (void)getreg32(STM32_RCC_APB4HENR);
+
+  /* The boot ROM can close debug access in flash boot mode.  Reopen it
+   * at the current protection level before clock and memory initialization
+   * so a debugger can attach without changing the boot pins.
+   */
+
+  putreg32(BSEC_AP_UNLOCK_UNLOCK, STM32_BSEC_AP_UNLOCK);
+  putreg32(BSEC_DBGCR_AUTH_SEC | BSEC_DBGCR_UNLOCK |
+           ((getreg32(STM32_BSEC_HDPLSR) & BSEC_HDPLSR_HDPL_MASK) <<
+            BSEC_DBGCR_AUTH_HDPL_SHIFT), STM32_BSEC_DBGCR);
+#endif
+
   /* Force plain SLEEP (not DEEPSLEEP) on WFI so the system clock keeps
    * running and SysTick continues to wake us.  Cleared once here so
    * up_idle() does not need to touch it on every idle entry.