Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/test-configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,8 @@ jobs:
arch: arm
config-file: ./config/examples/stm32wba.config

# DEBUG_UART=1 variant: compiles the GPIO/UART drivers and board.h pin table.
# DEBUG_UART=1 variant: compiles the GPIO/UART drivers and the
# wolfHAL_board.h pin table.
stm32wba_wolfhal_debug_uart_test:
uses: ./.github/workflows/test-build.yml
with:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ ifeq ($(WOLFHAL),1)
$(error BOARD=$(BOARD) has no hal/boards/$(BOARD)/board.mk)
endif
# wolfHAL backend: hal/wolfhal.o replaces hal/$(TARGET).o above. The
# board's board.c provides hal_init/hal_prepare_boot and the wolfHAL
# board's wolfHAL_board.c provides hal_init/hal_prepare_boot and the wolfHAL
# device handles; board.mk pulls in chip drivers.
OBJS+=./hal/boards/$(BOARD)/board.o
OBJS+=./hal/boards/$(BOARD)/wolfHAL_board.o
Comment thread
AlexLanzano marked this conversation as resolved.
include hal/boards/$(BOARD)/board.mk
endif

Expand Down
26 changes: 13 additions & 13 deletions docs/wolfHAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ The integration consists of four parts:

2. **Board directory** (`hal/boards/<board>/`) — contains three files that fully
describe a board:
- `board.h` — includes the chip-specific wolfHAL driver headers and defines
any board-level pin/peripheral enums.
- `board.c` — device instances (clock, flash, GPIO, UART), configuration
structs, and `hal_init`/`hal_prepare_boot` implementations.
- `wolfHAL_board.h` — includes the chip-specific wolfHAL driver headers
and defines any board-level pin/peripheral enums.
- `wolfHAL_board.c` — device instances (clock, flash, GPIO, UART),
Comment thread
AlexLanzano marked this conversation as resolved.
configuration structs, and `hal_init`/`hal_prepare_boot` implementations.
- `board.mk` — build variables (`ARCH_FLASH_OFFSET`, `LSCRIPT_IN`, the
`WHAL_CFG_*_API_MAPPING_*` flags, wolfHAL driver objects, `RAM_CODE`
linker rules).
Expand All @@ -56,16 +56,16 @@ arch.mk

Makefile
└─ OBJS += hal/wolfhal.o (replaces hal/$(TARGET).o)
└─ OBJS += hal/boards/$(BOARD)/board.o
└─ OBJS += hal/boards/$(BOARD)/wolfHAL_board.o
└─ include hal/boards/$(BOARD)/board.mk

hal/wolfhal.c (generic — calls whal_Flash_Write, whal_Uart_Send, etc.)
└─ #include "board.h" (resolved via -I to the board directory)
└─ #include "wolfHAL_board.h" (resolved via -I to the board directory)

