STM32 Embedded Coder collect2.exe: error: ld returned 1 exit status
11 views (last 30 days)
Show older comments
Hello, I want to generate and embed code for my STM34F407G Discovery board, but I get an error even though I do all the steps correctly in the led lighting video in the simple tutorial on the matlab site. I tried many ways but none of them gave correct results. The methods I tried are :
I downloaded and installed Mingw,
I reinstalled MATLAB and all STM related programs,
I made sure the COM port was correct,
I deleted the Include path,
None of these have yielded positive results, please help.
### Starting build procedure for: bling
### Generating code and artifacts to 'Model specific' folder structure
### Generating code into build folder: C:\Users\Kadir\Desktop\Coder\bling_ert_rtw
### Invoking Target Language Compiler on bling.rtw
### Using System Target File: C:\Program Files\MATLAB\R2024a\rtw\c\ert\ert.tlc
### Loading TLC function libraries
.......
### Initial pass through model to cache user defined code
.
### Caching model source code
.............................
### Writing header file bling_types.h
.
### Writing header file bling.h
### Writing header file rtwtypes.h
### Writing source file bling.c
### Writing header file bling_private.h
### Writing source file bling_data.c
.
### Writing header file rtmodel.h
### Writing source file ert_main.c
### TLC code generation complete (took 2.321s).
### Saving binary information cache.
### Using toolchain: GNU Tools for ARM Embedded Processors
### 'C:\Users\Kadir\Desktop\Coder\bling_ert_rtw\bling.mk' is up to date
### Building 'bling': "C:\PROGRA~1\MATLAB\R2024a\bin\win64\gmake" -f bling.mk all
C:\Users\Kadir\Desktop\Coder\bling_ert_rtw>cd .
C:\Users\Kadir\Desktop\Coder\bling_ert_rtw>if "all" == "" ("C:\PROGRA~1\MATLAB\R2024a\bin\win64\gmake" -f bling.mk all ) else ("C:\PROGRA~1\MATLAB\R2024a\bin\win64\gmake" -f bling.mk all )
"C:/ProgramData/MATLAB/SupportPackages/R2024a/3P.instrset/gnuarm-armcortex.instrset/win/bin/arm-none-eabi-gcc" -ffunction-sections -fdata-sections -Wall -MMD -MP -MF"bling.dep" -MT"bling.o" -c -O0 -mcpu=cortex-m4 -mthumb -mlittle-endian -mthumb-interwork -mfpu=fpv4-sp-d16 -mfloat-abi=hard -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DUSE_FULL_LL_DRIVER -DSTM32F407xx -DUSE_HAL_DRIVER -DMW_TIMEBASESOURCE=TIM5 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTERMFCN=1 -DONESTEPFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DXCP_CUSTOM_PLATFORM -DXCP_MEM_DAQ_RESERVED_POOL_BLOCKS_NUMBER=10 -D__FPU_PRESENT=1U -D__FPU_USED=1U -DSTACK_SIZE=64 -DRT -DMODEL=bling -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 @bling_comp.rsp -o "bling.o" "C:/Users/Kadir/Desktop/Coder/bling_ert_rtw/bling.c"
"C:/ProgramData/MATLAB/SupportPackages/R2024a/3P.instrset/gnuarm-armcortex.instrset/win/bin/arm-none-eabi-gcc" -ffunction-sections -fdata-sections -Wall -MMD -MP -MF"bling_data.dep" -MT"bling_data.o" -c -O0 -mcpu=cortex-m4 -mthumb -mlittle-endian -mthumb-interwork -mfpu=fpv4-sp-d16 -mfloat-abi=hard -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DUSE_FULL_LL_DRIVER -DSTM32F407xx -DUSE_HAL_DRIVER -DMW_TIMEBASESOURCE=TIM5 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTERMFCN=1 -DONESTEPFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DXCP_CUSTOM_PLATFORM -DXCP_MEM_DAQ_RESERVED_POOL_BLOCKS_NUMBER=10 -D__FPU_PRESENT=1U -D__FPU_USED=1U -DSTACK_SIZE=64 -DRT -DMODEL=bling -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 @bling_comp.rsp -o "bling_data.o" "C:/Users/Kadir/Desktop/Coder/bling_ert_rtw/bling_data.c"
"C:/ProgramData/MATLAB/SupportPackages/R2024a/3P.instrset/gnuarm-armcortex.instrset/win/bin/arm-none-eabi-gcc" -ffunction-sections -fdata-sections -Wall -MMD -MP -MF"overrideHALDelay.dep" -MT"overrideHALDelay.o" -c -O0 -mcpu=cortex-m4 -mthumb -mlittle-endian -mthumb-interwork -mfpu=fpv4-sp-d16 -mfloat-abi=hard -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DUSE_FULL_LL_DRIVER -DSTM32F407xx -DUSE_HAL_DRIVER -DMW_TIMEBASESOURCE=TIM5 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTERMFCN=1 -DONESTEPFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DXCP_CUSTOM_PLATFORM -DXCP_MEM_DAQ_RESERVED_POOL_BLOCKS_NUMBER=10 -D__FPU_PRESENT=1U -D__FPU_USED=1U -DSTACK_SIZE=64 -DRT -DMODEL=bling -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 @bling_comp.rsp -o "overrideHALDelay.o" "C:/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/shared/supportpackages/stm32/src/overrideHALDelay.c"
"C:/ProgramData/MATLAB/SupportPackages/R2024a/3P.instrset/gnuarm-armcortex.instrset/win/bin/arm-none-eabi-gcc" -ffunction-sections -fdata-sections -Wall -MMD -MP -MF"platform_timer.dep" -MT"platform_timer.o" -c -O0 -mcpu=cortex-m4 -mthumb -mlittle-endian -mthumb-interwork -mfpu=fpv4-sp-d16 -mfloat-abi=hard -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DUSE_FULL_LL_DRIVER -DSTM32F407xx -DUSE_HAL_DRIVER -DMW_TIMEBASESOURCE=TIM5 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTERMFCN=1 -DONESTEPFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DXCP_CUSTOM_PLATFORM -DXCP_MEM_DAQ_RESERVED_POOL_BLOCKS_NUMBER=10 -D__FPU_PRESENT=1U -D__FPU_USED=1U -DSTACK_SIZE=64 -DRT -DMODEL=bling -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 @bling_comp.rsp -o "platform_timer.o" "C:/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/shared/supportpackages/stm32/src/platform_timer.c"
"C:/ProgramData/MATLAB/SupportPackages/R2024a/3P.instrset/gnuarm-armcortex.instrset/win/bin/arm-none-eabi-gcc" -ffunction-sections -fdata-sections -Wall -MMD -MP -MF"SysTickScheduler.dep" -MT"SysTickScheduler.o" -c -O0 -mcpu=cortex-m4 -mthumb -mlittle-endian -mthumb-interwork -mfpu=fpv4-sp-d16 -mfloat-abi=hard -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DUSE_FULL_LL_DRIVER -DSTM32F407xx -DUSE_HAL_DRIVER -DMW_TIMEBASESOURCE=TIM5 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTERMFCN=1 -DONESTEPFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DXCP_CUSTOM_PLATFORM -DXCP_MEM_DAQ_RESERVED_POOL_BLOCKS_NUMBER=10 -D__FPU_PRESENT=1U -D__FPU_USED=1U -DSTACK_SIZE=64 -DRT -DMODEL=bling -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 @bling_comp.rsp -o "SysTickScheduler.o" "C:/PROGRA~1/MATLAB/R2024a/toolbox/target/shared/armcortexmbase/scheduler/src/SysTickScheduler.c"
"C:/ProgramData/MATLAB/SupportPackages/R2024a/3P.instrset/gnuarm-armcortex.instrset/win/bin/arm-none-eabi-gcc" -ffunction-sections -fdata-sections -Wall -MMD -MP -MF"m3m4m4f_multitasking.dep" -MT"m3m4m4f_multitasking.o" -c -O0 -mcpu=cortex-m4 -mthumb -mlittle-endian -mthumb-interwork -mfpu=fpv4-sp-d16 -mfloat-abi=hard -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DUSE_FULL_LL_DRIVER -DSTM32F407xx -DUSE_HAL_DRIVER -DMW_TIMEBASESOURCE=TIM5 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTERMFCN=1 -DONESTEPFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DXCP_CUSTOM_PLATFORM -DXCP_MEM_DAQ_RESERVED_POOL_BLOCKS_NUMBER=10 -D__FPU_PRESENT=1U -D__FPU_USED=1U -DSTACK_SIZE=64 -DRT -DMODEL=bling -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 @bling_comp.rsp -o "m3m4m4f_multitasking.o" "C:/PROGRA~1/MATLAB/R2024a/toolbox/target/shared/armcortexmbase/scheduler/src/m3m4m4f_multitasking.c"
"C:/ProgramData/MATLAB/SupportPackages/R2024a/3P.instrset/gnuarm-armcortex.instrset/win/bin/arm-none-eabi-gcc" -ffunction-sections -fdata-sections -Wall -MMD -MP -MF"ert_main.dep" -MT"ert_main.o" -c -O0 -mcpu=cortex-m4 -mthumb -mlittle-endian -mthumb-interwork -mfpu=fpv4-sp-d16 -mfloat-abi=hard -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DUSE_FULL_LL_DRIVER -DSTM32F407xx -DUSE_HAL_DRIVER -DMW_TIMEBASESOURCE=TIM5 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTERMFCN=1 -DONESTEPFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DXCP_CUSTOM_PLATFORM -DXCP_MEM_DAQ_RESERVED_POOL_BLOCKS_NUMBER=10 -D__FPU_PRESENT=1U -D__FPU_USED=1U -DSTACK_SIZE=64 -DRT -DMODEL=bling -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 @bling_comp.rsp -o "ert_main.o" "C:/Users/Kadir/Desktop/Coder/bling_ert_rtw/ert_main.c"
C:/Users/Kadir/Desktop/Coder/bling_ert_rtw/ert_main.c: In function 'main':
C:/Users/Kadir/Desktop/Coder/bling_ert_rtw/ert_main.c:64:3: warning: implicit declaration of function 'SystemClock_Config'; did you mean 'SysTick_Config'? [-Wimplicit-function-declaration]
64 | SystemClock_Config();
| ^~~~~~~~~~~~~~~~~~
| SysTick_Config
C:/Users/Kadir/Desktop/Coder/bling_ert_rtw/ert_main.c:65:3: warning: implicit declaration of function 'PeriphCommonClock_Config' [-Wimplicit-function-declaration]
65 | PeriphCommonClock_Config();
| ^~~~~~~~~~~~~~~~~~~~~~~~
"### Creating standalone executable "../bling.elf" ..."
"C:/ProgramData/MATLAB/SupportPackages/R2024a/3P.instrset/gnuarm-armcortex.instrset/win/bin/arm-none-eabi-g++" -Wl,--gc-sections -Wl,-Map="bling.map" --specs=nano.specs -mcpu=cortex-m4 -mthumb -mlittle-endian -mthumb-interwork -mfpu=fpv4-sp-d16 -mfloat-abi=hard --entry Reset_Handler --specs=nosys.specs -o ../bling.elf @bling.rsp C:/ProgramData/MATLAB/SupportPackages/R2024a/3P.instrset/cmsis_dsp.instrset/Lib/GCC/arm_cortexm4ldfsp_math/libCMSISDSP.a C:/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/shared/supportpackages/stm32/lib/GCC/libmw_pdmfilter_m4_spfp.lib -lm
c:/programdata/matlab/supportpackages/r2024a/3p.instrset/gnuarm-armcortex.instrset/win/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/programdata/matlab/supportpackages/r2024a/3p.instrset/gnuarm-armcortex.instrset/win/bin/../lib/gcc/arm-none-eabi/11.3.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-closer.o): in function `_close_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/closer.c:47: warning: _close is not implemented and will always fail
c:/programdata/matlab/supportpackages/r2024a/3p.instrset/gnuarm-armcortex.instrset/win/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/programdata/matlab/supportpackages/r2024a/3p.instrset/gnuarm-armcortex.instrset/win/bin/../lib/gcc/arm-none-eabi/11.3.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lseekr.o): in function `_lseek_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/lseekr.c:49: warning: _lseek is not implemented and will always fail
c:/programdata/matlab/supportpackages/r2024a/3p.instrset/gnuarm-armcortex.instrset/win/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/programdata/matlab/supportpackages/r2024a/3p.instrset/gnuarm-armcortex.instrset/win/bin/../lib/gcc/arm-none-eabi/11.3.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-readr.o): in function `_read_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/readr.c:49: warning: _read is not implemented and will always fail
c:/programdata/matlab/supportpackages/r2024a/3p.instrset/gnuarm-armcortex.instrset/win/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/programdata/matlab/supportpackages/r2024a/3p.instrset/gnuarm-armcortex.instrset/win/bin/../lib/gcc/arm-none-eabi/11.3.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-writer.o): in function `_write_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/writer.c:49: warning: _write is not implemented and will always fail
c:/programdata/matlab/supportpackages/r2024a/3p.instrset/gnuarm-armcortex.instrset/win/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: startup_stm32f407vgtx.o: in function `LoopFillZerobss':
(.text.Reset_Handler+0x38): undefined reference to `_estack'
c:/programdata/matlab/supportpackages/r2024a/3p.instrset/gnuarm-armcortex.instrset/win/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: (.text.Reset_Handler+0x3c): undefined reference to `_sdata'
c:/programdata/matlab/supportpackages/r2024a/3p.instrset/gnuarm-armcortex.instrset/win/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: (.text.Reset_Handler+0x44): undefined reference to `_sidata'
c:/programdata/matlab/supportpackages/r2024a/3p.instrset/gnuarm-armcortex.instrset/win/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: (.text.Reset_Handler+0x48): undefined reference to `_sbss'
c:/programdata/matlab/supportpackages/r2024a/3p.instrset/gnuarm-armcortex.instrset/win/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: (.text.Reset_Handler+0x4c): undefined reference to `_ebss'
collect2.exe: error: ld returned 1 exit status
gmake: *** [../bling.elf] Error 1
C:\Users\Kadir\Desktop\Coder\bling_ert_rtw>echo The make command returned an error of 2
The make command returned an error of 2
C:\Users\Kadir\Desktop\Coder\bling_ert_rtw>exit /B 1
### Build procedure for bling aborted due to an error.
0 Comments
Answers (1)
Adit Kirtani
on 12 Apr 2024
Hi,
It looks like the linker file is not generated, which is why there are undefined references to _sbss, _ebss and so on. It should be located under the STM32CubeIDE folder where the ".ioc" file is saved.
Kindly try generating code from STM32CubeMX manually to see if any errors occur. If the issue still persists, contact Technical Support.
I hope this helps.
Regards,
Adit Kirtani.
0 Comments
See Also
Categories
Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!