nRF51822 memory layout and compilation

Hello, guys.

We are using nRF51822 SoC together with nRF5 v12.3.0 SDK.

Here is what the memory footprint of our application code should look like:

We have SoftDevice, Application area, Application data area (for flash data storage and Peer Manager), Bootloader, ... In the image above you can clearly see the borders between different memory areas that we tried to specify in our application linker and bootloader linker files.

Application linker:

MEMORY
{
  FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x1E800
  RAM (rwx) :  ORIGIN = 0x20002028, LENGTH = 0x5f58
  /** Location of non initialized RAM. */
  NOINIT (rwx) :  ORIGIN = 0x20007F80, LENGTH = 0x80
}

Bootloader linker:

MEMORY
{
  FLASH (rx) : ORIGIN = 0x3A400, LENGTH = 0x5800
  RAM (rwx) :  ORIGIN = 0x20002C00, LENGTH = 0x5380

  /** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
   *  from application to bootloader when using buttonluss DFU OTA.
   */
  NOINIT (rwx) :  ORIGIN = 0x20007F80, LENGTH = 0x80

  /** Location of bootloader setting in at the last flash page. */
  BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0003FC00, LENGTH = 0x0400

  /** Location in UICR where bootloader start address is stored. */
  UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
}

In the sdk_config.h file, we have reserved 3 pages for flash data storage (FDS) and specified that the virtual page size is equal to 1024 bits:

#define FDS_VIRTUAL_PAGES 3

#define FDS_VIRTUAL_PAGE_SIZE 1024

What we have noticed though is that, after adding some new features to the code, we come to the point when the device continuously reboots due to some error that happens during the FDS initialization (fds_record_write() function). We have caught this error with the app_error_fault_handler():

...

It seems that our application code overwrites the Application data flash area and thus corrupts the flash data storage (FDS) system. Our expectation was that the code will not compile and link successfully when the code is too big to fit into the Application flash area.

Do you have any idea what we are doing wrong here? Perhaps the borders between the flash areas have not been set properly (e.g. the border needs to be multiple of flash page size...)?

Thanks in advance for your time and efforts.

Sincerely,
Bojan.

Parents Reply Children
No Data
Related