This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDK 15 linker issue nrfx_common.ld and undefined references

Hi,

I got some issues with migrating from SDK 14.0.0 to SDK 15.3.0 on a project that was developped from the previous developper. I have already done a lot of migration modifications. The softdevice is 6.1.1.

Problem looks to be about the linker...  Sorry for this long detailled message coming now. Hope you will understand it otherwise I will explain if you have questions. I'm a begginer in the field.. 

STATE : 

In our project we have our folder "eclipse_armgcc\Tools" that contains Makefile, Makefile.common, and Makefile.windows, Makefile.posix.

We have our linker file ourProject.ld in the folder "eclipse_armgcc\Project " with one is defined in the makefile LINKER_SCRIPT = ourProject.ld. 

In this linker file at the very end there is INCLUDE "nrf5x_common.ld"

I had to replace the Makefile.common that was used before with sdk13 because it called the FILE_LIST.mk which one doesn't exist anymore in sdk 15. So I replaced it with the Makefile.common from the SDK15 folder "nRF5_SDK_15.3.0_59ac345\components\toolchain\gcc", there a lot of changes then I replaced, and I just had inside the line (yellow background) like it was in the previous one  : 

PLATFORM_SUFFIX := $(if $(filter Windows%,$(OS)),windows,posix)
TOOLCHAIN_CONFIG_FILE := $(TEMPLATE_PATH)/Makefile.$(PLATFORM_SUFFIX)
TEMPLATE_PATH := ../../../../nRF5_SDK_15.3.0_59ac345/components/toolchain/gcc
include $(TOOLCHAIN_CONFIG_FILE)

Here below is my makefile configuration, I have tried two differents configuration which are colored background below (orange and green).

================================================================================================
# Libraries common to all targets
LIB_FILES += \
$(SDK_ROOT)/components/nfc/t2t_lib/nfc_t2t_lib_gcc.a \
$(SDK_ROOT)/components/toolchain/cmsis/dsp/GCC/libarm_cortexM4lf_math.a \

# C flags common to all targets
CFLAGS += -DBLE_STACK_SUPPORT_REQD
CFLAGS += -DCONFIG_GPIO_AS_PINRESET
CFLAGS += -DNRF52
CFLAGS += -DFREERTOS
CFLAGS += -DNRF52832_XXAA
CFLAGS += -DNRF52_PAN_12
CFLAGS += -DNRF52_PAN_15
CFLAGS += -DNRF52_PAN_20
CFLAGS += -DNRF52_PAN_31
CFLAGS += -DNRF52_PAN_36
CFLAGS += -DNRF52_PAN_51
CFLAGS += -DNRF52_PAN_54
CFLAGS += -DNRF52_PAN_55
CFLAGS += -DNRF52_PAN_58
CFLAGS += -DNRF52_PAN_64
CFLAGS += -DNRF52_PAN_74
CFLAGS += -DNRF_DFU_SVCI_ENABLED
CFLAGS += -DNRF_DFU_TRANSPORT_BLE=1
CFLAGS += -DNRF_SD_BLE_API_VERSION=6
CFLAGS += -DS132
CFLAGS += -DSOFTDEVICE_PRESENT
CFLAGS += -DNRF_LOG_USES_RTT=1
CFLAGS += -DSWI_DISABLE0
CFLAGS += -DARM_MATH_CM4
CFLAGS += -D__HEAP_SIZE=1024 -D__STACK_SIZE=2048
CFLAGS += -mcpu=cortex-m4
CFLAGS += -mthumb -mabi=aapcs
CFLAGS += -Wall -Werror -O3 -g3 -Wfatal-errors
CFLAGS += -Wno-error=misleading-indentation -Wno-error=unused-variable
CFLAGS += -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=implicit-function-declaration -Wno-error=pointer-compare
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
# keep every function in separate section, this allows linker to discard unused ones
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
CFLAGS += -fno-builtin --short-enums

DEPS += $(PROJECT_SOURCE_DIR)/Application/config/ffconf.h \

# C++ flags common to all targets
CXXFLAGS += \

# Assembler flags common to all targets
ASMFLAGS += -x assembler-with-cpp -g3
ASMFLAGS += -DBLE_STACK_SUPPORT_REQD
ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
ASMFLAGS += -DNRF52
ASMFLAGS += -DFREERTOS
ASMFLAGS += -DNRF52832_XXAA
ASMFLAGS += -DNRF52_PAN_12
ASMFLAGS += -DNRF52_PAN_15
ASMFLAGS += -DNRF52_PAN_20
ASMFLAGS += -DNRF52_PAN_31
ASMFLAGS += -DNRF52_PAN_36
ASMFLAGS += -DNRF52_PAN_51
ASMFLAGS += -DNRF52_PAN_54
ASMFLAGS += -DNRF52_PAN_55
ASMFLAGS += -DNRF52_PAN_58
ASMFLAGS += -DNRF52_PAN_64
ASMFLAGS += -DNRF52_PAN_74
ASMFLAGS += -DNRF_DFU_SVCI_ENABLED
ASMFLAGS += -DNRF_DFU_TRANSPORT_BLE=1
ASMFLAGS += -DNRF_SD_BLE_API_VERSION=6
ASMFLAGS += -DS132
ASMFLAGS += -DSOFTDEVICE_PRESENT
ASMFLAGS += -DNRF_LOG_USES_RTT=1
ASMFLAGS += -DSWI_DISABLE0
ASMFLAGS += -DARM_MATH_CM4
ASMFLAGS += -D__HEAP_SIZE=1024 -D__STACK_SIZE=2048

