STM32U5 support and clean up#44
Merged
Merged
Conversation
Member
AlexLanzano
commented
May 28, 2026
- 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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.