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

Bootloader: DFU Start by Flash content instead of Key operation

Controller: nRF52832-QFAA

Reference project: nRF5_SDK_11.0.0_89a8197/examples/dfu/bootloader/pca10040/dual_bank_ble_s132

Question: The idea is, to store a init_DFU_by_flag into the data flash by the application to initiate the DFU service after RESET. The bootloader has to clear this flag after its recognizing by the erasing of the regarding data page. I guess, the NORDIC-bootloader could use the pstorage raw functions. Exists there a possibility to erase one special data page inside of more than one data page by help of the functions the bootloader uses for the upload of firmware?.

  • May I ask why don't you want to use GPREGRET retention register to do the task ( as default ) ?

    If you want to use flash to send the command, it's fine. That actually how we did it in our Secure DFU in SDK v12.0 We write to bootloader setting to tell the bootloader to enter DFU mode. pstorage was not used though.

    Note that we prefer to use GPREGRET as it's easier to fall back after you switch to bootloader. For example if there is a problem when updating firmware, you can always reset and come back to the application. If you write to flash, and if the bootloader isn't managed to erase the flash, then you will stuck in bootloader mode, can't go back to normal application.

  • Many thanks for your answer. To be honest, I'm a little bit afraid of changing the application from SDK11 base to SDK12 base. Or is it sufficient to change only the bootloader SDK from 11 to 12? The application based on SDK11 uses pstorage RAW functions and it wasn't so easy (for us) to get the system running.

  • Hi Uwe,

    In your application , I would suggest you to use pstorage instead of pstorage raw. If you use pstorage raw, make sure you implement this deadlock fix.

    The bootloader on SDK v12 is quite different from SDK v11. If you don't have the need of having Secure DFU, where the integrity and genuine of the firmware is verified by a signature, then you can continue to use the bootloader on SDK v11.

    I mentioned SDK v12 just as an example you can have a look. I don't see a problem using flash to set the flag. Just less clean than using the GPREGRET.

  • Sorry for my delayed next question. Sometimes I had to work on other parts of the project: I set the GPREGRET register with the value 0xB1 and tried to start the DFU - with the following sequency:

    err_code = sd_power_gpregret_clr(0xFF); APP_ERROR_CHECK(err_code); err_code = sd_power_gpregret_set(BOOTLOADER_DFU_START); APP_ERROR_CHECK(err_code); err_code = sd_power_gpregret_get(&GPREGRET); APP_ERROR_CHECK(err_code); if (0xB1==GPREGRET) { NVIC_SystemReset(); }

    But the bootloader didn't start the DFU and went ahead with the normal start of application. What is wrong?

  • Please set a break point inside the bootloader and check. Note that in SDK v11 we expect the application to branch to the softdevice, not to do a reset.

    If you do a reset you need to comment out the line if (init_softdevice) inside ble_stack_init() in main.c

    If you plan to branch instead of softreset, please have a look at the example ble_app_hrm with dfu.

Related