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

Write Value in Flash during Compiling/Linking

Hello,

I have exercised the flash driver and that is working fine. I want to save a certain value into a specific address in NVM and I want that part of the .hex file. I am assuming this would be done using __attribute or some other GCC symbol, but I have never done this with SES or a placement file.

Let's say I wanted to save 16 bytes at a fixed address in NVM. How would I do that by allocation a section and adding the correct declaration in the code?

I appreciate the help.

  • Hi,

    We do something like that in the Secure DFU bootloader, where in nrf_dfu_settings.c you will find:

        uint8_t m_dfu_settings_buffer[BOOTLOADER_SETTINGS_PAGE_SIZE]
            __attribute__((section(".bootloader_settings_page")))
            __attribute__((used));

    What ".bootloader_settings_page" refers to in this piece of code, is the following memory segment from the flash_placement.xml file for the project:

      <MemorySegment name="bootloader_settings_page" start="0x000FF000" size="0x1000">
        <ProgramSection alignment="4" keep="Yes" load="No" name=".bootloader_settings_page" address_symbol="__start_bootloader_settings_page" end_symbol="__stop_bootloader_settings_page" start = "0x000FF000" size="0x1000" />
      </MemorySegment>

    I hope that helps!

    Regards,
    Terje

Related