sysbuild: support sample configuration of extra images
This commit introduces the possibility of a sample to locate configuration files for extra images that are used when building with MCUboot. This allows use-cases where a sample, A, want to include MCUboot but has adjustments to the default MCUboot configuration. By adding a Kconfig fragment `<sample>/sysbuild/mcuboot.conf`, then that fragment will be used together with the default configuration for MCUboot. It is also possible to completely replace the MCUboot configuration. This is done by creating `<sample>/sysbuild/mcuboot/` folder. This folder will then be used as the `APPLICATION_CONFIG_DIR` when building MCUboot. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
parent
bf39f545e3
commit
303c1eb60c
|
@ -24,6 +24,7 @@ include_guard(GLOBAL)
|
|||
|
||||
include(extensions)
|
||||
|
||||
zephyr_get(APPLICATION_CONFIG_DIR)
|
||||
if(DEFINED APPLICATION_CONFIG_DIR)
|
||||
string(CONFIGURE ${APPLICATION_CONFIG_DIR} APPLICATION_CONFIG_DIR)
|
||||
if(NOT IS_ABSOLUTE ${APPLICATION_CONFIG_DIR})
|
||||
|
|
63
doc/build/sysbuild/index.rst
vendored
63
doc/build/sysbuild/index.rst
vendored
|
@ -484,6 +484,69 @@ disable it using the Kconfig option ``SECOND_SAMPLE``.
|
|||
For more information on setting sysbuild Kconfig options,
|
||||
see :ref:`sysbuild_kconfig_namespacing`.
|
||||
|
||||
Zephyr application configuration
|
||||
================================
|
||||
|
||||
When adding a Zephyr application to sysbuild, such as MCUboot, then the
|
||||
configuration files from the application (MCUboot) itself will be used.
|
||||
|
||||
When integrating multiple applications with each other, then it is often
|
||||
necessary to make adjustments to the configuration of extra images.
|
||||
|
||||
Sysbuild gives users the ability of creating Kconfig fragments or devicetree
|
||||
overlays that will be used together with the application's default configuration.
|
||||
Sysbuild also allows users to change :ref:`application-configuration-directory`
|
||||
in order to give users full control of an image's configuration.
|
||||
|
||||
Zephyr application Kconfig fragment and devicetree overlay
|
||||
----------------------------------------------------------
|
||||
|
||||
In the folder of the main application, create a Kconfig fragment or a devicetree
|
||||
overlay under a sysbuild folder, where the name of the file is
|
||||
:file:`<image>.conf` or :file:`<image>.overlay`, for example if your main
|
||||
application includes ``my_sample`` then create a :file:`sysbuild/my_sample.conf`
|
||||
file or a devicetree overlay :file:`sysbuild/my_sample.overlay`.
|
||||
|
||||
A Kconfig fragment could look as:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
# sysbuild/my_sample.conf
|
||||
CONFIG_FOO=n
|
||||
|
||||
Zephyr application configuration directory
|
||||
------------------------------------------
|
||||
|
||||
In the folder of the main application, create a new folder under
|
||||
:file:`sysbuild/<image>/`.
|
||||
This folder will then be used as ``APPLICATION_CONFIG_DIR`` when building
|
||||
``<image>``.
|
||||
As an example, if your main application includes ``my_sample`` then create a
|
||||
:file:`sysbuild/my_sample/` folder and place any configuration files in
|
||||
there as you would normally do:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
<home>/application
|
||||
├── CMakeLists.txt
|
||||
├── prj.conf
|
||||
└── sysbuild
|
||||
└── my_sample
|
||||
├── prj.conf
|
||||
├── app.overlay
|
||||
└── boards
|
||||
├── <board_A>.conf
|
||||
├── <board_A>.overlay
|
||||
├── <board_B>.conf
|
||||
└── <board_B>.overlay
|
||||
|
||||
All configuration files under the :file:`sysbuild/my_sample/` folder will now
|
||||
be used when ``my_sample`` is included in the build, and the default
|
||||
configuration files for ``my_sample`` will be ignored.
|
||||
|
||||
This give you full control on how images are configured when integrating those
|
||||
with ``application``.
|
||||
|
||||
Adding non-Zephyr applications to sysbuild
|
||||
******************************************
|
||||
|
||||
|
|
|
@ -117,6 +117,39 @@ function(ExternalZephyrProject_Add)
|
|||
)
|
||||
endif()
|
||||
|
||||
set(sysbuild_image_conf_dir ${APP_DIR}/sysbuild)
|
||||
set(sysbuild_image_name_conf_dir ${APP_DIR}/sysbuild/${ZBUILD_APPLICATION})
|
||||
# User defined `-D<image>_CONF_FILE=<file.conf>` takes precedence over anything else.
|
||||
if (NOT ${ZBUILD_APPLICATION}_CONF_FILE)
|
||||
if(EXISTS ${sysbuild_image_name_conf_dir})
|
||||
set(${ZBUILD_APPLICATION}_APPLICATION_CONFIG_DIR ${sysbuild_image_name_conf_dir}
|
||||
CACHE INTERNAL "Application configuration dir controlled by sysbuild"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Check for sysbuild related configuration fragments.
|
||||
# The contents of these are appended to the image existing configuration
|
||||
# when user is not specifying custom fragments.
|
||||
if(NOT "${CONF_FILE_BUILD_TYPE}" STREQUAL "")
|
||||
set(sysbuil_image_conf_fragment ${sysbuild_image_conf_dir}/${ZBUILD_APPLICATION}_${CONF_FILE_BUILD_TYPE}.conf)
|
||||
else()
|
||||
set(sysbuild_image_conf_fragment ${sysbuild_image_conf_dir}/${ZBUILD_APPLICATION}.conf)
|
||||
endif()
|
||||
|
||||
if (NOT ${ZBUILD_APPLICATION}_OVERLAY_CONFIG AND EXISTS ${sysbuild_image_conf_fragment})
|
||||
set(${ZBUILD_APPLICATION}_OVERLAY_CONFIG ${sysbuild_image_conf_fragment}
|
||||
CACHE INTERNAL "Kconfig fragment defined by main application"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Check for overlay named <ZBUILD_APPLICATION>.overlay.
|
||||
set(sysbuild_image_dts_overlay ${sysbuild_image_conf_dir}/${ZBUILD_APPLICATION}.overlay)
|
||||
if (NOT ${ZBUILD_APPLICATION}_DTC_OVERLAY_FILE AND EXISTS ${sysbuild_image_dts_overlay})
|
||||
set(${ZBUILD_APPLICATION}_DTC_OVERLAY_FILE ${sysbuild_image_dts_overlay}
|
||||
CACHE INTERNAL "devicetree overlay file defined by main application"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
# CMake variables which must be known by all Zephyr CMake build systems
|
||||
# Those are settings which controls the build and must be known to CMake at
|
||||
# invocation time, and thus cannot be passed though the sysbuild cache file.
|
||||
|
|
Loading…
Reference in a new issue