cancel
Showing results for 
Search instead for 
Did you mean: 

Linking Errors When Building SDK with FreeRTOS on STM32

Das
Associate II

Hello STM Community,

I am currently working on integrating a third party SDK(blockchain sdk) with my FreeRTOS-based project on an STM32 microcontroller, and I have encountered a series of linking errors that I'm struggling to resolve. The build process goes smoothly until I set  SDK=true in my CMake build configuration, after which I receive multiple errors related to functions that are typically provided by a POSIX-compliant operating system (such as _exit, _read, _write etc).

 

/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libg.a(libc_a-fstatr.o): in function `_fstat_r':
/build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/fstatr.c:55: undefined reference to `_fstat'
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libg.a(libc_a-gettimeofdayr.o): in function `_gettimeofday_r':
/build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/gettimeofdayr.c:62: undefined reference to `_gettimeofday'
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libg.a(libc_a-openr.o): in function `_open_r':
/build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/openr.c:50: undefined reference to `_open'
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libg.a(libc_a-sbrkr.o): in function `_sbrk_r':
/build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/sbrkr.c:51: undefined reference to `_sbrk'
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libg.a(libc_a-unlinkr.o): in function `_unlink_r':
/build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/unlinkr.c:47: undefined reference to `_unlink'
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libg.a(libc_a-abort.o): in function `abort':
/build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/stdlib/abort.c:59: undefined reference to `_exit'
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libg.a(libc_a-closer.o): in function `_close_r':
/build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/closer.c:47: undefined reference to `_close'
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libg.a(libc_a-isattyr.o): in function `_isatty_r':
/build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/isattyr.c:52: undefined reference to `_isatty'
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libg.a(libc_a-lseekr.o): in function `_lseek_r':
/build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/lseekr.c:49: undefined reference to `_lseek'
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libg.a(libc_a-readr.o): in function `_read_r':
/build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/readr.c:49: undefined reference to `_read'
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libg.a(libc_a-signalr.o): in function `_kill_r':
/build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/signalr.c:53: undefined reference to `_kill'
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libg.a(libc_a-signalr.o): in function `_getpid_r':
/build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/signalr.c:83: undefined reference to `_getpid'
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.macos64_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libg.a(libc_a-writer.o): in function `_write_r':
/build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/writer.c:49: undefined reference to `_write'

 

My build command: 

 

cmake -DCMAKE_TOOLCHAIN_FILE=stm32-arm-gcc.cmake -DIN3_LIB=false -DTRANSPORTS=false -DUSE_SCRYPT=false -DTHREADSAFE=false -DBASE64=false -DSTM32=true -DSDK=true -DCMAKE_BUILD_TYPE=Debug -S ./ -B Debug -G"Unix Makefiles"

 

Changing SDK=false leads to a successful application build, indicating the issue is with the SDK integration. I suspect there may be some incompatibility or misconfiguration with the SDK and the STM32/FreeRTOS environment, especially around syscalls and POSIX expectations.

Here's what I have tried so far:

  • Ensuring all necessary syscalls are properly implemented for my environment.
  • Verifying library configurations and conditional compilation flags.
  • Reviewing compilation flags for consistency, especially regarding floating-point operations.

I am seeking guidance on how to properly configure or modify the SDK or my project settings to resolve these linking errors. Any insights, suggestions, or experiences you could share would be immensely helpful.

Thank you in advance for your time and assistance.

1 ACCEPTED SOLUTION

Accepted Solutions
Das
Associate II

The reported issue got solved. There were some executable  targets present in the sdk side which was not at all required for STM32 based application also that Created issue while linking.  So please close the issue. 

View solution in original post

1 REPLY 1
Das
Associate II

The reported issue got solved. There were some executable  targets present in the sdk side which was not at all required for STM32 based application also that Created issue while linking.  So please close the issue.