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
  • The S110 stack provides a pstorage API that uses the sd_flash functions. I took a look at the function used to get data out of flash and it is merely using a memcpy call to get the data out of the program space. I'd guess you can do the same with the S210 stack.

  • 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?

Reply
  • 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?

Children
No Data
Related