Skip to content

Commit 980022d

Browse files
dgarskedanielinux
authored andcommitted
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 8b7ce4e commit 980022d

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
@@ -536,6 +536,12 @@ jobs:
536536
arch: arm
537537
config-file: ./config/examples/stm32l5-wolfcrypt-tz.config
538538

539+
stm32u3_test:
540+
uses: ./.github/workflows/test-build.yml
541+
with:
542+
arch: arm
543+
config-file: ./config/examples/stm32u3.config
544+
539545
stm32u5_nonsecure_dualbank_test:
540546
uses: ./.github/workflows/test-build.yml
541547
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
@@ -1709,6 +1709,82 @@ arm-none-eabi-gdb
17091709
```
17101710
17111711
1712+
## STM32U3
1713+
1714+
The STM32U3 family (for example the STM32U385RG on NUCLEO-U385RG-Q) is a
1715+
Cortex-M33 part **without TrustZone**, so the port is single-image only
1716+
(no `-tz` or `-ns` variants). 1 MB internal flash, 256 KB SRAM, 8 KB
1717+
pages, 128-bit (quad-word) flash write quantum.
1718+
1719+
### Flash layout (stm32u3.config)
1720+
1721+
Dual-bank flash (2 x 512 KB, 4 KB pages). Bank 1 holds wolfBoot + BOOT,
1722+
bank 2 holds UPDATE + SWAP:
1723+
1724+
```
1725+
Bank 1:
1726+
0x08000000 - 0x0800FFFF wolfBoot bootloader (64 KB)
1727+
0x08010000 - 0x0807FFFF BOOT partition (0x70000, 448 KB)
1728+
Bank 2:
1729+
0x08080000 - 0x080EFFFF UPDATE partition (0x70000, 448 KB)
1730+
0x080F0000 - 0x080F0FFF SWAP sector (4 KB)
1731+
```
1732+
1733+
### Clock and UART
1734+
1735+
UART is always available in the test-app and enabled in wolfBoot via
1736+
`DEBUG_UART=1` (on by default in the example config). USART1 on PA9
1737+
(TX) / PA10 (RX), AF7, 115200 8N1 — the ST-LINK VCP on NUCLEO-U385RG-Q.
1738+
1739+
### Building
1740+
1741+
```sh
1742+
cp config/examples/stm32u3.config .config
1743+
make clean
1744+
make
1745+
```
1746+
1747+
`DEBUG_UART=1` is enabled by default. To also run the flash self-test:
1748+
1749+
```sh
1750+
make TEST_FLASH=1
1751+
```
1752+
1753+
### Flashing
1754+
1755+
Use `STM32_Programmer_CLI` (from STM32CubeIDE or STM32CubeProgrammer).
1756+
`st-flash` does not yet support chipid 0x454.
1757+
1758+
```sh
1759+
STM32_Programmer_CLI -c port=SWD reset=HWrst -e all \
1760+
-d factory.bin 0x08000000 -v -rst
1761+
```
1762+
1763+
The test app blinks LD2 (PA5): slow on v1, fast on v2 (post-update).
1764+
1765+
### Testing an Update
1766+
1767+
Sign the test application as version 2 and write the update trigger
1768+
magic (`pBOOT`) at the tail of the partition:
1769+
1770+
```sh
1771+
tools/keytools/sign --ecc384 --sha384 test-app/image.bin \
1772+
wolfboot_signing_private_key.der 2
1773+
echo -n "pBOOT" > trigger_magic.bin
1774+
./tools/bin-assemble/bin-assemble \
1775+
update.bin \
1776+
0x0 test-app/image_v2_signed.bin \
1777+
0x6FFFB trigger_magic.bin
1778+
STM32_Programmer_CLI -c port=SWD reset=HWrst \
1779+
-d update.bin 0x08080000 -v -rst
1780+
```
1781+
1782+
Reset the board — wolfBoot verifies v2, swaps partitions, and jumps to
1783+
the new image. LD2 transitions from the slow (v1) blink to the fast
1784+
(v2) blink; with `DEBUG_UART=1` the UART log shows the v1 → v2
1785+
transition.
1786+
1787+
17121788
## STM32H5
17131789
17141790
Like [STM32L5](#stm32l5) and [STM32U5](#stm32u5), STM32H5 support is also demonstrated

0 commit comments

Comments
 (0)