Yocto: Difference between revisions
Adds section how to set systemd as the initialization manager. |
|||
Line 98: | Line 98: | ||
<br /> | <br /> | ||
== | == devtool == | ||
Use '''devtool''' to make changes to an existing recipe and automatically generate an append recipe from those changes. | Use '''devtool''' to make changes to an existing recipe and automatically generate an append recipe from those changes. | ||
<br /> | |||
<br /> | |||
== Initialization Manager == | |||
After the kernel is done with its basic booting tasks, it passes control to the initialization manager. To use the ''systemd'' initialization manager (used by the Linux distributions Debian and Ubuntu) instead of ''SysVinit'', make the following entries in ''${TOPDIR}/conf/distro/distro.conf'' | |||
<pre class="code"> | |||
DISTRO_FEATURES_append = " systemd" | |||
DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit" | |||
VIRTUAL-RUNTIME_init_manager = "systemd" | |||
VIRTUAL-RUNTIME_initscripts = "" | |||
</pre> | |||
<br /> |
Revision as of 2022-11-26T17:02:58
Prerequisites
sudo apt install gcc g++ \ python3-distutils python-is-python3
Images
Images are recipes that ultimately inherit from meta/classes/image.bbclass and set the global variable IMAGE_INSTALL. Most images, however, will inherit from meta/classes/core-image.bbclass which inherits directly from image.bbclass, provides a mapping from IMAGE_FEATURES to package groups, and adds the two package groups packagegroup-core-boot and packagegroup-base-extended to IMAGE_INSTALL.
Images are defined in recipe files with the file extension 'bb'. In order to separate them from package recipes, there is a convention to put image recipes into a folder named images. Making use of this, we can list all images defined by all layers via
cd poky ls meta*/recipes*/images/*.bb
IMAGE_FEATURES
The IMAGE_FEATURES variable is defined in meta/classes/image.bbclass with an empty value. It accepts only a predefined set of features (e.g., x11, debug-tweaks, dev-pkgs, dbg-pkgs). This affects how recipes will execute their tasks and which packages will be selected to go into the image. The image recipe meta/recipes-core/images/core-image-base.bb, for example, adds the splash feature.
IMAGE_INSTALL
Holds a list of package groups whose packages (from the package feed area) will go into the filesystem image.
Reference images
The following reference images are defined in the meta layer:
core-image-minimal | small image that just boots the target device | |
core-image-minimal-dev | core-image-minimal with headers and libraries allowing development work | |
core-image-minimal-initramfs | core-image-minimal with kernel support for in-RAM filesystem | |
core-image-base | console-only system fully supporting the target hardware | |
core-image-full-cmdline | console-only image that includes many system tools | |
core-image-x11 | image with basic X11 and a terminal |
These image definitions are provided as a starting point for creating project-specific, custom image definitions.
Creating a Custom Image
- In your custom layer, create the images subdirectory in one of your recipes-...' directory.
- In the images directory, create two image recipe files that inherit from core-image:
SUMMARY = "My deployment image" LICENSE = "MIT" inherit core-image IMAGE_FEATURES += "splash"
and
SUMMARY = "My development image" inherit core-image require my-image.bb IMAGE_FEATURES += "ssh-server-dropbear tools-debug debug-tweaks" CORE_IMAGE_EXTRA_INSTALL += "i2c-tools "
where the first image recipe is for deployment and the second is for development. Note that the development version includes the deployment version with the require statement, and adds to IMAGE_FEATURES and CORE_IMAGE_EXTRA_INSTALL.
Image Filesystem Packaging
The system image generated by Bitbake can be packaged in the form of an image file, whose contents can be transferred on a boot medium (SD card or eMMC) such that the primary boot loader of the target device can discover the system and boot it.
Unless you restrict the type of packaging used for the image file, Yocto will generate multiple To restrict the generated image files (these are large files) to a certain
# Multiple types of image files are created by default. # Uncomment the desired lines below to prevent the # corresponding type of image file from being generated. #IMAGE_FSTYPES::remove = "tar.gz" #IMAGE_FSTYPES::remove = "tar.bz" #IMAGE_FSTYPES::remove = "wic.bz2 wic.bmap"
Package Groups
Package groups are recipes that inherit from meta/classes/packagegroup.bbclass and set the content of the global variable PACKAGES. Package groups are defined in recipe files with the file extension 'bb'.
Note that the packagegroup must be inherited before PACKAGES is defined.
inherit packagegroup PACKAGES = '...'
devtool
Use devtool to make changes to an existing recipe and automatically generate an append recipe from those changes.
Initialization Manager
After the kernel is done with its basic booting tasks, it passes control to the initialization manager. To use the systemd initialization manager (used by the Linux distributions Debian and Ubuntu) instead of SysVinit, make the following entries in ${TOPDIR}/conf/distro/distro.conf
DISTRO_FEATURES_append = " systemd" DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit" VIRTUAL-RUNTIME_init_manager = "systemd" VIRTUAL-RUNTIME_initscripts = ""