Skip to content

Linking issue with FDCAN on STM32G0B1CBTx #2473

@0x0fe

Description

@0x0fe

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:

C:/Users/xxxxxxx/AppData/Local/Arduino15/packages/STMicroelectronics/tools/xpack-arm-none-eabi-gcc/13.2.1-1.1/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\xxxxxxx\AppData\Local\Temp\arduino\sketches\7D345039B4813D6501D07371AD0DC887\sketch\BareMinimum.ino.cpp.o: in function `setup':
BareMinimum.ino.cpp:(.text.setup+0x4a): undefined reference to `HAL_FDCAN_Init'
collect2.exe: error: ld returned 1 exit status

Using library SrcWrapper at version 1.0.1 in folder: C:\Users\xxxxxxx\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.8.1\libraries\SrcWrapper 
exit status 1
Compilation error: exit status 1

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:

Using cached library dependencies for file: C:\Users\xxxxxxx\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.8.1\libraries\SrcWrapper\src\HAL\stm32yyxx_hal_can.c
Using cached library dependencies for file: 
C:\Users\xxxxxxx\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.8.1\libraries\SrcWrapper\src\HAL\stm32yyxx_hal_fdcan.c

And below, i can see an object file for hal_can but none for hal_fdcan

Using previously compiled file: C:\Users\xxxxxxx\AppData\Local\Temp\arduino\sketches\FA0B4FB95CC62D998AFD8E0B0B49444E\libraries\SrcWrapper\HAL\stm32yyxx_hal_can.c.o

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions