Skip to content

arch/arm/src/stm32h7/stm32_fdcan_sock: fix clock, ILS register and ID#18300

Open
vrmay23 wants to merge 1 commit intoapache:masterfrom
vrmay23:up_st7796
Open

arch/arm/src/stm32h7/stm32_fdcan_sock: fix clock, ILS register and ID#18300
vrmay23 wants to merge 1 commit intoapache:masterfrom
vrmay23:up_st7796

Conversation

@vrmay23
Copy link
Contributor

@vrmay23 vrmay23 commented Feb 1, 2026

fix clock, ILS register and ID (extended).

Fix three issues in the STM32H7 FDCAN SocketCAN driver:

Clock configuration: Allow board.h to override STM32_FDCANCLK. Previously the driver hardcoded STM32_HSE_FREQUENCY, ignoring any board-specific clock configuration.

ILS register bug: Fix putreg32 call that was writing FDCAN_ILS_TCL constant instead of the computed regval, causing interrupt routing issues.

Extended ID filter size: Increase n_extid from 64 to 128. Despite the reference manual (RM0433) suggesting 64 max, testing shows that 128 is required for reliable extended ID frame reception. With 64, some extended ID frames were silently dropped.

Note: Please adhere to Contributing Guidelines.

Summary

Fix three critical bugs in the STM32H7 FDCAN SocketCAN driver:

  1. Clock configuration: Allow board.h to override STM32_FDCANCLK. Previously the driver hardcoded STM32_HSE_FREQUENCY, ignoring board-specific clock configurations. This causes incorrect bit timing on boards that use PLL-derived clocks instead of HSE.

  2. ILS register bug: Fix putreg32 call writing FDCAN_ILS_TCL constant instead of the computed regval variable. This is a read-modify-write bug that zeroes other ILS register bits and breaks interrupt routing.

  3. Extended ID filter size: Increase n_extid from 64 to 128. Testing shows the STM32H7 hardware supports 128 filters despite ambiguous documentation. With 64 filters, extended ID frames are silently dropped under load.

Impact

Improves driver reliability and portability. Users with non-HSE FDCAN clocks or heavy extended ID usage will see immediate improvements. Backward compatible with existing configurations.

Testing

Hardware: STM32 Nucleo-H753ZI + external CAN transceiver TJA1051T and TJA1050T.
Peer: Linux PC with PEAK USB-FD adapter
Config: nucleo-h753zi:evaluation
Tools: candump, cansend

image image

@github-actions github-actions bot added Arch: arm Issues related to ARM (32-bit) architecture Size: S The size of the change in this PR is small labels Feb 1, 2026
Copy link
Contributor

@linguini1 linguini1 left a comment

Choose a reason for hiding this comment

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

Please fill out the PR template

@vrmay23
Copy link
Contributor Author

vrmay23 commented Feb 2, 2026

Please fill out the PR template

I think it is correct now. Could you please check it again? Thank you!

@vrmay23
Copy link
Contributor Author

vrmay23 commented Feb 2, 2026

@xiaoxiang781216 I have finished the reviews. Thanks for feedback!

Fix three issues in the STM32H7 FDCAN SocketCAN driver:

1. Clock configuration: Allow board.h to override STM32_FDCANCLK.
   Previously the driver hardcoded STM32_HSE_FREQUENCY, ignoring
   any board-specific clock configuration.

2. ILS register bug: Fix putreg32 call that was writing FDCAN_ILS_TCL
   constant instead of the computed regval, causing interrupt routing
   issues.

3. Extended ID filter size: Increase n_extid from 64 to 128. Despite
   the reference manual (RM0433) suggesting 64 max, testing shows
   that 128 is required for reliable extended ID frame reception.
   With 64, some extended ID frames were silently dropped.

Signed-off-by: Vinicius May <vmay.sweden@gmail.com>
@vrmay23
Copy link
Contributor Author

vrmay23 commented Feb 4, 2026

Starting up:

image

candump (500kpbs 1 msg per 10 ms):

image

cansend (I have created an 'canflood app' to test NuttX SocketCAN transmission power, later on I'll also submit this PR):

image image

I'm wonder if it is needed a long stress test. If needed just tell me how to provide it.
Thanks!

@vrmay23 vrmay23 requested a review from linguini1 February 4, 2026 20:51
Copy link
Contributor

@linguini1 linguini1 left a comment

Choose a reason for hiding this comment

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

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants