tinyusb icon indicating copy to clipboard operation
tinyusb copied to clipboard

"multiple definition of `dcd_..." if cmpiling for STM32F2

Open DaGo1120 opened this issue 3 years ago • 2 comments

Operating System

Linux

Board

Custom

Firmware

#ifndef TUSB_CONFIG_H_ #define TUSB_CONFIG_H_

#ifdef __cplusplus extern "C" { #endif

// RHPort number used for device can be defined by board.mk, default to port 0 #ifndef BOARD_TUD_RHPORT #define BOARD_TUD_RHPORT 0 #endif

#ifndef CFG_TUSB_RHPORT0_MODE #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED) #endif

#ifndef CFG_TUSB_RHPORT1_MODE #define CFG_TUSB_RHPORT1_MODE 0 #endif

// RHPort max operational speed can defined by board.mk #ifndef BOARD_TUD_MAX_SPEED #define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED #endif

#ifndef BOARD_DEVICE_RHPORT_SPEED #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED #endif

// defined by compiler flags for flexibility #ifndef CFG_TUSB_MCU #define CFG_TUSB_MCU OPT_MCU_STM32F2 #endif

#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_FREERTOS #endif

#ifndef CFG_TUSB_DEBUG #define CFG_TUSB_DEBUG 0 #endif

// Enable Device stack #define CFG_TUD_ENABLED 1

// Default is max speed that hardware controller could support with on-chip PHY #define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED

#ifndef CFG_TUSB_MEM_SECTION #define CFG_TUSB_MEM_SECTION #endif

#ifndef CFG_TUSB_MEM_ALIGN #define CFG_TUSB_MEM_ALIGN attribute ((aligned(4))) #endif

#ifndef CFG_TUD_ENDPOINT0_SIZE #define CFG_TUD_ENDPOINT0_SIZE 64 #endif

#define CFG_TUD_USBTMC 1 #define CFG_TUD_USBTMC_ENABLE_INT_EP 1 #define CFG_TUD_USBTMC_ENABLE_488 1

#ifdef __cplusplus } #endif

#endif /* TUSB_CONFIG_H_ */ `

What happened ?

I Followed your "Getting started" guide using STM32CubeIDE and created a new custom project. If I Compile the project, I get errors like these:

/opt/st/stm32cubeide_1.9.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.linux64_1.0.0.202111181127/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: ./tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.o: in function dcd_init': /home/danielg/STM32-projects/Testadapter_CAN-USB2V2/Debug/../tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c:485: multiple definition of dcd_init'; ./tinyusb/src/portable/st/synopsys/dcd_synopsys.o:/home/danielg/STM32-projects/Testadapter_CAN-USB2V2/Debug/../tinyusb/src/portable/st/synopsys/dcd_synopsys.c:463: first defined here

If I either comment out the whole code in src/portable/synopsys/dwc2/dcd_dwc2.c OR in src/portable/st/synopsys/dcd_synopsys.c the project compiles without problems.

So my Question is: Is this an TinyUSB code issue or do I something wrong?

How to reproduce ?

As described above

Debug Log as txt file

08:53:20 **** Incremental Build of configuration Debug for project Testadapter_CAN-USB2V2 **** make -j4 all arm-none-eabi-gcc "../Core/Src/main.c" -mcpu=cortex-m3 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F205xx -c -I../Core/Inc -I../Drivers/STM32F2xx_HAL_Driver/Inc -I../Drivers/STM32F2xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32F2xx/Include -I../Drivers/CMSIS/Include -I../Middlewares/Third_Party/FreeRTOS/Source/include -I../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3 -I"/home/danielg/STM32-projects/Testadapter_CAN-USB2V2/tinyusb/src" -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Core/Src/main.d" -MT"Core/Src/main.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Core/Src/main.o" arm-none-eabi-gcc -o "Testadapter_CAN-USB2V2.elf" @"objects.list" -mcpu=cortex-m3 -T"/home/danielg/STM32-projects/Testadapter_CAN-USB2V2/STM32F205ZCTX_FLASH.ld" --specs=nosys.specs -Wl,-Map="Testadapter_CAN-USB2V2.map" -Wl,--gc-sections -static --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group /opt/st/stm32cubeide_1.9.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.linux64_1.0.0.202111181127/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: ./tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.o: in function dcd_init': /home/danielg/STM32-projects/Testadapter_CAN-USB2V2/Debug/../tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c:485: multiple definition of `dcd_init'; ./tinyusb/src/portable/st/synopsys/dcd_synopsys.o:/home/danielg/STM32-projects/Testadapter_CAN-USB2V2/Debug/../tinyusb/src/portable/st/synopsys/dcd_synopsys.c:463: first defined here

...

/opt/st/stm32cubeide_1.9.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.linux64_1.0.0.202111181127/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: ./tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.o: in function dcd_int_handler': /home/danielg/STM32-projects/Testadapter_CAN-USB2V2/Debug/../tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c:1219: multiple definition of dcd_int_handler'; ./tinyusb/src/portable/st/synopsys/dcd_synopsys.o:/home/danielg/STM32-projects/Testadapter_CAN-USB2V2/Debug/../tinyusb/src/portable/st/synopsys/dcd_synopsys.c:1128: first defined here collect2: error: ld returned 1 exit status make: *** [makefile:114: Testadapter_CAN-USB2V2.elf] Error 1 "make -j4 all" terminated with exit code 2. Build might be incomplete.

08:53:21 Build Failed. 25 errors, 0 warnings. (took 804ms)`

Screenshots

No response

I have checked existing issues, dicussion and documentation

  • [X] I confirm I have checked existing issues, dicussion and documentation.

DaGo1120 avatar Aug 23 '22 09:08 DaGo1120

mentioned in #1591, remove or filter the old driver portable/st/synopsys/dcd_synopsys.c. It will be removed from repo in the future soon.

hathach avatar Aug 23 '22 09:08 hathach

This is the workaround I have been working with so far. Thanks for clarification!

DaGo1120 avatar Aug 23 '22 10:08 DaGo1120