This repository contains a minimal Yocto build configuration for Raspberry Pi 4 (64-bit) with:
- SSH enabled
- systemd as init system
- Docker container runtime
- GitHub Actions CI/CD pipeline
- Automates the Yocto build environment setup
- Downloads required Yocto layers (poky, meta-raspberrypi, meta-openembedded)
- Configures the build with systemd and SSH
- Runs the bitbake process to build the image
- Uses GitHub Actions to automatically build the image on every push or PR
- Maximizes build space to accommodate Yocto's requirements
- Installs required dependencies
- Runs the build script
- Uploads the resulting image as an artifact using actions/upload-artifact@v4
conf/layer.conf
: Registers the custom layer with Yoctorecipes-core/images/minimal-ssh-image.bb
: Defines the minimal image with SSH and systemdrecipes-core/systemd/systemd-networkd-configuration.bb
: Provides network configurationrecipes-core/systemd/files/20-wired.network
: Configures the ethernet interface
-
Install dependencies (Ubuntu/Debian):
sudo apt-get update sudo apt-get install -y 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 libegl1-mesa libsdl1.2-dev pylint3 xterm
-
Clone this repository:
git clone https://github.com/yourusername/yocto-cicd-test.git cd yocto-cicd-test
-
Run the build script:
./scripts/build.sh
-
Find your image at
build/tmp/deploy/images/raspberrypi4-64/minimal-ssh-image-raspberrypi4-64.wic.bz2
The image recipe (minimal-ssh-image.bb
) creates a streamlined 64-bit system with:
- OpenSSH server for remote access
- systemd init system
- Docker container runtime and docker-compose
- Network configuration via systemd-networkd
- OPKG package manager
- Raspberry Pi Camera support
- Audio/Voice capabilities
- U-Boot bootloader
- Essential kernel modules
The system is configured with:
- Static IP address (192.168.4.103) through systemd-networkd for Ethernet
- You can directly connect via SSH:
ssh [email protected]
- WiFi support with WPA Supplicant pre-configured
- No password is required for SSH (debug-tweaks enabled)
The image comes with WiFi support pre-configured. To connect to your WiFi network:
-
Before building, customize the WiFi credentials in:
meta-custom/recipes-core/systemd/files/wpa_supplicant-wlan0.conf
-
Alternatively, after first boot, edit the WiFi configuration:
nano /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
Then restart the WiFi service:
systemctl restart wpa_supplicant@wlan0
-
Verify connectivity:
ip a show wlan0 ping -I wlan0 google.com
┌─────────────────┐ ┌──────────────────┐ ┌───────────────┐
│ │ │ │ │ │
│ Yocto Project │────►│ Build System │────►│ Custom Layer │
│ │ │ │ │ │
└─────────────────┘ └──────────────────┘ └───────┬───────┘
│
▼
┌─────────────────┐ ┌──────────────────┐ ┌───────────────┐
│ │ │ │ │ │
│ CI/CD Pipeline │────►│ GitHub Actions │────►│ Image Output │
│ │ │ │ │ │
└─────────────────┘ └────────┬─────────┘ └───────▲───────┘
│ │
▼ │
┌──────────────────┐ ┌───────────────┐
│ │ │ │
│ Raspberry Pi 4 │ │ Recipe │
│ Image Files │ │ Components │
└──────────────────┘ └───────────────┘
The Yocto CI/CD for Raspberry Pi 4 system implements a complete pipeline for building customized Linux distributions:
-
Source Layer
- Poky: Core Yocto Project files providing the build system
- meta-raspberrypi: BSP layer for Raspberry Pi hardware support
- meta-openembedded: Additional packages and recipes
- meta-custom: Project-specific customizations and configurations
-
Build System Layer
- BitBake: Task executor and scheduler for recipe processing
- Shared State Cache: Accelerates builds by caching build artifacts
- Fetch System: Downloads source code from upstream repositories
- Package Management: Creates OPKG packages for the final system
-
Integration Layer
- CI/CD Pipeline: Automates build process through GitHub Actions
- Docker Integration: Provides containerized environment for final system
- Deployment: Prepares bootable images for Raspberry Pi 4
-
Runtime Layer
- systemd: Init system for service management
- SSH: Remote access and administration
- Docker: Container runtime for application deployment
- Network Configuration: Ethernet and WiFi connectivity setup
- Edit
meta-custom/recipes-core/images/minimal-ssh-image.bb
to add more packages - Copy
conf/local.conf.sample
to your build directory aslocal.conf
for local builds - Modify
meta-custom/recipes-core/systemd/files/20-wired.network
to change network settings
After booting your Raspberry Pi with the built image:
-
Docker is pre-installed and ready to use
-
Check Docker status:
systemctl status docker
-
Run a test container:
docker run --rm hello-world
-
Create containers with docker-compose:
docker-compose up -d
The image comes with support for the Raspberry Pi Camera module:
-
Connect the camera module to the Raspberry Pi CSI connector
-
Use the following commands to test the camera:
# List available cameras libcamera-hello --list-cameras # Display a preview libcamera-hello # Capture an image libcamera-still -o test.jpg # Record a video (5 seconds) libcamera-vid -t 5000 -o test.h264
-
GStreamer is also included for advanced video processing:
gst-launch-1.0 libcamerasrc ! videoconvert ! jpegenc ! filesink location=test.jpg
The image comes with full audio support for the Raspberry Pi:
-
Testing your audio setup:
# List audio devices aplay -l # Test audio output speaker-test -t wav -c 2 # Play an audio file aplay /usr/share/sounds/alsa/Front_Center.wav
-
Recording audio:
# Record audio for 5 seconds arecord -d 5 -f cd test.wav # Play back the recording aplay test.wav
-
Audio configuration:
# Adjust volume alsamixer # Save volume settings alsactl store
-
PulseAudio is also included for advanced audio routing and mixing.
The image comes with OPKG package manager pre-installed:
-
Update package lists:
opkg update
-
Install a package:
opkg install <package-name>
-
List installed packages:
opkg list-installed
-
Search for packages:
opkg list | grep <search-term>
curl -L https://github.com/docker/compose/releases/download/v2.34.0/docker-compose-linux-armv7 -o /usr/bin/docker-compose chmod +x /usr/bin/docker-compose