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

Calculate available space to use flash data read and write

Hello Nordic Team

I am working on nRF52832 MCU, SDK-11. I want to calculate available space so that I can save custom sensors data in chip.

According to datasheet we have space 512 KB. Here Bootloader  occupied 24 KB, Softdevice occupied 108 KB, Application need at least 100 KB so total will be 232 KB and available space is 280 KB.

NOTE: Also this application supports the DFU so we need to reserve some space for that.

Questions: 

1. How much space need to reserve for DFU?

2. In above calculation we have 280 KB space left. So, how much space I can use for use for save custom sensors data?

3. If you provide any calculation then it will be great.

Please let me know my question is not clear or you need any more information.

Thanks

Rajneesh

  • Hi,

    1. You do not strictly need to reserve room for DFU. The bootloader will use dual bank if there is available flash but will fall back to single bank if there is no additional room. That means that the bootloader would delete the application so that the new application could be written directly to the same location in flash, not needing any temporary flash memory.

    2. You can use all available flash for sensor data. However, it seems you did not include flash needed for the peer manager (storing BLE bonding information) in your calculation. This uses FDS. Typically, you will use three flash pages for that, but it is configurable (depend on how many bonds you want to be able to store).

    3. I think your calculations were correct, except for the missing FDS pages for the peer manager. Essentially you need the following:

    1. MRB (Fixed for a given SoftDevice version)
    2. SoftDevice (Fixed for a given SoftDevice version)
    3. Application (Variable depending on your application)
    4. FDS pages (Configurable in your applications sdk_config.h)
    5. Bootloader (including bootloader settings page. Given by the bootloader / SDK version)
    6. Any remaining flash can be used as you like.
  • Thanks Einor for quick reply.

    I have two questions:

    1. Does 1st and 2nd are different? If yes then how much space required for MRB?

    2. Regarding FSD pages, How much minimum space required?

    When I get above two answer I can calculate the available space in my system.

  • Hi,

    1. I was not precise enough at this point. The MBR is included in the SoftDevice, so if you use the SoftDevice you do not have to account for the MBR. (However, it is also available standalone so if you do not use the SoftDevice but for example need a USB bootloader for the nRF52840, then you need the MBR and would account for its size.)

    2. The minimum number of FDS pages is 2, as one of the pages are reserved for garbage collection. The SDK examples that only need the peer manager typically use 3 FDS pages (FDS_VIRTUAL_PAGES in the projects sdk_config.h). If you need to store more data with FDS, you should increase the number of pages accordingly.

  • Thanks.

    I will not count FSD size because I am softdevice is used in my project.

    One question, How can I know the starting location where I need to start data recording. And what is the last location?

  • I am not sure I understand. The FDS has nothing to do with the SoftDevice. If you use it (directly or indirectly because you use a module that use it, such as the Peer manager), then you need to account for it. If you don't use it, then you don't account for it.

    If you want to use raw flash for data recording, then you should account for everything that use flash. Once that is accounted for, you can use everything else for whatever you want. Typically you would have available flash between the end of the application (lower address) and the start of FDS pages (if used) or bootloader (higher address). Essentially look at the list in my original answer, and fill in the start and end address for each point. (You can even draw a memory layout ad done here). That will show you exactly what flash  you have available at which start address.

Related