# Linker flags
#LDFLAGS += -mthumb -mabi=aapcs -L$(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
LDFLAGS += -mthumb -mabi=aapcs -L$(SDK_ROOT)/modules/nrfx/mdk -T$(LINKER_SCRIPT)
LDFLAGS += -mcpu=cortex-m4
LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
# let linker to dump unused sections
LDFLAGS += -Wl,--gc-sections
# use newlib in nano version
LDFLAGS += --specs=nano.specs

# Add standard libraries at the very end of the linker input, after all objects
# that may need symbols provided by these libraries.
LIB_FILES += -lc -lnosys -lm

.PHONY: $(TARGETS) default all clean help flash flash_softdevice

# Default target - first one defined
default: nrf52832_xxaa

# Print all targets that can be built
help:
@echo following targets are available:
@echo nrf52832_xxaa

LINKER_SCRIPT := ourProject.ld
TEMPLATE_PATH := ../Tools

include $(TEMPLATE_PATH)/Makefile.common

$(foreach target, $(TARGETS), $(call define_target, $(target)))

# Flash the program
flash: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex
@echo Flashing: $<
nrfjprog --program $< -f nrf52 --sectorerase
nrfjprog --reset -f nrf52

# Flash softdevice
flash_softdevice:
@echo Flashing: s132_nrf52_6.1.1_softdevice.hex
nrfjprog --program $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_6.1.1_softdevice.hex -f nrf52 --sectorerase
nrfjprog --reset -f nrf52

erase:
nrfjprog --eraseall -f nrf52

 ==============================================================================

The orange one give me a lot of undefine reference (181 errors).

The green one give me this error : 

Linking target: _build/nrf52832_xxaa.out
"make" -s --no-print-directory -f "../../../../nRF5_SDK_15.3.0_59ac345/components/toolchain/gcc/dump.mk" VARIABLE=CONTENT_TO_DUMP > _build/nrf52832_xxaa.in
'C:/Program Files (x86)/GNU Tools ARM Embedded/7 2018-q2-update/bin/arm-none-eabi-gcc' -mthumb -mabi=aapcs -L../../../../nRF5_SDK_15.3.0_59ac345/components/toolchain/gcc -Tkassius.ld -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs @_build/nrf52832_xxaa.in -Wl,-Map=_build/nrf52832_xxaa.map -o _build/nrf52832_xxaa.out
c:/program files (x86)/gnu tools arm embedded/7 2018-q2-update/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot open linker script file nrf5x_common.ld: No such file or directory
collect2.exe: error: ld returned 1 exit status

Of course there is no more nrf5x_common.ld in the folder of gcc (TEMPLATE_PATH). It is in the folder mdk now. 

So it looks that I should add some libraries paths or something like that in the makefile or modifying something in the Makefile.common... ? 

Thank you a lot in advance for your help.

Best regards,

Alan

Parents
  • Hi,

    I cannot find any reference to nrf5x_common.ld in SDK 15.3.0. The local linker scripts in the project directories includes nrf_common.ld. Could you try to change your linker script to include this file instead?

    Best regards,
    Jørgen

  • Hi Jorgen, 

    Thank you for answer. I tried to change my linker script with nrf_common.ld instead. The same, it does not find it... 

    Linking target: _build/nrf52832_xxaa.out
    "make" -s --no-print-directory -f "../../../../nRF5_SDK_15.3.0_59ac345/components/toolchain/gcc/dump.mk" VARIABLE=CONTENT_TO_DUMP > _build/nrf52832_xxaa.in
    'C:/Program Files (x86)/GNU Tools ARM Embedded/7 2018-q2-update/bin/arm-none-eabi-gcc' -mthumb -mabi=aapcs -L../../../../nRF5_SDK_15.3.0_59ac345/components/toolchain/gcc -TourProject.ld -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs @_build/nrf52832_xxaa.in -Wl,-Map=_build/nrf52832_xxaa.map -o _build/nrf52832_xxaa.out
    c:/program files (x86)/gnu tools arm embedded/7 2018-q2-update/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot open linker script file nrf_common.ld: No such file or directory
    collect2.exe: error: ld returned 1 exit status
    make: *** [../Tools/Makefile.common:295: _build/nrf52832_xxaa.out] Error 1

    Have you other suggestions please ? 

    Regards,

    Alan

Reply
  • Hi Jorgen, 

    Thank you for answer. I tried to change my linker script with nrf_common.ld instead. The same, it does not find it... 

    Linking target: _build/nrf52832_xxaa.out
    "make" -s --no-print-directory -f "../../../../nRF5_SDK_15.3.0_59ac345/components/toolchain/gcc/dump.mk" VARIABLE=CONTENT_TO_DUMP > _build/nrf52832_xxaa.in
    'C:/Program Files (x86)/GNU Tools ARM Embedded/7 2018-q2-update/bin/arm-none-eabi-gcc' -mthumb -mabi=aapcs -L../../../../nRF5_SDK_15.3.0_59ac345/components/toolchain/gcc -TourProject.ld -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs @_build/nrf52832_xxaa.in -Wl,-Map=_build/nrf52832_xxaa.map -o _build/nrf52832_xxaa.out
    c:/program files (x86)/gnu tools arm embedded/7 2018-q2-update/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot open linker script file nrf_common.ld: No such file or directory
    collect2.exe: error: ld returned 1 exit status
    make: *** [../Tools/Makefile.common:295: _build/nrf52832_xxaa.out] Error 1

    Have you other suggestions please ? 

    Regards,

    Alan

Children
No Data
Related