Include MCUBoot as an External Library

Hello,

I am currently working with the nRF5340DK kit.

For my project, I need to incorporate some additional custom checks/code into the project's bootloader(MCUBoot).

As you know, MCUBoot is included in the project from the SDK when enabled through prj.conf.

  • If I make changes directly to the MCUBoot folder in the SDK, adding my own code, etc., would this be advisable?
  • My concern is that if there is an update to the MCUBoot library and I try to update my MCUBoot folder, it might either throw errors or simply overwrite the folder, removing my changes. Is my understanding correct?

Alternatively, I am considering cloning the MCUBoot folder, adding my custom code to it, then including this modified version as an external library and using it to build my application as a bootloader.

  • Would this approach work? Could you please provide guidance on how to do this?

Is there any alternative approach to achieving this without treating MCUBoot as an external library?

Best Regards
Dheeraj

  • Hello Dheeraj,

    You can maintain your own fork of the mcuboot repo if you need to make changes to it, see Forking a repository of the nRF Connect SDK. It's also possible to make the changes directly in your local repo.  You will need to re-apply these changes every time you update SDK. 

    It's also possible to supply a pre-compiled version of MCUBoot to the build by adding the following configurations to your parent image:

    CONFIG_MCUBOOT_BUILD_STRATEGY_USE_HEX_FILE=y
    CONFIG_MCUBOOT_HEX_FILE="<absolute path to mcuboot.hex>"
    # Key file to sign the app images. This key must match the key used to build the MCUBoot hex.
    CONFIG_BOOT_SIGNATURE_KEY_FILE="root-ec-p256.pem"
    # Sign application image to make it bootable for MCUBoot
    CONFIG_SIGN_IMAGES=y

    Best regards,

    Vidar

Related