Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Linker script

Hi,

I need to write a linker (ld) script for our nRF52 application. Essentially I need to combine the linker script that we already use with the scripts that exist in the nRF SDK.

The SDK examples typically use two script files: the project (example) specific, e.g. ble_app_gatts_c_gcc_nrf52.ld and generic nrf_common.ld.

The SDK declares a few custom sections, for example .fs_data which contains an initialised variable that is placed in RAM. The initialisation value is placed in the flash.

What I don't understand is what causes the LMA address of the .fs_data section to be in the flash area.

In the linker file:

.fs_data :
{
PROVIDE(__start_fs_data = .);
KEEP(*(.fs_data))
PROVIDE(__stop_fs_data = .);
} > RAM

and in the generated map file (note "load address 0x00038da4"):

.fs_data 0x200028f8 0x14 load address 0x00038da4
0x200028f8 PROVIDE (__start_fs_data = .)
*(.fs_data)
.fs_data 0x200028f8 0x14 _build/nrf52840_xxaa/fds.c.o
0x200028f8 m_fs
0x2000290c PROVIDE (__stop_fs_data = .)

This seems to be the effect of the INSERT AFTER command. If I remove the insert command, LMA and VMA of the fs_data section are equal and in the RAM area. But I can not replicate this behaviour in my linker script. Regardless whether INSERT is present or not in my script, I get LMA=VMA and in RAM. Below is a fragment of my resulting map file.

.fs_data        0x20003e28       0x14
                0x20003e28                PROVIDE (__start_fs_data = .)
 *(.fs_data)
 .fs_data       0x20003e28       0x14 build/release/out/c/fds.o
                0x20003e28                m_fs
                0x20003e3c                PROVIDE (__stop_fs_data = .)

Related