-
So, i need to use FDCAN on STM32G0B1CBTx target, since there is no wrapper i will directly access via the HAL APIs, however there seems to be some issue with scrwrapper, while i can see the HEL FDCAN sources are compiled, it cannot link with the functions from FDCAN, here is the error:
and here is a sketch to reproduce the issue : //target STM32G0B1CBT6
#include "stm32g0xx_hal.h"
#include "stm32g0xx_hal_fdcan.h"
FDCAN_HandleTypeDef hfdcan1;
void setup() {
Serial.begin(115200);
__HAL_RCC_FDCAN_CLK_ENABLE();
hfdcan1.Instance = FDCAN1;
hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
hfdcan1.Init.Mode = FDCAN_MODE_INTERNAL_LOOPBACK; // FDCAN_MODE_NORMAL
hfdcan1.Init.ProtocolException = DISABLE;
hfdcan1.Init.NominalPrescaler = 16;
hfdcan1.Init.NominalSyncJumpWidth = 1;
hfdcan1.Init.NominalTimeSeg1 = 1;
hfdcan1.Init.NominalTimeSeg2 = 1;
hfdcan1.Init.DataPrescaler = 16;
hfdcan1.Init.DataSyncJumpWidth = 1;
hfdcan1.Init.DataTimeSeg1 = 1;
hfdcan1.Init.DataTimeSeg2 = 1;
if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK) {
Serial.println("FDCAN1 init error");
}
}
void loop() {
} I tried to set the HAL includes as extern C but it did not help. How to fix this issue? I suspect there is some issue with srcwrapper since i can see:
And below, i can see an object file for hal_can but none for hal_fdcan
I do not understand, provided that STM32G0B1 does not have any hal_can.c file, it only has hal_fdcan.c https://github.com/stm32duino/Arduino_Core_STM32/tree/main/system/Drivers/STM32G0xx_HAL_Driver/Src |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
so, it seems the problem boils down to what i mentioned, however when trying to make a quick and dirty fix I ended up with another linking issue: So what i did was to add
in
and now i can see the object file for hal_fdcan.c
However i get a new linking issue related to the IRQ handler
|
Beta Was this translation helpful? Give feedback.
-
so, i found a fix : first, need to force #define HAL_FDCAN_MODULE_ENABLED in stm32yyxx_hal.conf, declaring it in the usercode prior to includes doesnt work. Then need to declare these two pointers Into the usercode, to satisfy the external references of hardwaretimer.cpp
Then i can compile without linking error.
Not sure why the issue has been closed promptly and converted to "discussion" it is clearly a bug in the toolchain. |
Beta Was this translation helpful? Give feedback.
-
OK, i see, anyway it works. and indeed i will move the define to |
Beta Was this translation helpful? Give feedback.
No you don't have to change the
stm32yyxx_hal.conf
, you can use thebuild_opt.h
orhal_conf_extra.h
. As the core does not provide (FD)CAN support it is disabled so up to end user to properly enable it.See: https://github.com/stm32duino/Arduino_Core_STM32/wiki/HAL-configuration#customize-hal-or-variant-definition
Right, it is to allow…