/meta-raspberrypi-bootgen

Configuration files and instructions for building a Yocto image with bootgen for the Raspberry Pi 4 (64-bit)

Primary LanguageBitBake

meta-raspberrypi-bootgen

This repository contains the configuration files, recipes, and dependencies needed to build a Raspberry Pi 4 GNU/Linux SD Card image with the bootgen command line tool using the Yocto project.

Project Structure

Disclaimer

This guide (and code) was written and tested on Debian 12 (Bookworm), so it is recommended that you use the same or a similar system to follow this guide. However, it should be reproducible on other GNU/Linux distributions.

Prerequisites

  • git
  • Yocto Host Build dependencies

Getting Prerequisites on Debian

You can install gcc on a Debian based system with the following command on your terminal.

sudo apt update
sudo apt install -y git

As for the Yocto Host Build dependencies, you should follow the Compile Linux Distribution guide on the Yoco Project's official documentation. As of the writing of this guide however, the dependencies can be installed with the following commands:

sudo apt install gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 python3-subunit zstd liblz4-tool file locales libacl1
sudo locale-gen en_US.UTF-8

# While not listed on the official documentation, you might still needed
# to run the following command to avoid having locale issues with your
# system.
#
# After running this command you'll be taken to a text based user interface
# and will be asked which locales you'd wish to generate. Scroll down the
# list using the up/down arrow keys and select "en_US.UTF-8 UTF-8" if it's
# not selected already, then press enter. If asked which locale you'd like to
# use as the default in your system, simply select the one your system already
# had (you can find out which one that is by opening another terminal window
# and typing echo $LANG) with the up/down arrow keys and hit enter.
sudo dpkg-reconfigure locales

Cloning

Before running the code on this repository, you'll have to clone it into your system. You can do so by running the following command on your terminal.

git clone https://github.com/TheLastBilly/meta-raspberrypi-bootgen

This will create a directory called meta-raspberrypi-bootgen on your system, this will be the root of this repository. Simply cd into it and follow the next instructions.

cd meta-raspberrypi-bootgen

Lastly, you'll need to initialize the repository's submodules in order to properly fetch all of their files. You can do so with the following commands:

git submodule update --init --recursive

Compiling

CAUTION: Yocto takes a significant amount of storage space (~49GB at the time of testing) to compile this image. As such, make sure you have at least 80GB of space available in your system before compiling the project, otherwise you might not be able to complete the process. And, while this is not a requirement, it is recommended you build this project from a SSD drive, as doing so from a hard drive might take significantly longer.

The build process is largely automated by Yocto. As such, you'll just need to run the following commands to build the image.

source poky/oe-init-build-env
bitbake core-image-minimal

This process can take a long time to complete (~45 minutes on a Ryzen 5 2400G and 16GB of RAM from an SSD) and might make your system sluggish as a lot of processes will be created to parallelize the compilation process as much as possible.

Deploying

Once the buld process is complete, you'll be left with a file called core-image-minimal-raspberrypi4-64.wic.bz2, located inside build/tmp/deploy/images/raspberrypi4-64/. This is a compressed file, so you'll need to decompress it before flashing it into your SD Card.

# source poky/oe-init-build-env should have
# taken you to build/, in the case it didn't run
# cd build/
cd tmp/deploy/images/raspberrypi4-64/
bzip2 -df core-image-minimal-raspberrypi4-64.wic.bz2

Now you should have a file named core-image-minimal-raspberrypi4-64.wic inside of build/tmp/deploy/images/raspberrypi4-64/. You can flash it to your SD Card by using the dd command.

CAUTION: Be extremely careful with the following command, as using the wrong argument on <path to your SD Card>, could potentially break your system permanently.

# Replace <path to your SD Card> with the path your SD Card in your filesystem
dd if=core-image-minimal-raspberrypi4-64.wic of=<path to your SD Card> bs=1M status=progress