Downsizing Flash pages (FDS_VIRTUAL_PAGES) after the fact causes FDS_ERR_NO_PAGES on fds_init()

Hi,
We have a product running on 833 in production.
Recently we noticed that our flash is running low.
To amend this, we wish to downsize the amount of FDS_VIRTUAL_PAGES (currently 17) that we have given the app.
Before testing with DFU, I have simply tested this on a device without a bootloader.
After the first init with 17, and then rehexing after downsizing FDS_VIRTUAL_PAGES to 12, I consistently receive FDS_ERR_NO_PAGES on fds_init().
When raising FDS_VIRTUAL_PAGES, even without erasing, I stop receiving the error, and fds_init terminates correctly.
Is there a way to downsize the flash pages for our prod boards?
Thanks!
Roi

  • Hi Roi,

    In principle, you can just update to a firmware variant with a different sdk_config.h configuratio, where the number of pages is smaller. With that, FDS will use fewer pages. However, you will need some custom code to run before you init FDS the first time, to handle some issues.

    1. If there is data on the pages you no longer use for FDS (those furthest down, away from the bootloader / lover addresses), this will be lost. If this is acceptable, then you can ignore it. If not, you would need to update to a temporary application that moves the data to the higher pages. This is not supported by FDS, so you would have to handle this yourself.

    2. FDS consists of data pages and a swap page. If the swap page was lost, FDS will have problems. So you need to make sure that one of the remaining pages is the swap page (which page is swap page is dynamic, and changes after every garbage collection, but there must always be done. When FDS is initialized it iterates thorough all FDS pages and initializes them, so you can simply do a similar thing yourself before initialization, and if there is no swap page among the remaining FDS pages, just perform a page erase of one of the pages. Then, this will become the swap page wen FDS is initialized. Obviously, the data that was on this page will be lost.

    So in other words, if loss of data is acceptable, this is quite straight-forward. If loss of data is not acceptable, you will need to rewrite the FDS pages yourself to move all data to the pages that will remain.

  • Thanks very much Einar!
    This seems a bit risky to us, as we may end up losing important flash data like this. 
    Thanks in any case!
    Roi

Related