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

Changing the Serial DFU bootloader to OTA DFU bootloader.

I have bootloader that supports Serial(HCI) DFU on the nrf52832 device which I have to update to Bootloader that supports OTA DFU and also a new application firmware. I tried following things:

  • generated a combined zip of new bootloader and new application and tried DFU through serial. It worked for small time and then gave an error. The bootloader gets updated but not the new application.
  • tried updating the new application zip and then the new bootloader zip. The serial dfu process executes successfully but the device is stuck in new bootloader and the application firmware doesn't start.

I am using SDK11 and softdevice version s132

So how should I proceed about this issue?

  • Hi Sourabh,

    I would suggest you verify first:

    • If the new OTA bootloader work properly (when flashing using a programmer)
    • If any bootloader setting are conflict between the Serial and the BLE bootloader

    You should try to update only the OTA bootloader first and then try to do OTA DFU the application. Just to make sure all of them work together.

    Then you can start to debug the bootloader and check why it doesn't jump to the application. You can also read out the flash (nrfjprog.exe --readcode ) and compare the hex to see what could be the difference.

  • Hi Hung, I tried both things as you mentioned and in both cases the new OTA bl worked as expected.

    I read out the code from flash and I found out that the one line in bootloader region at address 0x7F000 as this: :10F00000FF000000FF000000000000000000000002

    which needs to be as this for normal working: (This I got from the hex dump of a working OTA bl case) :10F0000001000000FF0000004CD1030000000000E0

    And this is the patch that needs to be applied to the application hex when flashing through nrfjprog to make the bootloader think that APP is Valid.

    So after the serial DFU the OTA bl thinks that the APP is not Valid.

    So I tried changing this in OTA bl:

    if (bootloader_app_is_valid(DFU_BANK_0_REGION_START) && !bootloader_dfu_sd_in_progress())
    {
        // Select a bank region to use as application region.
        // @note: Only applications running from DFU_BANK_0_REGION_START is supported.
    	bootloader_app_start(DFU_BANK_0_REGION_START);
    }
    

    to:

        if (1)
    {
        // Select a bank region to use as application region.
        // @note: Only applications running from DFU_BANK_0_REGION_START is supported.
        bootloader_app_start(DFU_BANK_0_REGION_START);
    }
    

    But still the application doesn't start/device hangs. And even the bootloader is not running as I can't see the device as "DfuTarg" through bluetooth scan using my mobile phone which I usually see when a OTA bootloader is running.

    So now the application start address is not available to the new bootloader.

    I would like to attach the hex dumps I got from the working and not working scenarios, but I don't know how to attach files here.

  • Hi Sourabh,

    I just checked the bootloader in SDK v11 again, seems that the combination bootloader+application is not supported in this bootloader.

    In the new secure bootloader from SDK v12 we do support all combinations.

    If I recall correctly, when the bootloader is updated, it automatically mark the application as invalid and wait for an update.

    If it's OK for you to do two step, first update the bootloader, 2nd update the application via OTA. Then you don't need to modify anything.

    If you really need to have application+bootloader, we can think of modifying the bootloader so it won't check for application valid in the bootloader setting on the first time it starts.

Related