Skip to content

drivers: can: various RTR fixes #47903

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

Conversation

henrikbrixandersen
Copy link
Member

@henrikbrixandersen henrikbrixandersen commented Jul 16, 2022

The newly added test cases were verified on the following boards:

  • lpcxpresso55s16
  • nucleo_g474re
  • twr_ke18f
  • mimxrt1024_evk
  • frdm_k64f
  • stm32f3_disco
  • native_posix_64
  • keyestudio_can_bus_ks0411 (shield)

The Bosch M_CAN IP does not support RX filtering of the RTR bit, so the
driver handles this bit in software.

If a recevied frame matches a filter with RTR enabled, the RTR bit of the
frame must match that of the filter in order to be passed to the RX
callback function. If the RTR bits do not match the frame must be dropped.

Improve the readability of the the logic for determining if a frame should
be dropped and add a missing FIFO acknowledge write for dropped frames.

Fixes: zephyrproject-rtos#47204

Signed-off-by: Henrik Brix Andersen <[email protected]>
When installing a RX filter, the driver uses "filter->rtr &
filter->rtr_mask" for setting the filter mask. It should just be using
filter->rtr_mask, otherwise filters for non-RTR frames will match RTR
frames as well.

When transmitting a RTR frame, the hardware automatically switches the
mailbox used for TX to RX in order to receive the reply. This, however,
does not match the Zephyr CAN driver model, where mailboxes are dedicated
to either RX or TX. Attempting to reuse the TX mailbox (which was
automatically switched to an RX mailbox by the hardware) fails on the first
call, after which the mailbox is reset and can be reused for TX. To
overcome this, the driver must abort the RX mailbox operation when the
hardware performs the TX to RX switch.

Fixes: zephyrproject-rtos#47902

Signed-off-by: Henrik Brix Andersen <[email protected]>
Check the frame ID type and RTR bit when comparing loopback CAN frames
against installed RX filters.

Fixes: zephyrproject-rtos#47904

Signed-off-by: Henrik Brix Andersen <[email protected]>
Add test for CAN RX filtering of RTR frames.

Signed-off-by: Henrik Brix Andersen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: CAN backport v2.7-branch Request backport to the v2.7-branch bug The issue is a bug, or the PR is fixing a bug platform: NXP NXP
Projects
None yet
5 participants