STMicroelectronics / STM32CubeG0

STM32Cube MCU Full Package for the STM32G0 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
165 stars 75 forks source link

STM32CubeMX does not generate needed static library imports in Makefile #25

Closed DinkDonk closed 2 years ago

DinkDonk commented 2 years ago

Set-up

Description When setting up a USB-PD project – STM32CubeMX does not generate the needed static library imports in the Makefile, causing a lot of undefined reference errors when compiling. These references are impossible to look up due to them being defined in archived libraries, making it impossible to debug.

How To Reproduce

  1. Set up a new project in STMCubeMX according to AN5418.

  2. Choose Makefile as Toolchain / IDE in the Project Manager tab.

  3. Generate the code and build with $ make

  4. Observe failed build caused by undefined reference errors in the output.

Solution The error is caused by missing static library definitions in the generated Makefile.

Generated Makefile:

# libraries
LIBS = -lc -lm -lnosys 
LIBDIR = 
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections

Expected Makefile:

# libraries
LIBS = -lc -lm -lnosys 
LIBDIR = Middlewares/ST/STM32_USBPD_Library/Core/lib/USBPDCORE_PD3_FULL_CM0PLUS_wc32.a
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections

Observe change in LIBDIR.
The static library is chosen by selecting a Stack Configuration for the USBPD middleware in STM32CubeMX.
Correct behaviour can be seen when doing the exact same project setup inside STM32CubeIDE.

RKOUSTM commented 2 years ago

Hi @DinkDonk,

Thank you for this report. Unfortunately we don't treat aspect related to CubeMx tool in our GitHub repositories. Please allow me to redirect you to the ST Community. You can report this issue in the CubeMX related section. There you shall find people who will address your request and whom you will hopefully find a solution with.

Thank you again for your report. We are looking forward to reading from you again.

With regards,

RKOUSTM commented 2 years ago

Hi @DinkDonk,

An internal tracker has been logged and a fix will be implemented and made available in the frame of a future release of CubeMX.

Thank you for your contribution. We are looking forward to reading from you again.

With regards,

RKOUSTM commented 2 years ago

ST Internal Reference: 120440