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

How to read from flash?

In s210 there are functions sd_flash_page_erase, sd_flash_protect, and sd_flash_write. There is no sd_flash_read.

How do I read from flash? I can write to is using sd_flash_write, but how do I later read this data?

Parents Reply Children
  • I've found (using the Keil debugger) that my problem is writing to flash, not reading from.

    I'm doing this:

    uint32_t pg_size = NRF_FICR->CODEPAGESIZE;
    uint32_t pg_num = NRF_FICR->CODESIZE - 1;
    
    uint32_t *addr;
    addr = (uint32_t *)(pg_size * pg_num);
    
    sd_flash_write(addr, flashList, 4);
    

    Where flashList is an integer array of stuff I want to write to the flash. Those first few lines come from the flash example.

    However, when I check the location in memory pointed at by addr in the debugger, I get all FFs, which is probably why flash read is seeming not work (giving all Fs).

    Any ideas?

  • I can suggest a couple of things to try:

    1. Check the error code from your call to sd_flash_write and make sure it is returning NRF_SUCCESS
    2. Make sure the stack has returned a NRF_EVT_FLASH_OPERATION_SUCCESS before reading the memory.
    3. If the S210 stack provides a pstorage API like the S110, use that as it hides all of the nit picky details for you.
Related