Enabling X-Cube-AI in STM32CubeIDE project causes "undefined reference to `__wrap_malloc'" errors during compile.
Steps to reproduce:
1. Enable X-CUBE-AI core and add a network model.
2. Go back into main.c and setup the calls to feed and run the model with data.
3. Build the project.
Upon build, produces the following errors:
arm-none-eabi-gcc -o "NUCLEO-L476RG-Vibration_detect1.elf" @"objects.list" -larm_cortexM4lf_math -l:NetworkRuntime600_CM4_GCC.a -mcpu=cortex-m4 -T"C:\Users\feist\git\ROW_stationary_sensors\NUCLEO-L476RG-Vibration_detect1\STM32L476RGTX_FLASH.ld" --specs=nosys.specs -Wl,-Map="NUCLEO-L476RG-Vibration_detect1.map" -Wl,--gc-sections -static -Wl,--start-group -larm_cortexM4lf_math -l:NetworkRuntime600_CM4_GCC.a -Wl,--end-group -L../Middlewares/Third_Party/ARM_CMSIS/CMSIS/DSP/Lib/GCC -L../Middlewares/ST/AI/Lib -Wl,--wrap=malloc -Wl,--wrap=free -u _printf_float --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
c:\st\stm32cubeide_1.6.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: c:/st/stm32cubeide_1.6.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924/tools/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libc_nano.a(lib_a-dtoa.o): in function `_dtoa_r':
dtoa.c:(.text._dtoa_r+0x24): undefined reference to `__wrap_malloc'
c:\st\stm32cubeide_1.6.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: c:/st/stm32cubeide_1.6.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924/tools/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libc_nano.a(lib_a-mprec.o): in function `_Balloc':
mprec.c:(.text._Balloc+0xc): undefined reference to `__wrap_malloc'
c:\st\stm32cubeide_1.6.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: c:/st/stm32cubeide_1.6.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924/tools/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libc_nano.a(lib_a-mprec.o): in function `_Bfree':
mprec.c:(.text._Bfree+0xc): undefined reference to `__wrap_malloc'
c:\st\stm32cubeide_1.6.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: c:/st/stm32cubeide_1.6.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924/tools/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libc_nano.a(lib_a-mprec.o): in function `__pow5mult':
mprec.c:(.text.__pow5mult+0x2a): undefined reference to `__wrap_malloc'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:66: NUCLEO-L476RG-Vibration_detect1.elf] Error 1
"make -j8 all" terminated with exit code 2. Build might be incomplete.
It seems enabling X-CUBE-AI automatically adds the following GCC Linker flags in the C/C++ Build Settings of project properties:
-Wl,--wrap=malloc -Wl,--wrap=free
I can remove these flags to get a successful build, but then during runtime I get a hard fault when trying to run my ai model. Seemingly because X-CUBE-AI needs these linked libraries that the compiler cant find.
I’ve tried reverting back to X-CUBE-AI (v5.2) but getting the same errors.
STM32CubeIDE (v1.6)
X-Cube-AI (v6.0.0)
Target board: Nucleo-L476RG
Targeted Language: C
