This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF5340 Multi-Image example configuration help

I am working on a project that is being ported from the nRF52840 to the nRF5340 and the once unified radio and app codebase needs to be split to the app CPU and network CPU.

The problem I am facing is I don't quite understand how to create a multi image project and the examples provided by nrf_connect dont seme to have a multi image example.

All I see are options when selecting the example for app cpu or net cpu which look to configure the device tree  for that CPU but I don't see any for multi image projects.

When reading the documentation for the radio_test example I see that the app CPU needs to be flashed with the empty_app_core project but I would like to include this project as a parent to the radio_test child project.

Is there any examples on how to do this?

Parents
  • Hello,

    I didn't get the mutlig image build to to work with the radio test example even though 'empty_app_core' is defined as a child image in \nrf\samples\CMakelists.txt. I need to investigate this a bit more and get back to you.

    That said, there are mulitple examples of multi image projects in NCS. The BLE projects do for instance include the 'HCI_rpsmg' sample as a child image when you build for the app core. Have you tried that?

    Best regards,

    Vidar

  • Hello,

    Taking another look at this problem, I have made the following modifications.

    In my project root Kconfig I have the following entry

    module=CHILD_NET
    source "${ZEPHYR_BASE}/../nrf/subsys/partition_manager/Kconfig.template.build_strategy_domain"
    

    copied from ncs/nrf/subsys/partition_manager/Kconfig:73

    Then in my project root CMakeLists.txt I have the following

    set(NETCORE_IMAGE "child_net")
    set(NETCORE_IMAGE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/net")
    message("Adding ${NETCORE_IMAGE} firmware as child image")
    
    add_child_image(
      NAME ${NETCORE_IMAGE}
      SOURCE_DIR ${NETCORE_IMAGE_PATH}
      DOMAIN CPUNET
      BOARD ${CONFIG_DOMAIN_CPUNET_BOARD})

    which was copied from ncs/nrf/samples/CMakeLists.txt

    When I run west build --pristine -b nrf5340dk_nrf5340_cpuapp I get the following error

    fatal error: pm_config.h: No such file or directory
       38 | #include <pm_config.h>
          |          ^~~~~~~~~~~~~
    compilation terminated.

    How to I fix this?

  • Hello,

    I tried with NCS v1.5.1 now, and I managed to build "empty app core" as a child image to the radio test example just by adding 'CONFIG_NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE=y' to the boards/nrf5340dk_nrf5340_cpunet.conf overlay. I don't recall what the problem I encountered earlier was, but seems to be working now at least.

    But to answer your question, the "pm_config.h: No such file or directory" error indicates that the partition manager is not being enabled in your build (CONFIG_PARTITION_MANAGER_ENABLED). You may create a new config setting similiar to NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE in nrf\samples\Kconfig which selects the PARTION_MANAGER_ENABLED symbol.

    PARTITION_MANAGER_ENABLED enabled by NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE:

  • Thanks, I was able to get it working by adding a new entry for my child image in nrf\samples\Kconfig and nrf\samples\CMakeLists.txt with the directory path pointing out of tree. This worked for building a net image as a child to the app image and for building an app image as a child to the net image.

    Still not sure why adding the same entry to the app project's CMakeLists.txt and Kconfig does not achieve the same results but for now it will have to do.

  • Hi Anthony, can you please share with us what you edit in your files, and exact path to them. It is very hard to understand how to create multi-image for nrf5340 from their documentation, especially for beginners.

    I think many would be thankful.

  • sure,

    Since the west build process requires child images to be built in the scope of the ncs directory but if the child image is out of tree there's a cyclical dependency problem.

    My solution was based on Vidar's advice but since I did not want to hard code images such as the way hci_rpmsg and others in the files listed above, I created a variable build config with a new file called external_child_image.cmake in ncs/nrf/cmake 

    if (CONFIG_BUILD_EXTERNAL_CHILD_IMAGE)
        if (NOT CONFIG_CHILD_IMAGE_NAME)
            message(FATAL_ERROR "CONFIG_CHILD_IMAGE_NAME not set")
        endif()
    
        if (NOT CONFIG_CHILD_IMAGE_PATH)
            message(FATAL_ERROR "CONFIG_CHILD_IMAGE_PATH not set")
        endif()
    
        # allow the use of cmake variables in kconfig or prj.conf
        string(CONFIGURE ${CONFIG_CHILD_IMAGE_PATH} CHILD_IMAGE_PATH)
    
        message("Adding child image ${CONFIG_CHILD_IMAGE_NAME}\n"
        "located at ${CHILD_IMAGE_PATH}\n"
        "since CONFIG_BUILD_EXTERNAL_CHILD_IMAGE is set to 'y'")
    
        if (${CONFIG_CHILD_IMAGE_DOMAIN} STREQUAL "CPUNET")
            set(CHILD_IMAGE_BOARD_TARGET ${CONFIG_DOMAIN_CPUNET_BOARD})
        elseif (${CONFIG_CHILD_IMAGE_DOMAIN} STREQUAL "CPUAPP")
            set(CHILD_IMAGE_BOARD_TARGET ${CONFIG_DOMAIN_CPUAPP_BOARD})
        else()
            message(FATAL_ERROR "CHILD_IMAGE_DOMAIN not set to CPUNET or CPUAPP")
        endif()
    
        add_child_image(
        NAME ${CONFIG_CHILD_IMAGE_NAME}
        SOURCE_DIR ${CHILD_IMAGE_PATH}
        DOMAIN ${CONFIG_CHILD_IMAGE_DOMAIN}
        BOARD ${CHILD_IMAGE_BOARD_TARGET})
    endif()

    Then added the following entry to ncs/nrf/Kconfig.nrf

    config BUILD_EXTERNAL_CHILD_IMAGE
    	bool "Enable building an out of tree child image"
    	default n
    	select PARTITION_MANAGER_ENABLED
    
    if BUILD_EXTERNAL_CHILD_IMAGE
    
    config CHILD_IMAGE_NAME
    	string "external child image name"
    
    config CHILD_IMAGE_PATH
    	string "external child image path"
    
    config CHILD_IMAGE_DOMAIN
    	string "external child image domain"
    	help 
    		Child image CPU domain.
    		Can be CPUNET or CPUAPP
    
    endif #BUILD_EXTERNAL_CHILD_IMAGE

    Now in any external project with a dependent child image that is also external I have the following in the parent's prj.conf

    # add net cpu child image to build
    CONFIG_BUILD_EXTERNAL_CHILD_IMAGE=y
    CONFIG_CHILD_IMAGE_NAME="extern child image"
    CONFIG_CHILD_IMAGE_PATH="${APPLICATION_SOURCE_DIR}/path/to/child/image"
    CONFIG_CHILD_IMAGE_DOMAIN="CPUNET"

  • Thank you a lot!

    I have one more question:

    Does your child image folder contains pm.yml file?

Reply Children
  • I did not change anything else besides the above. I am also only using one image per domain (no bootloader, extra 3rd party hex, etc) so the pm.yml wasn't needed.

    Since I am building from source for both the child image and parent image the image placement in app and net domains is automatically calculated via board dts files when building. It's the same process as the peripheral_lbs example when building a single BT enabled app which will use hci_rpmsg as a child image on the net core. However, in my case I replace hci_rpmsg with a custom net core project.

    When building multiple images in the same domain I believe is when pm.yml is needed, however if you still have issues I would open a separate question for clarification from nordic.

Related