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

How do I set flash_placement.xml for nRF52 bootloader in SES?

I've seen several similar questions -- none of which were concerned with the bootloader project.

I believe the linker is looking for sections called .noinit and .bootloaderSettings. I think these need to be specified in flash_placement.xml in order to generate the correct .ld file.

I have experimented with adding

<ProgramSection alignment="4" load="Yes" name=".bootloaderSettings" start="$(BOOTLOADER_SETTINGS_START:)" size="$(BOOTLOADER_SETTINGS_SIZE:)" />

and

<ProgramSection alignment="4" load="no" name=".noinit" start="$(NOINIT_START:)" size="$(NOINIT_SIZE:)" />

in various configurations. The linker still complains about overlaps and sizes. A sample placement file for the bootloader project would be greatly appreciated.


EDIT

I have managed to have the project build after carefully inspecting my flash_placement.xml file. I have attached it below for reference. I will report back if it is a successful configuration.

<!DOCTYPE Linker_Placement_File>
<Root name="Flash Section Placement">
  <MemorySegment name="$(FLASH_NAME:FLASH)" start="0x00000000" size="0x00080000">
    <ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START:)" />
    <ProgramSection alignment="4" load="Yes" name=".init" />
    <ProgramSection alignment="4" load="Yes" name=".init_rodata" />
    <ProgramSection alignment="4" load="Yes" name=".text" />
    <ProgramSection alignment="4" load="Yes" name=".dtors" />
    <ProgramSection alignment="4" load="Yes" name=".ctors" />
    <ProgramSection alignment="4" load="Yes" name=".rodata" />
    <ProgramSection alignment="4" load="Yes" name=".ARM.exidx" address_symbol="__exidx_start" end_symbol="__exidx_end" />
    <ProgramSection alignment="4" load="Yes" runin=".fast_run" name=".fast" />
    <ProgramSection alignment="4" load="Yes" runin=".data_run" name=".data" />
    <ProgramSection alignment="4" load="Yes" runin=".tdata_run" name=".tdata" />
    <ProgramSection alignment="4" load="Yes" name=".bootloaderSettings" start="$(BOOTLOADER_SETTINGS_START:)" size="$(BOOTLOADER_SETTINGS_SIZE:)" />
  </MemorySegment>
  <MemorySegment name="$(RAM_NAME:RAM)" start="0x20000000" size="0x00008000" >
    <ProgramSection alignment="0x100" load="No" name=".vectors_ram" start="$(RAM_START:$(SRAM_START:))" />
    <ProgramSection alignment="4" load="No" name=".fast_run" />
    <ProgramSection alignment="4" load="No" name=".data_run" />
    <ProgramSection alignment="4" load="No" name=".tdata_run" />
    <ProgramSection alignment="4" load="No" name=".bss" />
    <ProgramSection alignment="4" load="No" name=".tbss" />
    <ProgramSection alignment="4" load="No" name=".non_init" />
    <ProgramSection alignment="4" load="No" name=".noinit" start="$(NOINIT_START:)" size="$(NOINIT_SIZE:)" />
    <ProgramSection alignment="4" size="__HEAPSIZE__" load="No" name=".heap" />
    <ProgramSection alignment="8" size="__STACKSIZE__" load="No" place_from_segment_end="Yes" name=".stack" />
    <ProgramSection alignment="8" size="__STACKSIZE_PROCESS__" load="No" name=".stack_process" />
  </MemorySegment>
  <MemorySegment name="$(UICR_NAME:UICR)" start="0x10001000" size="0x80">
    <ProgramSection alignment="4" load="No" name=".uicrBootStartAddress" start="$(UICR_BOOTLOADER_START)" size="0x04" />
  </MemorySegment>
  <MemorySegment name="$(FLASH2_NAME:FLASH2)">
    <ProgramSection alignment="4" load="Yes" name=".text2" />
    <ProgramSection alignment="4" load="Yes" name=".rodata2" />
    <ProgramSection alignment="4" load="Yes" runin=".data2_run" name=".data2" />
  </MemorySegment>
  <MemorySegment name="$(RAM2_NAME:RAM2)">
    <ProgramSection alignment="4" load="No" name=".data2_run" />
    <ProgramSection alignment="4" load="No" name=".bss2" />
  </MemorySegment>
</Root>

EDIT

My current challenge is writing FLASH_START to uicr bootloaderstart The generated ld file contains:

  __uicrBootStartAddress_load_start__ = 0x10001014;
  .uicrBootStartAddress 0x10001014 (NOLOAD) : AT(0x10001014)
  {
    __uicrBootStartAddress_start__ = .;
    *(.uicrBootStartAddress .uicrBootStartAddress.*)
    . = ALIGN(MAX(__uicrBootStartAddress_start__ + 0x04 , .), 4);
  }
  __uicrBootStartAddress_end__ = __uicrBootStartAddress_start__ + SIZEOF(.uicrBootStartAddress);
  __uicrBootStartAddress_size__ = SIZEOF(.uicrBootStartAddress);
  __uicrBootStartAddress_load_end__ = __uicrBootStartAddress_end__;

  __UICR_segment_used_end__ = 0x10001014 + SIZEOF(.uicrBootStartAddress);
  __UICR_segment_used_size__ = __UICR_segment_used_end__ - __UICR_segment_start__;

Which is good, but when debugging, I find the memory uninitialized (0xFF). It looks like

volatile uint32_t m_uicr_bootloader_start_address  __attribute__ ((section(".uicrBootStartAddress"))) = BOOTLOADER_REGION_START;

isn't operating as intended


EDIT (3) - solution

Seems like I needed to add 'load="Yes"' to the uicr section. That attribute's documentation wasn't terribly helpful to me, but now I know. :)

Related