Announcing wolfHAL v1.0.0

wolfSSL is releasing wolfHAL v1.0.0, the first stable version of our hardware abstraction layer for embedded targets. wolfHAL is a small C library that gives you one driver model for GPIO, UART, SPI, I2C, flash, timers, DMA, hardware crypto and more, on any compiler and with or without an RTOS.

Why wolfHAL

Vendor SDKs are large, tied to one chip family, and often pull in an RTOS or build system. wolfHAL takes the other path:

  • No dependencies. It’s plain C source, and it needs only a compiler plus stdint.h and stddef.h.
  • OS- and compiler-agnostic. It runs bare metal or under any RTOS, with GCC or a vendor toolchain.
  • One API across vendors. whal_Uart_Send() reads the same on an STM32, a PIC32CZ, or an AMD Versal.

That makes wolfHAL a natural base for wolfSSL products that run close to the hardware, such as wolfBoot and wolfCrypt on bare-metal targets.

How it works

Every peripheral in wolfHAL is a device struct with three fields: the register base address, a driver, and a driver-specific config.

struct whal_Uart {
    const uintptr_t base;          /* register block address */
    const whal_UartDriver *driver; /* driver vtable */
    void *cfg;                     /* driver-specific config */
};

Your application calls the generic API, such as whal_Uart_Send(dev, buf, len). How that call reaches the driver is a per-device build choice:

  • Vtable dispatch (default). The generic API calls through the driver’s function table. Use it when one build has several drivers of the same type, such as on-chip flash and an external SPI NOR flash.
  • Direct API mapping. One -D flag maps the generic API straight onto a single driver’s functions. There’s no function pointer and no table, so the code is smaller and faster.

Drivers can also be built as single-instance devices. The driver owns its device struct, so the board passes WHAL_INTERNAL_DEV instead of a pointer, and the compiler can fold the base address and config into constants.
The board layer ties it together. It’s a small BSP made of wolfHAL_board.h, wolfHAL_board.c and board.mk. Board_Init() brings up clocks, enables peripheral clocks and initializes each device. Applications reach devices only through BOARD__DEV macros, so the same main.c builds for every board.

Either path ends in the same driver code. The board decides which one each device takes, so the application code never changes.

What’s in 1.0.0

v1.0.0 ships 20 device types and about 145 driver and dispatch sources across 13 chip families, from Cortex-M0 parts up to a Cortex-A78. Each family has a reference board in the repository.

Platform CPU Reference board Driver types
STM32C0 Cortex-M0+ NUCLEO-C031C6 flash, GPIO, SPI, UART
STM32F0 Cortex-M0 NUCLEO-F091RC flash, GPIO, I2C, SPI, UART, watchdog
STM32F3 Cortex-M4 NUCLEO-F302R8 flash, GPIO, I2C, SPI, UART, watchdog
STM32F4 Cortex-M4 WeAct BlackPill F411 flash, GPIO, SPI, UART
STM32L1 Cortex-M3 NUCLEO-L152RE flash, GPIO, I2C, SPI, UART, watchdog
STM32H5 Cortex-M33 NUCLEO-H563ZI Ethernet, flash, GPIO, RNG, SPI, UART
STM32U5 Cortex-M33 NUCLEO-U5A5ZJ-Q AES, hash, DMA, flash, GPIO, I2C, RNG, SPI, UART, watchdog
STM32N6 Cortex-M55 NUCLEO-N657X0-Q AES, hash, DMA, Ethernet, GPIO, I2C, RNG, SPI, UART, watchdog
STM32WB Cortex-M4 NUCLEO-WB55RG AES, PKA, DMA, flash, GPIO, I2C, PWM, RNG, SPI, UART, watchdog
STM32WB0 Cortex-M0+ NUCLEO-WB05KZ PKA, DMA, flash, GPIO, I2C, RNG, SPI, UART, watchdog
STM32WBA Cortex-M33 NUCLEO-WBA55CG AES, hash, DMA, flash, GPIO, I2C, RNG, SPI, UART, watchdog
Microchip PIC32CZ Cortex-M7 PIC32CZ CA Curiosity Ultra flash, GPIO, UART
AMD Versal Gen 2 Cortex-A78 VEK385 (and QEMU amd-versal2-virt) PL011 UART, Cadence OSPI, OSPI DMA, NOR flash

wolfHAL also includes drivers for common off-chip parts, which work on any board that has the bus they need:

  • SPI NOR and OSPI NOR flash
  • SD cards over SPI, exposed as a block device
  • Sharp Memory LCD displays
  • Bosch BMI270 IMU
  • Microchip LAN8742A Ethernet PHY

Hardware crypto

wolfHAL gives the crypto engines on modern MCUs the same treatment as any other peripheral: one generic API, with a driver per chip behind it.

  • AES: ECB, CBC, CTR, GCM, GMAC and CCM
  • Hashing: SHA-1, SHA-224 and SHA-256, plus HMAC for each
  • Public key (PKA): modular exponentiation, modular inverse, modular reduction, integer multiply and subtract, and RSA-CRT exponentiation
  • True random number generators on the STM32WB, WB0, WBA, H5, U5 and N6

Testing and CI

wolfHAL ships with an on-target test suite: 68 test files and over 400 test cases, run on the reference boards.

  • Generic tests (test_.c) exercise the public API and run unchanged on every board that has that device type.
  • Platform tests (test__.c) check chip-specific behavior and register state. They build in automatically for the matching board.
  • Peripheral tests cover the off-chip drivers, such as SPI NOR flash and SD cards, and you opt in with PERIPHERALS=.
  • Host-side core tests cover the bit operations, register access, dispatch, endianness and timeout helpers with the native compiler.

Getting started

Clone the repository and build the blinky example for any reference board. You need only make and the board’s GCC cross toolchain.

git clone https://github.com/wolfSSL/wolfHAL.git
cd wolfHAL/examples/blinky
make BOARD=stm32wb55xx_nucleo

The binary lands in build//. To run the test suite on a board, run make BOARD= from tests/.
The documentation in the repository walks through the rest:

wolfHAL is dual-licensed under GPLv3 and a commercial license from wolfSSL.

Tell us which chips and peripherals you want next. Questions, feature requests and porting help: contact us at facts@wolfssl.com. For commercial licensing, contact licensing@wolfssl.com. And if wolfHAL is useful to you, give it a star on GitHub.

If you have questions about any of the above, please contact us at facts@wolfssl.com or call us at +1 425 245 8247.

Download wolfSSL Now