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.

Parents
  • @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.

Reply
  • @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.

Children
No Data
Related