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

BLE Secure DFU Bootloader - Noob Doubts

Hello,

I have a working application on nrf52832, running sdk version 15.0 and SD132 version 6.0.0. Now I would like to add dfu functionality. I followed the instructions at https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.0.0%2Fble_sdk_app_dfu_bootloader.html.

Regarding this I have some questions and hoping someone can clarify these 

  1. I followed the instructions and compiled the standard bootloader project under nRF5_SDK_15.0.0/examples/dfu/secure_bootloader. The final hex file produced was of size 64Kb. My understanding was that as per the memory map, we have 24kb bootloader space in the region 0x0007 8000 to 0x0007 E000. Why is this hex bigger in size?

    ls -liah dfu/bootloader/pca10040_ble/armgcc/_build
    total 552K
    13869703 drwxrwxr-x 3 ankit ankit 4.0K Oct 10 19:57 .
    13869746 drwx------ 3 ankit ankit 4.0K Oct 10 19:57 ..
    13869747 drwxrwxr-x 2 ankit ankit 4.0K Oct 10 19:57 secure_dfu_bootloader
    13794307 -rwxrwxr-x 1 ankit ankit 256M Oct 10 19:57 secure_dfu_bootloader.bin
    13794294 -rw-rw-r-- 1 ankit ankit  66K Oct 10 19:57 secure_dfu_bootloader.hex
    13794295 -rw-rw-r-- 1 ankit ankit 3.2K Oct 10 19:57 secure_dfu_bootloader.in
    13794297 -rw-rw-r-- 1 ankit ankit  89K Oct 10 19:57 secure_dfu_bootloader.map
    13794298 -rwxrwxr-x 1 ankit ankit 434K Oct 10 19:57 secure_dfu_bootloader.out
    


  2. To generate the bootloader settings hex file, I need to specify application-version, bootloader-version & bl-settings-version. For what and how are these values used by the bootloader? Under my dfu process, I plan to only ever update the application fw. Never the SD or the bootloader itself.

  3. Within the bootloader itself, I want to be able to activate the dfu mode from software. To do this, I set the NRF_BL_DFU_ENTER_METHOD_BUTTONLESS define in sdk_config.h file under the bootloader project. Now to enter dfu mode I need to Enter DFU mode when the Boolean enter_buttonless_dfu in DFU settings is true. How do I do this?

  4. My understanding is that whenever the system boots up, the bootloader comes up and boots the application immediately, if present. If this is true, what is the define NRF_BL_DFU_INACTIVITY_TIMEOUT_MS for? Or is it that on boot bootloader comes up and waits for NRF_BL_DFU_INACTIVITY_TIMEOUT_MS before loading a valid application if present?

Thank you for the help.

  • Hi,

    Here are the answers to most of your questions:

    1. Sounds like you are building the debug version of the bootloader.   The debug version enables all of the log statements which end up making the bootloader very large.  That said from the image above it looks like you are using the hex file size which will always be large than a binary file given it's in ASCII and includes the metadata for address location.

    2. Even if you don't plan on updating the bootloader or SD you need these regardless as the DFU will use some of them to ensure compatibility during a DFU.  I don't believe there is a why to block bootloader or SD updates.  Also in my experience being able to update the bootloader isn't something we planned on using either but it saved us in a recent project.

    3. Have you looked at the ble_app_buttonless_dfu example?  This details how to go about doing this.  In my experience I don't like the fact that a write to flash is required every time I want to enter the bootloader so I use

    NRF_BL_DFU_ENTER_METHOD_GPREGRET

    4. Your understanding for boot is correct.  The NRF_BL_DFU_INACTIVITY_TIMEOUT_MS is used to if you enter the bootloader from the application and no BLE activity is occurs within the timeout.  Without this it would be possible to for your application to stay in the bootloader indefinitely if it was entered from the application.

    Cheers!

  • Hi,

    1. The size of the hex file is much larger than the actual size of the binary data, as it is an ASCII encoded version of the binary data including addresses, checksums and other commands in addition to the data itself. See the Intel HEX Wikipedia article for more information on the format of hex files, and for examples.

    2. BL settings version is needed so that the bootloader knows the format of the settings page is correct. If it is different from what the bootloader expects then it will treat it as if it was empty.

    For the other settings in 2., and for 3. and 4., I refer to the answers provided by . I might add for 4. that the inactivity timeout is used regardless of how you enter DFU mode.

    Regards,
    Terje

Related