Skip to content

Update STM32F7xx HAL to v1.3.3#11514

Open
daijoubu wants to merge 9 commits intoiNavFlight:maintenance-10.xfrom
daijoubu:feature/stm32f7-hal-v1.3.3-update
Open

Update STM32F7xx HAL to v1.3.3#11514
daijoubu wants to merge 9 commits intoiNavFlight:maintenance-10.xfrom
daijoubu:feature/stm32f7-hal-v1.3.3-update

Conversation

@daijoubu
Copy link
Copy Markdown
Contributor

@daijoubu daijoubu commented Apr 26, 2026

Summary

Updates the STM32F7xx HAL library from v1.2.2 to v1.3.3 for STM32F7-based flight controllers (e.g. MATEKF765, MATEKF765SE).

Changes

  • HAL update: Migrates CAN driver to use the updated HAL v1.3.3 API (HAL_CAN_AddTxMessage non-blocking interface, new header object structure)
  • Build fixes: Suppresses and eliminates macro redefinition warnings introduced by HAL v1.3.3 under WARNINGS_AS_ERRORS
  • BTR register fix: Corrects CAN bit timing register (BTR) bit positions which shifted in the new HAL
  • DroneCAN TX fix: Drains the TX queue after RX processing to ensure multi-frame transfers (e.g. GetNodeInfo responses) complete correctly
  • Docs: Regenerates docs/Settings.md to reflect CAN-related setting additions (CAN current/vbat sources, DRONECAN GPS protocol, can_speed allowed values)
  • Git fix: Converts HAL source directories from orphaned submodule gitlinks (mode 160000) to plain tracked files — resolves CI fatal: No url found for submodule path error

Testing

Tested on MATEKF765SE hardware:

  • DroneCAN battery monitor (node 73, BatteryInfo DTID 1092) detected and reporting correct voltage/current
  • GetNodeInfo multi-frame responses complete correctly
  • SD card baseline tests 1–6 all pass (write speed 136.5 KB/s)
  • Build verified: zero compilation errors, zero warnings on MATEKF765SE, FLYWOOF745, and ANYFCF7 targets
  • CAN BUS_OFF recovery: AutoBusOff=ENABLE confirmed in HAL init; hardware auto-recovers without firmware intervention
  • CAN ERROR_PASSIVE recovery: state machine present in dronecanUpdate(); transitions handled correctly

Test plan

  • Build MATEKF765SE, FLYWOOF745, ANYFCF7 — confirm zero errors and zero warnings
  • Verify DroneCAN device communication (battery monitor or other node)
  • Verify SD card / blackbox logging functional

daijoubu and others added 9 commits April 15, 2026 17:55
Drop-in replacement of STM32F7xx HAL driver and CMSIS Device headers from
STM32CubeF7. Updates from v1.2.2 (2017) to v1.3.3 (2025), incorporating:

- 8+ years of bug fixes and errata workarounds
- SD card reliability improvements
- I2C transmission stalled workaround
- UART DMA race condition fixes
- USB connection/disconnect handling
- ETH receive process rework

API verified compatible - no code changes required. Existing HAL config
file at src/main/target/stm32f7xx_hal_conf.h remains unchanged.

This update is applied on top of DroneCAN integration (PR iNavFlight#11313).

Related: iNavFlight#11299

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Change __FPU_PRESENT cmake definitions from =1 to =1U in cortex-m7.cmake
and cortex-m4f.cmake. The device headers define it as 1U; GCC treats 1
and 1U as different token strings and warns on redefinition. The cmake
flag must be kept (CMSIS DSP math library requires it).

Fix ART_ACCLERATOR_ENABLE (misspelled) → ART_ACCELERATOR_ENABLE in
stm32f7xx_hal_conf.h to avoid redefinition with the legacy alias added
in HAL v1.3.3 (stm32_hal_legacy.h:4402).

Both warnings repeated across all 528 STM32F7 compilation units and
are now fully resolved. MATEKF765SE builds cleanly.
Two vendor files in STM32F7xx HAL v1.3.3 produce -Wunused-parameter
warnings that fail CI builds with -DWARNINGS_AS_ERRORS=ON:

- stm32f7xx_ll_rcc.h: inline function with unused LPTIMx parameter
  (fires in every translation unit that includes the header)
- stm32f7xx_ll_rcc.c: LL_RCC_GetSPDIFRXClockFreq unused parameter

Fix 1: Add SYSTEM_INCLUDE_DIRECTORIES support to add_stm32_executable
and target_stm32 in stm32.cmake, and route STM32F7_INCLUDE_DIRS through
it in stm32f7.cmake. This causes the HAL/CMSIS include dirs to be added
with -isystem, suppressing warnings from vendor headers.

Fix 2: Set COMPILE_OPTIONS "-Wno-unused-parameter" on stm32f7xx_ll_rcc.c
via set_source_files_properties inside target_stm32f7xx(), scoped to the
caller's directory where add_executable() runs.
HAL v1.3.3 changed HAL_CAN_Init() to OR the SyncJumpWidth, TimeSeg1,
and TimeSeg2 fields directly into the BTR register, expecting them to
be pre-shifted to their correct bit positions (TS1@16, TS2@20, SJW@24).

The driver was passing raw 0-based counts (e.g. 6 for 7TQ), which the
old HAL would shift internally. With HAL v1.3.3, these unshifted values
landed in the BRP prescaler field, producing completely wrong bit timing
that caused immediate bus errors and prevented all CAN transmission.

Fix: shift the computed timing values to their BTR register positions
using the CAN_BTR_TS1_Pos, CAN_BTR_TS2_Pos, and CAN_BTR_SJW_Pos
constants before assigning to hcan1.Init.
…ame transfers

processCanardTxQueue() was only called once at the top of the state before
RX processing. Response frames queued by RX handlers (e.g. GetNodeInfo)
were not drained until the next 2ms task cycle. With NodeStatus occupying
one of three STM32 CAN TX mailboxes, only two response frames could be sent
before the mailboxes filled, preventing multi-frame EOT from being transmitted.

Add processCanardTxQueue() after the RX loop and after process1HzTasks()
so any frames queued in the same cycle are sent immediately.
Updates CAN current/vbat sources, can_speed allowed values, DRONECAN
GPS protocol, and OSD_REFRESH debug mode.
stm32cubef7_extract/cmsis_device_f7 and stm32cubef7_extract/stm32f7xx_hal_driver
were tracked as gitlink entries (mode 160000) with an empty .gitmodules, causing
CI to fail with "No url found for submodule path" during post-job cleanup.

Removed embedded .git directories and re-added the HAL sources as regular
tracked files (mode 100644).
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