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

DFU - Updating from Legacy(SDK v11.0.0) Bootloader to Secure(SDK v12.x.0) Bootloader

My nRF52 device has been flashed with the Legacy Bootloader from SDK v11.0.0 and now I want to update to the new Secure Bootloader in SDK v12.x.0. However, when I try to update my device with a combined SoftDevice and Bootloader image I get the following error: REMOTE DFU DATA SIZE EXCEEDS LIMIT. Is it possible to update from the Legacy Bootloader to the Secure one using DFU over BLE?

Parents
  • Warning and disclaimer:

    The suggested "fix" is applicable to the nRF52 only! The modifications described in this answer will alter the bootloader start address and will not be fail-safe if the device is reset before the MBR has received and stored the COPY_BL command. This should be used as a last resort, i.e. if the legacy devices cannot be flashed with the new Secure bootloader with a programmer.


    Answer:

    The error is caused by the Secure Bootloader requiring ~24kB, while the Legacy bootloader only required ~15kB. With the nRF51 Series we have stated that the new bootloader image must have the same start address as the old image, i.e. the new image cannot be larger than the old bootloader and if its smaller it must still have the same start address. This is because the bootloader start address is written to the UICR registers of the nRF51, which cannot be altered without erasing the entire chip and then re-flashing the chip with a programmer. After a DFU update the Master Boot Record(MBR) will jump to this address, thus, it is important that the bootloader vector table is located there.

    However, on the nRF52 Series it is possible to erase the UICR registers from code without erasing the entire chip, i.e. it is possible to modify the start address at runtime. This means that we can alter the bootloader start address just before the bootloader signals the MBR to swap the old bootloader with the new bootloader image so that the MBR jumps to the start address of the new bootloader and not the old.

    I have created a custom bootloader that allows you to DFU in the Secure Bootloader + the S132 v3.0.0 SoftDevice. You will have to DFU the custom bootloader first and then you can DFU in the Secure Bootloader and the S132 SoftDevice.

    However, before you proceed you must implement the fix described in this answer.

    In order to implement this start address change one has to disable the size check in the legacy bootloader so that it accepts the larger secure bootloader image, buffer the UICR data just before the bootloader swap is performed, erase the UICR registers, modify the bootloader start address and then write it back to the UICR registers. All these changes are done in dfu_dual_bank.c. The modified dfu_dual_bank.c file as well as the diff against the unaltered file is attached below

    Attachments:

    Modified dfu_dual_bank.c: dfu_dual_bank.c

    Diff: dfu_dual_bank_diff.txt

    Note: The custom bootloader will only work for an image with a Bootloader with start address 0x78000 + a compatible SoftDevice. This means that once you have flashed the custom bootloader it is not possible to use another firmware image where the bootloader has another start address than 0x78000.

  • Is there any way to do bootloader update in nRF51?

Reply Children
No Data
Related