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

Reading flash with pstorage module

I am using a nrf52832 with SDK 11.0.0 and sd132. I need to add in-flash storage to my application so I'm looking at the NVMEM documentation and the pstorage module. I understand that writing to flash has some limitations as you can only write zeros and a flash page can only be written a given number of times before it has to be erased. That basically means that if you need to write random data on a flash page you need to erase it before if you want to keep it simple.

However, reading from flash should be as easy as accessing RAM memory, provided you enabled the Ren bit in the CONFIG register in NRF_NVMC->CONFIG. So theoretically you should be able to simply treat any pointer to a memory position that maps to flash as any other pointer that maps to RAM, provided you only read from it.

Is that correct? If so, is it strictly necessary to do a memcpy when you load from flash as pstorage_load function does? Is it possible to avoid calling pstorage_load and the memcpy call provided you only read that data and the application does not try to update it?

Also, I understand that you'll eventually need to erase a page before you update it so, unless you are updating that whole page, you'll need to load it first, erase it and only then you'll be able to update it with the new + old contents merged. However, I can't see any buffer in the pstorage module to hold a flash page. Might it be that this is handled internally in the soft device? If so, do I need to ensure the SD has enough memory in any way?

Parents Reply Children
No Data
Related