This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit ffcc9192204f15c470127bf10447edee82e4e4a9 Author: raiden00pl <[email protected]> AuthorDate: Wed Nov 25 21:54:07 2026 +0100 arch/arm/stm32: Fix the RX reports of the FDCAN v2 SocketCAN driver. Received CAN FD frames had no CANFD_BRS and CANFD_ESI flags. Without CONFIG_NET_CAN_ERRORS nothing cleared IR.RF0L, so every receive after the first lost message counted an RX error, and the PEA/PED interrupts were enabled again only on TX complete, so a node that only receives reported a protocol error once. Set the flags, clear RF0L and enable the interrupts again when a frame is received. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: raiden00pl <[email protected]> --- .../arm/src/common/stm32/stm32_fdcan_mcan_v2_sock.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/arm/src/common/stm32/stm32_fdcan_mcan_v2_sock.c b/arch/arm/src/common/stm32/stm32_fdcan_mcan_v2_sock.c index 4a9f2fc60bb..f8d063c46e6 100644 --- a/arch/arm/src/common/stm32/stm32_fdcan_mcan_v2_sock.c +++ b/arch/arm/src/common/stm32/stm32_fdcan_mcan_v2_sock.c @@ -1053,6 +1053,16 @@ static netpkt_t *fdcan_rxframe(struct fdcan_driver_s *priv, frame->len = g_can_dlc_to_len[rf->header.dlc]; + if (rf->header.brs) + { + frame->flags |= CANFD_BRS; + } + + if (rf->header.id.esi) + { + frame->flags |= CANFD_ESI; + } + uint32_t *frame_data_word = (uint32_t *)&frame->data[0]; for (int i = 0; i < (frame->len + 4 - 1) / 4; i++) @@ -1144,6 +1154,11 @@ static netpkt_t *fdcan_receive(struct netdev_lowerhalf_s *dev) if ((regval & FDCAN_RXF0S_RF0L) != 0) { NETDEV_RXERRORS(&dev->netdev); +#ifndef CONFIG_NET_CAN_ERRORS + /* Without error frames nothing else clears the flag */ + + putreg32(FDCAN_IR_RF0L, priv->base + STM32_FDCAN_IR_OFFSET); +#endif } while ((regval & FDCAN_RXF0S_F0FL) > 0) @@ -1159,6 +1174,12 @@ static netpkt_t *fdcan_receive(struct netdev_lowerhalf_s *dev) if (pkt != NULL) { +#ifdef CONFIG_NET_CAN_ERRORS + /* A frame was received: report protocol errors again */ + + modifyreg32(priv->base + STM32_FDCAN_IE_OFFSET, 0, + FDCAN_IE_PEAE | FDCAN_IE_PEDE); +#endif leave_critical_section(flags); return pkt; }
