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

sd_flash_page_erase problem

Hi, I'm using the ant_broadcast_rx example for my nRF51422 with S310 softdevice sdk 10.0.0. I've configured and changed all parameters of the example to make it work with the S310 softdevice, everything is working. At this point I want to include a piece of code to make the application restart in bootloader, i've seen the routine in the ota_tester example, i've added the code but the application hangs on the sd_flash_page_erase() function. Inside ant_boot_settings_api.c this piece of code make me think a bit:

volatile uint8_t mb_flash_busy = false;
/*
 * sd_flash_page_erase() and sd_flash_write() generates an event at SD_EVT_IRQHandler
 * Please include run this function inside SD_EVT_IRQHandler
 *
 */
void ant_boot_settings_event (uint32_t ulEvent)
{
    if ((ulEvent == NRF_EVT_FLASH_OPERATION_SUCCESS) || (ulEvent == NRF_EVT_FLASH_OPERATION_ERROR))
    {
        mb_flash_busy = false;
    }
}

The mb_flash_busy remains true, i've tried many approaches to try to trigger the ant_boot_settings_event function inside the SD_EVT_IRQHandler to wait and set mb_flash_busy but it looks very tricky.

This is my softdevice setup

static void softdevice_setup(void)
{
    uint32_t err_code;
	
	err_code = softdevice_ant_evt_handler_set(ant_evt_dispatch);
    APP_ERROR_CHECK(err_code);
	
	err_code = softdevice_handler_init(NRF_CLOCK_LFCLKSRC_SYNTH_250_PPM, NULL, 0, NULL);
    APP_ERROR_CHECK(err_code);
	
		
	err_code = ant_stack_static_config();
    APP_ERROR_CHECK(err_code);
    
	// Also tried this but not working...
	//err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
	//APP_ERROR_CHECK(err_code);
		
		
		
}

Any ideas? Thanks Max

Related