Initial CMake yaml module to facilitate reading yaml files into CMake,
update yaml settings and write it back to a file.
The yaml module also supports creation of yaml files from scratch.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Adds a sysbuild Kconfig to select the operating mode of MCUboot
which is then propagated to the MCUboot and application images
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Check for existence of APPLICATION_CONFIG_DIR in sysbuild.
sysbuild.conf is an optional file, meaning that sysbuild will not fail
if APPLICATION_CONFIG_DIR points to a non-existing folder.
A normal Zephyr build already fails when passing an invalid
APPLICATION_CONFIG_DIR but only because it cannot find a required
prj.conf in the folder.
Checking the existence of APPLICATION_CONFIG_DIR in sysbuild and fail
the build when a non-existing folder is passed to sysbuild ensures
sysbuild behaves similar to a normal Zephyr build regarding a
non-existing folder, while still allow sysbuild.conf itself to be
optional.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The sysbuild part of sysbuild/application creates a sysbuild/application
folder under top-level build dir. However, having a sysbuild folder at
this level means that tab completion for sysbuild pre-fixed build
targets will stop after completing just `sysbuild` and then show several
subfolders, making it hard to see important build targets, such as:
`ninja sysbuild_menuconfig`.
As `sysbuild/application` is just a folder name, then move it to
`_sysbuild` instead to avoid impacting tab completion for ninja and
make.
Also strip the `application` part in the process, as the extra folder
doesn't provide any extra benefit, but is just one more level to enter
when browsing the build folder structure.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
If not defined by caller, then set APPLICATION_BINARY_DIR to
CMAKE_CURRENT_BINARY_DIR. This is normally be done by
`find_package(Zephyr)`, but due to the indirection introduced with
fc1884ecf5 to allow applications to
provide their own sysbuild entry point, then the APPLICATION_BINARY_DIR
is unexpectedly set to the bin dir of the entry point.
Restore the old behavior so that APPLICATION_BINARY_DIR per default
again points to top-level sysbuild binary dir.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Sysbuild sets the EXTRA_CONF_FILE before loading kconfig.cmake.
This hides any user defined EXTRA_CONF_FILE added to the sysbuild cache.
Clear the local sysbuild EXTRA_CONF_FILE so that the hidden cache
variable re-enters current scope.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes an issue whereby strings are placed in UTF-8 format but the
application doesn't read them in when configured using sysbuild
and another issue whereby sysbuild then reads the application's
cache and did not treat them as UTF-8
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes: #73066
Introduce sysbuild_root CMake module similar to the Zephyr root CMake
module. The sysbuild_root CMake module works similar to existing root
module, but with the difference that root paths are adjusted relative to
APP_DIR which is the main image, instead of relative to sysbuild.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #73065
Update APPLICATION_CONFIG_DIR is Zephyr CMake and sysbuild to follow
the common principle in Zephyr for relative paths.
This means that relative paths are taken from the application source
directory when specified on command line, and require local scoped
defined APPLICATION_CONFIG_DIR to be given as absolute, for example by
using CMAKE_CURRENT_LIST_DIR.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
APPLICATION_CONFIG_DIR is supported in Zephyr and allows to adjust the
location from which prj.conf and friends are picked up.
This also works for images when using sysbuild, however sysbuild itself
ignores the value of APPLICATION_CONFIG_DIR, meaning that sysbuild only
accepts sysbuild.conf located directly in the sample folder.
Extend sysbuild to support APPLICATION_CONFIG_DIR so sysbuild follows
regular Zephyr CMake behavior.
Introduce SB_APPLICATION_CONFIG_DIR to allow changing the location
for sysbuild only, without propagating the value to images.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit refactors sysbuild entry code by creating a CMake sysbuild
module for image processing and place sysbuild entry code in a
<app>/sysbuild/CMakeLists.txt file.
A template/CMakeLists.txt file will be use as template for applications
which doesn't provide their own entry file.
An application may create a sysbuild/CMakeLists.txt file.
The sysbuild/CMakeLists.txt file is similar in nature to the
toplevel CMakeLists.txt file but intended to used by sysbuild.
This allows application developers to adjust how an application is
built with sysbuild.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Use of ARGV1 is undefined when number of arguments to function is less
than 2. Therefore switch to ARGN which holds arguments beyond required
arguments.
If there are no optional arguments, then ARGN is just an empty list,
thus making it safe to use.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The sysbuild_cache_set() supports setting variables in a dedicated
sysbuild image cache. When appending to a list, the list is checked for
existance of the variable to avoid appending it again on reruns.
This was done be checking with `string(FIND ...)`, but that will also
return an index on a partial match.
A much safer approach is to use the `if(<val> IN_LIST <list>)` approach
to check for existance.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Unless `SB_CONF_FILE` is set by the user, an optional `sysbuild.conf`
file is taken by default. If `FILE_SUFFIX=foo` is set, then it should
also be possible to find `sysbuild_foo.conf`, just like with `prj.conf`.
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
Followup: #69905
Adopting new board terminology for CMake, python, and Kconfig code to
use qualifiers instead of identifiers.
Also adjusted to board target where applicable.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Adds support for the Kconfig option to enable compiler warnings
being treated as errors in all images that are build. This is a
sticky-set option which means enabling it in sysbuild will
enable it in all images, if it is then disabled in sysbuild it
will not be disabled in any of the images as a result and would
need to be manually unselected.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Add parentheses missing around $BOARD_REVISION.
The syntax without parentheses has been deprecated for at least 5 years:
374f488734
That same documentation states "Using the old syntax with an undefined
environment variable keeps the string as is." This what actually happens
on Windows where `build/zephyr/.config` looks like this:
CONFIG_BOARD_REVISION="$BOARD_REVISION"
I found this because the behavior differs on Linux where the same,
"old" syntax produces this instead:
CONFIG_BOARD_REVISION=""
This could be because environment variables work differently?
(BOARD_REVISION is passed from kconfig.cmake to kconfiglib.py thanks to
cmake -E env)
Let's not try to debug this and just drop the deprecated syntax. It
aligns both Windows and Linux on the same, expected, empty string
behavior.
Note these are the only two `def_string` found across all Kconfig files
right now.
Fixes commit c11b7852d1 ("Kconfig: add CONFIG_BOARD_REVISION")
Fixes commit e2ff2a88ba ("sysbuild: include HWMv2 Kconfig in sysbuild")
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Including HWMv2 Kconfig in sysbuild allows sysbuild to introduce
configuration options or defaults based on selected board and SoC.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Simply added the missing 'a' in guaranteed. Found this
when I was too lazy to search for the correct spelling
and was hoping to just grep for it.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Adds supports for sysbuild loading project-specific Kconfiguration
fragments that are suffixed with the user-provided value
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes an issue with shields that have Kconfig file fragments when
being used with sysbuild, they would be loaded into sysbuild
itself which would then fail because it does not have the Kconfig
tree that zephyr applications have
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Makes the MCUboot image configuration task run before the
application image configuration, this is so information can be
generated by MCUboot and then used in the application
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Assuming that all supported releases require at least CMake
version 3.0, we should be able to calculate the md5sum in a
much simpler way using string().
https://cmake.org/cmake/help/v3.0/command/string.html
This avoids writing a temporary file into the source directory
and therefore mitigates the possibility of the following
warning.
share/zephyr-package/cmake/zephyr_export.cmake:19 (string):
string sub-command SUBSTRING requires four arguments.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Add 3 new functions to perform functions typically needed
for native_simulator based targes and reduce the amount
of boilerplate.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Prevents allowing the user to enter a signing key when the signing
mode is set to hash check only without signatures
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes wrongly setting configuration to generate an unsigned image
in the MCUboot configuration when this does not apply to MCUboot
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Create dedicated function, sysbuild_cache(), for handling sysbuild's
image specific cache file.
This provides a cleaner handling of said cache file, and provides a
mechanism for updating the cache file at later sysbuild CMake stages.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
These variables need to be converted to absolute paths internally, but
so far this has only worked when each value consisted of a single path.
Add a common loop to handle lists of paths.
As a bonus, run `string(CONFIGURE)` to expand those variables in the
same way as the regular CONF_FILE and EXTRA_CONF_FILE.
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
The recent support for BUILD_ONLY images was implemented by excluding
them from `domains.yaml`, in order to crudely prevent them from being
picked up by `west flash`. Arguably, this is incorrect or unexpected,
because the sysbuild documentation defines a "domain" as:
Every Zephyr CMake build system managed by sysbuild.
Another consequence is that, given a build-only `<image>`, this makes it
impossible to pass `--domain <image>` to `west flash`, `west debug`, and
ironically `west build`.
To fix that, `domains.yaml` should again represent all domains, and the
build-only ones should be indicated in another way. Enter `flash_order`:
a new top-level key in the domains YAML schema. It contains the default
sequence of images used by `west flash`, where the build-only images are
excluded, and the order is influenced by `sysbuild_add_dependencies()`.
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
Adds support for controlling the MCUboot (and application) signing
key, and allows for generating encrypted updates.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adjust the order in which image-specific `sysbuild.cmake` files are
iteratively included by sysbuild.
This is motivated by the introduction of `sysbuild_add_dependencies()`.
In the following example:
sysbuild_add_dependencies(CONFIGURE my_sample sample_a sample_b)
the `my_sample` image is expected to be added before this function is
called. Success depends not only on the placement of the call, but on
the order in which new images are added, which itself is influenced by
the order in which `sysbuild.cmake` files are included. This last order
can be tweaked to make the "dependencies" feature more user-friendly.
This is done by rewriting the internal `sysbuild.cmake` processing loop
into a new, general purpose function - `sysbuild_add_subdirectory()` -
which is a wrapper for `add_subdirectory(<source_dir>)` that recursively
includes `sysbuild.cmake` files for all images found in `<source_dir>`.
With the new function, all images that are expected to be found in a
given `<source_dir>` are guaranteed to be added around the same time.
This wasn't the case with the old processing loop, because the image-
specific `sysbuild.cmake` files (where "sub-images" could be defined)
were left to be processed at the very end.
Below is the initial order in which sysbuild will add all images.
Note: the order of Zephyr modules (from 1 to n) is well-defined.
1. Main application (aka DEFAULT_IMAGE)
2. MCUboot (optional)
3. All images added via these directories:
3.1. <module-1>.sysbuild-cmake
3.2. <module-2>.sysbuild-cmake
...
3.n. <module-n>.sysbuild-cmake
4. All images added via these files:
4.1. ${BOARD_DIR}/sysbuild.cmake
4.2. ${APP_DIR}/sysbuild.cmake (aka sub-images of DEFAULT_IMAGE)
These images are intended to be sorted for the users' convenience, from
most to least important in the build system, or least to most dependent
on other images for configuration (potentially).
Finally, the use of `sysbuild_add_subdirectory()` requires updating the
directory structure in sysbuild:
./images
- All images should belong here. The `DEFAULT_IMAGE` should be the
first and only image at the top level, so that it gets added first
and its sub-images get added last.
./images/bootloader
- Moved from ./bootloader.
./images/boards
- Adds images from the board-specific `sysbuild.cmake` file.
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
This variable was originally provided for two indended purposes:
* Let users manually add a new image in a desired order in the list.
* Let users set build-only images, which are excluded from the list.
Given the recent additions of the `sysbuild_add_dependencies()` function
and the `BUILD_ONLY` parameter, `IMAGES` should be considered obsolete.
Furthermore, the list of images added to sysbuild should be updated
automatically when calling `ExternalZephyrProject_Add()`. This is now
possible by using a GLOBAL property internal to sysbuild.
With that, the `IMAGES` variable can be removed. Its existing usage for
image ordering is replaced with `sysbuild_add_dependencies()` treewide.
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
Fixes#53650
The existing solution for image ordering involves the `IMAGES` variable,
which sysbuild originally provided to let users manually add a new image
in a desired order. This isn't very flexible for the following reasons:
* The order in which `IMAGES` is updated across multiple modules and
`sysbuild.cmake` files is not well defined.
* Having a single variable means that the same order is used for both
configuration and flashing. Usually, there is no reason for the
flashing order to be the same as the configuration order.
Introduce the `sysbuild_add_dependencies()` function for more fine-tuned
ordering of images. It makes one image depend on other images in either
configuration or flashing order. Its usage is similar to the standard
CMake function `add_dependencies()`, but with an extra parameter to
distinguish between two types of dependencies:
sysbuild_add_dependencies(CONFIGURE my_sample sample_a sample_b)
sysbuild_add_dependencies(FLASH my_sample sample_c sample_d)
CONFIGURE dependencies determine the order in which sysbuild configures
(runs CMake for) the individual images. This is useful if there is some
information from one application's build which needs to be available to
another application.
FLASH dependencies control the sequence of images used by `west flash`.
This could be used if a specific flashing order is required by an SoC,
a runner, or something else. Note that these dependencies are not valid
for images specified as `BUILD_ONLY`.
The internal `sysbuild_images_order()` function is responsible for
assembling two sorted lists of images based on the added dependencies,
with the help of `topological_sort()`.
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
Refactor image_config.cmake so that it is no longer sourced
unconditionally for all images. Instead image_config.cmake has been
split into BOOTLOADER_image_default.cmake and MAIN_image_default.cmake
and is set as property on the image.
This means the code in image_config.cmake can be split into dedicated
files which depends on the image type. Furthermore it allows sysbuild
modules to append extra config snippets to process for sysbuild kconfig
overwrite, or even remove the default snippet and have full control.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Export Zephyr image byproducts through `BYPRODUCT_<VAR>` cache
variables.
This allow external tools, such as sysbuild, to read information on
products produced by a Zephyr build from the image CMake cache.
For sysbuild, this means that all byproducts will be added to a phony
build target, which again allow sysbuild itself to depends on target
output and properly describe dependencies between byproducts and their
producing targets.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Add a new parameter to `ExternalZephyrProject_Add()`, which determines
whether a given sysbuild image should only be built and not considered
for flashing and debugging. By adding the following arguments:
BUILD_ONLY TRUE
the image will be marked as build-only and excluded from `domains.yaml`.
For cases where this setting should be controlled by users or individual
samples, Kconfig can be used:
ExternalZephyrProject_Add(
APPLICATION foo
SOURCE_DIR /path/to/foo
BUILD_ONLY ${CONFIG_FOO_IS_BUILD_ONLY}
)
This would be particularly fitting for "general-purpose" images, defined
in-tree or via Zephyr modules (whose inclusion in the multi-image build
should also be Kconfigurable).
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
Fixes an issue with relative paths both with and without using
sysbuild where they would not be updated properly or a warning
would previously be emitted.
Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Lately, sysbuild started filtering out variable names matching ^BOARD
during sysbuild cache file generation. As a result, one of the cache
variables that is no longer exported to other domains is BOARD_ROOT,
which breaks the recent support for out-of-tree boards in sysbuild.
Of those variables, the only one which is reasonable to filter out is
BOARD itself, because the purpose of that is to substitute a different
value for the one found in sysbuild's own CMake cache, which has the
board revision stripped out.
Update the relevant if-condition and use a single regex for brevity.
Fixes#59114.
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
When calling `sysbuild_get(<out-var> VAR <lookup-var> ...)` user
specifically specify the output variable and in such cases the overwrite
warning should not be printed, because such invocation is similar to a
regular `set(<var> <val>)` CMake call.
Only the invocation where the same variable name is used for lookup and
return variable, then the warning must be printed to avoid unintentional
overwriting of existing variables.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Sysbuild now generates a .config.sysbuild config file which specifies
settings controlled by sysbuild.
Any setting specified in this .config will overrule user provided
setting, and a warning will be raised if the sysbuild controlled value
is different from the value specified by the user.
This has the following benefits:
- Allow sysbuild to control any build setting without adjustments to
the existing Kconfig tree
- Allow sysbuild to adjust settings based on knowledge regarding enabled
images / bootloaders.
- Cleanup CMake code, as settings in sysbuild no longer needs to be
propagated using CMake cache variables.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit improves the BOARD handling for Zephyr images.
Concatenate sysbuild BOARD and BOARD_REVISION to BOARD when creating the
image sysbuild cache file. This ensures that the proper sysbuild
BOARD@REVISION can be correctly inherited.
Current solution creates image specific <image>_BOARD cache variables
whenever a board revision is in use, even if the image is expected to
inherit the BOARD@REVISION value from sysbuild.
This improvement means that only when a dedicated board or
board@revision is specified for an image, then an image sysbuild cache
entry will be created.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Align sysbuild with Zephyr CMake so that sysbuild supports
SB_EXTRA_CONF_FILE. Keep support for the old SB_OVERLAY_CONFIG.
This ensures that sysbuild is consistent with Zephyr CMake configuration
file handling.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This fixes a minor issue in sysbuild, where `-DOVERLAY_CONFIG=...` would
be applied not only to the main application, but also sysbuild itself.
This was incorrect, because sysbuild imports a different Kconfig tree
than normal Zephyr builds, so the same Kconfig fragment file would not
necessarily be valid for both.
This adds a new variable SB_OVERLAY_CONFIG to resolve this ambiguity.
It functions along the lines of SB_CONF_FILE, with both being sysbuild-
specific versions of existing variables.
To ensure that OVERLAY_CONFIG is still passed on to the main application
verbatim, its value is now loaded in `configuration_files.cmake`, rather
than `kconfig.cmake`. This is because the former file is not imported by
sysbuild, and it is where the related variables, such as CONF_FILE and
DTC_OVERLAY_FILE, are loaded as well.
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
Adds a new CMake helper function that can be used from sysbuild to
set or update sysbuild CMake cache variables.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes an issue whereby the direct variable was being used instead
of the cache variable when configuring target images.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>