I am running into an issue with the Fstorage Library with SDK14 that I did not have using SDK12.
When I am not connected to BLE I can erase and write flash with no issues.
When I am connected to BLE I am now getting timeouts errors when I try to erase 1 flash page. (see code below, I get ERR=13)
error = nrf_fstorage_erase(&fstorage, fstorage.start_addr, 1, NULL);
My BLE is only a simple NUS peripheral. I would think there should be plenty of time for the soft device to erase the flash, right?
Is there a way to change BLE settings so I can get consistent erases and flashes? Perhaps higher connection intervals?
My handler and my sdk_config.h settings are below.
static void fstorage_evt_handler(nrf_fstorage_evt_t * p_evt) { if (p_evt->result != NRF_SUCCESS) { NRF_LOG_INFO("fs_storage - evt failed ERR=%d", p_evt->result); nvWriteState = NVRAM_WRITE_ERROR; } else { NRF_LOG_INFO("fs_storage - evt complete"); fs_callback_flag = 0; } }
// <e> NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library //========================================================== #ifndef NRF_FSTORAGE_ENABLED #define NRF_FSTORAGE_ENABLED 1 #endif // <h> nrf_fstorage_sd - Implementation using the SoftDevice. // <i> Configuration options for the fstorage implementation using the SoftDevice. //========================================================== // <o> NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations. // <i> Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. #ifndef NRF_FSTORAGE_SD_QUEUE_SIZE #define NRF_FSTORAGE_SD_QUEUE_SIZE 8 #endif // <o> NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy. // <i> Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. // <i> The SoftDevice might fail to schedule flash access due to high BLE activity. #ifndef NRF_FSTORAGE_SD_MAX_RETRIES #define NRF_FSTORAGE_SD_MAX_RETRIES 10 #endif // <o> NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation. // <i> This value must be a multiple of four. // <i> Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. // <i> This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. // <i> That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. #ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE #define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 #endif