Skip to content

Update STM32H7xx HAL to v1.11.6 and CMSIS Device to v1.10.7#11578

Open
daijoubu wants to merge 4 commits into
iNavFlight:maintenance-10.xfrom
daijoubu:fix/stm32h7-hal-v1.13.0-update
Open

Update STM32H7xx HAL to v1.11.6 and CMSIS Device to v1.10.7#11578
daijoubu wants to merge 4 commits into
iNavFlight:maintenance-10.xfrom
daijoubu:fix/stm32h7-hal-v1.13.0-update

Conversation

@daijoubu
Copy link
Copy Markdown
Contributor

@daijoubu daijoubu commented May 22, 2026

Summary

Update the STM32H7xx HAL driver from V1.11.4 to V1.11.6 and CMSIS
Device from V1.10.5 to V1.10.7, sourced from STM32CubeH7 v1.13.0.

Key Bug Fixes Included

  • DMA IRQHandler CT bit inversion (HAL V1.11.5) — Wrong callbacks
    triggered, affecting SPI, UART, and SDMMC on H7

  • SPI TX buffer overflow in ISR (HAL V1.11.6) — Silent corruption
    on gyro, baro, and OSD

  • FDCAN overflow prevention (HAL V1.11.5) — DroneCAN stability

  • HCLK frequency calculation fix (HAL V1.11.6) — LL_RCC_GetSystemClocksFreq()
    and HAL_RCC_GetHCLKFreq() were missing the D1 core prescaler (D1CPRE)
    in their HCLK computation. On H7, the clock path is:

    SYSCLK -> AHB prescaler -> HCLK -> D1CPRE -> CPU
    

    The old code stopped at the AHB prescaler, returning an HCLK value that
    was 2x-8x too high when D1CPRE divided. Every HAL_RCC_GetPCLK1/2Freq()
    call internally uses HAL_RCC_GetHCLKFreq(), so all peripheral clocks
    derived from HCLK were affected.

    Impact on INAV (H7 targets):

    Caller What it affects
    drivers/timer_stm32h7xx.c Timer/PWM frequencies via HAL_RCC_GetPCLK1/2Freq()
    drivers/dronecan/libcanard/canard_stm32h7xx_driver.c FDCAN bit timing via HAL_RCC_GetPCLK1Freq()
    drivers/bus_i2c_hal.c I2C baud rate via HAL_RCC_GetPCLK1Freq()
    fc/cli.c CLI clock display

    (Most H7 targets set D1CPRE=0, so the bug only manifests when
    a non-zero D1CPRE divider is configured.)

  • GPIO_MODER typo fixes (CMSIS V1.10.7) — MODER10_Po/_Ms
    corrected to MODER10_Pos/_Msk

  • HAL_RCC_GetHCLKFreq() single-core fix — Returns correct frequency
    on single-core H7 parts (H743, H750, H753) where the D1CPRE register
    lives at RCC->D1CFGR vs RCC->CDCFGR1 on dual-core parts

Changes

  • lib/main/STM32H7/Drivers/STM32H7xx_HAL_Driver/ — HAL sources
  • lib/main/STM32H7/Drivers/CMSIS/ — CMSIS device files
  • cmake/stm32.cmake — Add SYSTEM_INCLUDE_DIRECTORIES support
  • cmake/stm32h7.cmake — Route H7 vendor headers through -isystem
  • re applied ifndef __FPU_PRESENT guard to stm32h743xx.h header as H7 hal uses 1U but F7 hal uses 1.

Testing

  • All 234 CI targets built cleanly (0 errors, 0 warnings)
  • 42+ H7 boards verified including MATEKH743, KAKUTEH7, MAMBAH743
  • Hardware validation: 4,661 arm/disarm cycles on MATEKH743, zero
    CAN errors (TEC=0, REC=0)

Fixes #11563

daijoubu added 2 commits May 16, 2026 19:27
Update the STM32H7xx HAL driver from V1.11.4 to V1.11.6 and CMSIS
Device from V1.10.5 to V1.10.7, sourced from STM32CubeH7 v1.13.0.

Key fixes included in this update:
- DMA IRQHandler CT bit inversion fix (HAL V1.11.5)
- HCLK frequency calculation fix (HAL V1.11.6)
- GPIO_MODER MODER10_Pos/Msk typo fixes (CMSIS V1.10.7)

INAV-specific patches reapplied after swap:
- Remove dead #include "common/log.h" from stm32h7xx_hal_fdcan.c
  (LOG_DEBUG calls were removed in a prior commit)

Build verified on MATEKH743, SPEEDYBEEF405WING, MATEKF765SE, and SITL.
Pass __FPU_PRESENT=1U (matching the CMSIS header) instead of =1,
and route vendor include directories through SYSTEM_INCLUDE_DIRECTORIES
(-isystem) so upstream vendor headers can't trigger -Wmacro-redefined.

Also remove the INAV-specific #ifndef __FPU_PRESENT guard from
stm32h743xx.h — it is not present in the upstream ST CMSIS and is
no longer needed with the cmake fix in place. This avoids confusion
on future HAL/CMSIS updates.
@qodo-code-review
Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

daijoubu added 2 commits May 21, 2026 17:56
cortex-m4f.cmake is shared by F4 and AT32 targets only (not H7).
The F4 CMSIS header defines __FPU_PRESENT as 1 (without U suffix),
so passing =1U from cmake triggers -Wmacro-redefined which is fatal
with -Werror. Revert to =1 to match the header value.
cortex-m7.cmake: back to __FPU_PRESENT=1 (matches F7 headers, avoids
-Wmacro-redefined on F7 targets where headers define '1' not '1U')

stm32h743xx.h: restore #ifndef guard so the header's own 1U define
is skipped when cmake has already set __FPU_PRESENT=1, avoiding
any token mismatch between cmake '1' and header '1U'
@github-actions
Copy link
Copy Markdown

Test firmware build ready — commit 80cac21

Download firmware for PR #11578

234 targets built. Find your board's .hex file by name on that page (e.g. MATEKF405SE.hex). Files are individually downloadable — no GitHub login required.

Development build for testing only. Use Full Chip Erase when flashing.

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.

1 participant