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



  • I'm getting somewhere now. I've had to play with the common build properties, copying them from an example project.

    The .settingsStore appears to be working, I shall test tomorrow.

    I still don't know how to attain the correct start address that the softdevice will jump to, but I suspect it is the FLASH_START value in the macro list pulled from an example porject, so I should modify FLASH_SIZE and RAM_SIZE for the 810?


    FLASH_PH_START=0x0

    FLASH_PH_SIZE=0x80000

    RAM_PH_START=0x20000000

    RAM_PH_SIZE=0x10000

    FLASH_START=0x26000

    FLASH_SIZE=0x5a000

    RAM_START=0x200022f0

    RAM_SIZE=0xdd10





  • HI Snoopy, 

    The SoftDevice expects the application to be placed on the first flash page after the SoftDevice. The SoftDevice flash requirements are listed in the SoftDevice release notes. The SoftDevice that are supported on the nRF52810 are listed in SDKs and SoftDevices. I recommend using the S112 or S113 v7.0.1

    The release notes can be found in the nRF5_SDK_16.0.0_684aa2c\components\softdevice\s1xx\doc foler

    S112 v7.0.1 Release Notes

    The combined MBR and SoftDevice memory requirements for this version are as follows:

    • Flash: 100.0 kB (0x19000 bytes)
    • RAM: 3.7 kB (0xeb8 bytes). This is the minimum required memory. The actual requirements depend on the configuration chosen at sd_ble_enable() time.

    S113 v7.0.1 Release Notes

    The combined MBR and SoftDevice memory requirements for this version are as follows:

    • Flash: 112.0 kB (0x1C000 bytes)
    • RAM: 4.4 kB (0x1198 bytes). This is the minimum required memory. The actual requirements depend on the configuration chosen at sd_ble_enable() time

    Best regards

    Bjørn

  • I'll go with s112. I found in the s112 pdf the value - APP_CODE_BASE 0x00018000.

    So now I need to find out how to set this in segger so the linker offsets the application code addresses.

    One more thing, that memory I reserved for settings at the end of the flash. When debugging is the whole flash erased or only those touched by the generated code addresses?  I'd like to retain the settings across debugging if possible (in MPLABX there is a feature to copy over the data before flash and then place back into place).




  • snoopy20 said:
    So now I need to find out how to set this in segger so the linker offsets the application code addresses.

    Set the following flash placement macros in the SES project

    FLASH_PH_START=0x0

    FLASH_PH_SIZE=0x30000

    RAM_PH_START=0x20000000

    RAM_PH_SIZE=0x6000

    FLASH_START=0x18000

    FLASH_SIZE=0x18000

    RAM_START=0x20001198

    RAM_SIZE=0x4e68

    THe only thing you may have to adjust is the RAM_START and RAM_SIZE depending on the returned values from sd_ble_enable()

    snoopy20 said:
    One more thing, that memory I reserved for settings at the end of the flash. When debugging is the whole flash erased or only those touched by the generated code addresses?  I'd like to retain the settings across debugging if possible (in MPLABX there is a feature to copy over the data before flash and then place back into place).

     You should be able to attach to a running program without reflashing the entire binary in SES. Target > Attach Debugger

  • OK, so the SoftDevice consumes 100Kb. Let's forget the RAM, I have plenty for now.

    100Kb / 4

    How do I tell segger to offset the address of my application to 0x19000 (which is a page start)?

    Right now I'm compiling but the debugger won't break on the first instruction inside main(), I guess because I haven't set the correct offset.


Related