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

nrf_dfu_flash_* callbacks don't get called

I am modifying the bootloader_secure_ble code to receive a serial number via BLE and store it in flash. However, whenever I call nrf_dfu_flash_store or nrf_dfu_flash_erase, the callback is never called. Here is my code (stripped of other functions and comments):

#define FLASH_SERIAL_ADDR 0x77000
volatile static uint8_t fs_callback_flag;

void serial_flash_callback(fs_evt_t const * const evt, fs_ret_t result){
	fs_callback_flag = 0;
}
void setSerialNumber(uint8_t const * const src){
	uint32_t * dest = (uint32_t *)FLASH_SERIAL_ADDR;
	
	fs_callback_flag = 1;
	fs_ret_t ret = nrf_dfu_flash_store(dest, (uint32_t *)&src[0], 16, serial_flash_callback);
	if (ret != FS_SUCCESS){
	}
	while(fs_callback_flag == 1)  {}
}

Even though the callback never gets called, the flash operation completes (I can read the flash via nrfjprog or via the BLE characteristic).

I've read several other similar questions, and some have suggested making sure that fs_init gets called after the SD gets initialized, but it appears that the nrf_dfu_flash library already accounts for that. Am I missing something?

Related