2021-02-12 09:32 AM
Hi,
I am using STM32CubeMX, ver 6.1.1 on Linux and I noticed the following bugs in the Makefile generation:
The first problem: The C_INCLUDES variable.
--------------------------------------------------------------
If a Makefile does not exist in the target directory, a Makefile is generated and this mostly works. However, on regenerating the code after the initial generation, an extra line is appended after the C_INCLUDES variable. This causes a failure on running make. The variable looks something like this after the initial generation:
C_INCLUDES = \
-ICore/Inc \
.
.
-IDrivers/CMSIS/Include
After the second generation, it looks like this:
C_INCLUDES = \
-ICore/Inc \
.
.
-IDrivers/CMSIS/Include
-IDrivers/CMSIS/Include
Note that the second last include line has no \ behind it, so make assumes that the last line is a make target "-IDrivers/CMSIS/Include". This is an error.
The line should not be generated, so to get the Makefile to work, this line always needs to be deleted manually.
The second problem: Linking with libPDMFilter_CM4_GCC_wc32.a
-------------------------------------------------------------------------------------------
When enabling the PDM2PCM option (after enabling CRC!), in STM32CubeMX, the LIBS variable is setup wrongly:
LIBS = -lc -lm -lnosys \
-llibPDMFilter_CM4_GCC_wc32.a
A ':' is missing between -l and libPDMFilter_CM4_GCC_wc32.a
So it should be changed to:
LIBS = -lc -lm -lnosys \
-l:libPDMFilter_CM4_GCC_wc32.a
The third problem: link flags are wrong when linking with pre-compiled libs.
--------------------------------------------------------------------------------------------------------
The following gets generated:
LIBS = -lc -lm -lnosys \
-llibPDMFilter_CM4_GCC_wc32.a
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
This produces linking errors like:
...... newlib/libm/math/wf_pow.c:77: undefined reference to `__errno'
I had a look at what AtollicStudio generates in its makefiles.
Using the following, solves the problem:
LIBS = -specs=nosys.specs -static \
-l:libPDMFilter_CM4_GCC_wc32.a
LDFLAGS = $(MCU) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref \
-Wl,--gc-sections \
-Wl,--defsym=malloc_getpagesize_P=0x80 \
-Wl,--start-group -lc -lm -Wl,--end-group \
-specs=nano.specs
I found that te above works for several different CPUs with hard- and soft-float configurations.
I hope that these tips come in handy and that they will find their way into the next STM32CubeMX release.
Thanks
2021-02-15 01:03 AM
Hello @Wingunder ,
First let me thank you for this detailed description and for the proposed suggestions.
> The first problem: The C_INCLUDES variable and the second problem: Linking with libPDMFilter_CM4_GCC_wc32.
Concerning these issues, they were already detected and reported to be fixed. I'll inform you once the fix is available.
> The third problem: link flags are wrong when linking with pre-compiled libs.
This will be reported internally to be reviewed. I'll keep you posted with the updates.
Thanks for your contribution :)
Khouloud.
2021-02-15 03:00 AM
Hi @Khouloud OTHMAN ,
Thanks for following up on this.
Is there a place where all the know, but not fixed bugs are listed?
If so, this would certainly help a lot.
Thanks & best regards
2021-02-19 09:28 AM
Hi @Wingunder ,
Actually there is not such a list, but we are always improving our tools maybe this will be implemented in the future.
Otherwise, I will get back to you as soon as the fix is available :smiling_face_with_smiling_eyes:
Thanks for your patience.
Khouloud.