nuttx/arch
Jacob Dahl 58181135ab arch/arm/src/imxrt: Fix FlexCAN TX timeout aborting live mailboxes.
imxrt_txtimeout_work() had four defects that together let one expired frame
take the interface down permanently.

It aborted mailbox RXMBCOUNT + mbi while the deadline it consulted belongs to
RXMBCOUNT + 1 + mbi, so every abort landed one mailbox low and mbi == 0 wrote
CAN_TXMB_ABORT into the buffer reserved for the ERR005829 workaround, while
the highest TX mailbox was never aborted at all.

Its expiry test read `now.tv_sec > d.tv_sec || now.tv_usec > d.tv_usec`, which
declares any deadline that crosses a second boundary expired: in that case the
deadline's microsecond field is always the smaller of the two. The `now` it
compared against was a struct timespec cast to a struct timeval, so writing
tv_usec wrote over tv_nsec and tv_sec was whatever the cast happened to line
up with.

imxrt_txdone() cancelled the watchdog but left txmb[].deadline set, so a
retired mailbox looked expired forever and the next watchdog expiry on any
other mailbox aborted whatever frame had since been loaded there.

The walk ran to TXMBCOUNT, which counts the reserved mailbox as well, so its
last iteration addressed mailbox TOTALMBCOUNT - one past the ring, and
mb_address[] one past its end. Only txmb[] never being written that far kept
it in bounds. TXMBRINGSIZE now names the ring size that the rest of the driver
already assumes.

Aborting a frame that is already on the wire raises a bit error, so the
transmit error counter climbs and the node goes error passive. Since
imxrt_txmb_next() only hands out a mailbox above every pending one, a mailbox
left in DATAORREMOTE also pins the allocator at TOTALMBCOUNT and transmit
never recovers.

Measured on an ARK FMU-v6XRT with a DroneCAN GNSS node on the bus, offering
736 frames/s (9% of a 1 Mbit/s bus) from the PX4 uavcan driver: before, the
interface transmitted 0 frames/s with ECR[TXERRCNT] pinned at 128 and
ESR1[FLTCONF] error passive, and stayed dead across a reboot. After, 734
frames/s, 0.1% loss, TXERRCNT 0, error active.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-08-27 01:04:57 +08:00
..
arm arch/arm/src/imxrt: Fix FlexCAN TX timeout aborting live mailboxes. 2026-08-27 01:04:57 +08:00
arm64 nuttx/atomic: replace atomic_fetch_xxx with atomic_xxx just like zephyr 2026-08-24 13:20:45 +08:00
avr nuttx/atomic: select LIBC_ATOMIC_IRQ for archs without atomic support 2026-08-24 13:20:45 +08:00
ceva !sched/arch/libc: Give fork() and vfork() their real, separate semantics. 2026-08-10 08:57:30 -03:00
dummy
hc tools: fix stale archive members surviving a Kconfig-driven CSRCS change 2026-07-28 21:26:03 -03:00
mips mips/Makefile: Add nuttx build with CONFIG_ALLSYMS enabled. 2026-08-11 09:53:38 -03:00
misoc tools: fix stale archive members surviving a Kconfig-driven CSRCS change 2026-07-28 21:26:03 -03:00
or1k tools: fix stale archive members surviving a Kconfig-driven CSRCS change 2026-07-28 21:26:03 -03:00
renesas nuttx/libc: refine the atomic related Kconfig 2026-08-24 13:20:45 +08:00
risc-v arch/risc-v: initialize qemu-rv mmu pagetable data to zero 2026-08-27 00:42:52 +08:00
sim nuttx/atomic: replace atomic_fetch_xxx with atomic_xxx just like zephyr 2026-08-24 13:20:45 +08:00
sparc nuttx/atomic: select LIBC_ATOMIC_IRQ for archs without atomic support 2026-08-24 13:20:45 +08:00
tricore arch/tricore: drop iLLD dependency in hwdebug 2026-08-20 01:25:52 +08:00
x86 arch/x86: Provide vfork(). 2026-08-15 09:00:20 -03:00
x86_64 arch/intel64: fix nxstyle issues 2026-08-26 12:17:21 +02:00
xtensa {arm,xtensa}/otg: indent switch bodies per the coding standard. 2026-08-25 16:07:35 +08:00
z16 tools: fix stale archive members surviving a Kconfig-driven CSRCS change 2026-07-28 21:26:03 -03:00
z80 style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
CMakeLists.txt cmake: Use NUTTX(_DIR/_BIN_DIR) instead CMAKE(_SRC_DIR/_BIN_DIR) 2026-08-09 11:13:08 -03:00
Kconfig arch/tricore: use tricore arch-atomic-instruction version 2026-08-25 10:07:25 +08:00