Skip to content

Wolfhal uart flash - #998

Open
AlexLanzano wants to merge 2 commits into
wolfSSL:masterfrom
AlexLanzano:wolfhal-uart-flash
Open

AlexLanzano wants to merge 2 commits into
wolfSSL:masterfrom
AlexLanzano:wolfhal-uart-flash

Conversation

@AlexLanzano

Copy link
Copy Markdown
Member

No description provided.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_DIR paths 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

Comment thread arch.mk Resolved

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Let wolfHAL builds read board files from BOARD_DIR, defaulting to
hal/boards/$(BOARD). Relative paths resolve against the wolfBoot root.
Comment thread test-app/Makefile
ifeq ($(UART_FLASH),1)
CFLAGS+=-D"UART_FLASH=1"
APP_OBJS+= ../src/uart_flash.o ../hal/uart/uart_drv_$(UART_TARGET).o
APP_OBJS+=../src/uart_flash.o

@vhdirk vhdirk Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we could also make the uart_flash protocol itself configurable? We currently have a completely alternate implementation of ext_flash_read/write, so I was wondering if this is something that needs to end up in wolfHAL as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wolfHAL is more for containing hardware abstractions rather than software implemented protocols. You could implement your own uart_flash protocol out of tree using wolfHAL's uart interface as a wolfBoot ext_flash_read/write instead. You would need to write your own server to handle that though.

What specifically do you need to be more configurable for the uart_flash protocol? It might be easier to address that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just have a completely different protocol for communicating over uart. It's a very generic protocol that we use throughout our application and sort of behaves like RPC. I don't think it makes sense here to aim for inclusion in wolfBoot.
As for the uart itself: we use 2 gpios to signal readiness to the remote party. That is also rather non-standard I suppose.

The track I'm currently on is:

  • support stm32l0 in wolfHAL
  • create a board with this signalling uart interface
  • patch wolfboot to inject a custom uart_flash protocol on top of the wolfHAL uart.

Perhaps there are easier approaches, but this way we can reuse the uart init steps that already exist in wolfBoot.
I don't suppose you already have a wolfHAL implementation for the stm32l0 lying around?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that track will definitely work. I don't have support for the L0 yet but I wonder if some of the existing drivers we have could be reused like we do for other STM32 platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants