New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: can: mcan: Add CAN statistics #62758
Conversation
cf64b20
to
30b22fc
Compare
30b22fc
to
8d7d951
Compare
No, that is expected. The Bosch M_CAN will attempt retransmission when it sees a missing ACK (and trigger the AckError interrupt). The retransmission also sees a missing ACK and so it continues. |
I wonder how you verified this? Did you use an out-of-tree driver front-end? You neglected to update all the in-tree driver front-ends from using |
Yes, although I thought the controller would go to bus-off after enough failures. I tested this with a zero byte CAN payload at 1Mbps, it generated an ISR every 54us until the controller state went to error-passive, and then every 62us indefinitely. Do you think this could cause loading/performance issues on some CPUs (especially with external controllers like tcan4x5x over SPI)? On second thought, this driver is only really an interface to the hardware, and that's just what the hardware does 🤷 |
8d7d951
to
8856dbd
Compare
8856dbd
to
e2e938d
Compare
Do you have |
I did try toggling that, same result. Is auto-recovery implemented for MCAN, it looked like the config only optionally compiled the recover function? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! One thing missing is a call to CAN_STATS_RESET()
in can_mcan_start()
. See
zephyr/drivers/can/can_mcux_flexcan.c
Line 314 in 8e7c7c6
CAN_STATS_RESET(dev); |
That implementation does look a bit fishy. We will need to look into that. From a quick test here, it looks like the controller is going into bus-off, but auto-recovers. I think this explains the jump from 54 usec to 62 usec. |
Ahh, right. Good find. I still think it is okay behaviour for now. If you can add the call to reset the statistics on start, I think it's ready to go in. |
e2e938d
to
d0bec5b
Compare
Add CAN stats for MCAN drivers. Update MCAN drivers to use CAN_DEVICE_DT_INST_DEFINE which initialises and registers CAN stats if enabled. Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
d0bec5b
to
68042c4
Compare
I had a go at adding MCAN statistics, although I ran into a couple of issues:
The PSR Protocol Exception Event (PXE) bit never seems to get set- I misunderstood what this is used forI am testing with this MCAN version:
Any thoughts/ideas on these?
@henrikbrixandersen