arch/arm/src/stm32h7: treat classic data_bitrate 0 as arbitration - #397
Draft
AlexKlimaj wants to merge 3 commits into
Draft
arch/arm/src/stm32h7: treat classic data_bitrate 0 as arbitration#397AlexKlimaj wants to merge 3 commits into
AlexKlimaj wants to merge 3 commits into
Conversation
Classic CAN SIOCSCANBITRATE callers pass data_bitrate 0. fdcan_bittiming() then fails after FDCAN IE has been cleared, so RX interrupts never run and DNA/esc frames sit in the FIFO unread. Map a zero data-phase rate onto the arbitration rate (BRSE stays off), reject a zero target bitrate before dividing, and do not ifup after initialize fails. Assisted-by: Grok:grok-4.6 Signed-off-by: alexklimaj <alex@arkelectron.com>
There was a problem hiding this comment.
Pull request overview
Handles classic CAN bitrate ioctls correctly in the STM32H7 FDCAN socket driver.
Changes:
- Rejects zero target bitrates safely.
- Maps a zero data bitrate to the arbitration bitrate.
- Propagates initialization failures from
fdcan_ifup().
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| */ | ||
| if (priv->data_timing.bitrate == 0) | ||
| { | ||
| priv->data_timing.bitrate = priv->arbi_timing.bitrate; |
dakejahl
marked this pull request as draft
August 26, 2026 23:38
Without transceiver delay compensation the H7 samples its own delayed bit on the data phase and goes bus-off. Same TDCO formula as the PX4 stm32h7 UAVCAN driver. Required to talk CAN FD at 2/4 Mbps to the ARK G431 ESC. Assisted-by: Grok:grok-4.6 Signed-off-by: alexklimaj <alex@arkelectron.com>
Hold the net lock across can_datahandler(), drop the FDCAN critical section before can_input(), and clear recycled connection readahead pointers. STM32H7 FDCAN was hardfaulting (IMPRECISERR) in can_datahandler / can_readahead_signal when UAVCAN RX ran on HPWORK. Assisted-by: Grok:grok-4.6 Signed-off-by: alexklimaj <alex@arkelectron.com>
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.
Problem
Classic CAN
SIOCSCANBITRATEcallers (PX4 UAVCAN/SLCAN) passdata_bitrate = 0.fdcan_bittiming()rejects that afterfdcan_initialize()has already cleared FDCANIE, so RX interrupts never run. On an ARK FPV + DroneCAN ESC this filled RX FIFO 0 (RF0Lset) while UAVCAN showedRX frames: 0and dynamic node allocation never completed.Fix
BRSEstays off andIE.RF0NEis programmed.ifupafterfdcan_initialize()fails.Verified on ARK FPV: after this plus the matching PX4 SocketCAN caller change, CAN1 RX runs, DNA allocates node 123, and
esc.Statusis received.