Persistent storage section in NRF52840 Flash

Hi all,

On a BLE project I was working using version 2.5.0 of the VS Code dev environment I was able to set up a partition where I could store non volatile data, such as BLE name, serial number, etc.

I have updated to 3.11 and if I understand correctly the IDE uses Sysbuild now. The old configuration does not work anymore but I need to get that storage space back up.

I'm trying to set up a small partition at the last 4KBytes of the flash memory so I can update those parameters when required. That means that my main memory would be 996 KBytes long with a last section of 4 KBytes.

I'm struggling to find an example how to define the partition and how to use the Zephyr API to delete, read or write that section.

Any help or pointers to documentation, examples, etc, is appreciated.

Kind regards,

Alberto 

Parents
  • Thank you Amanda,

    I did that, yes, it seems to work, the memory report shows the correct partitions:

    My problem now is that I cannot erase or flash section "custom" above, the micro crashes when calling:

        nrfx_nvmc_page_erase(0xFF000);
        nrfx_nvmc_words_write(0xFF000, (uint8_t*)&nv_mem_slot, sizeof(sNVMemSlotStruct)/4);

    The program already crashes when I try to erase that section. I tried enabling the "erase" bit in the config register to no avail either:

    if(!(NRF_NVMC->CONFIG & NRF_NVMC_MODE_ERASE))
    {
        LOG_INF("Enabling NVMEM Erase");
        NRF_NVMC->CONFIG |= NRF_NVMC_MODE_ERASE;
    }
    nrfx_nvmc_page_erase(0xFF000);

    Related to flash memory, my proj.conf has the following:

    CONFIG_NRFX_NVMC=y

    That used to work with revision 2.5.0 of NCS. Has anything else changed significantly?

    Kind regards,

    Alberto

Reply
  • Thank you Amanda,

    I did that, yes, it seems to work, the memory report shows the correct partitions:

    My problem now is that I cannot erase or flash section "custom" above, the micro crashes when calling:

        nrfx_nvmc_page_erase(0xFF000);
        nrfx_nvmc_words_write(0xFF000, (uint8_t*)&nv_mem_slot, sizeof(sNVMemSlotStruct)/4);

    The program already crashes when I try to erase that section. I tried enabling the "erase" bit in the config register to no avail either:

    if(!(NRF_NVMC->CONFIG & NRF_NVMC_MODE_ERASE))
    {
        LOG_INF("Enabling NVMEM Erase");
        NRF_NVMC->CONFIG |= NRF_NVMC_MODE_ERASE;
    }
    nrfx_nvmc_page_erase(0xFF000);

    Related to flash memory, my proj.conf has the following:

    CONFIG_NRFX_NVMC=y

    That used to work with revision 2.5.0 of NCS. Has anything else changed significantly?

    Kind regards,

    Alberto

Children
No Data
Related