I am using the NUCLEO_F412ZG Board and i want to setup an MQTT-Application with an w5500 mac-phy. Adding step by step my Kconfig-Parameters, i get a linker error after adding CONFIG_NET_TCP.
CONFIG_MQTT_LIB implicitly sets CONFIG_NET_SOCKETS=y. So far so good. Without CONFIG_NET_TCP build is fine. But after turning this switch to y i get the linker error below.
I build up my Kconfg with the help of the zephyr-samples. So i think CONFIG_NET_TCP is necessary for mqtt comminication.
Building on Zephyrâs âwestâ is fine.
Logs and console output
Linking .pio/build/my_eval_board/zephyr/firmware-pre.elf
/Project/.piocore/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.bfd: .piocore/packages/toolchain-gccarmnoneeabi/arm-none-eabi/lib/thumb/v7e-m+fp/hard/libc.a(lib_a-fini.o): in function `__libc_fini_array':
fini.c:(.text.__libc_fini_array+0x26): undefined reference to `_fini'
collect2: error: ld returned 1 exit status
*** [.pio/build/my_eval_board/zephyr/firmware-pre.elf] Error 1
Environment (please complete the following information):
Some code in the project is calling into exit() which requires _fini (finish) (see here, but the function is either not implemented or not auto-included by the compiler under the current compiler settings.
I did a diff between the Kconfig of West-build and PlatformIO-Build. So both use:
#
# C Library
#
# CONFIG_MINIMAL_LIBC is not set
CONFIG_NEWLIB_LIBC=y
# CONFIG_EXTERNAL_LIBC is not set
CONFIG_HAS_NEWLIB_LIBC_NANO=y
# CONFIG_NEWLIB_LIBC_NANO is not set
CONFIG_NEWLIB_LIBC_MIN_REQUIRED_HEAP_SIZE=8192
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
# CONFIG_NEWLIB_LIBC_FLOAT_SCANF is not set
CONFIG_STDOUT_CONSOLE=y
# end of C Library
Differences are:
CONFIG_TOOLCHAIN_GNUARMEMB=y
vs. CONFIG_TOOLCHAIN_ZEPHYR_0_13=y
I tried to change the libc.a. So i copied it from Zephyr-Sdk to Platformio-Toolchain. Then the Build works. So i think something is suitable concerning the Toolchain platformio uses.
thatâs what I changed it from, to nucleo_f429zi, and it still worked.
Even if I rename src\main.c to src\main.cpp (with some (void*) cast fixes) and the appropriate change in zephyr\CMakeLists.txt it still builds.
I then added CONFIG_CPLUSPLUS=y and the build still went through.
Added CONFIG_LIB_CPLUSPLUS=y and CONFIG_STD_CPP11=y and it stell went through.
Added CONFIG_NEWLIB_LIBC=y and it still went through.
Add CONFIG_NEWLIB_LIBC_NANO=n and it broke the build.
c:/users/max/.platformio/packages/toolchain-gccarmnoneeabi@1.80201.190214/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Max\.platformio\packages\toolchain-gccarmnoneeabi@1.80201.190214\arm-none-eabi\lib\thumb\v7e-m\nofp\libc.a(lib_a-fini.o): in function `__libc_fini_array':
fini.c:(.text.__libc_fini_array+0x26): undefined reference to `_fini'
collect2.exe: error: ld returned 1 exit status
Changed to CONFIG_NEWLIB_LIBC_NANO=y, cleaned & rebuilt and compilation goes through again.
So for me at least the error is only if CONFIG_NEWLIB_LIBC_NANO=n.
Hi,
i just tested out your project and building is fine.
After adding CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y linker errors are back:
myProject/.piocore/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.bfd: .pio/build/test_nucleo/zephyr/lib/libc/newlib/liblib__libc__newlib.a(libc-hooks.c.o): in function `__malloc_lock':
myProject/.piocore/packages/framework-zephyr/lib/libc/newlib/libc-hooks.c:304: multiple definition of `__malloc_lock'; .piocore/packages/toolchain-gccarmnoneeabi/arm-none-eabi/lib/thumb/v7e-m/nofp/libc_nano.a(lib_a-mlock.o):mlock.c:(.text.__malloc_lock+0x0): first defined here
myProject/.piocore/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.bfd: .pio/build/test_nucleo/zephyr/lib/libc/newlib/liblib__libc__newlib.a(libc-hooks.c.o): in function `__malloc_unlock':
myProject/.piocore/packages/framework-zephyr/lib/libc/newlib/libc-hooks.c:309: multiple definition of `__malloc_unlock'; .piocore/packages/toolchain-gccarmnoneeabi/arm-none-eabi/lib/thumb/v7e-m/nofp/libc_nano.a(lib_a-mlock.o):mlock.c:(.text.__malloc_unlock+0x0): first defined here
collect2: error: ld returned 1 exit status
*** [.pio/build/test_nucleo/zephyr/firmware-pre.elf] Error 1
Yes this option auto-includes back NEWLIB_LIBC (source) and not NEWLIB_LIBC_NANO which I think is the source of the problems. Two different C libraries being included. Try including the float-printf from newlib-nano in a different way, as seen in e.g. Sprintf not working on bluepill (build_flags = -Wl,--undefined,_printf_float).