Repository navigation
Wolfhal uart flash - #998
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The board-path default in arch.mk duplicates WOLFBOOT_ROOT during normalization, causing standalone test-app builds to fail the board.mk existence check for an in-tree board.
1 open issue
What changed in this PR
This PR adds UART-backed remote flash support to wolfBoot’s wolfHAL integration and allows board files to live outside the repository.
Changes:
- Add wolfHAL UART adapters and STM32WB timeout configuration for remote flash operations.
- Use configurable
BOARD_DIRpaths in bootloader and test-application builds. - Document the setup and add build coverage for encrypted UART flash.
| File | Description |
|---|---|
test-app/Makefile |
Use BOARD_DIR and omit the legacy UART driver with wolfHAL. |
src/uart_flash.c |
Use wolfHAL’s receive timeout for protocol waits. |
options.mk |
Exclude the legacy UART driver from wolfHAL builds. |
Makefile |
Load and compile board files from BOARD_DIR. |
hal/wolfhal.c |
Provide UART flash functions through wolfHAL APIs. |
hal/boards/stm32wb_nucleo/wolfHAL_board.h |
Define the UART flash device and timeout configuration. |
hal/boards/stm32wb_nucleo/wolfHAL_board.c |
Add poll-based timeouts and UART flash initialization. |
hal/boards/stm32wb_nucleo/board.mk |
Enable timeouts and required drivers for UART flash. |
docs/wolfHAL.md |
Document external boards and UART flash setup. |
arch.mk |
Define WOLFHAL and resolve board-directory paths. |
.github/workflows/test-configs.yml |
Add an encrypted UART flash build configuration for wolfHAL. |
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #998
Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .github/workflows/test-configs.yml, Makefile, arch.mk, docs/wolfHAL.md, hal/boards/stm32wb_nucleo/board.mk, hal/boards/stm32wb_nucleo/wolfHAL_board.h, options.mk, test-app/Makefile
Coverage: 3 of 3 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Max
8f4a5e2 to
cb73ff1
Compare
Implement uart_init/tx/rx in hal/wolfhal.c and rely on the board's wolfHAL UART timeout in uart_flash.c. Enable it on stm32wb_nucleo, with docs and a CI build.
Let wolfHAL builds read board files from BOARD_DIR, defaulting to hal/boards/$(BOARD). Relative paths resolve against the wolfBoot root.
cb73ff1 to
5743b7f
Compare
dgarske
left a comment
There was a problem hiding this comment.
Changes look good. Built and compared against master (arm-none-eabi-gcc 13.2.1):
- stm32wb UART_FLASH (both configs), out-of-tree BOARD_DIR (absolute and relative), standalone test-app: all build.
- stm32wb/stm32wba wolfHAL builds without UART_FLASH, and the legacy UART flash build, are byte-identical to master.
No WB55 here, so not hardware tested on my side.
The Copilot test-app BOARD_DIR comment does not reproduce at 5743b7f. Please reply/resolve it if it was fixed by the second commit.
Skip non-ACK bytes, give the erase ACK ERASE_TIMEOUT board timeouts, and document that UART_FLASH_BITRATE is ignored.

Summary
Adds UART flash (
UART_FLASH=1) support for wolfHAL boards, so the update and swap partitions can live on a remote host served bytools/uart-flash-server. Also addsBOARD_DIRso wolfHAL boards can be kept outside the wolfBoot tree.UART flash on wolfHAL
hal/wolfhal.cimplementsuart_init,uart_txanduart_rxon top of the wolfHAL UART API, using the board'sBOARD_UART_FLASH_DEV. WithWOLFHAL=1, the legacyhal/uart/uart_drv_<target>.cdriver is no longer linked (options.mk,test-app/Makefile).src/uart_flash.c: withWOLFHALdefined,uart_rxblocks until the board's wolfHAL UART timeout instead of returning immediately, so the ACK, read and erase waits call it once rather than spinning in a loop ofuart_rxcalls.stm32wb_nucleo:DEBUG_UARTorUART_FLASHis setUART_FLASH=1BOARD_UART_FLASH_DEVas the debug UARTwhal_Timeout(500000 polls, matching the legacy loop count)docs/wolfHAL.mdgains a UART Flash section: how it works, board requirements, a timeout example, and build/test steps.stm32wb_wolfhal_uart_flash_encryption_testjob buildingstm32wb-uart-flash-encryption.configwithWOLFHAL=1 BOARD=stm32wb_nucleo.BOARD_DIRwolfHAL builds read
board.mk,wolfHAL_board.candwolfHAL_board.hfromBOARD_DIR, which defaults tohal/boards/$(BOARD). Relative paths resolve against the wolfBoot root, so an out-of-tree board can be built with:Testing
stm32wb.configwithWOLFHAL=1 BOARD=stm32wb_nucleo UART_FLASH=1, andstm32wb-uart-flash-encryption.configwithWOLFHAL=1 BOARD=stm32wb_nucleo.ufserver, following thetest-enc-updatesteps. v1 boots and triggers the update, wolfBoot fetches and swaps in the encrypted v2 image, and the app reports version 2. Same result as the legacy UART driver baseline.