summaryrefslogtreecommitdiffstats
path: root/documentation/ref-manual/classes.rst
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/ref-manual/classes.rst')
-rw-r--r--documentation/ref-manual/classes.rst245
1 files changed, 164 insertions, 81 deletions
diff --git a/documentation/ref-manual/classes.rst b/documentation/ref-manual/classes.rst
index 54a98bf24f..f2f6e6e411 100644
--- a/documentation/ref-manual/classes.rst
+++ b/documentation/ref-manual/classes.rst
@@ -1732,77 +1732,158 @@ Its behavior is mainly controlled by the following variables:
1732- :term:`KERNEL_DTC_FLAGS`: flags for ``dtc``, the Device Tree Compiler 1732- :term:`KERNEL_DTC_FLAGS`: flags for ``dtc``, the Device Tree Compiler
1733- :term:`KERNEL_PACKAGE_NAME`: base name of the kernel packages 1733- :term:`KERNEL_PACKAGE_NAME`: base name of the kernel packages
1734 1734
1735.. _ref-classes-kernel-fitimage: 1735.. _ref-classes-kernel-fit-image:
1736 1736
1737``kernel-fitimage`` 1737``kernel-fit-image``
1738=================== 1738====================
1739 1739
1740The :ref:`ref-classes-kernel-fitimage` class provides support to pack a kernel image, 1740The :ref:`ref-classes-kernel-fit-image` class provides support to pack a kernel image,
1741device trees, a U-boot script, an :term:`Initramfs` bundle and a RAM disk 1741device trees, a U-boot script, and an :term:`Initramfs` into a single FIT image.
1742into a single FIT image. In theory, a FIT image can support any number 1742In theory, a FIT image can support any number of kernels, U-boot scripts,
1743of kernels, U-boot scripts, :term:`Initramfs` bundles, RAM disks and device-trees. 1743:term:`Initramfs`, and device trees.
1744However, :ref:`ref-classes-kernel-fitimage` currently only supports 1744However, :ref:`ref-classes-kernel-fit-image` currently only supports
1745limited usecases: just one kernel image, an optional U-boot script, 1745limited usecases: just one kernel image, an optional U-boot script,
1746an optional :term:`Initramfs` bundle, an optional RAM disk, and any number of 1746an optional :term:`Initramfs`, and any number of device trees.
1747device trees. 1747
1748 1748The FIT image is created by a recipe which inherits the
1749To create a FIT image, it is required that :term:`KERNEL_CLASSES` 1749:ref:`ref-classes-kernel-fit-image` class.
1750is set to include ":ref:`ref-classes-kernel-fitimage`" and one of :term:`KERNEL_IMAGETYPE`, 1750One such example is the ``linux-yocto-fitimage`` recipe which creates a FIT
1751:term:`KERNEL_ALT_IMAGETYPE` or :term:`KERNEL_IMAGETYPES` to include "fitImage". 1751image for the Linux Yocto kernel.
1752 1752Additionally, it is required that :term:`KERNEL_CLASSES` is set to include
1753The options for the device tree compiler passed to ``mkimage -D`` 1753:ref:`ref-classes-kernel-fit-extra-artifacts`.
1754when creating the FIT image are specified using the 1754The :ref:`ref-classes-kernel-fit-extra-artifacts` class exposes the required kernel
1755:term:`UBOOT_MKIMAGE_DTCOPTS` variable. 1755artifacts to the :term:`DEPLOY_DIR_IMAGE` which are used by the
1756 1756:ref:`ref-classes-kernel-fit-image` class to create the FIT image.
1757Only a single kernel can be added to the FIT image created by 1757
1758:ref:`ref-classes-kernel-fitimage` and the kernel image in FIT is mandatory. The 1758The simplest example for building a FIT image is to add::
1759address where the kernel image is to be loaded by U-Boot is 1759
1760specified by :term:`UBOOT_LOADADDRESS` and the entrypoint by 1760 KERNEL_CLASSES += "kernel-fit-extra-artifacts"
1761:term:`UBOOT_ENTRYPOINT`. Setting :term:`FIT_ADDRESS_CELLS` to "2" 1761
1762is necessary if such addresses are 64 bit ones. 1762to the machine :term:`configuration file` and to execute::
1763 1763
1764Multiple device trees can be added to the FIT image created by 1764 bitbake linux-yocto-fitimage
1765:ref:`ref-classes-kernel-fitimage` and the device tree is optional. 1765
1766The address where the device tree is to be loaded by U-Boot is 1766This results in a ``fitImage`` file deployed to the :term:`DEPLOY_DIR_IMAGE`
1767specified by :term:`UBOOT_DTBO_LOADADDRESS` for device tree overlays 1767directory and a ``linux-yocto-fitimage`` package which can be installed.
1768and by :term:`UBOOT_DTB_LOADADDRESS` for device tree binaries. 1768
1769 1769The same approach works for all variants of the ``linux-yocto`` kernel.
1770Only a single RAM disk can be added to the FIT image created by 1770For example, if the ``linux-yocto-rt`` kernel should be used, add the following
1771:ref:`ref-classes-kernel-fitimage` and the RAM disk in FIT is optional. 1771lines to the machine configuration file::
1772The address where the RAM disk image is to be loaded by U-Boot 1772
1773is specified by :term:`UBOOT_RD_LOADADDRESS` and the entrypoint by 1773 KERNEL_CLASSES += "kernel-fit-extra-artifacts"
1774:term:`UBOOT_RD_ENTRYPOINT`. The ramdisk is added to the FIT image when 1774 PREFERRED_PROVIDER_virtual/kernel = "linux-yocto-rt"
1775:term:`INITRAMFS_IMAGE` is specified and requires that :term:`INITRAMFS_IMAGE_BUNDLE` 1775
1776is not set to 1. 1776The FIT image, this time including the RT kernel, is built again by calling::
1777 1777
1778Only a single :term:`Initramfs` bundle can be added to the FIT image created by 1778 bitbake linux-yocto-fitimage
1779:ref:`ref-classes-kernel-fitimage` and the :term:`Initramfs` bundle in FIT is optional. 1779
1780In case of :term:`Initramfs`, the kernel is configured to be bundled with the root filesystem 1780For other kernels provided by other layers, the same approach would work.
1781in the same binary (example: zImage-initramfs-:term:`MACHINE`.bin). 1781However, it is usually more intuitive to add a custom FIT image recipe next to
1782When the kernel is copied to RAM and executed, it unpacks the :term:`Initramfs` root filesystem. 1782the custom kernel recipe.
1783The :term:`Initramfs` bundle can be enabled when :term:`INITRAMFS_IMAGE` 1783For example, if a layer provides a ``linux-vanilla`` recipe, a
1784is specified and requires that :term:`INITRAMFS_IMAGE_BUNDLE` is set to 1. 1784``linux-vanilla-fitimage`` recipe may be added as well.
1785The address where the :term:`Initramfs` bundle is to be loaded by U-boot is specified 1785The ``linux-vanilla-fitimage`` recipe can be created as a customized copy of
1786by :term:`UBOOT_LOADADDRESS` and the entrypoint by :term:`UBOOT_ENTRYPOINT`. 1786the ``linux-yocto-fitimage`` recipe.
1787 1787
1788Only a single U-boot boot script can be added to the FIT image created by 1788Usually the kernel is built as a dependency of an image.
1789:ref:`ref-classes-kernel-fitimage` and the boot script is optional. 1789If the FIT image should be used as a replacement for the kernel image which
1790The boot script is specified in the ITS file as a text file containing 1790is installed in the root filesystem, then the following variables can be set
1791U-boot commands. When using a boot script the user should configure the 1791e.g. in the machine configuration file::
1792U-boot :ref:`ref-tasks-install` task to copy the script to sysroot. 1792
1793So the script can be included in the FIT image by the :ref:`ref-classes-kernel-fitimage` 1793 # Create and deploy the vmlinux artifact which gets included into the FIT image
1794class. At run-time, U-boot CONFIG_BOOTCOMMAND define can be configured to 1794 KERNEL_CLASSES += "kernel-fit-extra-artifacts"
1795load the boot script from the FIT image and execute it. 1795
1796 1796 # Do not install the kernel image package
1797The FIT image generated by the :ref:`ref-classes-kernel-fitimage` class is signed when the 1797 RRECOMMENDS:${KERNEL_PACKAGE_NAME}-base = ""
1798variables :term:`UBOOT_SIGN_ENABLE`, :term:`UBOOT_MKIMAGE_DTCOPTS`, 1798 # Install the FIT image package
1799:term:`UBOOT_SIGN_KEYDIR` and :term:`UBOOT_SIGN_KEYNAME` are set 1799 MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "linux-yocto-fitimage"
1800appropriately. The default values used for :term:`FIT_HASH_ALG` and 1800
1801:term:`FIT_SIGN_ALG` in :ref:`ref-classes-kernel-fitimage` are "sha256" and 1801 # Configure the image.bbclass to depend on the FIT image instead of only
1802"rsa2048" respectively. The keys for signing the FIT image can be generated using 1802 # the kernel to ensure the FIT image is built and deployed with the image
1803the :ref:`ref-classes-kernel-fitimage` class when both :term:`FIT_GENERATE_KEYS` and 1803 KERNEL_DEPLOY_DEPEND = "linux-yocto-fitimage:do_deploy"
1804:term:`UBOOT_SIGN_ENABLE` are set to "1". 1804
1805 1805The :ref:`ref-classes-kernel-fit-image` class processes several variables that
1806allow configuration:
1807
1808- The options for the device tree compiler passed to ``mkimage -D``
1809 when creating the FIT image are specified using the
1810 :term:`UBOOT_MKIMAGE_DTCOPTS` variable.
1811
1812- Only a single kernel can be added to the FIT image created by
1813 :ref:`ref-classes-kernel-fit-image` and it is a mandatory component of the
1814 FIT image.
1815 The address where the kernel image is to be loaded by U-Boot is
1816 specified by :term:`UBOOT_LOADADDRESS` and the entrypoint by
1817 :term:`UBOOT_ENTRYPOINT`. Setting :term:`FIT_ADDRESS_CELLS` to "2"
1818 is necessary if such addresses are 64 bit ones.
1819
1820- Multiple device trees can be added to the FIT image created by
1821 :ref:`ref-classes-kernel-fit-image` and the device tree is optional.
1822 The address where the device tree is to be loaded by U-Boot is
1823 specified by :term:`UBOOT_DTBO_LOADADDRESS` for device tree overlays
1824 and by :term:`UBOOT_DTB_LOADADDRESS` for device tree binaries.
1825
1826- Only a single :term:`Initramfs` can be added to the FIT image created by
1827 :ref:`ref-classes-kernel-fit-image`. The :term:`Initramfs` in FIT is optional.
1828 The address where the RAM disk image is to be loaded by U-Boot
1829 is specified by :term:`UBOOT_RD_LOADADDRESS` and the entrypoint by
1830 :term:`UBOOT_RD_ENTRYPOINT`. The :term:`Initramfs` is added to the FIT image
1831 when :term:`INITRAMFS_IMAGE` is specified.
1832
1833- It's recommended to add the :term:`Initramfs` and the kernel image as
1834 independent image nodes to the FIT image.
1835 Bundling a RAM disk image with the kernel image and including the bundle
1836 (:term:`INITRAMFS_IMAGE_BUNDLE` set to "1") in the FIT image is possible.
1837 However, this approach has the disadvantage that any change to the RAM
1838 disk image necessitates rebuilding the kernel image.
1839 This process requires the full kernel build directory, which is kind of
1840 incompatible with the :term:`SSTATE_DIR` and, consequently, with SDKs.
1841
1842- Only a single U-Boot boot script can be added to the FIT image created by
1843 :ref:`ref-classes-kernel-fit-image`. The boot script is optional.
1844 The boot script is specified in the ITS file as a text file containing
1845 U-Boot commands. When using a boot script the recipe which inherits the
1846 :ref:`ref-classes-kernel-fit-image` class should add the script to
1847 :term:`SRC_URI` and set the :term:`FIT_UBOOT_ENV` variable to the name of the
1848 file like the following::
1849
1850 FIT_UBOOT_ENV = "boot.txt"
1851 SRC_URI += "file://${FIT_UBOOT_ENV}"
1852
1853 At run-time, U-boot's boot command can be configured to load the boot script
1854 from the FIT image and source it.
1855
1856- The FIT image generated by the :ref:`ref-classes-kernel-fit-image` class is signed when the
1857 variables :term:`UBOOT_SIGN_ENABLE`, :term:`UBOOT_MKIMAGE_DTCOPTS`,
1858 :term:`UBOOT_SIGN_KEYDIR` and :term:`UBOOT_SIGN_KEYNAME` are set
1859 appropriately. The default values used for :term:`FIT_HASH_ALG` and
1860 :term:`FIT_SIGN_ALG` in :ref:`ref-classes-kernel-fit-image` are "sha256" and
1861 "rsa2048" respectively. The keys for signing the FIT image can be generated using
1862 the :ref:`ref-classes-kernel-fit-image` class when both :term:`FIT_GENERATE_KEYS` and
1863 :term:`UBOOT_SIGN_ENABLE` are set to "1".
1864
1865.. _ref-classes-kernel-fit-extra-artifacts:
1866
1867``kernel-fit-extra-artifacts``
1868==============================
1869
1870The :ref:`ref-classes-kernel-fit-extra-artifacts` class exposes the required
1871kernel artifacts to the :term:`DEPLOY_DIR_IMAGE` directory.
1872These artifacts are used by the :ref:`ref-classes-kernel-fit-image` class to
1873create a FIT image that can include the kernel, device trees, an optional
1874U-Boot script, and an optional Initramfs.
1875
1876This class is typically included by adding it to the :term:`KERNEL_CLASSES`
1877variable in your kernel recipe or machine configuration when building FIT images.
1878It ensures that all necessary files are available for packaging into the FIT image,
1879such as the kernel binary, device tree blobs (DTBs), and other related files.
1880
1881For example, to enable this class, set::
1882
1883 KERNEL_CLASSES += "kernel-fit-extra-artifacts"
1884
1885This is required when using the :ref:`ref-classes-kernel-fit-image` class to
1886generate FIT images for your kernel.
1806 1887
1807.. _ref-classes-kernel-grub: 1888.. _ref-classes-kernel-grub:
1808 1889
@@ -2050,7 +2131,8 @@ a couple different ways:
2050 Not using this naming convention can lead to subtle problems 2131 Not using this naming convention can lead to subtle problems
2051 caused by existing code that depends on that naming convention. 2132 caused by existing code that depends on that naming convention.
2052 2133
2053- Create or modify a target recipe that contains the following:: 2134- Or, create a :ref:`ref-classes-native` variant of any target recipe (e.g.
2135 ``myrecipe.bb``) by adding the following to the recipe::
2054 2136
2055 BBCLASSEXTEND = "native" 2137 BBCLASSEXTEND = "native"
2056 2138
@@ -2081,24 +2163,25 @@ couple different ways:
2081 inherit statement in the recipe after all other inherit statements so 2163 inherit statement in the recipe after all other inherit statements so
2082 that the :ref:`ref-classes-nativesdk` class is inherited last. 2164 that the :ref:`ref-classes-nativesdk` class is inherited last.
2083 2165
2084- Create a :ref:`ref-classes-nativesdk` variant of any recipe by adding the following:: 2166 .. note::
2085 2167
2086 BBCLASSEXTEND = "nativesdk" 2168 When creating a recipe, you must follow this naming convention::
2087 2169
2088 Inside the 2170 nativesdk-myrecipe.bb
2089 recipe, use ``:class-nativesdk`` and ``:class-target`` overrides to
2090 specify any functionality specific to the respective SDK machine or
2091 target case.
2092 2171
2093.. note::
2094 2172
2095 When creating a recipe, you must follow this naming convention:: 2173 Not doing so can lead to subtle problems because there is code that
2174 depends on the naming convention.
2096 2175
2097 nativesdk-myrecipe.bb 2176- Or, create a :ref:`ref-classes-nativesdk` variant of any target recipe (e.g.
2177 ``myrecipe.bb``) by adding the following to the recipe::
2098 2178
2179 BBCLASSEXTEND = "nativesdk"
2099 2180
2100 Not doing so can lead to subtle problems because there is code that 2181 Inside the
2101 depends on the naming convention. 2182 recipe, use ``:class-nativesdk`` and ``:class-target`` overrides to
2183 specify any functionality specific to the respective SDK machine or
2184 target case.
2102 2185
2103Although applied differently, the :ref:`ref-classes-nativesdk` class is used with both 2186Although applied differently, the :ref:`ref-classes-nativesdk` class is used with both
2104methods. The advantage of the second method is that you do not need to 2187methods. The advantage of the second method is that you do not need to
@@ -3436,7 +3519,7 @@ See U-Boot's documentation for details about `verified boot
3436and the `signature process 3519and the `signature process
3437<https://source.denx.de/u-boot/u-boot/-/blob/master/doc/uImage.FIT/signature.txt>`__. 3520<https://source.denx.de/u-boot/u-boot/-/blob/master/doc/uImage.FIT/signature.txt>`__.
3438 3521
3439See also the description of :ref:`ref-classes-kernel-fitimage` class, which this class 3522See also the description of :ref:`ref-classes-kernel-fit-image` class, which this class
3440imitates. 3523imitates.
3441 3524
3442.. _ref-classes-uki: 3525.. _ref-classes-uki: