Setting up custom Secure Bootloader

Hello Nordic Team,

I'm developing an project using VS Code with nRF Connect Extension for an nRF52832 board. The SDK version I use is 2.7.0, build system is sysbuild.
I want to use both Secure Bootloader and MCUboot in my project, so I created sysbuild.conf file and filled it with the following:

SB_CONFIG_SECURE_BOOT_APPCORE=y
SB_CONFIG_SECURE_BOOT_SIGNING_KEY_FILE="<PATH_TO_PRIVATE_KEY"

SB_CONFIG_BOOTLOADER_MCUBOOT=y
SB_CONFIG_BOOT_SIGNATURE_TYPE_RSA=y
SB_CONFIG_BOOT_SIGNATURE_KEY_FILE="PATH_TO_PRIVATE_KEY"


Everything is fine here, I'm able to build an application, both Secure Bootloader and MCUboot along with S1 variant of the image, but at some point I decided to add some functionality to the Secure Bootloader.

So I moved the source code of it (which is located at <SDK_DIR>/nrf/samples/bootloader) away from the SDK and made some changes, and then tried to somehow build my project with that custom bootloader. I spent plenty of time reading the documentation about adding child images, but all my attempts to impement any solution lead to nothing.
Then I tried to delve deeper into how the sysbuild works in terms of setting up and building Secure Bootoader, and found out that lines in nrf/sysbuild/secureboot.cmake:

...  
  if(SB_CONFIG_SECURE_BOOT_APPCORE)
    set(secure_boot_source_dir ${ZEPHYR_NRF_MODULE_DIR}/samples/bootloader)

    ExternalZephyrProject_Add(
      APPLICATION b0
      SOURCE_DIR ${secure_boot_source_dir}
      BUILD_ONLY true
    )
...


And now it seems to me that there is no easy way to add a custom bootloader to my project since the path to the Secure Bootloader sources is hardcoded in the SDK, and there are plenty of things binded with that 
SB_CONFIG_SECURE_BOOT_APPCORE config option (such as building S1 variant, for instance), but I'm rather new at sysbuild and nRF Connect SDK as a whole, so I might be mistaken.

I would greatly appreciate any help on providing an information of how I actually can configure my project to use custom bootloader during build process instead of one which is located in SDK directory.

Thank you in advance!

Related