Building a Yocto-based Knoppix for the Raspberry Pi
BitBaking Software Packages and Images
The command that does everything in the correct order, parallelizing whenever possible and reporting errors in Yocto (and OpenEmbedded, on which Yocto is based), is BitBake, which calls a series of actions for each software recipe (files ending with .bb
). BitBake
1. fetches sources and unpacks and verifies the checksum,
2. configures software packages,
3. compiles software packages in the desired architecture (some for the host, some for the target system, as needed),
4. installs in a host or native sysroot directory, and
5. creates software packages and installs them in the target image or directory.
The bitbake
command is mostly called with the desired recipe as a single argument, but it also has some options to control the build process or clean up after a failed build, to avoid errors from leftover files. The standard command for building the Poky sample distribution would be
bitbake core-image-minimal
Of course, the real name of the target image is provided by the target distribution's build recipes.
A Simple Raspberry Pi "Hardware Up" Image
A good start for building Raspberry Pi images based on Yocto/Poky is the Board Support Package layer meta-raspberrypi
from Yocto Project, which is available under the MIT license [4]. It features recipes to build a recent kernel, base system (SysVinit or systemd – your choice), and embedded Qt5 for building applications running directly on the framebuffer (which I will probably not use; Knoppix needs full X11 support to provide a common desktop). The simple original image is created by
bitbake rpi-hwup-image
which builds a kernel, bootloader, and root filesystem as an SD card image and needs about two hours for the first run. This SD card image successfully boots the Raspberry Pi 2 into a shell and even supports the serial port connection over GPIO pins.
More Layers
The meta-office layer that contains LibreOffice was fetched from GitHub [5] and meta-lxde from OpenEmbedded [6]. If space is tight on the disk used for building the distro, adding this line to build/conf/local.conf
makes sure that unpacked sources and temporary files are being removed after successfully building a component:
INHERIT += "rm_work"
The current layer configuration for Knoppix for Raspberry Pi is set forth in build/conf/bblayers.conf
shown in Listing 2.
Listing 2
build/conf/bblayers.conf
The meta-raspi-knoppix
directory contains all recipes for Knoppix-specific packages, custom kernel configurations and patches, and software choices. The contents of file meta-raspi-knoppix/recipes-core/images/rpi-knoppix-image.bb
are shown in Listing 3.
Listing 3
Knoppix Image .bb File
The current feature list for Knoppix for Raspberry Pi includes:
- Cloop block compression. Unlike the Intel/AMD architecture DVD version of Knoppix, compression is not really needed for space reasons, because the usual Raspberry Pi SD card size of 8GB is plenty. However, if the system is compressed, physical reads are reduced to about a third of the usual volume, which may speed up read access and makes it easier to update the system in the form of compressed files containing all essential data except for the user's private files and configuration. Benchmarks for the choice of fastest decompression algorithm on the Raspberry Pi's CPU architecture need to show whether there is a substantial performance gain in this approach.
- AuFS [7] stacked filesystem. If system data is compressed in a read-only cloop container file, the user's changes need to be stored inside a writable partition mounted as
overlay
. - ADRIANE audio desktop assisting blind computer users.
- Accelerated graphics support for Compiz.
- LXDE, LibreOffice, browser(s), ….
AuFS and cloop have already been tested successfully as patches for the kernel, and both are working fine on the architecture (although the gzip algorithm implementation seems much slower on ARM than on Intel/AMD).
The build process for the Knoppix image is started with:
bitbake rpi-knoppix-image
Because of the libreoffice package, the build process now takes half a day on my build machine, compared with the two hours of the initial "minimal" image.
If a recipe fails to build in the process, it might be necessary to remove the sstate-cache
files for that component to force a "clean build" of all included binaries:
bitbake -c cleansstate libreoffice
One very useful debugging tool is the devshell
subcommand of bitbake
; for example:
bitbake -c devshell linux-raspberrypi
Instead of building a package, this command will change directory to the unpacked sources and then start an xterm terminal window with a shell – with all variables correctly set for the recipe – and allow a manual build, as in the traditional
./configure make ...
to detect errors in the build process and allow manually changing files in the temporary build folders.
After all required recipes are completed in
bitbake rpi-knoppix-image
(which adds up to around 8,000 tasks that BitBake shows during the build process), an SD card image resides in build/tmp/deploy/images/raspberrypi2/
that can be flashed to an SD card. For example, for an MMC card reader, use:
dd if=rpi-knoppix-image-raspberrypi2.rpi-sdimg of=/dev/mmcblk0 bs=1M
Booting the image on Raspberry Pis 2 and 3 worked perfectly for me, although I'm not yet starting the graphical environment and haven't changed the startup procedure to the Knoppix-specific "single shell script" boot. Of course, the Yocto-created image does not offer much of the software yet that you would get in a Raspbian installation, but it's comparably small and only contains software really needed for now.
I will continue writing about the next steps of creating Knoppix for Raspberry Pi in the next issue.
Infos
- OpenEmbedded: https://www.openembedded.org/wiki/Main_Page
- Yocto: https://www.yoctoproject.org/
- Host system packages: http://www.yoctoproject.org/docs/2.3/mega-manual/mega-manual.html#required-packages-for-the-host-development-system
- meta-rpi: http://git.yoctoproject.org/cgit.cgi/meta-raspberrypi/
- meta-office: https://github.com/schnitzeltony/meta-office
- meta-lxde: https://layers.openembedded.org/layerindex/branch/master/layer/meta-lxde/
- AuFS: http://aufs.sourceforge.net/
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.