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

sd_flash_write writes corrupted data when BLE is enabled

Hi,

I wrote some code that writes to the flash perfectly when BLE is not enabled but when it is enabled, some of the data are correct while others are either missing or shifted to a later address. Below is a snippet of the code:

uint32_t retval;
while(NRF_ERROR_BUSY == (retval = sd_flash_write(p_dst, p_src, num_words)));
ASSERT(NRF_SUCCESS == retval);

I'm trying to avoid pstorage since I'm want to write to a contiguous block of flash much greater then the page size.

Thanks.

Parents
  • I think the write flash require you to write per page only. You cannot cross the page boundary. What you are experiencing look like cross boundary issue. Try pstorage_store, it handle cross boundary for you. I think, can't confirm at the moment. You can try and see.

  • I'm setting the handler with softdevice_sys_evt_handler_set() after I initialize the BLE and I was able to confirm that the SD is calling my handler instead of the pstorage's throughout the lifetime of the code. With the slight delay after the sd_flash_write() call, I'm able to write to the flash properly except when I'm inside another callback such as onConnectionCallback() as I've explained above. And occasionally I would get into a hardfault if I try to ble.updateCharacteristicValue() after I call sd_flash_write().

Reply
  • I'm setting the handler with softdevice_sys_evt_handler_set() after I initialize the BLE and I was able to confirm that the SD is calling my handler instead of the pstorage's throughout the lifetime of the code. With the slight delay after the sd_flash_write() call, I'm able to write to the flash properly except when I'm inside another callback such as onConnectionCallback() as I've explained above. And occasionally I would get into a hardfault if I try to ble.updateCharacteristicValue() after I call sd_flash_write().

Children
No Data
Related