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?

  • 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?

  • 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.

  • Below everything anthony has done which is great,

    in ncs/nrf/CMakeList.txt, following line must be added :

    include(cmake/external_child_image.cmake)

Related