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

Buttonless OTA Hanging

I am using nRF52840 with SDK16 building with armgcc and trying to intergrate buttonless OTA into my project. 

App details:

  • Based on the ble_app_hrs_freertos example project
    • Peer manager disabled as it was causing issues with USB DFU
  • CDC ACM enabled

Bootloader details:

  • Based on secure_bootloader pca10056_usb
    • Configured for buttoned DFU

As far as I can tell, I have migrated the necessary code from ble_app_buttonless_ota into my app code and from secure_bootloader pca10056_ble into my bootloader. When I try and run the code, I am seeing potentially 2 issues.

  1. I get a hang on boot when calling ble_dfu_buttonless_async_svci_init() -> nrf_dfu_svci_vector_table_set()
  2. If I comment out ble_dfu_buttonless_async_svci_init(), then my app code can fully run without problem. But if I attempt to send OTA  from nRF Toolbox DFU, I seem to get stuck in a loop of attempting to enter the bootloader but instead resetting into the app code after some time. This goes on until I reprogram the app code entirely.
    1. I have used the debugger to get to where I know it is getting through the various events of ble_dfu_evt_handler(), but compared to the raw example code, I do not see my app code get to app_shutdown_handler()

Anyone have any ideas as to what is going on?

  • Hi Kyle, 
    nrf_drv_power_init() should be called before the softdevice initialized. You may want to change the location that the function is called to before softdevice initialized (inside ble_stack_init() in nrf_dfu_ble.c ) 
    The main purpose for the nrf_drv_power is to handle/detect USB power event. 

  • Is the handling/detecting of USB power events to help with USB enumerating as a DFU device?

    I tried your suggestion of calling nrf_drv_power_init() before the softdevice is initialized in ble_stack_init() and reverted the changes I made to nrf_drv_power_init(). I could not get USB to enumerate as a DFU device with those changes. With a breakpoint in nrf_drv_power_init() I saw that it got called twice, once by ble_stack_init() and again by usb_dfu_transport_init().

    Falling back to my original changes, I did see it enumerate. Is there something else that I might be missing to go along with your suggestions to get USB to enumerate in DFU?

  • Hi Kyle, 
    If it's called in ble_stack_init() then you should not call it again in usb_dfu_transport_init().

    Or you can just ignore the error if you receive NRF_ERROR_MODULE_ALREADY_INITIALIZED. 

Related