1
votes

I'm just starting to learn STM32 development (on Ubuntu 16.04).

I've used STM32CubeMX to build a Makefile-based project.

The generated Makefiles have repeated entries in C_SOURCES which (obviously) cause linking to fail because of duplicated symbols.

C_SOURCES =  \
Src/stm32f0xx_it.c \
Src/stm32f0xx_hal_msp.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rtc.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim_ex.c \
Src/stm32f0xx_it.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc_ex.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart_ex.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2s.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pcd.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_dma.c \
Src/usbd_conf.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr_ex.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_cortex.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c_ex.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash.c \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pcd_ex.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rtc_ex.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc.c \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \
Src/usb_device.c \
Src/usbd_desc.c \
Src/stm32f0xx_hal_msp.c \
Middlewares/ST/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_cec.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_crc.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_gpio.c \
Src/usbd_desc.c \
Src/usbd_conf.c \
Src/system_stm32f0xx.c \
Src/usb_device.c \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c \
Src/main.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_crc_ex.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c.c \
Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash_ex.c \
Src/main.c  

Src/main.c, Src/stm32f0xx_hal_msp.c, Src/stm32f0xx_it.c, Src/usbd_conf.c, Src/usbd_desc.c and Src/usb_device.c are each in this list twice.

If I remove the duplicates from the Makefile, the generated project builds.

Am I doing something wrong, or is this a bug in STM32CubeMX?

1
As a hint, you can do a $(sort $(C_SOURCES)) at its points of use (instead of manually throwing out the multiple occurrences) to get rid of duplicates.Vroomfondel
Note this is the same issue as: *** missing separator. Stop. In the generated makefile. In my case it's because of a duplicate line -IDrivers/CMSIS/IncludeOwl

1 Answers

2
votes

This is a bug and it has been already reported at ST Generated Makefile has duplicated entries for some source files.

The correction should be available in CubeMX 4.26.0 version.