There is a wrong assert in os/hal/platform/STM32/can_lld.c, function can_lld_stop:
505 #if STM32_CAN_USE_CAN2
506 chDbgAssert(CAND2.state == CAN_STOP,
507 "can_lld_stop(), #1", "CAN2 must be stopped");
508 #endif
Not only driver state assertions belong in the common high level driver, it is code for CAN1 but it is checking CAN2 state.
Trivial fix: just remove the assertion.
Hi,
CAN2 cannot operate independtly from CAN1 because the filters are shared, this is why that assertion exists, this is also an extra check in can_lld.h. Enabling CAN2 requires CAN1 enabled too.
It is an STM32-specific check too so it does not beling to the high level.
Giovanni