Skip to content

Commit 3775436

Browse files
committed
Add wolfBoot port for STM32U3 (NUCLEO-U385RG-Q)
New HAL port for the STM32U3 family (Cortex-M33, no TrustZone, 1MB dual-bank flash with 4KB pages, 64-bit double-word writes). Features: - hal/stm32u3.c, hal/stm32u3.h, hal/stm32u3.ld: flash driver, clock init (96 MHz MSIRC0 via EPOD booster), inline UART, ICACHE - config/examples/stm32u3.config: ECC384/SHA384, DEBUG_UART=1, NVM_FLASH_WRITEONCE=1, RAM_CODE=1, dual-bank layout - test-app/app_stm32u3.c: LED blink + UART output + version check - tools/scripts/prepare_update_u3.sh: v2 pBOOT update image builder - docs/Targets.md: STM32U3 section with build/flash/update instructions - CI: stm32u3_test job + Clang rebuild coverage Tested on NUCLEO-U385RG-Q: - Verified boot with ECC384/SHA384 signature - 96 MHz clock (MSIRC0 + SMPS + EPOD booster + VOS1) - UART output on USART1 PA9/PA10 (ST-LINK VCP) - TEST_FLASH erase/write/readback on both flash banks - A/B firmware update (v1 -> v2 swap with pBOOT trigger)
1 parent 877ffea commit 3775436

12 files changed

Lines changed: 933 additions & 1 deletion

File tree

.github/workflows/test-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
if: |
5151
inputs.config-file == './config/examples/stm32h7.config' ||
5252
inputs.config-file == './config/examples/stm32h7-octospi.config' ||
53+
inputs.config-file == './config/examples/stm32u3.config' ||
5354
inputs.config-file == './config/examples/stm32u5.config' ||
5455
inputs.config-file == './config/examples/stm32u5-wolfcrypt-tz.config' ||
5556
inputs.config-file == './config/examples/stm32u5-nonsecure-dualbank.config' ||

.github/workflows/test-configs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,12 @@ jobs:
530530
arch: arm
531531
config-file: ./config/examples/stm32l5-wolfcrypt-tz.config
532532

533+
stm32u3_test:
534+
uses: ./.github/workflows/test-build.yml
535+
with:
536+
arch: arm
537+
config-file: ./config/examples/stm32u3.config
538+
533539
stm32u5_nonsecure_dualbank_test:
534540
uses: ./.github/workflows/test-build.yml
535541
with:

arch.mk

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,15 @@ ifeq ($(ARCH),ARM)
255255
SPI_TARGET=stm32
256256
endif
257257

258+
ifeq ($(TARGET),stm32u3)
259+
CORTEX_M33=1
260+
CFLAGS+=-Ihal
261+
ARCH_FLASH_OFFSET=0x08000000
262+
WOLFBOOT_ORIGIN=0x08000000
263+
LSCRIPT_IN=hal/$(TARGET).ld
264+
SPI_TARGET=stm32
265+
endif
266+
258267
ifeq ($(TARGET),stm32h5)
259268
CORTEX_M33=1
260269
CFLAGS+=-Ihal

config/examples/stm32u3.config

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
ARCH?=ARM
2+
TZEN?=0
3+
TARGET?=stm32u3
4+
SIGN?=ECC384
5+
HASH?=SHA384
6+
DEBUG?=0
7+
VTOR?=1
8+
CORTEX_M0?=0
9+
CORTEX_M33?=1
10+
NO_ASM?=0
11+
NO_MPU=1
12+
EXT_FLASH?=0
13+
SPI_FLASH?=0
14+
ALLOW_DOWNGRADE?=0
15+
NVM_FLASH_WRITEONCE?=1
16+
WOLFBOOT_VERSION?=1
17+
V?=0
18+
SPMATH?=1
19+
RAM_CODE?=1
20+
DUALBANK_SWAP?=0
21+
# Flash layout for dual-bank (2x512KB, 8KB pages):
22+
# Bank 1 (0x08000000): wolfBoot (64KB) + BOOT partition (448KB)
23+
# Bank 2 (0x08080000): UPDATE partition (448KB) + SWAP (8KB)
24+
# Future: DUALBANK_SWAP=1 eliminates swap and uses HW bank-swap
25+
WOLFBOOT_SECTOR_SIZE?=0x1000
26+
WOLFBOOT_PARTITION_SIZE?=0x70000
27+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x08010000
28+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x08080000
29+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x080F0000
30+
FLAGS_HOME=0
31+
DISABLE_BACKUP=0
32+
DEBUG_UART=1

