DFU process for NRF52840 using UART in SDK 17.1, button less DFU

Hi, I want DFU the NRF52840 using the UART. Please let me know the following quires .

Process- 

  1. I want to create two partition of memory one will store the my main application code and another partition will only store the custom bootloader code.
  2. In custom bootloader , I will initialize the UART communication for receiving the application code bytes and want to store that data in Application code partition.
  3. After writing the whole Application code , Bootloader code will reboot the system and after reboot it will read a flag from flash if "application is available "
  4. Incase of application code available, it will start the application code to run and Incase of any failure the code will go to Bootloader mode again to receive the new application code
  5. While running the application code when , It will receive command for DFU it should reboot and go to DFU mode.

Issues

  1. How do I create partition in memory or set address in code on which it should store ?
  2. In what ratio I should do that partition?
  3. In case of writing the whole application code , what instructions are required to run in code so that It start running the application from given address?
  4. Is there any way to check if stored application code is correctly stored in memory, one way I am assuming is to calculate the checksum of whole application code?
  5. Do I have to make changes in .ld files of Application code and Bootloader code ?
  6. How do I jump to bootloader mode from Application mode ?


    Note - For all above queries I want a hint or brief idea to proceed 

IDE used

  1. I am using Segger Embedded Development Studio for development purpose.
  2. SDK version 17.1

Please let me know if any more details required .
Thanks and regards

  • Hi Sarvesh,

    Have you tested without bootloader solution  ? The example is located at \examples\dfu\secure_bootloader 
    You can find the documentation about the DFU bootloader here.

    The bootloader can do pretty much what you listed. You can read about the DFU process and the memory layout here.

    The only thing missing, and in my opinion, hard to achieve is on how to know if the application is failed to rollback to the bootloader. How would the bootloader knows that the application is not working as it expected ? The integrity of the application image can be checked by CRC and hash but the bootloader has no way to know if the application is operate correctly or not. I would assume this should be tested before you release the new image. 

    However, it's still possible to jump to the bootloader in case the application is failed. By default you can enter DFU mode by holding a button when reset. 

    I have made a blog about how to test the bootloader here. I would highly recommend to go through and get familiar to the bootloader before you move to anything mode advanced. 

  • Thanks for reply

    Have you tested without bootloader solution  ? The example is located at \examples\dfu\secure_bootloader 
    You can find the documentation about the DFU bootloader here.

    Yes I have looked into it.

    The only thing missing, and in my opinion, hard to achieve is on how to know if the application is failed to rollback to the bootloader. How would the bootloader knows that the application is not working as it expected ? The integrity of the application image can be checked by CRC and hash but the bootloader has no way to know if the application is operate correctly or not. I would assume this should be tested before you release the new image. 

    Sorry for the misunderstanding I want to check the integrity of the Application Image only, in case of any bytes get altered while transmission or storing.  

    However, it's still possible to jump to the bootloader in case the application is failed. By default you can enter DFU mode by holding a button when reset. 

    Here is the problem for me I do not have this facility to holding a button when reset because I will not be able to access the NRF52840 physically. So please suggest me ,Is there any other way to Goto Bootloader mode incase application fails ?

    Do I have to make changes in .ld files of Application code and Bootloader code ?

    Do I have to do that also ? or memory related changes

  • Hi Sarvesh, 
    As I mentioned, the integrity of the application image is checked using CRC and hash. Please have a look here.

    Only after the image is verified as it's been received correctly it then will be used to replace the original image. 

    If you don't have any button to enter DFU mode, you can use buttonless solution. I explained a little bit about it here. You can find the example in \examples\ble_peripheral\ble_app_buttonless_dfu and the documentation about it here.

    You don't need to modify the application's .ld file. Just need to flash the bootloader it works transparently to the application. 

Related