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

Segger Fixed Memory Allocation in Flash and SoftDevice compatibility.

Hi All,

New user here but couldn't find a concrete answer to the following question.

In PIC land I've usually allocated fixed memory using the _at_ or __attribute__ label but Segger doesn't support this. From googling I read to add a reference to the xml file, which I've done as shown below:

<!DOCTYPE Board_Memory_Definition_File>
<root name="nRF52810_xxAA">
  <MemorySegment access="ReadOnly" name="FLASH1" size="0x00030000" start="0x00000000" />
  <MemorySegment access="Read/Write" name="RAM1" size="0x00006000" start="0x20000000" />
  <MemorySegment access="Read/Write" name="CODE_RAM1" size="0x00006000" start="0x00800000" />

  <MemorySegment name="$(FLASH_NAME:FLASH)">
    <ProgramSection alignment="4" load="Yes" name=".settingsStore" start="0x00000000" />
  </MemorySegment>
</root>

You can see that the start is 0x0 which is probably a bad idea, likely the entry point of the application if it's like PIC's. A related question to ask at this point is where does a SoftDevice get placed in Flash?

Back to the main question, I then have the following to take up a 4kb page of flash (actual usage is 1kb so plenty for futureproofing).

static const union {
  struct settingsProto settings;
  uint8_t pad[FLASH_PAGE_SIZE_BYTES];
} store __attribute__((section(".settingsStore"))); // reserve flash page

Upon build I receive the error:

unplaced section: .settingsStore [config.o], size=4000, align=4



  • DId you remove the old Memory Segment for .settingsStore from the flash_placement.xml file?

    <MemorySegment name="$(FLASH_NAME:FLASH)">
        <ProgramSection alignment="4" load="Yes" name=".settingsStore" start="0x00000000" />
      </MemorySegment>

  • So to get this value I have to compile a little code, add the softdevice and execute then see what it returns, but the code won't have the correct offsets so won't run. Seems to be catch 22.

  • I did, still errors. Currently:

    <!DOCTYPE Linker_Placement_File>
    <Root name="Flash Section Placement">
      <MemorySegment name="$(FLASH_NAME:FLASH);FLASH1">
        <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" />
      </MemorySegment>
      <MemorySegment name="$(RAM_NAME:RAM);SRAM;RAM1">
        <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=".bss" />
        <ProgramSection alignment="4" load="No" name=".tbss" />
        <ProgramSection alignment="4" load="No" name=".tdata_run" />
        <ProgramSection alignment="4" load="No" name=".non_init" />
        <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="$(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>
      <MemorySegment name="settingsStore" start="0x0002F000" size="0x1000">
        <ProgramSection alignment="4" keep="Yes" load="No" name=".settingsStore" address_symbol="__start_main_settings_page" end_symbol="__stop_main_settings_page" start = "0x0002F000" size="0x1000" />
      </MemorySegment>
    </Root>

  • The sd_softdevice_enable call should return regardless of which RAM_START address that is used by the application. You can set the RAM_START address to the minimum RAM requirement stated in the SoftDevice release notes of the SoftDevice you are using. 

  • I'm still either confused or unknowledgeable about how to retrieve APP_CODE_BASE.

    If the SoftDevice is flashed it takes over the 0x0 address. After it's done it's init it willl jump to APP_CODE_BASE address.

    If I can't compile a program because I don't know APP_CODE_BASE to add to the linker then how can I call SoftDevice's API in debug mode to find out what APP_CODE_BASE is? Why doesn't Nordic just publish it in the spec for the chips the SoftDevice works with instead of this merry-go-round?

Related