fdcanV2 wrong assertion in the filtering code Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
User avatar
alex31
Posts: 405
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 46 times
Been thanked: 77 times
Contact:

fdcanV2 wrong assertion in the filtering code  Topic is solved

Postby alex31 » Wed Nov 27, 2024 4:22 pm

Hello,

First, I want to thanks Edoardo for the hdcanv1/v2 refactor, and filtering integration.

I will in the future submit some patches driven by real usager in flying machine.

For now just a simple bug, fdcanv2 will wrongly assert when using filtering on CAND1 :

Code: Select all

void can_lld_set_filters(CANDriver *canp, uint8_t num, const CANFilter *cfp) {

  uint8_t i;
  uint8_t num_std_filter = 0;
  uint8_t num_ext_filter = 0;

  uint32_t can_offset_instance = 0;
  #if STM32_CAN_USE_FDCAN1
  if (&CAND1 == canp) {
    can_offset_instance = CAN1_OFFSET_INSTANCE;
  }
  #endif
  #if STM32_CAN_USE_FDCAN2
  if (&CAND2 == canp) {
    can_offset_instance = CAN2_OFFSET_INSTANCE;
  }
  #endif
  #if STM32_CAN_USE_FDCAN3
  if (&CAND3 == canp) {
    can_offset_instance = CAN3_OFFSET_INSTANCE;
  }
  #endif
  osalDbgAssert(can_offset_instance != 0, "CAN offset instance failed");
 


when using CAND1, CAN1_OFFSET_INSTANCE is 0, so the assert will always fire.

Alexandre

User avatar
Edoardo1982
Posts: 18
Joined: Thu Aug 03, 2017 8:39 am
Has thanked: 7 times
Been thanked: 14 times

Re: fdcanV2 wrong assertion in the filtering code

Postby Edoardo1982 » Wed Dec 04, 2024 7:46 pm

alex31 wrote:Hello,

First, I want to thanks Edoardo for the hdcanv1/v2 refactor, and filtering integration.

I will in the future submit some patches driven by real usager in flying machine.

For now just a simple bug, fdcanv2 will wrongly assert when using filtering on CAND1 :

Code: Select all

void can_lld_set_filters(CANDriver *canp, uint8_t num, const CANFilter *cfp) {

  uint8_t i;
  uint8_t num_std_filter = 0;
  uint8_t num_ext_filter = 0;

  uint32_t can_offset_instance = 0;
  #if STM32_CAN_USE_FDCAN1
  if (&CAND1 == canp) {
    can_offset_instance = CAN1_OFFSET_INSTANCE;
  }
  #endif
  #if STM32_CAN_USE_FDCAN2
  if (&CAND2 == canp) {
    can_offset_instance = CAN2_OFFSET_INSTANCE;
  }
  #endif
  #if STM32_CAN_USE_FDCAN3
  if (&CAND3 == canp) {
    can_offset_instance = CAN3_OFFSET_INSTANCE;
  }
  #endif
  osalDbgAssert(can_offset_instance != 0, "CAN offset instance failed");
 


when using CAND1, CAN1_OFFSET_INSTANCE is 0, so the assert will always fire.

Alexandre

Hi Alex,

I believe the code you posted is incorrect, and I’m not sure where it was taken from because it doesn’t seem like something I wrote, there’s no trace of it in the trunk.

In any case, I encourage you to check the latest changes I made to the FDCANv1 and v2 drivers into the trunk.

Edoardo

User avatar
alex31
Posts: 405
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 46 times
Been thanked: 77 times
Contact:

Re: fdcanV2 wrong assertion in the filtering code

Postby alex31 » Wed Dec 04, 2024 9:49 pm

My bad, I checked in trunk and there is no trace of this code,

Many apologizes for this.

Alexandre


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 17 guests