Leon Anavi
IT Tips && Tricks

Mobile & Embedded

Created: 21.01.2025 06:19 Last Modified: 21.01.2025 06:19 Views: 6
Keywords: bitbake, core-image-base, Linux, OpenEmbedded, Poky, Raspberry Pi 5, Scarthgap, systemd, Yocto

Building a Basic GNU Linux Distribution for Raspberry Pi 5 with the Yocto Project LTS Release Scarthgap

The Yocto Project is a widely used solution for creating custom embedded Linux distributions. As a collaborative project under the Linux Foundation, it leverages the OpenEmbedded build framework and the bitbake tool. With its reference system, Poky, following a six-month release cycle, Yocto provides developers with metadata organized into layers and recipes to build packages and images.

In this tutorial, we will guide you through building a very basic GNU/Linux image for the Raspberry Pi 5 using the Yocto LTS release, Scarthgap, and include systemd support. Follow these steps to get started using the community BSP layer meta-raspberrypi:

Step 1: Download the Source Code

To begin, clone the necessary repositories for Poky and Raspberry Pi-specific metadata:

git clone -b scarthgap https://git.yoctoproject.org/poky poky-rpi
cd poky-rpi
git clone -b scarthgap https://github.com/agherzan/meta-raspberrypi.git

Step 2: Initialize the Build Environment

Yocto requires an initialized build environment. Run the following command to set it up:

source oe-init-build-env

Step 3: Add the BSP Layer for Raspberry Pi

To include support for the Raspberry Pi hardware, add the meta-raspberrypi layer to the build configuration:

bitbake-layers add-layer ../meta-raspberrypi

Step 4: Configure Build Settings

Modify the build configuration file (conf/local.conf) to target the Raspberry Pi 5, use systemd, and accept additional licensing flags. Append the following lines to the end of the file:

MACHINE = "raspberrypi5"
INIT_MANAGER = "systemd"
LICENSE_FLAGS_ACCEPTED = "synaptics-killswitch"

Step 5: Build the Image

With the setup complete, build a minimal base image for the Raspberry Pi 5:

bitbake core-image-base

This process may take some time, depending on your system's resources.

Step 6: Flash the Image and Boot the Raspberry Pi

Once the build completes, flash the generated image onto a microSD card and insert it into your Raspberry Pi 5. Power it up, and it should boot into your custom Linux distribution.

Step 7: Establish Serial Communication

Use the Raspberry Pi Debug Probe to set up serial communication between your Raspberry Pi 5 and a PC. Log in as the user root with no password.

Conclusion

With these steps, you have built and deployed a basic Linux distribution tailored for the Raspberry Pi 5 using the Yocto Project. This lightweight image serves as a great starting point for adding additional features and customization to suit your embedded system needs. Whether you are a developer working on IoT devices, industrial applications, or personal projects, the Yocto Project offers unparalleled flexibility and control over your Linux-based systems.



  Home | About | Contact | Disclaimer | Sitemap © 2009-2022 Leon Anavi. All rights reserved.