2021-06-01 07:32 AM
Hi all,
I'm developping an application under system workbench for STM32. The compilation works fine, but when it comes to the Linker I get the following output :
16:08:46 **** Incremental Build of configuration Release for project Firmware ****
make all
Building target: Firmware.elf
Invoking: MCU GCC Linker
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -specs=nosys.specs -specs=nano.specs -T"../STM32F412ZETx_FLASH.ld" -Wl,-Map=output.map -Wl,--gc-sections -o "Firmware.elf" @"objects.list" -lm
Src/main.o: In function `main':
D:\dev\AEL_FW\Firmware\Release/../Src/main.c:119: undefined reference to `MX_USB_DEVICE_Init'
Src/stm32f4xx_it.o: In function `OTG_FS_IRQHandler':
D:\dev\AEL_FW\Firmware\Release/../Src/stm32f4xx_it.c:282: undefined reference to `hpcd_USB_OTG_FS'
collect2.exe: error: ld returned 1 exit status
make: *** [Firmware.elf] Error 1
makefile:43: recipe for target 'Firmware.elf' failed
16:08:47 Build Finished (took 981ms)
I've tried to trace back the error :
main.c :
#include "usb_device.h"
...
int main(void)
{
...
MX_USB_DEVICE_Init();
...
}
in usb_device.h :
void MX_USB_DEVICE_Init(void);
in usb_device.c
void MX_USB_DEVICE_Init(void)
{
/* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
/* USER CODE END USB_DEVICE_Init_PreTreatment */
/* Init Device Library, add supported class and start the library. */
if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK)
{
Error_Handler();
}
if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK)
{
Error_Handler();
}
if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK)
{
Error_Handler();
}
if (USBD_Start(&hUsbDeviceFS) != USBD_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */
/* USER CODE END USB_DEVICE_Init_PostTreatment */
}
It also seems that FS_Desc cannot be resolved eventhough usbd_desc.h and usbd_desc.c are included and FS_Desc is declared and defined :
USBD_DescriptorsTypeDef FS_Desc =
{
USBD_FS_DeviceDescriptor
, USBD_FS_LangIDStrDescriptor
, USBD_FS_ManufacturerStrDescriptor
, USBD_FS_ProductStrDescriptor
, USBD_FS_SerialStrDescriptor
, USBD_FS_ConfigStrDescriptor
, USBD_FS_InterfaceStrDescriptor
#if (USBD_LPM_ENABLED == 1)
, USBD_FS_USR_BOSDescriptor
#endif /* (USBD_LPM_ENABLED == 1) */
};
I've attached the whole project if you want to take a look at it.
Solved! Go to Solution.
2021-06-01 09:17 AM
You'll need to mark the directory containing "usb_device.c" and other USB source files as one that need compiled.
STM32CubeIDE is superior to the old system workbench for stm32. Consider switching if you can.
2021-06-01 09:17 AM
You'll need to mark the directory containing "usb_device.c" and other USB source files as one that need compiled.
STM32CubeIDE is superior to the old system workbench for stm32. Consider switching if you can.
2021-06-02 12:08 AM
Thanks, it worked indeed. I had thought of including all the Inc path, and didn't think about doing it for the sources too, shame on me !
About switching to CubeIDE, I actually tried but using "File >Import... > Import ac6 System Workbench for STM32 Project" just doesn't do anything (the project explorer stays empty)
Using "Files > Open project from file system" does the same.
Which is weird because the project is actually detected :
The only thing I managed to do was to go "File > Import > Existing project into workspace" which actually imported the project, but then the build configurations are lost...