Skip to main content
Phillip Wolstencroft
Associate II
July 12, 2023
Solved

STM32CubeIDE 1.13.0 problem

  • July 12, 2023
  • 17 replies
  • 33675 views

I have just updated the IDE from 1.12.1 and updated my project as requested but I have encountered an issue when compiling.

I get 3 errors on previously compiling  source code. as follows

PhillipWolstencroft_0-1689145531697.png

Can you help with what might be the problem?

PhilW

    Best answer by HBoss.1

    Same Problem here. Solved as follows:

    - create a new project with 1.13.1
    - grab the files syscalls.c and sysmem.c from Core/Src
    - add those files to your existing project

    You're done

    17 replies

    MGall.11
    Associate II
    September 4, 2023

    Hi everybody,

    I have the same problem working on an old workspace with STM32L4 fw package 1.11.0. The trick suggested by Peter works for me, but I would like to know if it depends on the old fw package or there is something else. I have regenerated the code from CubeMX and I have added my sources keeping the old version of HAL, LL and CMSIS libraries. I'm also using FreeRTOS version 10.1.1. So, doing this, only the project files have been updated (.cproject and .project files), but the problem is still there. Does anyone help me to figure it out? Which library has a reference to (or use) these "undeclared functions"?

    Thanks in advance.

    HBoss.1
    HBoss.1Best answer
    Explorer
    September 5, 2023

    Same Problem here. Solved as follows:

    - create a new project with 1.13.1
    - grab the files syscalls.c and sysmem.c from Core/Src
    - add those files to your existing project

    You're done

    MGall.11
    Associate II
    September 5, 2023

    Thank you! Now I get it, I didn't notice that those functions are defined in syscall.c. There were no sysmem.c and syscall.c in my old workspace.

    ANauz.1
    Senior
    November 6, 2023

    So, I still have problems with the GCC from STM32CubeIDE version 1.13.2, and no workaround is working for me.

    So fare:

    • My project is compiling perfectly fine with CMake and GCC from IDE version 1.12.1
    • When changing to GCC from IDE 1.13.2 (and changing only that), I have link error.
    • After copying sysmem.c and syscalls.c from a new project generated with IDE 1.13.2, I still have errors:
    C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-closer.o): in function `_close_r':
    (.text._close_r+0xc): warning: _close is not implemented and will always fail
    C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-lseekr.o): in function `_lseek_r':
    (.text._lseek_r+0x10): warning: _lseek is not implemented and will always fail
    C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-readr.o): in function `_read_r':
    (.text._read_r+0x10): warning: _read is not implemented and will always fail
    C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-writer.o): in function `_write_r':
    (.text._write_r+0x10): warning: _write is not implemented and will always fail
    C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: CMakeFiles/CLEANSD.dir/Core/Src/syscalls.c.obj: in function `_exit':
    C:/Work/Project/Core/Src/syscalls.c:57: multiple definition of `_exit'; C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libnosys.a(_exit.o):(.text._exit+0x0): first defined here
    C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: CMakeFiles/CLEANSD.dir/Core/Src/syscalls.c.obj: in function `_close':
    C:/Work/Project/Core/Src/syscalls.c:93: multiple definition of `_close'; C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libnosys.a(close.o):(.text._close+0x0): first defined here
    C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: CMakeFiles/CLEANSD.dir/Core/Src/syscalls.c.obj: in function `_lseek':
    C:/Work/Project/Core/Src/syscalls.c:114: multiple definition of `_lseek'; C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libnosys.a(lseek.o):(.text._lseek+0x0): first defined here
    C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: CMakeFiles/CLEANSD.dir/Core/Src/sysmem.c.obj: in function `_sbrk':
    C:/Work/Project/Core/Src/sysmem.c:54: multiple definition of `_sbrk'; C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libnosys.a(sbrk.o):(.text._sbrk+0x0): first defined here
    C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: Libs/libPrintf/liblibPrintf.a(libPrintf.c.obj): in function `_write':
    C:/Work/Project/Libs/libPrintf/libPrintf.c:48: multiple definition of `_write'; C:/ST/STM32CubeIDE_1.13.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard\libnosys.a(write.o):(.text._write+0x0): first defined here
    collect2.exe: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.

    Is there any other workaround to use?

    Do ST plan to release a corrected version of STM32CubeIDE version 13? First mentions of the problems are more than 3 month old! Or should I go back to version 1.12 and never update any more?

     

    Brian TIDAL
    Technical Moderator
    November 9, 2023

    Hi ANauz.1

    Those issues are not a bug or a defect from the latest STM32CubeIDE. This is a generic issue of gcc libraries causing a warning at linking stage.

    warning: _close is not implemented and will always fail” is not a linker error but a warning placed inside the recent implementation of libnosys as part of gcc libraries. This libnosys provides dummy system calls (read/write/close/lseek) and kindly warns the user during linking stage that any attempt to use those system calls will fail (as this is a dummy implementation). As explained, this is ‘just’ a warning, and the linker is able to generate a proper ELF file. As long as your application does not use read/write/close/lseek (which should be the case for a bare metal application), your application will run properly.

     

    So,

    • the first option is to ignore those warnings.
    • A second option is to patch the libnosys.a to get rid of those warnings (see stackoverflow discussion below).
    • A third option is to provide your ‘own’ implementation of the system calls. You can simply generate a new STM32CubeIDE project with STM32CubeMX and reuse the syscalls.c and sysmem.c files in your initial project.
    • and all other options suggested in this thread (use older toolchain, etc.).

     

    Regarding the multiple definition linker error in your application, this is likely caused by a duplicated object file having the system calls symbols or a duplicated syscall source file: clean your build directory, make sure your source files do not contains several definitions of those system calls. The linker map file should help to find the root cause of the duplicate symbol definition (or use linker verbose mode).

     

    See also

     

    Rgds

    BT

    In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
    Visitor II
    November 26, 2023

    1.) find your old version of syscalls.c

    2.) find the #if 0 and matching #endif

    3.) remove them.

    4.) enjoy!

     

    Mohammed Eshaq
    Associate II
    January 18, 2024

    This problem has been resolved with the latest update from STM32 CubeIDE. Just update your IDE and make sure you are using the following Toolchain: 11.3 rel 1.

     

    MohammedEshaq_0-1705566461975.png

     

    Associate III
    June 26, 2025

    i am  add this  code  in my project  and fit it!

     

    #if 1

    __attribute__((weak)) void _close(void){}

    __attribute__((weak)) void _lseek(void){}

    __attribute__((weak)) void _read(void){}

    __attribute__((weak)) void _write(void){}

     

    __attribute__((weak)) void _fstat(void){}

    __attribute__((weak)) void _isatty(void){}

    __attribute__((weak)) void _getpid(void){}

    __attribute__((weak)) void _kill(void){}

     

    #endif