@@ -43,6 +43,7 @@ This README describes configuration of supported targets.
4343* [ STM32F7] ( #stm32f7 )
4444* [ STM32G0] ( #stm32g0 )
4545* [ STM32H5] ( #stm32h5 )
46+ * [ STM32N6] ( #stm32n6 )
4647* [ STM32H7] ( #stm32h7 )
4748* [ STM32L0] ( #stm32l0 )
4849* [ STM32L4] ( #stm32l4 )
@@ -1819,6 +1820,123 @@ c
18191820` ` `
18201821
18211822
1823+ # # STM32N6
1824+
1825+ The STM32N6 (Cortex-M55) has no internal flash — all firmware resides on external
1826+ NOR flash (Macronix MX25UM51245G, 64MB) connected via XSPI2. The on-chip Boot ROM
1827+ copies the FSBL (First Stage Boot Loader) from external flash to internal SRAM and
1828+ jumps to it. wolfBoot serves as the FSBL, performing image verification and
1829+ chain-loading the application from external flash in XIP (Execute-In-Place) mode.
1830+
1831+ Tested on: ** NUCLEO-N657X0-Q** (STM32N657X0H, MB1940)
1832+
1833+ # ## Memory Layout
1834+
1835+ ```
1836+ XSPI2 NOR Flash (memory-mapped at 0x70000000):
1837+ 0x70000000 FSBL header area (128KB, future autonomous boot)
1838+ 0x70010000 Swap partition (64KB, device-relative: 0x00010000)
1839+ 0x70020000 Boot partition (1MB, app runs from here via XIP)
1840+ 0x70120000 Update partition (1MB, device-relative: 0x00120000)
1841+
1842+ AXISRAM (0x34000000):
1843+ 0x34000000 wolfBoot (loaded to SRAM via SWD or Boot ROM FSBL copy)
1844+ 0x34020000 Stack / work area
1845+ ```
1846+
1847+ ### Build and Flash
1848+
1849+ Use the example configuration and build:
1850+
1851+ ```sh
1852+ cp config/examples/stm32n6.config .config
1853+ make
1854+ make flash
1855+ ```
1856+
1857+ ` make flash ` uses OpenOCD with the stmqspi driver to:
1858+ 1 . Program the signed application to NOR flash at 0x70020000
1859+ 2 . Load wolfBoot to SRAM at 0x34000000
1860+ 3 . Start wolfBoot, which verifies and boots the application via XIP
1861+
1862+ Prerequisites:
1863+ - OpenOCD 0.12+ with stm32n6x target support (build from source if needed)
1864+ - ST-Link connected to the Nucleo board
1865+ - arm-none-eabi toolchain in PATH
1866+
1867+ ### Build Options
1868+
1869+ ``` sh
1870+ make TARGET=stm32n6 SIGN=ECC256
1871+ ```
1872+
1873+ The example config uses:
1874+ - ` EXT_FLASH=1 ` with ` PART_UPDATE_EXT=1 ` and ` PART_SWAP_EXT=1 `
1875+ - Boot partition at 0x70020000 (XIP, not marked EXT)
1876+ - Update/swap partitions use device-relative offsets
1877+ - 4KB sector size (` WOLFBOOT_SECTOR_SIZE=0x1000 ` )
1878+ - ECC256 + SHA256 for signature verification
1879+
1880+ ### XIP Constraints
1881+
1882+ Since the application executes directly from NOR flash via XSPI2 memory-mapped
1883+ mode, the following constraints apply:
1884+
1885+ - The application must NOT call ` hal_init() ` — XSPI2 is already configured by
1886+ wolfBoot for memory-mapped mode. Reinitializing XSPI2 would disable XIP and
1887+ crash the CPU.
1888+ - Calling ` wolfBoot_success() ` requires all flash write functions to be placed
1889+ in RAM (RAMFUNCTION). The HAL flash functions in ` hal/stm32n6.c ` need the
1890+ RAMFUNCTION attribute for this to work from an XIP application.
1891+
1892+ ### Flash Script Options
1893+
1894+ The flash script supports several modes:
1895+
1896+ ``` sh
1897+ ./tools/scripts/stm32n6_flash.sh # Build and flash all
1898+ ./tools/scripts/stm32n6_flash.sh --skip-build # Flash only (existing binaries)
1899+ ./tools/scripts/stm32n6_flash.sh --app-only # Flash signed app only
1900+ ./tools/scripts/stm32n6_flash.sh --test-update # Flash v1 boot + v2 update
1901+ ./tools/scripts/stm32n6_flash.sh --halt # Leave OpenOCD running
1902+ ```
1903+
1904+ ### Debugging
1905+
1906+ OpenOCD:
1907+
1908+ ``` sh
1909+ openocd -f config/openocd/openocd_stm32n6.cfg
1910+ ```
1911+
1912+ After OpenOCD starts, connect via telnet (port 4444). To manually load wolfBoot
1913+ and start it:
1914+
1915+ ``` sh
1916+ reset halt
1917+ load_image wolfboot.bin 0x34000000 bin
1918+ reg msplim_s 0x00000000
1919+ reg psplim_s 0x00000000
1920+ reg msp 0x34020000
1921+ mww 0xE000ED08 0x34000000
1922+ resume < entry_address>
1923+ ```
1924+
1925+ The entry address can be found with:
1926+ ``` sh
1927+ arm-none-eabi-nm wolfboot.elf | grep isr_reset
1928+ ```
1929+
1930+ GDB:
1931+
1932+ ``` sh
1933+ arm-none-eabi-gdb wolfboot.elf
1934+ target remote :3333
1935+ mon halt
1936+ add-symbol-file test-app/image.elf 0x70020400
1937+ ```
1938+
1939+
18221940## STM32H7
18231941
18241942The STM32H7 flash geometry must be defined beforehand.
0 commit comments