Building a Yocto-based Knoppix for the Raspberry Pi
Pi Recipes
The professor sets the stage for Knoppix on an SD card that runs on the Raspberry Pi.
Knoppix on a Raspberry Pi is an ongoing idea I started several years ago. The Raspberry Pi is a relatively cheap, yet widely available single-board computer, which is also used in embedded and mobile projects. Although many distributions are available for the Pi, creating a new one with some Knoppix technology could be a perfect base for projects.
Because of the Knoppix default hardware setting to boot from the internal SD card reader, the boot procedure already has many similarities with existing distributions. However, Raspbian (the Debian derivate) for Raspberry Pi increased complexity and became a "too many parts to tune" problem. Also, I'm not happy with Debian's move from SysVinit to systemd in Raspbian, which has caused some stuck-at-boot problems in Raspbian-based projects for me.
Therefore, I decided to give the "build-from-scratch" approach a try (Table 1) instead of basing Knoppix on Debian, as in previous versions.
Table 1
Pros and Cons of Knoppix Built from Scratch
Pros | Cons |
---|---|
The complete software is self-built and linked only with components included in the system |
May be incompatible with large software repositories like Raspbian |
No unwanted "leftover" packages |
Have to create build instructions for new programs |
Smallest system possible, which can be a base for incremental projects |
Needs recompilation with changes or add-ons |
No side effects expected from binary upstream |
Updates have to get pulled in at the source level |
Yocto and OpenEmbedded
Yocto is a framework for creating custom Linux distributions for specialized embedded hardware, as well as for standard boards. Yocto is based on OpenEmbedded, a build framework for embedded Linux [1].
Yocto [2] provides a sample distribution called "Poky," which is filled with templates for the so-called meta-layers. These are directories containing build recipes for software components, which can be thought of as stacked on top of each other, so you have a base layer for the hardware-dependent parts and features, and incremental layers for graphical environments and user software.
Optimally, all changes toward the standard meta-directories that come with the Yocto distribution would be placed into one or more self-created directories with your own recipes, add-ons, and override rules.
Striving to "guarantee 100% reproducible builds," Yocto first downloads, compiles, and installs a completely new development environment from original sources for the host and target architectures, so you have the same version of compilers and libraries on each build system, with no errors attributable to different versions or features. Still, to run Yocto scripts, the host distribution needs to meet some requirements:
- Git 1.8.3.1 or greater
tar
1.24 or greater- Python 3.4.0 or greater.
For Debian as the hosting distribution, the following installation and update command is provided in the documentation [3]:
sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping
After these packages are installed, Yocto is supposed to be able to build all software packages and images included in the Poky sample distribution. The integration hierarchy of Yocto is shown in Figure 1.
Layer Cake
The Yocto framework itself is rather small after installation; uncompressed, it is less than 100MB. During the build process, sources are downloaded via git
or http
, unpacked, and compiled, which fills up the build/tmp
directory with a tremendous amount of data (Table 2).
Table 2
yocto/poky Directory
Kilobytes | Directory | Contents |
---|---|---|
9,040 |
bitbake |
The bitbake command and tools |
19,688 |
documentation |
Yocto documentation sources |
29,908 |
meta |
First meta-layer with base recipes |
1,212 |
meta-lxde* |
Added layer for building LXDE components |
704 |
meta-office* |
Added layer for building LibreOffice |
55,512 |
meta-openembedded |
Added dependency layer for Office and LXDE |
316 |
meta-poky |
Layer for the "Poky" distribution |
2432 |
meta-raspberrypi* |
Added layer for supporting Raspberry Pi-specific rules |
28 |
meta-raspi-knoppix* |
Added layer for my own (Knoppix) configuration |
356 |
meta-selftest |
Layer for built-in tests |
168 |
meta-skeleton |
Layer containing recipe samples |
12 |
meta-yocto |
Layer for architecture-independent recipes |
232 |
meta-yocto-bsp |
Layer handling board-specific rules |
3,144 |
scripts |
Supporting scripts |
|
build |
Main working directory |
28 |
build/conf/*.conf |
Global configurations |
7477,860 |
build/sstate-cache |
Build process results as binary fragments and state information |
23,371,760 |
build/tmp |
Sysroot directories, build directories, images |
When first using Yocto, I found it somewhat unusual that all the seemingly important build stuff, including compilers and supporting binaries as well as the final generated SD card image, resided in a directory named tmp
. Even more remarkable is that when removing the tmp
directory and its contents completely, rebuilding the project takes less than a tenth of the original time, because most files will be restored quickly from the sstate-cache
.
Setting Up Yocto
Before starting the build process, an initial setup needs to be done. I'm using 32-bit userspace binaries on a 64-bit kernel, which is a special setup that Yocto does not yet handle well. For this reason, I start a new shell that changes the output of uname -m
from x86_64 to i686, which ensures Yocto will download and compile all supporting tools for the correct host architecture:
setarch i386 /bin/bash
Afterward, paths and the environment need to be configured in the poky
directory for the current shell:
cd yocto/poky source oe-init-build-env
These commands have to be repeated whenever I restart the build procedure from a new shell.
The resulting architecture and software choices, as well as the preferred configurations, can be changed by modifying some variables in build/conf/local.conf
(Listing 1).
Listing 1
build/conf/local.conf
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
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.