hal/boards/<board>/
├─ board.h (includes wolfHAL driver headers, pin enums)
├─ board.c (device instances, hal_init, hal_prepare_boot)
└─ board.mk (WHAL_CFG_*_API_MAPPING_*, driver objects, RAM_CODE rules)
├─ wolfHAL_board.h (includes wolfHAL driver headers, pin enums)
├─ wolfHAL_board.c (device instances, hal_init, hal_prepare_boot)
└─ board.mk (WHAL_CFG_*_API_MAPPING_*, driver objects, RAM_CODE rules)
```

The `WHAL_CFG_*_API_MAPPING_*` flags cause each wolfHAL driver source to emit
Expand Down Expand Up @@ -95,7 +95,7 @@ See `config/examples/*_wolfhal_*.config` for complete examples.

To add a new board, create a directory `hal/boards/<board_name>/` with three files:

### 1. `board.h` — Driver Headers and Pin Enums
### 1. `wolfHAL_board.h` — Driver Headers and Pin Enums

Include the chip-specific wolfHAL driver headers and declare any board-level
enums (pin indices, peripheral identifiers):
Expand All @@ -109,7 +109,7 @@ enums (pin indices, peripheral identifiers):
#include <wolfHAL/gpio/<family>_gpio.h>
#include <wolfHAL/uart/<family>_uart.h>

/* GPIO pin indices (matches pin array in board.c) */
/* GPIO pin indices (matches pin array in wolfHAL_board.c) */
enum {
BOARD_LED_PIN,
BOARD_UART_TX_PIN,
Expand All @@ -120,7 +120,7 @@ enum {
#endif /* WOLFHAL_BOARD_H */
```

### 2. `board.c` — Device Instances and Initialization
### 2. `wolfHAL_board.c` — Device Instances and Initialization

Define the wolfHAL device instances and implement `hal_init` and `hal_prepare_boot`
using the top-level wolfHAL API. The file must export `g_wbFlash` (and `g_wbUart`
Expand All @@ -129,7 +129,7 @@ when `DEBUG_UART` is enabled) as non-static globals — these are referenced by

```c
#include "hal.h"
#include "board.h"
#include "wolfHAL_board.h"

/* Clock controller */
whal_Clock g_wbClock = {
Expand Down
4 changes: 2 additions & 2 deletions hal/boards/stm32wb_nucleo/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ CFLAGS+=-DWHAL_CFG_NO_TIMEOUT
CFLAGS+=-DWHAL_CFG_STM32WB_FLASH_DIRECT_API_MAPPING
CFLAGS+=-DWHAL_CFG_STM32WB_GPIO_DIRECT_API_MAPPING
CFLAGS+=-DWHAL_CFG_STM32WB_UART_DIRECT_API_MAPPING
# UART driver is single-instance — reads whal_Stm32wb_Uart_Dev from board.h
# instead of the passed dev pointer.
# UART driver is single-instance — reads whal_Stm32wb_Uart_Dev from
# wolfHAL_board.h instead of the passed dev pointer.
CFLAGS+=-DWHAL_CFG_STM32WB_UART_SINGLE_INSTANCE

WOLFHAL_OBJS+=$(WOLFHAL_ROOT)/src/reg.o
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* board.c
/* wolfHAL_board.c
*
* STM32WB55 Nucleo board configuration using upstream wolfHAL drivers.
* Gpio/Flash/Uart singletons are instantiated by the driver .c files
* from WHAL_CFG_STM32WB_*_DEV initializer macros in board.h; board.c
* uses the BOARD_*_DEV handles for the rest. RCC is header-inlined and
* hardcodes WHAL_STM32WB_RCC_BASE — no dev pointer needed.
* from WHAL_CFG_STM32WB_*_DEV initializer macros in wolfHAL_board.h;
* wolfHAL_board.c uses the BOARD_*_DEV handles for the rest. RCC is
* header-inlined and hardcodes WHAL_STM32WB_RCC_BASE — no dev pointer needed.
*
* Copyright (C) 2026 wolfSSL Inc.
*
Expand All @@ -27,7 +27,7 @@

#include <stddef.h>
#include "hal.h"
#include "board.h"
#include "wolfHAL_board.h"

#ifdef DEBUG_UART
static const whal_Stm32wb_Rcc_PeriphClk g_periphClks[] = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* board.h
/* wolfHAL_board.h
*
* STM32WB55 Nucleo wolfHAL board header. Provides the WHAL_CFG_STM32WB_X_DEV
* initializer macros that the upstream chip drivers use to instantiate the
* whal_Stm32wb_X_Dev singletons (in their own .c file), plus the BOARD_X_DEV
* handles that the wolfBoot adapter (hal/wolfhal.c) and board.c pass into
* the wolfHAL API.
* handles that the wolfBoot adapter (hal/wolfhal.c) and wolfHAL_board.c
* pass into the wolfHAL API.
*
* Copyright (C) 2026 wolfSSL Inc.
*
Expand Down
4 changes: 2 additions & 2 deletions hal/boards/stm32wba55cg_nucleo/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ CFLAGS+=-DWHAL_CFG_STM32WBA_FLASH_DIRECT_API_MAPPING
# underlying stm32wb_gpio.c must be given the WB-prefixed flag directly.
CFLAGS+=-DWHAL_CFG_STM32WB_GPIO_DIRECT_API_MAPPING
CFLAGS+=-DWHAL_CFG_STM32WBA_UART_DIRECT_API_MAPPING
# UART is single-instance — reads its singleton from board.h instead of the
# passed dev pointer.
# UART is single-instance — reads its singleton from wolfHAL_board.h
# instead of the passed dev pointer.
CFLAGS+=-DWHAL_CFG_STM32WBA_UART_SINGLE_INSTANCE

WOLFHAL_OBJS+=$(WOLFHAL_ROOT)/src/reg.o
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* board.c
/* wolfHAL_board.c
*
* STM32WBA55CG Nucleo board configuration using upstream wolfHAL drivers.
* Flash/Gpio/Uart singletons are instantiated by the driver .c files from
* the WHAL_CFG_* initializer macros in board.h; board.c uses the
* BOARD_*_DEV handles for the rest. RCC is header-inlined and hardcodes
* its base — no dev pointer needed.
* the WHAL_CFG_* initializer macros in wolfHAL_board.h; wolfHAL_board.c
* uses the BOARD_*_DEV handles for the rest. RCC is header-inlined and
* hardcodes its base — no dev pointer needed.
*
* Clock target: HSE32 -> PLL1 (M=1, N=24, R=3) -> SYSCLK = 100 MHz, which
* requires PWR voltage scaling Range 1 and 3 flash wait states (RM0493).
Expand All @@ -30,7 +30,7 @@

#include <stddef.h>
#include "hal.h"
#include "board.h"
#include "wolfHAL_board.h"

/* Flash clock gate — enabled before raising the wait-state count. */
static const whal_Stm32wba_Rcc_PeriphClk g_flashClock = {WHAL_STM32WBA55_FLASH_CLOCK};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* board.h
/* wolfHAL_board.h
*
* STM32WBA55CG Nucleo wolfHAL board header. Provides the WHAL_CFG_*_DEV
* initializer macros that the upstream chip drivers use to instantiate the
* device singletons (in their own .c file), plus the BOARD_X_DEV handles
* that the wolfBoot adapter (hal/wolfhal.c) and board.c pass into the
* that the wolfBoot adapter (hal/wolfhal.c) and wolfHAL_board.c pass into the
* wolfHAL API.
*
* The STM32WBA GPIO/UART peripherals are register-compatible with the
Expand Down
4 changes: 2 additions & 2 deletions hal/wolfhal.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* (hal_flash_*, uart_write) is satisfied here by forwarding to the
* wolfHAL API. The chip drivers behind the wolfHAL API are singletons,
* instantiated by the driver .c files from initializer macros in
* board.h; this file passes the BOARD_*_DEV handles defined there.
* wolfHAL_board.h; this file passes the BOARD_*_DEV handles defined there.
*
* Copyright (C) 2026 wolfSSL Inc.
*
Expand All @@ -28,7 +28,7 @@
#include <stdint.h>
#include "hal.h"
#include "wolfboot/wolfboot.h"
#include "board.h"
#include "wolfHAL_board.h"
Comment thread
AlexLanzano marked this conversation as resolved.

void RAMFUNCTION hal_flash_unlock(void)
{
Expand Down
2 changes: 1 addition & 1 deletion test-app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ delta-extra-data: image.bin
../hal/uart/uart_drv_$(UART_TARGET)_ns.o: ../hal/uart/uart_drv_$(UART_TARGET).c FORCE
$(Q)$(CC) $(CFLAGS) -c -o $(@) ../hal/uart/uart_drv_$(UART_TARGET).c -DNONSECURE_APP

board_$(BOARD).o: ../hal/boards/$(BOARD)/board.c
board_$(BOARD).o: ../hal/boards/$(BOARD)/wolfHAL_board.c
Comment thread
AlexLanzano marked this conversation as resolved.
@echo "\t[CC-$(ARCH)] $@"
$(Q)$(CC) $(CFLAGS) -DDEBUG_UART -c $(OUTPUT_FLAG) $@ $<

Expand Down
4 changes: 2 additions & 2 deletions test-app/app_wolfhal.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
#include "wolfboot/wolfboot.h"
#include "target.h"

#include "board.h"
#include "wolfHAL_board.h"

/* Chip drivers behind the wolfHAL API are singletons (configured via
* board.h). Use the BOARD_*_DEV handles defined there. */
* wolfHAL_board.h). Use the BOARD_*_DEV handles defined there. */

/* Matches all keys:
* - chacha (32 + 12)
Expand Down
Loading