Skip to content

STM32U5 support and clean up#44

Merged
AlexLanzano merged 5 commits into
wolfSSL:mainfrom
AlexLanzano:stm32u5
May 28, 2026
Merged

STM32U5 support and clean up#44
AlexLanzano merged 5 commits into
wolfSSL:mainfrom
AlexLanzano:stm32u5

Conversation

@AlexLanzano
Copy link
Copy Markdown
Member

  • Fix cross-family macro aliasing
  • Fix bug in stm32wb has driver. Needed to buffer input
  • Add support for the stm32u5 and add a board for the stm32u5a5zj nucleo board

Each leaf driver (stm32wb_gpio.c, stm32wba_hash.c, stm32wb_uart.c, etc.)
previously carried an OR-chain like

    #if defined(WHAL_CFG_STM32WB_GPIO_DIRECT_API_MAPPING) || \
        defined(WHAL_CFG_STM32F4_GPIO_DIRECT_API_MAPPING) || \
        defined(WHAL_CFG_STM32H5_GPIO_DIRECT_API_MAPPING) || ...

so the driver TU was aware of every family that aliased into it. Each new
family that wanted to reuse a leaf driver had to touch every TU.

Move that responsibility out of the leaf driver into the family alias
header. Each family alias header (e.g. wolfHAL/gpio/stm32n6_gpio.h) now
forwards its family-prefixed WHAL_CFG_*_DEV initializer macros to the
leaf-family names that the leaf driver consumes. Boards rename their
config-init macros to the family-prefixed form. Leaf drivers only check
their own family's flag.

Adding a new family is now a header-only change.
The HASH peripheral DIN register expects 32-bit writes; the only way to
push fewer than 4 bytes is at the very end via the NBLW field. Earlier
the Process path wrote whatever bytes it had as a partial word mid-stream
when the per-call length wasn't a multiple of 4, which made the hash
output depend on how the caller chunked its input.

Carry 0-3 leftover bytes in a static staging buffer between calls. The
buffer is shared (single-instance peripheral, one streaming session at a
time). Process drains the buffer to a full word when a subsequent call
provides enough bytes; Finalize drains whatever remains as the final
partial word.

While here, this file also drops its own #if defined OR-chain following
the convention from the previous commit.
Previously the test read the test region first, asserted the contents
weren't the pattern, then erased. That relied on whatever happened to be
in flash at boot differing from the pattern. Erase first so the first
read is checking known-erased bytes.
New platform header (wolfHAL/platform/st/stm32u5a5zj.h) with peripheral
base addresses, driver pointers, and RCC clock-gate descriptors per
RM0456.

New RCC driver (wolfHAL/clock/stm32u5_rcc.h) handles PLL1 bring-up with
PLL1M/PLL1MBOOST, PWR voltage scaling, the EPOD booster (required above
55 MHz in Range 1), and RNG kernel-clock source selection.

New flash driver (src/flash/stm32u5_flash.c) handles dual-bank page
erase via BKER + 8-bit PNB and 128-bit (16-byte) programming through
volatile 4x32-bit stores.

Other peripherals (AES, HASH, RNG, GPDMA, GPIO, I2C, SPI, UART, IWDG,
WWDG) are register-compatible with existing leaf drivers; the U5 headers
are typedef + macro alias shims and the U5 .c files #include their
parent's TU after forwarding any DIRECT_API_MAPPING flags. SPI is
sourced from the H5 (V2 SPI with CFG1/CFG2); everything else is sourced
from WB or WBA.
Board for the STM32U5A5ZJTx (4 MB flash dual-bank, 2.5 MB SRAM, LQFP144).
Brings SYSCLK to 160 MHz via PLL1 from HSI16 with the EPOD booster and 4
flash wait states. Pin map: LD1 (PC7), USART1 (PA9/PA10), SPI1 (PB3/4/5
+ PA4 CS), I2C1 (PB6/7 open-drain).

Includes the board to both the boards.yml CI matrix and the
watchdog-tests.yml matrix (IWDG + WWDG variants).
@AlexLanzano AlexLanzano self-assigned this May 28, 2026
Copilot AI review requested due to automatic review settings May 28, 2026 18:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@AlexLanzano AlexLanzano requested a review from Copilot May 28, 2026 19:12
@AlexLanzano AlexLanzano merged commit f4095e9 into wolfSSL:main May 28, 2026
33 checks passed
@AlexLanzano AlexLanzano deleted the stm32u5 branch May 28, 2026 20:35
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.

2 participants