Reproducable for me.
Linking .pio\build\tb_sense_12\firmware.elf
c:/users/max/.platformio/packages/toolchain-gccarmnoneeabi@1.90201.191206/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lrail_efr32xg12_release.ar
collect2.exe: error: ld returned 1 exit status
-Wl,–start-group -lrail_efr32xg12_release -lrail_efr32xg12_release.ar
These linker commands are the cause of the problem, the -l
command shouldn’t contain the file extension and also not the lib
prefix of the file.
The file C:\User\<user>\.platformio\packages\framework-mbed\targets\TARGET_Silicon_Labs\TARGET_SL_RAIL\CMakeLists.txt
says
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
if("EFR32_12" IN_LIST MBED_TARGET_LABELS)
if(${MBED_TOOLCHAIN} STREQUAL "ARM")
set(LIB_RAIL efr32-rf-driver/rail/TARGET_EFR32_12/librail_efr32xg12_release.ar)
elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
set(LIB_RAIL efr32-rf-driver/rail/TARGET_EFR32_12/librail_efr32xg12_release.a)
endif()
endif()
target_link_libraries(mbed-core INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_RAIL})
target_include_directories(mbed-core
INTERFACE
efr32-rf-driver/rail
efr32-rf-driver/rail/ble
efr32-rf-driver/rail/ieee802154
)
and first of all PlatformIO or mbed-os seems to make an error here because our toolchain is GCC_ARM but still lrail_efr32xg12_release.ar
for the native ARM toolchain shows up in the linker command.
I’ve tried to replace the contents of that file with
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
if("EFR32_12" IN_LIST MBED_TARGET_LABELS)
set(LIB_RAIL efr32-rf-driver/rail/TARGET_EFR32_12/librail_efr32xg12_release.a)
endif()
target_link_libraries(mbed-core INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_RAIL})
target_include_directories(mbed-core
INTERFACE
efr32-rf-driver/rail
efr32-rf-driver/rail/ble
efr32-rf-driver/rail/ieee802154
)
but that didn’t work. By renaming the librail_efr32xg12_release.ar
file to do_not_link_me.ar
I found out that the build system just tries to link every single *.ar
and *.a
file in that folder and that it doesn’t seem to be dependent of the CMakeLists.txt logic at all.
So, after renaming the file in C:\Users\<user>\.platformio\packages\framework-mbed\targets\TARGET_Silicon_Labs\TARGET_SL_RAIL\efr32-rf-driver\rail\TARGET_EFR32_12\
from librail_efr32xg12_release.ar
to librail_efr32xg12_release.ar.backup
, and doing a “Clean”, “General → Miscellanenous → Rebuild IntelliSense” and “Build”, it works.
Checking size .pio\build\tb_sense_12\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 3.7% (used 9784 bytes from 262144 bytes)
Flash: [ ] 3.7% (used 38336 bytes from 1048576 bytes)
======================= [SUCCESS] Took 4.22 seconds =======================
I’ll report this bug to Issues · platformio/platform-siliconlabsefm32 · GitHub.
Edit: Reported to Blinky mbed-os firmware does not link for tb_sense_12 board because of ARM library · Issue #4 · platformio/platform-siliconlabsefm32 · GitHub