NRF_EVT_FLASH_OPERATION_SUCCESS event never fired

I am using the following code to enable the softdevice s130, which seems to run successfully:

    err_code = softdevice_enable(&ble_enable_params);
    APP_ERROR_CHECK(err_code);

    // Subscribe for BLE events.
    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);

    err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);

My sys_evt_dispatch then tries to filter out FLASH events, but never gets called:

void sys_evt_dispatch(uint32_t sys_evt) {
    NRF_LOG_WARNING("evt is flash: %d\n", sys_evt == NRF_EVT_FLASH_OPERATION_SUCCESS || sys_evt == NRF_EVT_FLASH_OPERATION_ERROR);
    storage_on_sys_evt(sys_evt);
    ble_advertising_on_sys_evt(sys_evt);
}

So, I never receive the 

NRF_EVT_FLASH_OPERATION_SUCCESS event, although something is being written onto the flash.
Is there any need to enable specific events for this? Do I need to do any additional setup to receive NRF_EVT_FLASH_OPERATION_SUCCESS and NRF_EVT_FLASH_OPERATION_ERROR?
Kind regards,
Daniel
Parents
  • Hi Daniel,

    Your sys_evt_dispatch() function that was registered with softdevice_sys_evt_handler_set() will be called for any system events, so if there is  a NRF_EVT_FLASH_OPERATION_SUCCESS or NRF_EVT_FLASH_OPERATION_ERROR it will be called (unless there is another issue somewhere that prevents the code from ever running).

    I do not see a filter in you rcode snippets, but I see that you print "evt is flash: " and will get 0 printed for most events for most events and 1 for the two you have specified. Is the issue here that you don't get any events, or do you always see "evt is flash: 0"? What do you do when you would have expected the event? Perhaps you can share a bit more of your code and how you test and what you see so that i get a full(er) picture of what you are doing?

    Einar

  • Hi,

    thanks for your answer, I was hoping I forgot something obvious. My issue that I am not seeing any events in that callback. So no DEBUG prints at all.

    Firstly, I am setting the event handler here. Then, I am calling dfu_init here, which sometimes issues a flash page erase.

    Then, I am calling advertising_start here, which may fail to start since there is a pending flash operation and waits for the NRF_EVT_FLASH_OPERATION_SUCCESS event to start advertising.

    That event does not seem to arrive, though, hence the advertising never starts.

    Kind regards,

    Daniel

  • I don't see anything obviously wrong related to the sys events in your code. Could it be that there is another issue that causes this as a side effect, for instance a same or higher priority interrupt that never completes, or something else that blocks it from being executed?

  • As far as i am concerned there is no Interrupt being fired at the same time. Also, my code continues executing after a flash event should be fired, so no ISR seems to block the processor...

Reply Children
Related