How to create custom MCUBOOT for DFU

Hello!

I am creating a DFU application and want to customize the bootloader code.

I used this example: https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/ncs-dfu

How can you include a custom MCUBOOT when doing this example?

Parents Reply Children
  • Hi Markus, 

    Please inspect which condition is failed inside img_mgmt_impl_upload_inspect(). 
    I'm not so sure how you created the chunks of compressed file but it need to reflect how the "normal" image is sent. 
    Especially in the first chunk, it must include the image header, and the hash SHA256 of the image. 

    As far as I can see, to be able to achieve what you planning to do, a deep study of the img_mgt library is needed. And I would suggest to go step by step as follow : 

    - First please try to study a normal DFU update using a very small image maybe just 1-2 pages in flash size. This make it easy to study a normal successful DFU update. 

    - After that you can try uploading slightly modified version of the same image. You can do for example XOR the image with a key. Then when you "decompress" it you XOR with the same key. This way, you modified the image but the size of the image/chunk is not changed. To be able to do this you must be able to handle image header and the hash correctly. In addition at this step you would be able to manipulate how the image is written to flash. 

    - The last step would be to do actual compression and sending smaller chunk  size or smaller number of chunks. Then when you write the image to flash you can do compression and manipulate the size of the image you are writing on flash. At this moment the offset in the image you sent and the offset in flash that you write the image would be different and you would need to find a solution to accommodate that.  

    Again, I haven't done this myself, so this is only a suggestion. And please be aware that img_mgmt is not our code it's contributed to Zephyr by mynewt. 

Related