docs/Targets.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,82 @@ arm-none-eabi-gdb
16851685
```
16861686
16871687
1688+
## STM32U3
1689+
1690+
The STM32U3 family (for example the STM32U385RG on NUCLEO-U385RG-Q) is a
1691+
Cortex-M33 part **without TrustZone**, so the port is single-image only
1692+
(no `-tz` or `-ns` variants). 1 MB internal flash, 256 KB SRAM, 8 KB
1693+
pages, 128-bit (quad-word) flash write quantum.
1694+
1695+
### Flash layout (stm32u3.config)
1696+
1697+
Dual-bank flash (2 x 512 KB, 4 KB pages). Bank 1 holds wolfBoot + BOOT,
1698+
bank 2 holds UPDATE + SWAP:
1699+
1700+
```
1701+
Bank 1:
1702+
0x08000000 - 0x0800FFFF wolfBoot bootloader (64 KB)
1703+
0x08010000 - 0x0807FFFF BOOT partition (0x70000, 448 KB)
1704+
Bank 2:
1705+
0x08080000 - 0x080EFFFF UPDATE partition (0x70000, 448 KB)
1706+
0x080F0000 - 0x080F0FFF SWAP sector (4 KB)
1707+
```
1708+
1709+
### Clock and UART
1710+
1711+
UART is always available in the test-app and enabled in wolfBoot via
1712+
`DEBUG_UART=1` (on by default in the example config). USART1 on PA9
1713+
(TX) / PA10 (RX), AF7, 115200 8N1 — the ST-LINK VCP on NUCLEO-U385RG-Q.
1714+
1715+
### Building
1716+
1717+
```sh
1718+
cp config/examples/stm32u3.config .config
1719+
make clean
1720+
make
1721+
```
1722+
1723+
`DEBUG_UART=1` is enabled by default. To also run the flash self-test:
1724+
1725+
```sh
1726+
make TEST_FLASH=1
1727+
```
1728+
1729+
### Flashing
1730+
1731+
Use `STM32_Programmer_CLI` (from STM32CubeIDE or STM32CubeProgrammer).
1732+
`st-flash` does not yet support chipid 0x454.
1733+
1734+
```sh
1735+
STM32_Programmer_CLI -c port=SWD reset=HWrst -e all \
1736+
-d factory.bin 0x08000000 -v -rst
1737+
```
1738+
1739+
The test app blinks LD2 (PA5): slow on v1, fast on v2 (post-update).
1740+
1741+
### Testing an Update
1742+
1743+
Sign the test application as version 2 and write the update trigger
1744+
magic (`pBOOT`) at the tail of the partition:
1745+
1746+
```sh
1747+
tools/keytools/sign --ecc384 --sha384 test-app/image.bin \
1748+
wolfboot_signing_private_key.der 2
1749+
echo -n "pBOOT" > trigger_magic.bin
1750+
./tools/bin-assemble/bin-assemble \
1751+
update.bin \
1752+
0x0 test-app/image_v2_signed.bin \
1753+
0x6FFFB trigger_magic.bin
1754+
STM32_Programmer_CLI -c port=SWD reset=HWrst \
1755+
-d update.bin 0x08080000 -v -rst
1756+
```
1757+
1758+
Reset the board — wolfBoot verifies v2, swaps partitions, and jumps to
1759+
the new image. LD2 transitions from the slow (v1) blink to the fast
1760+
(v2) blink; with `DEBUG_UART=1` the UART log shows the v1 → v2
1761+
transition.
1762+
1763+
16881764
## STM32H5
16891765
16901766
Like [STM32L5](#stm32l5) and [STM32U5](#stm32u5), STM32H5 support is also demonstrated

0 commit comments

Comments
 (0)