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

DFU OTA does not work from application

I followed the instructions from here developer.nordicsemi.com/.../a00081.html to make my application support DFU OTA. Despite of some errors in the instructions I managed to finish the task, and got my application running. After connecting from a phone using nRFTools DFU feature, I can connect to my application, select the desired .zip file and then the DFU should start.

However, after a short connection UI just gives an error "disconnected". When I debugged the target device, it seems that the bootloader is started as expected but then it simply jams into its event loop (being busy there).

This is my third day on this and I would be very happy if somebody could help me.

EDIT: Below is my current "dirty hack" solution for the problem. I do not mark it as an answer, because it does not solve the problem cleanly. The modification is at the bootloader's main.c, and it makes the bootloader to reset after it first enters from application, and only after that, it enters the actual bootloader code. However, two upload tries is now needed from nRFTools, so the solution is not optimal.

bool app_reset = (NRF_POWER->GPREGRET == BOOTLOADER_DFU_START);
bool app_reset2 = (NRF_POWER->GPREGRET == ~BOOTLOADER_DFU_START);

if (app_reset)
{
    NRF_POWER->GPREGRET = ~BOOTLOADER_DFU_START;
    NVIC_SystemReset();
}
else if (app_reset2)
{
    NRF_POWER->GPREGRET = 0;
}

In addition, few other changes are needed to support "app_reset2" (several places at main). At least it works now somehow. But it is really a dirty hack as I said.

  • Hi Jarmo, If you don't plan to share bond information, then you don't need device manager or app_context_load. The BSP module is to handle LED and button, I don't think it's needed. What make the difference is that we branch (jump) from application to bootloader, and we don't reinitialize the bootloader. When you reset the bootloader and have to reinitialize. They should both work (with some modification with your approach to remove the app_reset thingy, just call ble_stack_init(true);)

    Have you followed the instruction here ? It should work.

  • Thanks, I have followed those instructions earlier and double-checked it now, still. Also, I just converted the main file from app_hrs_dfu -example into my project, and thought my application would then do ota dfu, as well. But nope! I have really run out of ideas. Is there some size limit for the application, realated to bootloader? My app's binary is now around 21 KB in size. I guess the error might be very trivial, but since there's no feedback from the system, expect jamming, this is very difficult case :'(

  • What should I put here?

    cp_init.start_on_notify_cccd_handle    = m_hrs.hrm_handles.cccd_handle;
    

    I do not have heart rate monitor service, thus I guess something else should be put there. And I already forgot what was that stupid CCCCCCCCCD...

  • What is the way application's connection information is passed into the bootloader? If I understood right, the existing connection with the OTA DFU central point is passed to bootloader when entering there (shared RAM or something like that?). In my case this thing seems to fail and the central point is instantly disconnected. After that, bootloader sets up its BLE stack (it becomes visible as DfuTarg) but then it jams into its event loop, not being able to connect any more.

  • @Jarmo: You should not copy the ble_app_hrs_dfu main to your project. It's not needed. What you should do is described in the instruction I linked before. There are 3 files need to be added as mentioned in the instruction.

    But if you don't plan to share bond information. You can do these simple steps:

    • Write to GPREGRET a value, let say 0x55
    • Reset the chip using (sd_nvic_SystemReset)
    • Remove "if (init_softdevice)" in ble_stack_init
    • The bootloader should start advertise as DFUTarg.

    If you still have the issue " it jams into its event loop, not being able to connect any more" Please capture a sniffer trace when you try to connect to it. You can use the nRF Master Control panel app to try to connect to the DFUTarg.

Related