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

Problems with using Flash and fstorage

I am playing with flash and fstorage lib. I finally got it up and running - I can write and read to flash without having fatal errors. But it's not working as expected. I write "hello world" to 0x3E000 and right after I read some crappy string from that address.

So I tried the flash_fstorage example, compiled and run and I can see the same behaviour. See the output from the logs:

What is going wrong? Do I have my flash somehow corrupted?

Thank you.

EDIT 1:

I tested with another board. I erased the memory (make erase) and then flashed and run the flash_fstorage. The result is the same, only the string that I read back is different: "hL(o world".

EDIT 2:

nrf_fstorage_write() fires a NRF_FSTORAGE_EVT_WRITE_RESULT event which I can handle with evt_handler() from NRF_STORAGE_DEF. But nrf_fstorage_read() DOES NOT fire any event of this type - the evt_handler is not called. Why?

This is my evt_handler implementation:

  switch (p_evt->id) {
    case NRF_FSTORAGE_EVT_WRITE_RESULT:
      NRF_LOG_INFO("--> storage Event received: wrote %d bytes at address 0x%x.", p_evt->len, p_evt->addr);
    break;
    case NRF_FSTORAGE_EVT_ERASE_RESULT:
      NRF_LOG_INFO("--> storage Event received: erased %d page from address 0x%x.", p_evt->len, p_evt->addr);
    break;
    case NRF_FSTORAGE_EVT_READ_RESULT:
      NRF_LOG_INFO("--> storage Event received: erased %d page from address 0x%x.", p_evt->len, p_evt->addr);
    break;
    default:
      NRF_LOG_INFO("--> storage Event received: unknown action %d, %d page @ address 0x%x.", p_evt->id, p_evt->len, p_evt->addr);
    break;
  }

Parents Reply Children
No Data
Related