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

nrf_dfu_wait funcion never return

hello,

I use nrf51822 + S130 + SDK12.2 in my product, nrf51822 work at central + peripheral mode,and i use nrf_duf_flash module for my dfu funtion.

The problem is, i use my dongle(as central role) connect my product(as peripheral role) and send dfu commands to it, when my product do not connect a peripheral as central role, it looks like work well, the dfu process is ok, but when my product do connect a peripheral as central role(that means my product has to connection both as central and peripheral), some times the dfu is ok, but some times, program will dead in nrf_flash_wait function,in the loop

while ((m_flags & FLASH_FLAG_OPER) != 0)
{
        (void)sd_app_evt_wait();
}

and never out.

my dfu code like this:

if (nrf_dfu_flash_store((uint32_t *)(IAP_STORE_ADDR + s_tIAPState.write_ptr), (uint32_t  *)data_buf, (data_len >> 2), NULL) != FS_SUCCESS)
{
    tCmdPar.index = IAPERROR_WRITEFLASH;
}
else                                    
{
    if (nrf_dfu_flash_wait() != FS_SUCCESS)
    {
        tCmdPar.index = IAPERROR_WRITEFLASH;
        break;
    }
  
    //other code
}

I also try SDK12.3, the problem is same.

Is this a bug of SDK? How can i fix it, or, if do not use nrf_dfu_flash module, what can i do?

Parents
  • I do some test last night, found this problem is not caused by ble connection, it seems like caused by uart isr.

    When i got DFU_START command from ble dongle, i disable the uart, then this problem will not appear, if i do not disable uart, the problem will appear.

    I think, maybe when the uart is enabled, when uart receive data, the ISR is called, and this sometimes make the SWI2 ISR can not be called, then miss fs event, cause FLASH_FLAG_OPER flag never be clear. But the IRQ priority of uart is set to APP_IRQ_PRIORITY_LOWEST, how can it make CPU miss a higher priority IRQ (SWI2 used by softdevice)?

Reply
  • I do some test last night, found this problem is not caused by ble connection, it seems like caused by uart isr.

    When i got DFU_START command from ble dongle, i disable the uart, then this problem will not appear, if i do not disable uart, the problem will appear.

    I think, maybe when the uart is enabled, when uart receive data, the ISR is called, and this sometimes make the SWI2 ISR can not be called, then miss fs event, cause FLASH_FLAG_OPER flag never be clear. But the IRQ priority of uart is set to APP_IRQ_PRIORITY_LOWEST, how can it make CPU miss a higher priority IRQ (SWI2 used by softdevice)?

Children
No Data
Related