Improve multiconfig documentation
v2 cover Improve multiconfig documentation
This series moves the multiconfig doc to its own document in the dev manual, and adds 2 sections to improve it.
It also adds BB_CURRENT_MC to variables.rst, and fixes previous references of that variable in the doc.
This series depends on the following series that adds the BB_CURRENT_MC doc in bitbake: https://lists.openembedded.org/g/bitbake-devel/message/17185.
---
Changes in v2:
- reviews from Quentin (thanks!)
- add dependency on bitbake series
- fix first commit's bad reference, replace with a :doc:
- fix some typos
- add example install and deploy tasks in the suggested best practices
- mention that the baremetal scenario could also apply to a main Soc
with companion microcontroller + add a note on overriding MACHINE or
not
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Antonin Godard (6):
dev-manual: move multiconfig documentation to its own document variables.rst: add a reference to BB_CURRENT_MC from bbdocs migration-5.2: fix references to BB_CURRENT_MC dev-manual/multiconfig: rename to use Multiconfig term dev-manual/multiconfig: improve the current doc dev-manual/multiconfig: add suggested best practices and baremetal sections
documentation/dev-manual/building.rst | 156 +----------- documentation/dev-manual/index.rst | 1 + documentation/dev-manual/multiconfig.rst | 309 +++++++++++++++++++++++ documentation/migration-guides/migration-5.2.rst | 4 +- documentation/ref-manual/variables.rst | 3 + 5 files changed, 317 insertions(+), 156 deletions(-)
---
base-commit: 6eda443c7fcfeecebd6b44b96a1587c4bb093a34
change-id: 20250129-multiconfig-doc-c37342a6ab91
Best regards,
Signature · 1 line
Antonin Godard <[email protected]>
PATCH v2 1/6 dev-manual: move multiconfig documentation to its own document
In preparation of more section and examples to multiconfig, move the section about it in building.rst into its own document.
--- documentation/dev-manual/building.rst | 156 +----------------------------- documentation/dev-manual/index.rst | 1 + documentation/dev-manual/multiconfig.rst | 160 +++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+), 154 deletions(-)
documentation/dev-manual/building.rst +2 -154
@@ -113,160 +113,8 @@ The following figure and list overviews the build process: Building Images for Multiple Targets Using Multiple Configurations ================================================================== -You can use a single ``bitbake`` command to build multiple images or -packages for different targets where each image or package requires a -different configuration (multiple configuration builds). The builds, in -this scenario, are sometimes referred to as "multiconfigs", and this -section uses that term throughout. - -This section describes how to set up for multiple configuration builds -and how to account for cross-build dependencies between the -multiconfigs. - -Setting Up and Running a Multiple Configuration Build ------------------------------------------------------ - -To accomplish a multiple configuration build, you must define each -target's configuration separately using a parallel configuration file in -the :term:`Build Directory` or configuration directory within a layer, and you -must follow a required file hierarchy. Additionally, you must enable the -multiple configuration builds in your ``local.conf`` file. - -Follow these steps to set up and execute multiple configuration builds: - -- *Create Separate Configuration Files*: You need to create a single - configuration file for each build target (each multiconfig). - The configuration definitions are implementation dependent but often - each configuration file will define the machine and the - temporary directory BitBake uses for the build. Whether the same - temporary directory (:term:`TMPDIR`) can be shared will depend on what is - similar and what is different between the configurations. Multiple MACHINE - targets can share the same (:term:`TMPDIR`) as long as the rest of the - configuration is the same, multiple :term:`DISTRO` settings would need separate - (:term:`TMPDIR`) directories. - - For example, consider a scenario with two different multiconfigs for the same - :term:`MACHINE`: "qemux86" built - for two distributions such as "poky" and "poky-lsb". In this case, - you would need to use the different :term:`TMPDIR`. - - Here is an example showing the minimal statements needed in a - configuration file for a "qemux86" target whose temporary build - directory is ``tmpmultix86``:: - - MACHINE = "qemux86" - TMPDIR = "${TOPDIR}/tmpmultix86" - - The location for these multiconfig configuration files is specific. - They must reside in the current :term:`Build Directory` in a sub-directory of - ``conf`` named ``multiconfig`` or within a layer's ``conf`` directory - under a directory named ``multiconfig``. Here is an example that defines - two configuration files for the "x86" and "arm" multiconfigs: - - .. image:: figures/multiconfig_files.png - :align: center - :width: 50% - - The usual :term:`BBPATH` search path is used to locate multiconfig files in - a similar way to other conf files. - -- *Add the BitBake Multi-configuration Variable to the Local - Configuration File*: Use the - :term:`BBMULTICONFIG` - variable in your ``conf/local.conf`` configuration file to specify - each multiconfig. Continuing with the example from the previous - figure, the :term:`BBMULTICONFIG` variable needs to enable two - multiconfigs: "x86" and "arm" by specifying each configuration file:: - - BBMULTICONFIG = "x86 arm" - - .. note:: - - A "default" configuration already exists by definition. This - configuration is named: "" (i.e. empty string) and is defined by - the variables coming from your ``local.conf`` - file. Consequently, the previous example actually adds two - additional configurations to your build: "arm" and "x86" along - with "". - -- *Launch BitBake*: Use the following BitBake command form to launch - the multiple configuration build:: - - $ bitbake [mc:multiconfigname:]target [[[mc:multiconfigname:]target] ... ] - - For the example in this section, the following command applies:: - - $ bitbake mc:x86:core-image-minimal mc:arm:core-image-sato mc::core-image-base - - The previous BitBake command builds a ``core-image-minimal`` image - that is configured through the ``x86.conf`` configuration file, a - ``core-image-sato`` image that is configured through the ``arm.conf`` - configuration file and a ``core-image-base`` that is configured - through your ``local.conf`` configuration file. - -.. note:: - - Support for multiple configuration builds in the Yocto Project &DISTRO; - (&DISTRO_NAME;) Release does not include Shared State (sstate) - optimizations. Consequently, if a build uses the same object twice - in, for example, two different :term:`TMPDIR` - directories, the build either loads from an existing sstate cache for - that build at the start or builds the object fresh. - -Enabling Multiple Configuration Build Dependencies --------------------------------------------------- - -Sometimes dependencies can exist between targets (multiconfigs) in a -multiple configuration build. For example, suppose that in order to -build a ``core-image-sato`` image for an "x86" multiconfig, the root -filesystem of an "arm" multiconfig must exist. This dependency is -essentially that the -:ref:`ref-tasks-image` task in the -``core-image-sato`` recipe depends on the completion of the -:ref:`ref-tasks-rootfs` task of the -``core-image-minimal`` recipe. - -To enable dependencies in a multiple configuration build, you must -declare the dependencies in the recipe using the following statement -form:: - - task_or_package[mcdepends] = "mc:from_multiconfig:to_multiconfig:recipe_name:task_on_which_to_depend" - -To better show how to use this statement, consider the example scenario -from the first paragraph of this section. The following statement needs -to be added to the recipe that builds the ``core-image-sato`` image:: - - do_image[mcdepends] = "mc:x86:arm:core-image-minimal:do_rootfs" - -In this example, the `from_multiconfig` is "x86". The `to_multiconfig` is "arm". The -task on which the :ref:`ref-tasks-image` task in the recipe depends is the -:ref:`ref-tasks-rootfs` task from the ``core-image-minimal`` recipe associated -with the "arm" multiconfig. - -Once you set up this dependency, you can build the "x86" multiconfig -using a BitBake command as follows:: - - $ bitbake mc:x86:core-image-sato - -This command executes all the tasks needed to create the -``core-image-sato`` image for the "x86" multiconfig. Because of the -dependency, BitBake also executes through the :ref:`ref-tasks-rootfs` task for the -"arm" multiconfig build. - -Having a recipe depend on the root filesystem of another build might not -seem that useful. Consider this change to the statement in the -``core-image-sato`` recipe:: - - do_image[mcdepends] = "mc:x86:arm:core-image-minimal:do_image" - -In this case, BitBake must -create the ``core-image-minimal`` image for the "arm" build since the -"x86" build depends on it. - -Because "x86" and "arm" are enabled for multiple configuration builds -and have separate configuration files, BitBake places the artifacts for -each build in the respective temporary build directories (i.e. -:term:`TMPDIR`). +See the :doc:`multiconfig` section of the Yocto Project Development Tasks +Manual. Building an Initial RAM Filesystem (Initramfs) Image ====================================================
documentation/dev-manual/index.rst +1 -0
@@ -20,6 +20,7 @@ Yocto Project Development Tasks Manual development-shell python-development-shell building + multiconfig speeding-up-build libraries prebuilt-libraries
documentation/dev-manual/multiconfig.rst new file +160 -0
160 lines not on this page · raw message
Signature · 1 line
2.47.0
Re: [docs] [PATCH v2 1/6] dev-manual: move multiconfig documentation to its own document
Hi Antonin,
Quoted 4 lines · Antonin Godard via lists.yoctoproject.org
In preparation of more section and examples to multiconfig, move the section about it in
building.rstinto its own document.Signed-off-by Antonin Godard <[email protected]>
Thanks!
Quentin
PATCH v2 2/6 variables.rst: add a reference to BB_CURRENT_MC from bbdocs
In reply to Antonin GodardBB_CURRENT_MC is documented in the Bitbake user manual. Add a reference to it here.
--- documentation/ref-manual/variables.rst | 3 +++ 1 file changed, 3 insertions(+)
documentation/ref-manual/variables.rst +3 -0
@@ -390,6 +390,9 @@ system and gives an overview of their function and contents. :term:`BB_CURRENTTASK` See :term:`bitbake:BB_CURRENTTASK` in the BitBake manual. + :term:`BB_CURRENT_MC` + See :term:`bitbake:BB_CURRENT_MC` in the BitBake manual. + :term:`BB_DEFAULT_TASK` See :term:`bitbake:BB_DEFAULT_TASK` in the BitBake manual.
Signature · 1 line
2.47.0
Re: [docs] [PATCH v2 2/6] variables.rst: add a reference to BB_CURRENT_MC from bbdocs
Hi Antonin,
Quoted 4 lines · Antonin Godard via lists.yoctoproject.org
BB_CURRENT_MCis documented in the Bitbake user manual. Add a reference to it here.Signed-off-by Antonin Godard <[email protected]>
Thanks!
Quentin
PATCH v2 3/6 migration-5.2: fix references to BB_CURRENT_MC
In reply to Antonin GodardNow part of the documentation.
--- documentation/migration-guides/migration-5.2.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
documentation/migration-guides/migration-5.2.rst +2 -2
@@ -97,12 +97,12 @@ systemd changes Multiconfig changes ~~~~~~~~~~~~~~~~~~~ -The value of ``BB_CURRENT_MC`` was changed from ``default`` to an empty string +The value of :term:`BB_CURRENT_MC` was changed from ``default`` to an empty string for the default multiconfig configuration to avoid needing to map the values within BitBake. This was already not happening in some cases so this fixes some obscure bugs. -Any logic based on ``BB_CURRENT_MC`` equalling to ``default`` by default should +Any logic based on :term:`BB_CURRENT_MC` equalling to ``default`` by default should be changed to be equal to an empty string. Virtual toolchain provider changes
Signature · 1 line
2.47.0
Re: [docs] [PATCH v2 3/6] migration-5.2: fix references to BB_CURRENT_MC
Hi Antonin,
Quoted 3 lines · Antonin Godard via lists.yoctoproject.org
Now part of the documentation.
Signed-off-by Antonin Godard <[email protected]>
Thanks!
Quentin
PATCH v2 4/6 dev-manual/multiconfig: rename to use Multiconfig term
In reply to Antonin GodardRename this section to explicitely name the multiple configuration feature "multiconfig".
--- documentation/dev-manual/multiconfig.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
documentation/dev-manual/multiconfig.rst +2 -2
@@ -1,7 +1,7 @@ .. SPDX-License-Identifier: CC-BY-SA-2.0-UK -Building Images for Multiple Targets Using Multiple Configurations -****************************************************************** +Building Images for Multiple Targets With Multiconfig +***************************************************** You can use a single ``bitbake`` command to build multiple images or packages for different targets where each image or package requires a
Signature · 1 line
2.47.0
PATCH v2 5/6 dev-manual/multiconfig: improve the current doc
In reply to Antonin GodardAfter the suggestions from Mark Hatle on the list
(https://lists.yoctoproject.org/g/docs/topic/110487932), rewrite the introduction to multiconfig with the following changes:
- Move the part of overriding TMPDIR or not to a note.
- Use BB_CURRENT_MC in the example.
- Various additions of references & improved formatting.
--- documentation/dev-manual/multiconfig.rst | 65 +++++++++++++++++++------------- 1 file changed, 39 insertions(+), 26 deletions(-)
documentation/dev-manual/multiconfig.rst +39 -26
@@ -17,7 +17,7 @@ Setting Up and Running a Multiple Configuration Build ===================================================== To accomplish a multiple configuration build, you must define each -target's configuration separately using a parallel configuration file in +target's configuration separately using a parallel :term:`configuration file` in the :term:`Build Directory` or configuration directory within a layer, and you must follow a required file hierarchy. Additionally, you must enable the multiple configuration builds in your ``local.conf`` file.
@@ -25,31 +25,27 @@ multiple configuration builds in your ``local.conf`` file. Follow these steps to set up and execute multiple configuration builds: - *Create Separate Configuration Files*: You need to create a single - configuration file for each build target (each multiconfig). + :term:`Configuration File` for each build target (each multiconfig). The configuration definitions are implementation dependent but often - each configuration file will define the machine and the - temporary directory BitBake uses for the build. Whether the same - temporary directory (:term:`TMPDIR`) can be shared will depend on what is - similar and what is different between the configurations. Multiple MACHINE - targets can share the same (:term:`TMPDIR`) as long as the rest of the - configuration is the same, multiple :term:`DISTRO` settings would need separate - (:term:`TMPDIR`) directories. - - For example, consider a scenario with two different multiconfigs for the same - :term:`MACHINE`: "qemux86" built - for two distributions such as "poky" and "poky-lsb". In this case, - you would need to use the different :term:`TMPDIR`. + each configuration file will define the :term:`MACHINE` and the + temporary directory (:term:`TMPDIR`) BitBake uses for the build. - Here is an example showing the minimal statements needed in a - configuration file for a "qemux86" target whose temporary build - directory is ``tmpmultix86``:: + .. note:: - MACHINE = "qemux86" - TMPDIR = "${TOPDIR}/tmpmultix86" + Whether the same temporary directory (:term:`TMPDIR`) can be shared will + depend on what is similar and what is different between the + configurations. Multiple :term:`MACHINE` targets can share the same + :term:`TMPDIR` as long as the rest of the configuration is the same, + multiple :term:`DISTRO` settings would need separate :term:`TMPDIR` + directories. + + For example, consider a scenario with two different multiconfigs for the same + :term:`MACHINE`: "qemux86" built for two distributions such as "poky" and + "poky-lsb". In this case, you would need to use two different :term:`TMPDIR`. The location for these multiconfig configuration files is specific. They must reside in the current :term:`Build Directory` in a sub-directory of - ``conf`` named ``multiconfig`` or within a layer's ``conf`` directory + ``conf`` named ``multiconfig`` or within a :term:`Layer`'s ``conf`` directory under a directory named ``multiconfig``. Here is an example that defines two configuration files for the "x86" and "arm" multiconfigs:
@@ -58,7 +54,19 @@ Follow these steps to set up and execute multiple configuration builds: :width: 50% The usual :term:`BBPATH` search path is used to locate multiconfig files in - a similar way to other conf files. + a similar way to other configuration files. + + Here is an example showing the minimal statements needed in a + :term:`configuration file` named ``qemux86.conf`` for a ``qemux86`` target + whose temporary build directory is ``tmp-qemux86``:: + + MACHINE = "qemux86" + TMPDIR .= "-${BB_CURRENT_MC}" + + BitBake will expand the :term:`BB_CURRENT_MC` variable to the value of the + current multiconfig in use. We append this value to :term:`TMPDIR` so that + any change on the definition of :term:`TMPDIR` will automatically affect the + value of :term:`TMPDIR` for each multiconfig. - *Add the BitBake Multi-configuration Variable to the Local Configuration File*: Use the
@@ -88,11 +96,16 @@ Follow these steps to set up and execute multiple configuration builds: $ bitbake mc:x86:core-image-minimal mc:arm:core-image-sato mc::core-image-base - The previous BitBake command builds a ``core-image-minimal`` image - that is configured through the ``x86.conf`` configuration file, a - ``core-image-sato`` image that is configured through the ``arm.conf`` - configuration file and a ``core-image-base`` that is configured - through your ``local.conf`` configuration file. + The previous BitBake command builds several components: + + - A ``core-image-minimal`` image that is configured through the ``x86.conf`` + configuration file + + - A ``core-image-sato`` image that is configured through the ``arm.conf`` + configuration file + + - A ``core-image-base`` that is configured through your ``local.conf`` + configuration file .. note::
Signature · 1 line
2.47.0
Re: [docs] [PATCH v2 5/6] dev-manual/multiconfig: improve the current doc
Hi Antonin,
Quoted 10 lines · Antonin Godard via lists.yoctoproject.org
After the suggestions from Mark Hatle on the list
(https://lists.yoctoproject.org/g/docs/topic/110487932), rewrite the introduction to multiconfig with the following changes:- Move the part of overriding TMPDIR or not to a note.
- UseBB_CURRENT_MCin the example.
- Various additions of references & improved formatting.Suggested-by Mark Hatle <[email protected]>Signed-off-by Antonin Godard <[email protected]>
Though I would recommend to just strongly recommend having separate TMPDIR instead of trying to explain what a valid usecase for a common TMPDIR would be?
Thanks!
Quentin
Re: [docs] [PATCH v2 5/6] dev-manual/multiconfig: improve the current doc
Hi Quentin,
Quoted 11 lines · Quentin Schulz
Hi Antonin,
Quoted 8 lines · Antonin Godard via lists.yoctoproject.org
After the suggestions from Mark Hatle on the list
(https://lists.yoctoproject.org/g/docs/topic/110487932), rewrite the introduction to multiconfig with the following changes:- Move the part of overriding TMPDIR or not to a note.
- UseBB_CURRENT_MCin the example.
- Various additions of references & improved formatting.
Quoted 8 lines
Quoted 2 lines
Suggested-by Mark Hatle <[email protected]>Signed-off-by Antonin Godard <[email protected]>Reviewed-by Quentin Schulz <[email protected]>Though I would recommend to just strongly recommend having separate TMPDIR instead of trying to explain what a valid usecase for a common TMPDIR would be?
You're right, I will add the following sentence at the end of the ..note::
"""
In the general case, using separate :term:TMPDIR for the different multiconfigs is strongly recommended.
"""
Thanks,
Antonin
Signature · 3 lines
Antonin Godard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 6/6 dev-manual/multiconfig: add suggested best practices and baremetal sections
In reply to Antonin GodardAfter the suggestions from Mark Hatle on the list
(https://lists.yoctoproject.org/g/docs/topic/110487932), add two sections to the multiconfig doc:
- Suggested best practices: suggestion for better design of multiconfig builds.
- Common use case: baremetal build.
This section applies the guidelines from the first sections and apply it to a real-life example of how to use multiconfig. This one to build some baremetal firmware alongside a regular Linux build.
--- documentation/dev-manual/multiconfig.rst | 136 +++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+)
documentation/dev-manual/multiconfig.rst +136 -0
@@ -171,3 +171,139 @@ and have separate configuration files, BitBake places the artifacts for each build in the respective temporary build directories (i.e. :term:`TMPDIR`). +Suggested best practices +======================== + +- :term:`TMPDIR` (other than the default set in bitbake.conf) is only set in + ``local.conf`` by the user. This means that we should **not** manipulate + :term:`TMPDIR` in any way within the Machine or Distro :term:`configuration + file`. + +- A multiconfig should specify a :term:`TMPDIR`, and should specify it by + appending the multiconfig name via :term:`BB_CURRENT_MC`. + +- Recipes that are used to transfer the output from a multiconfig build to + another should use ``do_task[mcdepends]`` to trigger the build of the + component, and then transfer the item to the current configuration in + :ref:`ref-tasks-install` and :ref:`ref-tasks-deploy`, assuming the value of + the deployed item based on :term:`TMPDIR`. + + The :ref:`ref-tasks-install` and :ref:`ref-tasks-deploy` tasks should look + like this:: + + do_install() { + install -m 0644 ${TMPDIR}-<multiconfig>/tmp/deploy/images/<machine>/somefile ${D}/some/path + } + + do_deploy() { + install -m 0644 ${TMPDIR}-<multiconfig>/tmp/deploy/images/<machine>/somefile ${DEPLOYDIR}/somefile + } + + In the examples above: + + - ``<multiconfig>`` is the multiconfig name as set by the multiconfig + :term:`configuration file` (see the :ref:`dev-manual/multiconfig:Setting + Up and Running a Multiple Configuration Build` section above). + + - ``<machine>`` must be the :term:`MACHINE` for which ``somefile`` was built + and deployed. This value depends on whether the multiconfig + :term:`configuration file` is overriding the :term:`MACHINE` value or not. + +- Firmware recipes can set the :term:`INHIBIT_DEFAULT_DEPS` variable to ``1`` + if they don't rely on default dependencies such as the standard C library. + +Common use case: building baremetal firmware alongside a Linux build +==================================================================== + +A common use for multiconfig is to use the default configuration as the regular +Linux build, while one or more multiconfigs can be used to build special +components, such as baremetal firmware. It would also apply to a scenario where +a microcontroller, for example, is companion to a main processor where Linux is +running. This section details how one can achieve these kinds of scenarios with +a multiconfig build. + +Adding a multiconfig configuration file and recipe for a baremetal firmware +--------------------------------------------------------------------------- + +As described in :ref:`dev-manual/multiconfig:Setting Up and Running a Multiple +Configuration Build`, each multiconfig will require a separate +:term:`Configuration File`. In our case, we will make a separate temporary +directory for our baremetal firmware build configuration. + +For example, we will define a new ``conf/multiconfig/baremetal-firmware.conf`` +as follows:: + + TMPDIR .= "-${BB_CURRENT_MC}" + TCLIBC = "newlib" + +The ``baremetal-firmware.conf`` configure a separate :term:`TMPDIR` for holding +binaries compiled with the `newlib <https://sourceware.org/newlib/>`__ toolchain +(see :term:`TCLIBC`). + +.. note:: + + Here, the default :term:`MACHINE` is not overriden by the multiconfig + configuration file. As a consequence, the architecture of the built baremetal + binaries will be the same. In other cases, where the firmware runs on a + completely different architecture, the :term:`MACHINE` may be overriden. + +We then create a recipe ``my-firmware.bb`` that defines how the baremetal +firmware is built. The recipe should contain enough information for the +:term:`OpenEmbedded build system` to properly compile the firmware with our +toolchain. The building tasks may vary depending on the nature of the firmware. +However, the recipe should define a :ref:`ref-classes-deploy` task that deploys +the output into the :term:`DEPLOYDIR` directory. We will consider in the +following that the file is named ``my-firmware.elf``. + +Building the firmware +--------------------- + +The firmware can be built with BitBake with the following command:: + + $ bitbake mc:baremetal-firmware:my-firmware + +However, we would prefer for ``my-firmware`` to be automatically built when +triggering a normal Linux build. + +Using an ``mcdepend``, a recipe belonging to the Linux build can trigger the +build of ``my-firmware``. For example, let's consider that our Linux build needs +to assemble a "special" firmware that uses the output of our ``my-firmware`` +recipe - let's call it ``my-parent-firmware.bb``. Then, we should specify this +dependency in ``my-parent-firmware.bb`` with:: + + do_compile[mcdepends] = "mc::baremetal-firmware:my-firmware:do_deploy" + +The above will ensure that when the :ref:`ref-tasks-compile` task of +``my-parent-firmware`` is triggered, the :ref:`ref-tasks-deploy` task of +``my-firmware`` will already have run successfully. + +Using the output of ``my-firmware`` +----------------------------------- + +After we have deployed ``my-firmware`` by using ``mcdepends``, we need to use +the output in some way. We can make a series of assumptions, based on the +default Yocto Project variables in order to get the binary for packaging. + +First, we can set the following in ``my-parent-firmware.bb``:: + + FIRMWARE_FILE ??= "${TMPDIR}-baremetal-firmware/deploy/images/<machine>/my-firmware.elf" + FIRMWARE_FILE[vardepsexclude] += "TMPDIR" + +The first assignment stores the value of the path to the firmware built and +deployed by the ``my-firmware.bb`` recipe. The second assignment excludes the +:term:`TMPDIR` variable from being part of ``FIRMWARE_FILE``'s dependencies - +meaning that changing the value of :term:`TMPDIR` (for example, changing the +host on which the firmware is built) will not invalidate the :ref:`shared state +cache <overview-manual/concepts:shared state cache>`. + +Additionally, ``<machine>`` should be replaced by the :term:`MACHINE` for which +we are building in the baremetal-firmware context. + +We can then add a :ref:`ref-tasks-install` task to ``my-parent-firmware``:: + + do_install() { + install -Dm 0644 ${FIRMWARE_FILE} ${D}/lib/firmware/my-firmware.elf + } + +Doing the above will allow the firmware binary to be transferred and packaged +into the Linux context and rootfs.
Signature · 1 line
2.47.0
Re: [docs] [PATCH v2 6/6] dev-manual/multiconfig: add suggested best practices and baremetal sections
Hi Antonin,
Quoted 27 lines · Antonin Godard via lists.yoctoproject.org
After the suggestions from Mark Hatle on the list
(https://lists.yoctoproject.org/g/docs/topic/110487932), add two sections to the multiconfig doc:- Suggested best practices: suggestion for better design of multiconfig builds.
- Common use case: baremetal build.
This section applies the guidelines from the first sections and apply it to a real-life example of how to use multiconfig. This one to build some baremetal firmware alongside a regular Linux build.
Suggested-by Mark Hatle <[email protected]>Signed-off-by Antonin Godard <[email protected]>--- documentation/dev-manual/multiconfig.rst | 136 +++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+)documentation/dev-manual/multiconfig.rst +0
-0@@ -171,3 +171,139 @@ and have separate configuration files, BitBake places the artifacts for each build in the respective temporary build directories (i.e. :term:`TMPDIR`).
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 183
Quoted 10 lines
documentation/dev-manual/multiconfig.rst +10
-0+Suggested best practices +======================== + +- :term:`TMPDIR` (other than the default set in bitbake.conf) is only set in + ``local.conf`` by the user. This means that we should **not** manipulate + :term:`TMPDIR` in any way within the Machine or Distro :term:`configuration + file`. + +- A multiconfig should specify a :term:`TMPDIR`, and should specify it by + appending the multiconfig name via :term:`BB_CURRENT_MC`.
s/via/with/
Quoted 10 lines
documentation/dev-manual/multiconfig.rst +10
-0+ +- Recipes that are used to transfer the output from a multiconfig build to + another should use ``do_task[mcdepends]`` to trigger the build of the + component, and then transfer the item to the current configuration in + :ref:`ref-tasks-install` and :ref:`ref-tasks-deploy`, assuming the value of + the deployed item based on :term:`TMPDIR`. + + The :ref:`ref-tasks-install` and :ref:`ref-tasks-deploy` tasks should look + like this:: +
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 203
Quoted 10 lines
documentation/dev-manual/multiconfig.rst +10
-0+ do_install() { + install -m 0644 ${TMPDIR}-<multiconfig>/tmp/deploy/images/<machine>/somefile ${D}/some/path + } + + do_deploy() { + install -m 0644 ${TMPDIR}-<multiconfig>/tmp/deploy/images/<machine>/somefile ${DEPLOYDIR}/somefile + } + + In the examples above: +
s/examples/example/
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 211
Quoted 8 lines
documentation/dev-manual/multiconfig.rst +8
-0+ - ``<multiconfig>`` is the multiconfig name as set by the multiconfig + :term:`configuration file` (see the :ref:`dev-manual/multiconfig:Setting + Up and Running a Multiple Configuration Build` section above). + + - ``<machine>`` must be the :term:`MACHINE` for which ``somefile`` was built + and deployed. This value depends on whether the multiconfig + :term:`configuration file` is overriding the :term:`MACHINE` value or not. +
I can suggest:
"""
This value may differ from the current :term:MACHINE if the multiconfig :term:configuration file overrides it. """
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 218
Quoted 7 lines
documentation/dev-manual/multiconfig.rst +7
-0+- Firmware recipes can set the :term:`INHIBIT_DEFAULT_DEPS` variable to ``1`` + if they don't rely on default dependencies such as the standard C library. + +Common use case: building baremetal firmware alongside a Linux build +==================================================================== + +A common use for multiconfig is to use the default configuration as the regular
s/use/use case/ ?
Quoted 4 lines
documentation/dev-manual/multiconfig.rst +4
-0+Linux build, while one or more multiconfigs can be used to build special +components, such as baremetal firmware. It would also apply to a scenario where +a microcontroller, for example, is companion to a main processor where Linux is +running. This section details how one can achieve these kinds of scenarios with
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 232
Quoted 10 lines
documentation/dev-manual/multiconfig.rst +10
-0+a multiconfig build. + +Adding a multiconfig configuration file and recipe for a baremetal firmware +--------------------------------------------------------------------------- + +As described in :ref:`dev-manual/multiconfig:Setting Up and Running a Multiple +Configuration Build`, each multiconfig will require a separate +:term:`Configuration File`. In our case, we will make a separate temporary +directory for our baremetal firmware build configuration. +
Mmmm not sure what "separate temporary directory" should mean here? Are you talking about the conf/multiconfig/ directory or TMPDIR?
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 239
Quoted 7 lines
documentation/dev-manual/multiconfig.rst +7
-0+For example, we will define a new ``conf/multiconfig/baremetal-firmware.conf`` +as follows:: + + TMPDIR .= "-${BB_CURRENT_MC}" + TCLIBC = "newlib" + +The ``baremetal-firmware.conf`` configure a separate :term:`TMPDIR` for holding
s/configure/configures/
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 245
Quoted 6 lines
documentation/dev-manual/multiconfig.rst +6
-0+binaries compiled with the `newlib <https://sourceware.org/newlib/>`__ toolchain +(see :term:`TCLIBC`). + +.. note:: + + Here, the default :term:`MACHINE` is not overriden by the multiconfig
s/overriden/overridden/
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 247
Quoted 2 lines
documentation/dev-manual/multiconfig.rst +2
-0+ configuration file. As a consequence, the architecture of the built baremetal + binaries will be the same. In other cases, where the firmware runs on a
s/the same/the same as the one for the Linux build/
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 248
Quoted 1 line
documentation/dev-manual/multiconfig.rst +1
-0+ completely different architecture, the :term:`MACHINE` may be overriden.
s/may/must/
s/overriden/overridden/
Quoted 10 lines
documentation/dev-manual/multiconfig.rst +10
-0+ +We then create a recipe ``my-firmware.bb`` that defines how the baremetal +firmware is built. The recipe should contain enough information for the +:term:`OpenEmbedded build system` to properly compile the firmware with our +toolchain. The building tasks may vary depending on the nature of the firmware. +However, the recipe should define a :ref:`ref-classes-deploy` task that deploys +the output into the :term:`DEPLOYDIR` directory. We will consider in the +following that the file is named ``my-firmware.elf``. + +Building the firmware
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 268
Quoted 10 lines
documentation/dev-manual/multiconfig.rst +10
-0+--------------------- + +The firmware can be built with BitBake with the following command:: + + $ bitbake mc:baremetal-firmware:my-firmware + +However, we would prefer for ``my-firmware`` to be automatically built when +triggering a normal Linux build. + +Using an ``mcdepend``, a recipe belonging to the Linux build can trigger the
I read mcdepend as multiconfigdepend or macdepend, and not em-see-depend. So I would use "a" and not "an" but no strong opinion.
Quoted 5 lines
documentation/dev-manual/multiconfig.rst +5
-0+build of ``my-firmware``. For example, let's consider that our Linux build needs +to assemble a "special" firmware that uses the output of our ``my-firmware`` +recipe - let's call it ``my-parent-firmware.bb``. Then, we should specify this +dependency in ``my-parent-firmware.bb`` with:: +
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 283
Quoted 10 lines
documentation/dev-manual/multiconfig.rst +10
-0+ do_compile[mcdepends] = "mc::baremetal-firmware:my-firmware:do_deploy" + +The above will ensure that when the :ref:`ref-tasks-compile` task of +``my-parent-firmware`` is triggered, the :ref:`ref-tasks-deploy` task of +``my-firmware`` will already have run successfully. + +Using the output of ``my-firmware`` +----------------------------------- + +After we have deployed ``my-firmware`` by using ``mcdepends``, we need to use
I can suggest:
"""
After ``my-firmware`` recipe has deployed my-firmware.elf, we need to use """
otherwise it may imply that mcdepends it what deployed my-firmware which isn't the case, it just made sure my-firmware:do_deploy is finished before my-parent-firmware:do_compile starts.
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 294
Quoted 11 lines
documentation/dev-manual/multiconfig.rst +11
-0+the output in some way. We can make a series of assumptions, based on the +default Yocto Project variables in order to get the binary for packaging. + +First, we can set the following in ``my-parent-firmware.bb``:: + + FIRMWARE_FILE ??= "${TMPDIR}-baremetal-firmware/deploy/images/<machine>/my-firmware.elf" + FIRMWARE_FILE[vardepsexclude] += "TMPDIR" + +The first assignment stores the value of the path to the firmware built and +deployed by the ``my-firmware.bb`` recipe. The second assignment excludes the +:term:`TMPDIR` variable from being part of ``FIRMWARE_FILE``'s dependencies -
Michael really wanted to use em-dashes, so maybe use it here?
i.e.
---
c.f. c29a1bf4dd52 ("profile-manual: usage.rst: formatting fixes")
Cheers,
Quentin
Re: [docs] [PATCH v2 6/6] dev-manual/multiconfig: add suggested best practices and baremetal sections
Hi Quentin,
Quoted 101 lines · Quentin Schulz
Hi Antonin,
Quoted 27 lines · Antonin Godard via lists.yoctoproject.org
After the suggestions from Mark Hatle on the list
(https://lists.yoctoproject.org/g/docs/topic/110487932), add two sections to the multiconfig doc:- Suggested best practices: suggestion for better design of multiconfig builds.
- Common use case: baremetal build.
This section applies the guidelines from the first sections and apply it to a real-life example of how to use multiconfig. This one to build some baremetal firmware alongside a regular Linux build.
Suggested-by Mark Hatle <[email protected]>Signed-off-by Antonin Godard <[email protected]>--- documentation/dev-manual/multiconfig.rst | 136 +++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+)documentation/dev-manual/multiconfig.rst +0
-0@@ -171,3 +171,139 @@ and have separate configuration files, BitBake places the artifacts for each build in the respective temporary build directories (i.e. :term:`TMPDIR`).documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 183
Quoted 10 lines
documentation/dev-manual/multiconfig.rst +10
-0+Suggested best practices +======================== + +- :term:`TMPDIR` (other than the default set in bitbake.conf) is only set in + ``local.conf`` by the user. This means that we should **not** manipulate + :term:`TMPDIR` in any way within the Machine or Distro :term:`configuration + file`. + +- A multiconfig should specify a :term:`TMPDIR`, and should specify it by + appending the multiconfig name via :term:`BB_CURRENT_MC`.s/via/with/
Quoted 10 lines
documentation/dev-manual/multiconfig.rst +10
-0+ +- Recipes that are used to transfer the output from a multiconfig build to + another should use ``do_task[mcdepends]`` to trigger the build of the + component, and then transfer the item to the current configuration in + :ref:`ref-tasks-install` and :ref:`ref-tasks-deploy`, assuming the value of + the deployed item based on :term:`TMPDIR`. + + The :ref:`ref-tasks-install` and :ref:`ref-tasks-deploy` tasks should look + like this:: +documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 203
Quoted 10 lines
documentation/dev-manual/multiconfig.rst +10
-0+ do_install() { + install -m 0644 ${TMPDIR}-<multiconfig>/tmp/deploy/images/<machine>/somefile ${D}/some/path + } + + do_deploy() { + install -m 0644 ${TMPDIR}-<multiconfig>/tmp/deploy/images/<machine>/somefile ${DEPLOYDIR}/somefile + } + + In the examples above: +s/examples/example/
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 211
Quoted 8 lines
documentation/dev-manual/multiconfig.rst +8
-0+ - ``<multiconfig>`` is the multiconfig name as set by the multiconfig + :term:`configuration file` (see the :ref:`dev-manual/multiconfig:Setting + Up and Running a Multiple Configuration Build` section above). + + - ``<machine>`` must be the :term:`MACHINE` for which ``somefile`` was built + and deployed. This value depends on whether the multiconfig + :term:`configuration file` is overriding the :term:`MACHINE` value or not. +I can suggest:
"""
This value may differ from the current :term:MACHINEif the multiconfig :term:configuration fileoverrides it. """documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 218
Quoted 7 lines
documentation/dev-manual/multiconfig.rst +7
-0+- Firmware recipes can set the :term:`INHIBIT_DEFAULT_DEPS` variable to ``1`` + if they don't rely on default dependencies such as the standard C library. + +Common use case: building baremetal firmware alongside a Linux build +==================================================================== + +A common use for multiconfig is to use the default configuration as the regulars/use/use case/ ?
Quoted 9 lines
documentation/dev-manual/multiconfig.rst +9
-0+Linux build, while one or more multiconfigs can be used to build special +components, such as baremetal firmware. It would also apply to a scenario where +a microcontroller, for example, is companion to a main processor where Linux is +running. This section details how one can achieve these kinds of scenarios with +a multiconfig build. + +Adding a multiconfig configuration file and recipe for a baremetal firmware +--------------------------------------------------------------------------- +
Quoted 8 lines
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 232
Quoted 5 lines
documentation/dev-manual/multiconfig.rst +5
-0+As described in :ref:`dev-manual/multiconfig:Setting Up and Running a Multiple +Configuration Build`, each multiconfig will require a separate +:term:`Configuration File`. In our case, we will make a separate temporary +directory for our baremetal firmware build configuration. +Mmmm not sure what "separate temporary directory" should mean here? Are you talking about the conf/multiconfig/ directory or TMPDIR?
Yes, that wasn't clear. I was talking about the TMPDIR. Will rephrase to:
"""
In addition, we will define a separate :term:TMPDIR for our baremetal firmware build configuration.
"""
Quoted 45 lines
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 239
Quoted 7 lines
documentation/dev-manual/multiconfig.rst +7
-0+For example, we will define a new ``conf/multiconfig/baremetal-firmware.conf`` +as follows:: + + TMPDIR .= "-${BB_CURRENT_MC}" + TCLIBC = "newlib" + +The ``baremetal-firmware.conf`` configure a separate :term:`TMPDIR` for holdings/configure/configures/
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 245
Quoted 6 lines
documentation/dev-manual/multiconfig.rst +6
-0+binaries compiled with the `newlib <https://sourceware.org/newlib/>`__ toolchain +(see :term:`TCLIBC`). + +.. note:: + + Here, the default :term:`MACHINE` is not overriden by the multiconfigs/overriden/overridden/
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 247
Quoted 2 lines
documentation/dev-manual/multiconfig.rst +2
-0+ configuration file. As a consequence, the architecture of the built baremetal + binaries will be the same. In other cases, where the firmware runs on as/the same/the same as the one for the Linux build/
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 248
Quoted 1 line
documentation/dev-manual/multiconfig.rst +1
-0+ completely different architecture, the :term:`MACHINE` may be overriden.s/may/must/
s/overriden/overridden/
Quoted 15 lines
documentation/dev-manual/multiconfig.rst +15
-0+ +We then create a recipe ``my-firmware.bb`` that defines how the baremetal +firmware is built. The recipe should contain enough information for the +:term:`OpenEmbedded build system` to properly compile the firmware with our +toolchain. The building tasks may vary depending on the nature of the firmware. +However, the recipe should define a :ref:`ref-classes-deploy` task that deploys +the output into the :term:`DEPLOYDIR` directory. We will consider in the +following that the file is named ``my-firmware.elf``. + +Building the firmware +--------------------- + +The firmware can be built with BitBake with the following command:: + + $ bitbake mc:baremetal-firmware:my-firmware
Quoted 8 lines
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 268
Quoted 5 lines
documentation/dev-manual/multiconfig.rst +5
-0+ +However, we would prefer for ``my-firmware`` to be automatically built when +triggering a normal Linux build. + +Using an ``mcdepend``, a recipe belonging to the Linux build can trigger theI read mcdepend as multiconfigdepend or macdepend, and not em-see-depend. So I would use "a" and not "an" but no strong opinion.
Ha, that's right, I read it as em-see-depend. It's probably multiconfigdepends tbh, so I'll swap to "a".
Quoted 18 lines
Quoted 5 lines
documentation/dev-manual/multiconfig.rst +5
-0+build of ``my-firmware``. For example, let's consider that our Linux build needs +to assemble a "special" firmware that uses the output of our ``my-firmware`` +recipe - let's call it ``my-parent-firmware.bb``. Then, we should specify this +dependency in ``my-parent-firmware.bb`` with:: +documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 283
Quoted 10 lines
documentation/dev-manual/multiconfig.rst +10
-0+ do_compile[mcdepends] = "mc::baremetal-firmware:my-firmware:do_deploy" + +The above will ensure that when the :ref:`ref-tasks-compile` task of +``my-parent-firmware`` is triggered, the :ref:`ref-tasks-deploy` task of +``my-firmware`` will already have run successfully. + +Using the output of ``my-firmware`` +----------------------------------- + +After we have deployed ``my-firmware`` by using ``mcdepends``, we need to useI can suggest:
Quoted 7 lines
"""
After ``my-firmware`` recipe has deployedmy-firmware.elf, we need to use """otherwise it may imply that mcdepends it what deployed my-firmware which isn't the case, it just made sure my-firmware:do_deploy is finished before my-parent-firmware:do_compile starts.
+1, I agree
Quoted 14 lines
documentation/dev-manual/multiconfig.rst and have separate configuration files, BitBake places the artifacts for · line 294
Quoted 11 lines
documentation/dev-manual/multiconfig.rst +11
-0+the output in some way. We can make a series of assumptions, based on the +default Yocto Project variables in order to get the binary for packaging. + +First, we can set the following in ``my-parent-firmware.bb``:: + + FIRMWARE_FILE ??= "${TMPDIR}-baremetal-firmware/deploy/images/<machine>/my-firmware.elf" + FIRMWARE_FILE[vardepsexclude] += "TMPDIR" + +The first assignment stores the value of the path to the firmware built and +deployed by the ``my-firmware.bb`` recipe. The second assignment excludes the +:term:`TMPDIR` variable from being part of ``FIRMWARE_FILE``'s dependencies -Michael really wanted to use em-dashes, so maybe use it here?
Quoted 5 lines
i.e.
---
c.f.
c29a1bf4dd52("profile-manual:usage.rst: formatting fixes")
Will do
Thanks a lot!
Antonin
Signature · 3 lines
Antonin Godard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com