@@ -41,6 +41,7 @@ This README describes configuration of supported targets.
4141* [ STM32F7] ( #stm32f7 )
4242* [ STM32G0] ( #stm32g0 )
4343* [ STM32H5] ( #stm32h5 )
44+ * [ STM32N6] ( #stm32n6 )
4445* [ STM32H7] ( #stm32h7 )
4546* [ STM32L0] ( #stm32l0 )
4647* [ STM32L4] ( #stm32l4 )
@@ -1613,6 +1614,123 @@ c
16131614` ` `
16141615
16151616
1617+ # # STM32N6
1618+
1619+ The STM32N6 (Cortex-M55) has no internal flash — all firmware resides on external
1620+ NOR flash (Macronix MX25UM51245G, 64MB) connected via XSPI2. The on-chip Boot ROM
1621+ copies the FSBL (First Stage Boot Loader) from external flash to internal SRAM and
1622+ jumps to it. wolfBoot serves as the FSBL, performing image verification and
1623+ chain-loading the application from external flash in XIP (Execute-In-Place) mode.
1624+
1625+ Tested on: ** NUCLEO-N657X0-Q** (STM32N657X0H, MB1940)
1626+
1627+ # ## Memory Layout
1628+
1629+ ```
1630+ XSPI2 NOR Flash (memory-mapped at 0x70000000):
1631+ 0x70000000 FSBL header area (128KB, future autonomous boot)
1632+ 0x70010000 Swap partition (64KB, device-relative: 0x00010000)
1633+ 0x70020000 Boot partition (1MB, app runs from here via XIP)
1634+ 0x70120000 Update partition (1MB, device-relative: 0x00120000)
1635+
1636+ AXISRAM (0x34000000):
1637+ 0x34000000 wolfBoot (loaded to SRAM via SWD or Boot ROM FSBL copy)
1638+ 0x34020000 Stack / work area
1639+ ```
1640+
1641+ ### Build and Flash
1642+
1643+ Use the example configuration and build:
1644+
1645+ ```sh
1646+ cp config/examples/stm32n6.config .config
1647+ make
1648+ make flash
1649+ ```
1650+
1651+ ` make flash ` uses OpenOCD with the stmqspi driver to:
1652+ 1 . Program the signed application to NOR flash at 0x70020000
1653+ 2 . Load wolfBoot to SRAM at 0x34000000
1654+ 3 . Start wolfBoot, which verifies and boots the application via XIP
1655+
1656+ Prerequisites:
1657+ - OpenOCD 0.12+ with stm32n6x target support (build from source if needed)
1658+ - ST-Link connected to the Nucleo board
1659+ - arm-none-eabi toolchain in PATH
1660+
1661+ ### Build Options
1662+
1663+ ``` sh
1664+ make TARGET=stm32n6 SIGN=ECC256
1665+ ```
1666+
1667+ The example config uses:
1668+ - ` EXT_FLASH=1 ` with ` PART_UPDATE_EXT=1 ` and ` PART_SWAP_EXT=1 `
1669+ - Boot partition at 0x70020000 (XIP, not marked EXT)
1670+ - Update/swap partitions use device-relative offsets
1671+ - 4KB sector size (` WOLFBOOT_SECTOR_SIZE=0x1000 ` )
1672+ - ECC256 + SHA256 for signature verification
1673+
1674+ ### XIP Constraints
1675+
1676+ Since the application executes directly from NOR flash via XSPI2 memory-mapped
1677+ mode, the following constraints apply:
1678+
1679+ - The application must NOT call ` hal_init() ` — XSPI2 is already configured by
1680+ wolfBoot for memory-mapped mode. Reinitializing XSPI2 would disable XIP and
1681+ crash the CPU.
1682+ - Calling ` wolfBoot_success() ` requires all flash write functions to be placed
1683+ in RAM (RAMFUNCTION). The HAL flash functions in ` hal/stm32n6.c ` need the
1684+ RAMFUNCTION attribute for this to work from an XIP application.
1685+
1686+ ### Flash Script Options
1687+
1688+ The flash script supports several modes:
1689+
1690+ ``` sh
1691+ ./tools/scripts/stm32n6_flash.sh # Build and flash all
1692+ ./tools/scripts/stm32n6_flash.sh --skip-build # Flash only (existing binaries)
1693+ ./tools/scripts/stm32n6_flash.sh --app-only # Flash signed app only
1694+ ./tools/scripts/stm32n6_flash.sh --test-update # Flash v1 boot + v2 update
1695+ ./tools/scripts/stm32n6_flash.sh --halt # Leave OpenOCD running
1696+ ```
1697+
1698+ ### Debugging
1699+
1700+ OpenOCD:
1701+
1702+ ``` sh
1703+ openocd -f config/openocd/openocd_stm32n6.cfg
1704+ ```
1705+
1706+ After OpenOCD starts, connect via telnet (port 4444). To manually load wolfBoot
1707+ and start it:
1708+
1709+ ``` sh
1710+ reset halt
1711+ load_image wolfboot.bin 0x34000000 bin
1712+ reg msplim_s 0x00000000
1713+ reg psplim_s 0x00000000
1714+ reg msp 0x34020000
1715+ mww 0xE000ED08 0x34000000
1716+ resume < entry_address>
1717+ ```
1718+
1719+ The entry address can be found with:
1720+ ``` sh
1721+ arm-none-eabi-nm wolfboot.elf | grep isr_reset
1722+ ```
1723+
1724+ GDB:
1725+
1726+ ``` sh
1727+ arm-none-eabi-gdb wolfboot.elf
1728+ target remote :3333
1729+ mon halt
1730+ add-symbol-file test-app/image.elf 0x70020400
1731+ ```
1732+
1733+
16161734## STM32H7
16171735
16181736The STM32H7 flash geometry must be defined beforehand.
0 commit comments