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

Flash Data Storage & Bootloader Settings

Hi,

I have a custom application running on a custom PCBA using the nRF52840 MCU. The Softdevice (S140, v7.0.1) is also utilised because the main application supports BLE functionality.

The main application together with the Softdevice is running correctly.

However, we are now adding firmware update support and noticed the writing of the bootloader settings to the flash causes the application to fail. Specifically, it appears to be failing at the following SDK (16.0.0) code:

The error code returned by the fds_init function was "FDS_ERR_NO_PAGES".

My understanding is that the peer manager data is stored in flash starting from address 0xFD000 and I have verified this by confirming the magic "0xDEADC0DE" number was stored at that flash location. In my configuration, the amount of flash reserved for flash data storage is as follows:

#define FDS_VIRTUAL_PAGES 3
#define FDS_VIRTUAL_PAGE_SIZE 1024
#define FDS_VIRTUAL_PAGES_RESERVED 0

Which would equate to addresses: 0xFD000, 0xFE000, and 0xFF000.

Unfortunately, the flash address range used for flash data storage appears to conflict with those used for the bootloader settings, which appears to be 0xFF000 and 0xFE000 (backup).

I did some experimentation and figured out that if I disable the backup option when generating the bootloader settings, then all the software combined works correctly.

I would like to understand if it is a mis-configuration on my part (e.g. For FDS_VIRTUAL_PAGES and / or FDS_VIRTUAL_PAGES_RESERVED) that is causing the flash data storage failure. All suggestions welcomed.

Thanks to all in advance.

Parents
  • Hello,

    Did you erase the flash before you flashed the bootloader and application?

    Ideally, if you start with a blank flash, and flash the BL, APP and the SD, then the fds module should check whether or not there is a bootloader present:

     fds_init() -> flash_subsystem_init() -> flash_bounds_set() -> flash_end_addr():

    uint32_t end_addr = (bootloader_addr != 0xFFFFFFFF) ? bootloader_addr : (code_sz * page_sz);

    When it fails, what is end_addr? Is it moved down according to the bootloader address?

    Best regards,

    Edvin

  • Hi Edvin,

    Apologies for the late reply but I got distracted with other work. When I get a bit of spare time, I'll try your suggestion to check the end_addr location when the application startup fails and get back to you with my findings.

    Thanks.

Reply Children
No Data
Related