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

bootloader stuck in wait_for_events if started programatically

Hi,

I have modified slightly the OTA bootloader sample in SDK6.1 and SoftDevice 7.1.0. After flashing the bootloader code to the nrf51822 it works like charm, I can update the firmware on the module OTA with MCP. If I upload OTA a modified version of hrs example code in SDK with OTA DFU support, the bootloader gets started by writing 0x01 to the DFU control characteristic, but afterwards it is stuck in wait_for_events function in bootloader.c. I use gcc 4.9.3 as compiler on Linux. Do you have any ideas what I should check?

I have checked with the unmodified codes in SDK v6.1. DFU does not work with MCP with those codes either. Is gcc problematic with bootloader?

Thanks,

Tamas

Parents
  • Hi Tamas,

    MCP v3.7 should work with DFU from SDK v6.1. Could you try and test with stock example (ble_app_hrs_dfu) in SDK v6.1 and let me know the result ?

    Note that the ble_app_hrs_dfu won't do a chip reset, but jump directly from the application code to the bootloader when writing 1 to DFU control characteristic. So in the bootloader you should not reinitialize the softdevice when triggered from application.

    Attached file: ble_app_hrs - TestDFU.zip ble_app_hrs_dfu.hex

  • Hi Tamas,

    I summarize what I understand from your replies here please correct me if I am wrong:

    • You modified the bootloader so the start address is at 0x35000 (because you remove optimization I guess)

    • The modified bootloader worked fine with MCP that you can update different application firmwares and you used a button to enter DFU mode.

    • The modified bootloader doesn't work if you use the ble_app_hrs_dfu application and trigger the DFU by writing to the DFU control characteristic

    If it is the case, I think the easiest fix is to modify the bootloader_start() function in dfu_app_handler.c so that it will do a soft reset with sd_nvic_SystemReset after you have set the flag with sd_power_gpregret_set, note that you should also modify the bootloader source code so that it will reinitialize the softdevice, init_softdevice in ble_stack_init() should = true all the time.

    What we do with this workaround is to set a flag and do a reset, and then the bootloader will start pretty much the same way as holding a button when reset (which worked fine for you).

    It's pretty strange to here that it stuck at at wait_for_events(), how do you check that ? Step by step walkthrough with the code won't work with the softdevice active. Do you see the DFU bootloader advertise after the device enter DFU mode ?

Reply
  • Hi Tamas,

    I summarize what I understand from your replies here please correct me if I am wrong:

    • You modified the bootloader so the start address is at 0x35000 (because you remove optimization I guess)

    • The modified bootloader worked fine with MCP that you can update different application firmwares and you used a button to enter DFU mode.

    • The modified bootloader doesn't work if you use the ble_app_hrs_dfu application and trigger the DFU by writing to the DFU control characteristic

    If it is the case, I think the easiest fix is to modify the bootloader_start() function in dfu_app_handler.c so that it will do a soft reset with sd_nvic_SystemReset after you have set the flag with sd_power_gpregret_set, note that you should also modify the bootloader source code so that it will reinitialize the softdevice, init_softdevice in ble_stack_init() should = true all the time.

    What we do with this workaround is to set a flag and do a reset, and then the bootloader will start pretty much the same way as holding a button when reset (which worked fine for you).

    It's pretty strange to here that it stuck at at wait_for_events(), how do you check that ? Step by step walkthrough with the code won't work with the softdevice active. Do you see the DFU bootloader advertise after the device enter DFU mode ?

Children
No Data
Related