STM32H5: wolfIP NS application under wolfBoot (TZEN=1)#115
Conversation
danielinux
left a comment
There was a problem hiding this comment.
Only one (minor) remark about unnecessary large timeouts + related comments in the github actions.
The other two comments re: emulator mismatches are being addressed in m33mu (thank you for spotting those!)
|
|
||
| sudo m33mu src/port/stm32h563/app.bin \ | ||
| --cpu stm32h563 --tap:tap0 --uart-stdout --timeout 180 --quit-on-faults \ | ||
| # wolfBoot does a full software ECC256 verify of the 300 KB |
There was a problem hiding this comment.
The limit here seems to be too high. Could it be that the comment refers to when the test was running with debugging (e.g. with --gdb, --dump, --record, etc.) or any option that would disable "fast mode" with branch prediction in the emulator.
The actual test with the current options seems to take 182 seconds so those timeouts seem too high.
| while ((RCC_CR & RCC_CR_HSI48RDY) == 0u) { | ||
| /* Bounded waits throughout so emulators that do not model the | ||
| * HSI48 / RNG status bits (m33mu) cannot deadlock here. The RNG | ||
| * may not produce data on the emulator, but boot completes and |
There was a problem hiding this comment.
I have checked and the latest m33mu does not have this issue. I've added a non-regression test in m33mu for this. (This comment brings no action and can be resolved)
| /* CR.HSIDIV (bits 4:3, shift 3): 0=/1 (64M), 1=/2 (32M), 2=/4, 3=/8. | ||
| * Per RM0481 Table 108. Force /2 to match the H5 reset default. | ||
| * Wait for HSIDIVF (bit 5) to confirm propagation. Same bounded | ||
| * retry so emulators without HSIDIVF feedback cannot deadlock. */ |
There was a problem hiding this comment.
This is a real fidelity gap in the emulator. Fixing.(No actions)
Summary
Make
make TZEN=1on the NUCLEO-H563ZI build the wolfIP echo server as a Non-Secure application launched by wolfBoot (BLXNS), instead of running the whole stack in Secure world. The earlier all-secure-app approach deadlocked the ETH DMA; the Non-Secure split matches the H5's product-state defaults (peripherals are NS by default, the ETH DMA master is NS+unprivileged) and lets the same wolfIP feature set that runs under TZEN=0 also run under TZEN=1.Verified end-to-end on hardware: wolfBoot validates and
BLXNSes into the signed wolfIP image, PHY link comes up, DHCP succeeds, ICMP responds in ~0.6 ms, and TCP echo on port 7 round-trips a payload.Required matching wolfBoot patch
This depends on a corresponding wolfBoot HAL patch on the
stm32tzbranch of the wolfBoot repo: wolfSSL/wolfBoot#775hal/stm32_tz.chal_gtzc_init: cede SRAM2 to NS and clearMPCBB_PRIVCFGR_VCTRfor SRAM2 + SRAM3. Reset default leaves them privileged-only, which silently blocks the NS+unprivileged ETH DMA and parks the channel onDMACSR.TBU/DMADSR.TPS=6. Also widenhal_tz_sau_initregion 2 to0x20040000-0x2009FFFF.hal/stm32h5.cperiph_unsecure: clearGPIOx_SECCFGRfor A/B/C/D/G and enable the GPIOG clock. H5 product-state defaults every GPIO pin to secure-only, so without this the NS RMII pin mux silently no-ops.Layout
wolfBoot's
do_bootsetsMSP_NSfromapp_offset[0]andBLXNSes toapp_offset[1]. The NS app'sReset_HandlerwritesVTOR_NS = 0x08060400first thing so NS exceptions vector correctly. AfterBLXNSthe chip is left running on wolfBoot's 250 MHz PLL; the NS app reverts SYSCLK to HSI/2 = 32 MHz so the existing USART3 BRR and SysTick math from the TZEN=0 build keep working.Build
Produces
factory.bin=wolfboot.bin(padded to the boot-partition offset) + ECC256-signed NS app, ready forSTM32_Programmer_CLI -w factory.bin 0x08000000. TheIMAGE_HEADER_SIZE=1024env wrapper is required (sign tool defaults to 256 for ECC256, which would place the vector table at the wrong offset).WOLFBOOT_ROOTdefaults to../wolfbootand is overridable.