Skip to content
Open
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
12 changes: 12 additions & 0 deletions .github/workflows/test-configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,18 @@ jobs:
arch: arm
config-file: ./config/examples/stm32h5-dualbank.config

stm32n6_test:
uses: ./.github/workflows/test-build.yml
with:
arch: arm
config-file: ./config/examples/stm32n6.config

stm32n6_tz_test:
uses: ./.github/workflows/test-build.yml
with:
arch: arm
config-file: ./config/examples/stm32n6-tz.config

stm32h5_tz_test:
uses: ./.github/workflows/test-build.yml
with:
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ ifeq ($(TARGET),sama5d3)
MAIN_TARGET:=wolfboot.bin test-app/image_v1_signed.bin
endif

ifeq ($(TARGET),stm32n6)
# wolfBoot runs from SRAM, app from XIP on external NOR - no contiguous factory.bin
MAIN_TARGET:=wolfboot.bin test-app/image_v1_signed.bin
endif

ifeq ($(TARGET),rp2350)
MAIN_TARGET:=include/target.h keytools wolfboot_signing_private_key.der pico-sdk-info
endif
Expand Down Expand Up @@ -653,6 +658,12 @@ stack-usage: wolfboot.bin
image-header-size: wolfboot.bin
$(Q)echo $(IMAGE_HEADER_SIZE) > .image_header_size

## Target-specific flash targets
ifeq ($(TARGET),stm32n6)
flash: wolfboot.bin test-app/image_v1_signed.bin
$(Q)tools/scripts/stm32n6_flash.sh --skip-build
endif


cppcheck:
cppcheck -f --enable=warning --enable=portability \
Expand Down
29 changes: 26 additions & 3 deletions arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,19 @@ ifeq ($(ARCH),ARM)

endif

ifeq ($(TARGET),stm32n6)
CORTEX_M55=1
CFLAGS+=-Ihal
ARCH_FLASH_OFFSET=0x70000000
# Boot ROM copies FSBL from NOR to AXISRAM2 at 0x34180400.
# Use the same address for both TZEN=0 and TZEN=1 since the Boot ROM
# always uses the non-secure alias. SAU is configured in hal_init().
WOLFBOOT_ORIGIN=0x34180400
EXT_FLASH=1
PART_UPDATE_EXT=1
PART_SWAP_EXT=1
endif

ifeq ($(TARGET),rp2350)
CORTEX_M33=1
CFLAGS+=-Ihal
Expand Down Expand Up @@ -352,12 +365,22 @@ else
CORTEXM_ARM_EXTRA_CFLAGS+=-DWOLFSSL_ARMASM -DWOLFSSL_ARMASM_NO_HW_CRYPTO \
-DWOLFSSL_ARMASM_NO_NEON -DWOLFSSL_ARMASM_THUMB2
endif
ifeq ($(CORTEX_M55),1)
CORTEX_M33=1
CFLAGS+=-mcpu=cortex-m55 -DCORTEX_M55
LDFLAGS+=-mcpu=cortex-m55
endif
ifeq ($(CORTEX_M33),1)
CFLAGS+=-mcpu=cortex-m33 -DCORTEX_M33
LDFLAGS+=-mcpu=cortex-m33
CFLAGS+=-DCORTEX_M33
ifneq ($(CORTEX_M55),1)
CFLAGS+=-mcpu=cortex-m33
LDFLAGS+=-mcpu=cortex-m33
endif
ifeq ($(TZEN),1)
ifneq (,$(findstring stm32,$(TARGET)))
OBJS+=hal/stm32_tz.o
ifneq ($(TARGET),stm32n6)
OBJS+=hal/stm32_tz.o
endif
endif
CFLAGS+=-mcmse
ifeq ($(WOLFCRYPT_TZ),1)
Expand Down
24 changes: 24 additions & 0 deletions config/examples/stm32n6-tz.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ARCH?=ARM
TARGET?=stm32n6
TZEN?=1
SIGN?=ECC256
HASH?=SHA256
DEBUG?=0
DEBUG_UART?=1
VTOR?=1
NO_ASM?=0
NO_MPU=1
SPI_FLASH?=0
ALLOW_DOWNGRADE?=0
NVM_FLASH_WRITEONCE?=0
WOLFBOOT_VERSION?=1
V?=0
SPMATH?=1
RAM_CODE?=1
WOLFBOOT_SECTOR_SIZE?=0x1000
WOLFBOOT_PARTITION_SIZE?=0x100000
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x70020000
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x00120000
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x00010000
IMAGE_HEADER_SIZE?=1024
CFLAGS_EXTRA+=-DPART_BOOT_EXT
27 changes: 27 additions & 0 deletions config/examples/stm32n6.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
ARCH?=ARM
TARGET?=stm32n6
SIGN?=ECC256
HASH?=SHA256
DEBUG?=0
DEBUG_UART?=1
VTOR?=1
NO_ASM?=0
NO_MPU=1
SPI_FLASH?=0
ALLOW_DOWNGRADE?=0
NVM_FLASH_WRITEONCE?=0
WOLFBOOT_VERSION?=1
V?=0
SPMATH?=1
RAM_CODE?=1
WOLFBOOT_SECTOR_SIZE?=0x1000
WOLFBOOT_PARTITION_SIZE?=0x100000
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x70020000
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x00120000
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x00010000
IMAGE_HEADER_SIZE?=1024
# Boot partition is on the same XSPI2 NOR flash as update/swap.
# PART_BOOT_EXT ensures boot partition reads go through ext_flash API
# (SPI commands) instead of XIP, avoiding bus faults when XSPI2 toggles
# between memory-mapped and command mode during firmware updates.
CFLAGS_EXTRA+=-DPART_BOOT_EXT
108 changes: 108 additions & 0 deletions config/openocd/openocd_stm32n6.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# OpenOCD config for NUCLEO-N657X0-Q with MX25UM51245G NOR on XSPI2

