How to overlay b0n config in CMake?

Hello, we have a project in nRF Connect SDK, where we'd like to use a separate .conf file for b0n subimage in a multi-image build,

Let's say it's called b0n.conf. So, before any add_child_image is called, this line in CMakeLists.txt is invoked:

add_overlay_config(b0n ${CMAKE_CURRENT_SOURCE_DIR}/child_image/b0n.conf)

.But later in nrf/cmake/multi_image.cmake the following command is called, which overwrites b0n.confL

add_overlay_config(
    ${ACI_NAME}
    ${NRF_DIR}/subsys/partition_manager/partition_manager_enabled.conf
    )

As the result, the overlay config values are not applied. How can this be resolved?

  • I'll look into this

    In the meanwhile, if you're having issues with add_overlay_config() you could use this approach instead. Like explained by Håkon in this post. You could also set specific configs of a child image like I demonstrated in this reply.

    Best regards,

    Simon

  • Thanks for the response
    I'm not sure what to look at the github repository of mcuboot, from the first link
    The second link doesn't open correctly for me
    Also it's not a problem to change mcuboot.conf, this works fine. The problem is specifically with b0n.

  • EDITED 22.06.2022: Added strikethrough to an incorrect statement

    Sorry for the undetailed answer. There are several things I would like to address

    Modify the configurations of netboot (b0n) from the application

    The netboot application is actually a child image of a child image of the nRF5340 Bluetooth application.

    Let me explain. If you add netcore DFU support to an nRF5340 Bluetooth sample, the hci_rpmsg will be a child image of the Bluetooth example, and the netboot (b0n) will be a child image of the hci_rpmsg. The netboot sample will then be a child image of a child image of the Bluetooth sample. Take a look at the below image for an illustration (netcore dfu support is added to the peripheral_uart sample).

    It is not supported at the moment to modify a configurations of a child image of a child image. For example modify the configurations of b0n from the peripheral_uart sample. I have reported this internally, and hopefully we can provide a solution to this soon.

    Currently you need to modify the configurations of b0n from the hci_rpmsg sample (located in zephyr/samples/bluetooth/hci_rpmsg).

    Modify configurations of child images using a child_image folder

    If you create a folder named child_image/<child image name>, you can modify configurations of a child image. There is no need to use add_overlay_config() in cmake.

    For example if you build the hello world sample with mcuboot and would like to override the mcuboot prj.conf, you could add a file hello_world/child_image/mcuboot/prj.conf. If you would like to modify themcuboot configurations for a specific board, you could add a file hello_world/child_image/mcuboot/boards/nrf52840dk_nrf52840.conf (if you're using the nRF52840 DK).

    I did some testing, and it seems like this board specific approach will override the original prj.conf as well. If you copy over the original content of the prj.conf into your new file + your additions, you should be fine. I will take a closer look at this and see if I can find a cleaner way of going about this.

    Modify configurations of child images using add_overlay_config()

    I did some testing, and tried to get add_overlay_config() to work, without any success. I tried to modify the configuration of mcuboot from a hello_world sample using add_overlay_config() in the CMakeLists.txt and comment out the lines including the file partition_manager_enabled.conf, but it still didn't take effect.

    I will look into this.


    In the meanwhile you can use the approach under "Modify configurations of child images using a child_image folder". Also as I described in my initial reply, you can set a specific Kconfig from a parent application, like I explained in this reply. For example if you would like to set CONFIG_SERIAL=n in b0n, you add set(b0n_CONFIG_SERIAL n) in the CMakeLists.txt of zephyr/samples/bluetooth/hci_rpmsg.

    Best regards,

    Simon

  • Modify configurations of child images using a child_image folder (continuation)

    What I said initially about the file hello_world/child_image/mcuboot/boards/nrf52840dk_nrf52840.conf is not correct. As explained in Multi-image builds → Image-specific variables, this file will override the file <ncs location>/bootloader/mcuboot/boot/zephyr/boards/nrf52840dk_nrf52840.conf (however in this specific case there are no such file). The file hello_world/child_image/mcuboot/boards/nrf52840dk_nrf52840.conf also requires a file hello_world/child_image/mcuboot/prj.conf to be present.

    To simply overlay the present configurations of mcuboot you can add the file hello_world/child_image/mcuboot.conf

  • Basically, it means, when you want to use SMP server for nRF5340, which uses hci_rpmsg as a child image, and the hci_rpsmg uses nordic's secure bootloader (b0n) as a child image, you are not able to configure the b0n, because there is no way how to this.

    So I guess the only solution is to have 2 separate projects - one as your application (eg. providing SMP server) and the second the hci_rpmsg, for which one you can simply modify the child_image configuration for b0n.

    Is there a way how to prevent the SMP sample from building/erasing/loading the network core?
    Otherwise, you would have to load the full SMP sample and then again load the network core with your customized hci_rpmsg sample

Related