summaryrefslogtreecommitdiffstats
path: root/documentation/dev-manual/building.rst
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/dev-manual/building.rst')
-rw-r--r--documentation/dev-manual/building.rst246
1 files changed, 88 insertions, 158 deletions
diff --git a/documentation/dev-manual/building.rst b/documentation/dev-manual/building.rst
index fe502690dd..32c7aa5da0 100644
--- a/documentation/dev-manual/building.rst
+++ b/documentation/dev-manual/building.rst
@@ -48,7 +48,7 @@ The following figure and list overviews the build process:
48 :width: 100% 48 :width: 100%
49 49
50#. *Set up Your Host Development System to Support Development Using the 50#. *Set up Your Host Development System to Support Development Using the
51 Yocto Project*: See the ":doc:`start`" section for options on how to get a 51 Yocto Project*: See the ":doc:`/dev-manual/start`" section for options on how to get a
52 build host ready to use the Yocto Project. 52 build host ready to use the Yocto Project.
53 53
54#. *Initialize the Build Environment:* Initialize the build environment 54#. *Initialize the Build Environment:* Initialize the build environment
@@ -113,160 +113,8 @@ The following figure and list overviews the build process:
113Building Images for Multiple Targets Using Multiple Configurations 113Building Images for Multiple Targets Using Multiple Configurations
114================================================================== 114==================================================================
115 115
116You can use a single ``bitbake`` command to build multiple images or 116See the :doc:`/dev-manual/multiconfig` section of the Yocto Project Development Tasks
117packages for different targets where each image or package requires a 117Manual.
118different configuration (multiple configuration builds). The builds, in
119this scenario, are sometimes referred to as "multiconfigs", and this
120section uses that term throughout.
121
122This section describes how to set up for multiple configuration builds
123and how to account for cross-build dependencies between the
124multiconfigs.
125
126Setting Up and Running a Multiple Configuration Build
127-----------------------------------------------------
128
129To accomplish a multiple configuration build, you must define each
130target's configuration separately using a parallel configuration file in
131the :term:`Build Directory` or configuration directory within a layer, and you
132must follow a required file hierarchy. Additionally, you must enable the
133multiple configuration builds in your ``local.conf`` file.
134
135Follow these steps to set up and execute multiple configuration builds:
136
137- *Create Separate Configuration Files*: You need to create a single
138 configuration file for each build target (each multiconfig).
139 The configuration definitions are implementation dependent but often
140 each configuration file will define the machine and the
141 temporary directory BitBake uses for the build. Whether the same
142 temporary directory (:term:`TMPDIR`) can be shared will depend on what is
143 similar and what is different between the configurations. Multiple MACHINE
144 targets can share the same (:term:`TMPDIR`) as long as the rest of the
145 configuration is the same, multiple :term:`DISTRO` settings would need separate
146 (:term:`TMPDIR`) directories.
147
148 For example, consider a scenario with two different multiconfigs for the same
149 :term:`MACHINE`: "qemux86" built
150 for two distributions such as "poky" and "poky-lsb". In this case,
151 you would need to use the different :term:`TMPDIR`.
152
153 Here is an example showing the minimal statements needed in a
154 configuration file for a "qemux86" target whose temporary build
155 directory is ``tmpmultix86``::
156
157 MACHINE = "qemux86"
158 TMPDIR = "${TOPDIR}/tmpmultix86"
159
160 The location for these multiconfig configuration files is specific.
161 They must reside in the current :term:`Build Directory` in a sub-directory of
162 ``conf`` named ``multiconfig`` or within a layer's ``conf`` directory
163 under a directory named ``multiconfig``. Here is an example that defines
164 two configuration files for the "x86" and "arm" multiconfigs:
165
166 .. image:: figures/multiconfig_files.png
167 :align: center
168 :width: 50%
169
170 The usual :term:`BBPATH` search path is used to locate multiconfig files in
171 a similar way to other conf files.
172
173- *Add the BitBake Multi-configuration Variable to the Local
174 Configuration File*: Use the
175 :term:`BBMULTICONFIG`
176 variable in your ``conf/local.conf`` configuration file to specify
177 each multiconfig. Continuing with the example from the previous
178 figure, the :term:`BBMULTICONFIG` variable needs to enable two
179 multiconfigs: "x86" and "arm" by specifying each configuration file::
180
181 BBMULTICONFIG = "x86 arm"
182
183 .. note::
184
185 A "default" configuration already exists by definition. This
186 configuration is named: "" (i.e. empty string) and is defined by
187 the variables coming from your ``local.conf``
188 file. Consequently, the previous example actually adds two
189 additional configurations to your build: "arm" and "x86" along
190 with "".
191
192- *Launch BitBake*: Use the following BitBake command form to launch
193 the multiple configuration build::
194
195 $ bitbake [mc:multiconfigname:]target [[[mc:multiconfigname:]target] ... ]
196
197 For the example in this section, the following command applies::
198
199 $ bitbake mc:x86:core-image-minimal mc:arm:core-image-sato mc::core-image-base
200
201 The previous BitBake command builds a ``core-image-minimal`` image
202 that is configured through the ``x86.conf`` configuration file, a
203 ``core-image-sato`` image that is configured through the ``arm.conf``
204 configuration file and a ``core-image-base`` that is configured
205 through your ``local.conf`` configuration file.
206
207.. note::
208
209 Support for multiple configuration builds in the Yocto Project &DISTRO;
210 (&DISTRO_NAME;) Release does not include Shared State (sstate)
211 optimizations. Consequently, if a build uses the same object twice
212 in, for example, two different :term:`TMPDIR`
213 directories, the build either loads from an existing sstate cache for
214 that build at the start or builds the object fresh.
215
216Enabling Multiple Configuration Build Dependencies
217--------------------------------------------------
218
219Sometimes dependencies can exist between targets (multiconfigs) in a
220multiple configuration build. For example, suppose that in order to
221build a ``core-image-sato`` image for an "x86" multiconfig, the root
222filesystem of an "arm" multiconfig must exist. This dependency is
223essentially that the
224:ref:`ref-tasks-image` task in the
225``core-image-sato`` recipe depends on the completion of the
226:ref:`ref-tasks-rootfs` task of the
227``core-image-minimal`` recipe.
228
229To enable dependencies in a multiple configuration build, you must
230declare the dependencies in the recipe using the following statement
231form::
232
233 task_or_package[mcdepends] = "mc:from_multiconfig:to_multiconfig:recipe_name:task_on_which_to_depend"
234
235To better show how to use this statement, consider the example scenario
236from the first paragraph of this section. The following statement needs
237to be added to the recipe that builds the ``core-image-sato`` image::
238
239 do_image[mcdepends] = "mc:x86:arm:core-image-minimal:do_rootfs"
240
241In this example, the `from_multiconfig` is "x86". The `to_multiconfig` is "arm". The
242task on which the :ref:`ref-tasks-image` task in the recipe depends is the
243:ref:`ref-tasks-rootfs` task from the ``core-image-minimal`` recipe associated
244with the "arm" multiconfig.
245
246Once you set up this dependency, you can build the "x86" multiconfig
247using a BitBake command as follows::
248
249 $ bitbake mc:x86:core-image-sato
250
251This command executes all the tasks needed to create the
252``core-image-sato`` image for the "x86" multiconfig. Because of the
253dependency, BitBake also executes through the :ref:`ref-tasks-rootfs` task for the
254"arm" multiconfig build.
255
256Having a recipe depend on the root filesystem of another build might not
257seem that useful. Consider this change to the statement in the
258``core-image-sato`` recipe::
259
260 do_image[mcdepends] = "mc:x86:arm:core-image-minimal:do_image"
261
262In this case, BitBake must
263create the ``core-image-minimal`` image for the "arm" build since the
264"x86" build depends on it.
265
266Because "x86" and "arm" are enabled for multiple configuration builds
267and have separate configuration files, BitBake places the artifacts for
268each build in the respective temporary build directories (i.e.
269:term:`TMPDIR`).
270 118
271Building an Initial RAM Filesystem (Initramfs) Image 119Building an Initial RAM Filesystem (Initramfs) Image
272==================================================== 120====================================================
@@ -280,7 +128,9 @@ Follow these steps to create an :term:`Initramfs` image:
280#. *Create the Initramfs Image Recipe:* You can reference the 128#. *Create the Initramfs Image Recipe:* You can reference the
281 ``core-image-minimal-initramfs.bb`` recipe found in the 129 ``core-image-minimal-initramfs.bb`` recipe found in the
282 ``meta/recipes-core`` directory of the :term:`Source Directory` 130 ``meta/recipes-core`` directory of the :term:`Source Directory`
283 as an example from which to work. 131 as an example from which to work. The ``core-image-minimal-initramfs`` recipe
132 is based on the :ref:`initramfs-framework <dev-manual/building:Customizing an
133 Initramfs using \`\`initramfs-framework\`\`>` recipe described below.
284 134
285#. *Decide if You Need to Bundle the Initramfs Image Into the Kernel 135#. *Decide if You Need to Bundle the Initramfs Image Into the Kernel
286 Image:* If you want the :term:`Initramfs` image that is built to be bundled 136 Image:* If you want the :term:`Initramfs` image that is built to be bundled
@@ -308,6 +158,86 @@ Follow these steps to create an :term:`Initramfs` image:
308 and bundled with the kernel image if you used the 158 and bundled with the kernel image if you used the
309 :term:`INITRAMFS_IMAGE_BUNDLE` variable described earlier. 159 :term:`INITRAMFS_IMAGE_BUNDLE` variable described earlier.
310 160
161Customizing an Initramfs using ``initramfs-framework``
162------------------------------------------------------
163
164The ``core-image-minimal-initramfs.bb`` recipe found in
165:oe_git:`meta/recipes-core/images
166</openembedded-core/tree/meta/recipes-core/images>` uses the
167:oe_git:`initramfs-framework_1.0.bb
168</openembedded-core/tree/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb>`
169recipe as its base component. The goal of the ``initramfs-framework`` recipe is
170to provide the building blocks to build a customized :term:`Initramfs`.
171
172The ``initramfs-framework`` recipe relies on shell initialization scripts
173defined in :oe_git:`meta/recipes-core/initrdscripts/initramfs-framework
174</openembedded-core/tree/meta/recipes-core/initrdscripts/initramfs-framework>`. Since some of
175these scripts do not apply for all use cases, the ``initramfs-framework`` recipe
176defines different packages:
177
178- ``initramfs-framework-base``: this package installs the basic components of
179 an :term:`Initramfs`, such as the ``init`` script or the ``/dev/console``
180 character special file. As this package is a runtime dependency of all
181 modules listed below, it is automatically pulled in when one of the modules
182 is installed in the image.
183- ``initramfs-module-exec``: support for execution of applications.
184- ``initramfs-module-mdev``: support for `mdev
185 <https://wiki.gentoo.org/wiki/Mdev>`__.
186- ``initramfs-module-udev``: support for :wikipedia:`Udev <Udev>`.
187- ``initramfs-module-e2fs``: support for :wikipedia:`ext4/ext3/ext2
188 <Extended_file_system>` filesystems.
189- ``initramfs-module-nfsrootfs``: support for locating and mounting the root
190 partition via :wikipedia:`NFS <Network_File_System>`.
191- ``initramfs-module-rootfs``: support for locating and mounting the root
192 partition.
193- ``initramfs-module-debug``: dynamic debug support.
194- ``initramfs-module-lvm``: :wikipedia:`LVM <Logical_volume_management>` rootfs support.
195- ``initramfs-module-overlayroot``: support for mounting a read-write overlay
196 on top of a read-only root filesystem.
197
198In addition to the packages defined by the ``initramfs-framework`` recipe
199itself, the following packages are defined by the recipes present in
200:oe_git:`meta/recipes-core/initrdscripts </openembedded-core/tree/meta/recipes-core/initrdscripts>`:
201
202- ``initramfs-module-install``: module to create and install a partition layout
203 on a selected block device.
204- ``initramfs-module-install-efi``: module to create and install an EFI
205 partition layout on a selected block device.
206- ``initramfs-module-setup-live``: module to start a shell in the
207 :term:`Initramfs` if ``root=/dev/ram0`` in passed in the `Kernel command-line
208 <https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html>`__
209 or the ``root=`` parameter was not passed.
210
211To customize the :term:`Initramfs`, you can add or remove packages listed
212earlier from the :term:`PACKAGE_INSTALL` variable with a :ref:`bbappend
213<dev-manual/layers:Appending Other Layers Metadata With Your Layer>` on the
214``core-image-minimal-initramfs`` recipe, or create a custom recipe for the
215:term:`Initramfs` taking ``core-image-minimal-initramfs`` as example.
216
217Custom scripts can be added to the :term:`Initramfs` by writing your own
218recipes. The recipes are conventionally named ``initramfs-module-<module name>``
219where ``<module name>`` is the name of the module. The recipe should set its
220:term:`RDEPENDS` package-specific variables to include
221``initramfs-framework-base`` and the other packages on which the module depends
222at runtime.
223
224The recipe must install shell initialization scripts in :term:`${D} <D>`\
225``/init.d`` and must follow the ``<number>-<script name>`` naming scheme where:
226
227- ``<number>`` is a *two-digit* number that affects the execution order of the
228 script compared to others. For example, the script ``80-setup-live`` would be
229 executed after ``01-udev`` because 80 is greater than 01.
230
231 This number being two-digits is important here as the scripts are executed
232 alphabetically. For example, the script ``10-script`` would be executed
233 before the script ``8-script``, because ``1`` is inferior to ``8``.
234 Therefore, the script should be named ``08-script``.
235
236- ``<script name>`` is the script name which you can choose freely.
237
238 If two script use the same ``<number>``, they are sorted alphabetically based
239 on ``<script name>``.
240
311Bundling an Initramfs Image From a Separate Multiconfig 241Bundling an Initramfs Image From a Separate Multiconfig
312------------------------------------------------------- 242-------------------------------------------------------
313 243
@@ -661,7 +591,7 @@ If build speed and package feed maintenance are considerations, you
661should consider the points in this section that can help you optimize 591should consider the points in this section that can help you optimize
662your tunings to best consider build times and package feed maintenance. 592your tunings to best consider build times and package feed maintenance.
663 593
664- *Share the :term:`Build Directory`:* If at all possible, share the 594- *Share the* :term:`Build Directory` *:* If at all possible, share the
665 :term:`TMPDIR` across builds. The Yocto Project supports switching between 595 :term:`TMPDIR` across builds. The Yocto Project supports switching between
666 different :term:`MACHINE` values in the same :term:`TMPDIR`. This practice 596 different :term:`MACHINE` values in the same :term:`TMPDIR`. This practice
667 is well supported and regularly used by developers when building for 597 is well supported and regularly used by developers when building for
@@ -883,7 +813,7 @@ directory:
883 813
884#. *Using Local Files Only:* Inside your ``local.conf`` file, add the 814#. *Using Local Files Only:* Inside your ``local.conf`` file, add the
885 :term:`SOURCE_MIRROR_URL` variable, inherit the 815 :term:`SOURCE_MIRROR_URL` variable, inherit the
886 :ref:`ref-classes-own-mirrors` class, and use the 816 :ref:`ref-classes-own-mirrors` class, and add the
887 :term:`BB_NO_NETWORK` variable to your ``local.conf``:: 817 :term:`BB_NO_NETWORK` variable to your ``local.conf``::
888 818
889 SOURCE_MIRROR_URL ?= "file:///home/your-download-dir/" 819 SOURCE_MIRROR_URL ?= "file:///home/your-download-dir/"