source [find interface/stlink.cfg]
transport select swd

set CHIPNAME stm32n6x
set WORKAREASIZE 0x10000

source [find target/stm32n6x.cfg]

# Work-area above wolfBoot SRAM region
$_TARGETNAME configure -work-area-phys 0x34020000 -work-area-size $WORKAREASIZE -work-area-backup 0

# XSPI2 NOR flash bank (memory-mapped at 0x70000000, regs at 0x5802A000)
set XSPI2_BANK_ID [llength [flash list]]
flash bank $CHIPNAME.xspi2 stmqspi 0x70000000 0 0 0 $CHIPNAME.cpu 0x5802A000

# Mark VDDIO supplies valid (required for XSPI2 GPIO)
proc pwr_enable_io_supply {} {
mmw 0x5602825C 0x00040000 0 ;# RCC_AHB4ENR: PWR clock
mmw 0x56024834 0x00000100 0 ;# SVMCR1: VDDIO4SV
mmw 0x56024838 0x00000100 0 ;# SVMCR2: VDDIO5SV
mmw 0x5602483C 0x00000300 0 ;# SVMCR3: VDDIO2SV + VDDIO3SV
}

# Port N GPIO for XSPI2 (PN0-PN11, AF9, very high speed)
proc xspi2_gpio_init {} {
mmw 0x5602825C 0x00002000 0 ;# RCC_AHB4ENR: GPION clock
sleep 1
mmw 0x56023400 0x00AAAAAA 0x00555555 ;# MODER: AF mode
mmw 0x56023408 0x00FFFFFF 0 ;# OSPEEDR: very high
mmw 0x5602340C 0 0x00FFFFFF ;# PUPDR: no pull
mww 0x56023420 0x99999999 ;# AFRL: AF9
mww 0x56023424 0x00009999 ;# AFRH: AF9
}

# XSPI2 init: single-SPI, /16 prescaler, NOR reset, enter mmap mode
proc xspi2_init {} {
mmw 0x56028260 0x00003000 0 ;# RCC_AHB5ENR: XSPI2 + XSPIM clocks
mmw 0x56028248 0x00000008 0 ;# RCC_MISCENR: XSPI PHY comp clock
sleep 1

mww 0x5802A000 0x00000000 ;# CR: disable
sleep 1
mww 0x5802A008 0x001A0308 ;# DCR1: DLYBYP, DEVSIZE=26, CSHT=3
mww 0x5802A00C 0x0000000F ;# DCR2: prescaler /16
sleep 1
mww 0x5802A000 0x00000001 ;# CR: enable

# NOR flash software reset (0x66 + 0x99)
mmw 0x5802A000 0x00000002 0 ;# abort
sleep 1
mww 0x5802A024 0x0000000B ;# FCR: clear flags
mww 0x5802A100 0x00000001 ;# CCR: IMODE=single
mww 0x5802A108 0x00000000 ;# TCR: no dummy
mww 0x5802A110 0x00000066 ;# IR: Reset Enable
sleep 1

mmw 0x5802A000 0x00000002 0 ;# abort
sleep 1
mww 0x5802A024 0x0000000B
mww 0x5802A100 0x00000001
mww 0x5802A108 0x00000000
mww 0x5802A110 0x00000099 ;# IR: Reset Memory
sleep 10

xspi2_mem_mapped
}

# Memory-mapped fast-read mode (single-SPI, 4-byte addr, 8 dummy cycles)
proc xspi2_mem_mapped {} {
mmw 0x5802A000 0x00000002 0 ;# abort
sleep 1
mww 0x5802A000 0x30000001 ;# CR: mmap + enable
mww 0x5802A100 0x01003101 ;# CCR: IMODE=1, ADMODE=1, ADSIZE=3, DMODE=1
mww 0x5802A108 0x40000008 ;# TCR: DCYC=8, SSHIFT
mww 0x5802A110 0x0000000C ;# IR: Fast Read 4B
}

# Set NOR flash params manually (SFDP not readable in single-SPI mode)
proc xspi2_flash_set {} {
global XSPI2_BANK_ID
stmqspi set $XSPI2_BANK_ID MX25UM51245G 0x4000000 0x100 0x13 0 0x12 0x60 0x1000 0x21
}

# Full reinit for use when XSPI2 may already be configured
proc xspi2_reinit {} {
global XSPI2_BANK_ID
pwr_enable_io_supply
xspi2_gpio_init
xspi2_init
xspi2_flash_set
flash probe $XSPI2_BANK_ID
xspi2_flash_set
}

$_TARGETNAME configure -event reset-init {
global XSPI2_BANK_ID
pwr_enable_io_supply
xspi2_gpio_init
xspi2_init
xspi2_flash_set
flash probe $XSPI2_BANK_ID
# Re-set after probe (stmqspi driver quirk)
xspi2_flash_set
}

init
Loading
Loading