Skip to content

stm32h5: add STM32H573I-DK board support and fix the UART baud divisor - #1022

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:stm32h573i_dk
Open

dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:stm32h573i_dk

Conversation

@dgarske

@dgarske dgarske commented Dec 2, 2026

Copy link
Copy Markdown
Member

Adds a board option to the STM32H5 target for the STM32H573I-DK, which has a 25 MHz HSE, its ST-LINK console on USART1 (PA9/PA10) and LEDs on ports F and I.

What it adds

  • arch.mk, tools/config.mk - STM32H5_BOARD=h573i_dk adds -DSTM32H573I_DK
  • hal/stm32h5.c, hal/stm32h5.h - PLL1 settings for the 25 MHz HSE, USART1 and GPIOA/GPIOI definitions, release of USART1 and the LEDs to the non-secure side
  • test-app/app_stm32h5.c, test-app/startup_arm.c - board LEDs and the USART1 interrupt; interrupts enabled on entry when TrustZone is off, with the SysTick reload computed from the running clock instead of a fixed 250 MHz, and the UART interrupt clears an overrun so it cannot fire forever
  • config/examples/stm32h5-dk.config, stm32h5-dk-tz.config, docs/Targets.md, CI build jobs

Touches shared code

  • hal/uart/uart_drv_stm32h5.c - the divisor assumed a 64 MHz clock and only came out near 115200 because the prescaler was set to divide by 4 at a 250 MHz PLL. After the clock is restored to HSI (32 MHz) the application console was unusable. The divisor is now computed from the RCC registers with the prescaler at 1, and the UART is disabled while BRR and PRESC are written, as the reference manual requires
  • hal/stm32h5.h - the secure alias of USART3 pointed at I2C2; uart_init() now enables the USART3 clock; on the DK, GPIOG is clocked before it is released to the non-secure side
  • hal/stm32h5.c - with DEBUG_UART, wait for the last byte before switching the clock back
  • LPUART1 console (USE_UART1=1) never worked: the branch was compiled out, LPUART1 was not clocked (APB3, not APB2), the pins used AF7 instead of AF8, one alternate-function write went to AFH, and the baud divisor lacked the LPUART factor of 256
  • test-app/Makefile - with TZEN=1 the application links a non-secure build of the UART driver instead of the bootloader's secure one

Hardware / test status

STM32H573I-DK with TrustZone off and on: boot, update, rollback of an unconfirmed update, and confirm; with TrustZone off also with the PLL left running, and the application timebase measured at 1 kHz after the clock restore. NUCLEO-H563ZI with stm32h5-tz.config: the same sequence. LPUART1 on the NUCLEO-H563ZI was checked through its registers (clock, pins, baud divisor) but not with an adapter on the D0/D1 pins. The STM32H5 emulator tests pass.

Scope

No dual-bank configuration for the DK, and its external OCTOSPI flash is not used. The test application has no interrupt handler for LPUART1, so its console input works only on USART1/USART3.

Copilot AI balanced review requested due to automatic review settings December 2, 2026 19:37

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 DK CMake configuration omits its board definition, selecting incorrect clocks and UART pins, while the UART driver truncates low-baud divisors and silently transmits at the wrong rate.

2 open issues
What changed in this PR

Adds STM32H573I-DK support to the STM32H5 target and corrects shared UART clock and baud-rate handling.

Changes:

  • Adds DK clock settings, console pins, LEDs, and TrustZone peripheral handoff.
  • Fixes UART initialization and application interrupt/timebase handling.
  • Adds example configurations, documentation, and CI build jobs.
File Description
tools/​config.mk Preserves the board selection in generated configuration.
test-app/​startup_arm.c Routes the DK’s USART1 interrupt.
test-app/​Makefile Selects the non-secure UART driver for TrustZone.
test-app/​app_stm32h5.c Adds DK LEDs and updates interrupts and timing.
hal/​uart/​uart_drv_stm32h5.c Derives baud divisors from clocks and fixes UART setup.
hal/​stm32h5.h Adds board definitions and corrects peripheral mappings.
hal/​stm32h5.c Configures DK clocks and non-secure peripheral access.
docs/​Targets.md Documents DK configuration and update procedures.
config/​examples/​stm32h5-dk.config Adds a non-TrustZone DK configuration.
config/​examples/​stm32h5-dk-tz.config Adds a TrustZone DK configuration.
arch.mk Adds the DK compile-time selection.
.github/​workflows/​test-configs.yml Adds builds for both DK configurations.

Review effort: Balanced

Comment thread arch.mk Resolved
Comment thread hal/uart/uart_drv_stm32h5.c Resolved
@dgarske dgarske self-assigned this Dec 2, 2026

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.

🟢 Approval recommended

No active review issues block the STM32H573I-DK support and shared UART updates.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@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 #1022

Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .github/workflows/test-configs.yml, CMakeLists.txt, arch.mk, config/examples/stm32h5-dk-tz.config, config/examples/stm32h5-dk.config, docs/Targets.md, hal/stm32h5.h, test-app/Makefile, tools/config.mk
Coverage: 4 of 4 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

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.

3 participants