Dieser Artikel ist in Vorbereitung. Kommt bald.

Teil der Serie über mein privates BeagleBone-Black-Projekt.

1. Ziel

Dieses Tutorial beschreibt den Aufbau einer Yocto-Entwicklungsumgebung für den BeagleBone Black. Die komplette Build-Umgebung wird reproduzierbar in einem Ubuntu Docker Container erstellt.

Ziel:

  • Ubuntu Docker Build-Umgebung

  • Yocto Project Setup

  • BeagleBone Black BSP Integration

  • Erstes Yocto Image bauen

  • SD-Karte vorbereiten und booten

2. Voraussetzungen

Benötigt:

  • Linux Host (empfohlen Ubuntu 22.04/24.04)

  • Docker installiert

  • mindestens 50 GB freier Speicher

  • mindestens 8 GB RAM empfohlen

  • BeagleBone Black

  • SD-Karte

3. Step 1: Ubuntu Docker Build Environment erstellen

3.1. Verzeichnis anlegen

mkdir yocto-bbb
cd yocto-bbb

3.2. Dockerfile erstellen

Datei Dockerfile:

FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y \
    git \
    wget \
    curl \
    vim \
    nano \
    sudo \
    locales \
    build-essential \
    gcc \
    g++ \
    make \
    chrpath \
    cpio \
    diffstat \
    gawk \
    texinfo \
    unzip \
    socat \
    python3 \
    python3-pip \
    python3-pexpect \
    xz-utils \
    file \
    iputils-ping \
    rsync \
    zstd \
    lz4 \
    bzip2 \
    && rm -rf /var/lib/apt/lists/*

RUN locale-gen en_US.UTF-8

ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8

RUN useradd -ms /bin/bash yocto && \
    echo "yocto ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

USER yocto

WORKDIR /home/yocto

CMD ["/bin/bash"]

3.3. Docker Image bauen

docker build -t yocto-bbb .

3.4. Container starten

Den aktuellen Ordner als Workspace mounten:

docker run -it \
    --name yocto-bbb-build \
    -v $(pwd):/home/yocto/workspace \
    yocto-bbb

4. Step 2: Yocto Quellen holen

Im Container:

cd ~/workspace

git clone https://git.yoctoproject.org/poky
cd poky
git checkout kirkstone
cd ..

5. Step 3: Zusätzliche Layers installieren

git clone https://git.openembedded.org/meta-openembedded

cd meta-openembedded
git fetch --all
git checkout kirkstone
cd ..

git clone https://github.com/beagleboard/meta-beagleboard.git

6. Step 4: Build Environment initialisieren

cd ~/workspace/poky
source oe-init-build-env build-bbb

7. Step 5: BeagleBone Black konfigurieren

Datei conf/local.conf bearbeiten und folgenden Eintrag setzen:

MACHINE = "beaglebone-yocto"

8. Step 6: Layers aktivieren

bitbake-layers add-layer \
    ../meta-openembedded/meta-oe

bitbake-layers add-layer \
    ../meta-openembedded/meta-python

bitbake-layers add-layer \
    ../meta-openembedded/meta-networking

bitbake-layers add-layer \
    ../meta-beagleboard

9. Step 7: Erstes Image bauen

bitbake core-image-minimal

10. Step 8: Build Ergebnis

Nach erfolgreichem Build befinden sich die Artefakte in:

tmp/deploy/images/beaglebone-yocto/

Enthält:

  • Kernel (zImage)

  • Device Tree (*.dtb)

  • U-Boot (u-boot.img, MLO)

  • Root Filesystem (core-image-minimal-beaglebone-yocto.tar.xz)

11. Step 9: SD-Karte vorbereiten

Partitionen:

boot   FAT32
rootfs ext4

Boot-Dateien kopieren:

cp MLO /boot/
cp u-boot.img /boot/
cp *.dtb /boot/
cp zImage /boot/

RootFS installieren:

tar xf core-image-minimal*.tar.xz -C /mnt/rootfs

12. Step 10: BeagleBone Black starten

UART-Verbindung herstellen:

115200 baud
8N1

Bootmeldungen beobachten und System testen.

13. GitHub Actions Workflow

Der Yocto-Build lässt sich auch automatisiert in GitHub Actions ausführen — der folgende Workflow startet einen ubuntu:22.04-Container direkt auf dem GHA-Runner, installiert alle Abhängigkeiten und baut core-image-minimal.

Ein sstate-cache- und downloads-Cache reduziert Folgebuilds von mehreren Stunden auf ca. 20–40 Minuten.

Standard-GHA-Runner haben nur ~14 GB Disk — für einen vollständigen Yocto-Build wird ein self-hosted Runner mit ≥ 50 GB Disk und ≥ 8 GB RAM empfohlen.

name: Yocto Build – BeagleBone Black

on:
  workflow_dispatch:
  push:
    paths:
      - '.github/workflows/yocto-build.yml'

jobs:
  build:
    runs-on: ubuntu-latest

    container:
      image: ubuntu:22.04
      options: --user root

    env:
      DEBIAN_FRONTEND: noninteractive
      LANG: en_US.UTF-8
      LC_ALL: en_US.UTF-8

    steps:
      - name: Install Yocto dependencies
        run: |
          apt-get update && apt-get install -y \
            git wget curl sudo locales \
            build-essential gcc g++ make \
            chrpath cpio diffstat gawk texinfo \
            unzip socat python3 python3-pip python3-pexpect \
            xz-utils file rsync zstd lz4 bzip2 \
            && locale-gen en_US.UTF-8 \
            && rm -rf /var/lib/apt/lists/*

      - name: Create yocto user
        run: |
          useradd -ms /bin/bash yocto
          echo "yocto ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

      - name: Restore sstate-cache and downloads
        uses: actions/cache@v4
        with:
          path: |
            /home/yocto/downloads
            /home/yocto/sstate-cache
          key: yocto-kirkstone-bbb-${{ hashFiles('.github/workflows/yocto-build.yml') }}
          restore-keys: |
            yocto-kirkstone-bbb-

      - name: Clone poky (kirkstone)
        run: |
          su - yocto -c "git clone --depth=1 -b kirkstone https://git.yoctoproject.org/poky /home/yocto/poky"

      - name: Clone meta-openembedded (kirkstone)
        run: |
          su - yocto -c "git clone --depth=1 -b kirkstone https://git.openembedded.org/meta-openembedded /home/yocto/meta-openembedded"

      - name: Clone meta-beagleboard
        run: |
          su - yocto -c "git clone --depth=1 https://github.com/beagleboard/meta-beagleboard.git /home/yocto/meta-beagleboard"

      - name: Initialize build environment and configure
        run: |
          su - yocto -c "
            cd /home/yocto/poky
            source oe-init-build-env /home/yocto/build-bbb
            echo 'MACHINE = \"beaglebone-yocto\"' >> conf/local.conf
            echo 'DL_DIR = \"/home/yocto/downloads\"' >> conf/local.conf
            echo 'SSTATE_DIR = \"/home/yocto/sstate-cache\"' >> conf/local.conf
            bitbake-layers add-layer /home/yocto/meta-openembedded/meta-oe
            bitbake-layers add-layer /home/yocto/meta-openembedded/meta-python
            bitbake-layers add-layer /home/yocto/meta-openembedded/meta-networking
            bitbake-layers add-layer /home/yocto/meta-beagleboard
          "

      - name: Build core-image-minimal
        run: |
          su - yocto -c "
            cd /home/yocto/poky
            source oe-init-build-env /home/yocto/build-bbb
            bitbake core-image-minimal
          "

      - name: Upload build artifacts
        uses: actions/upload-artifact@v4
        with:
          name: beaglebone-yocto-image
          path: /home/yocto/build-bbb/tmp/deploy/images/beaglebone-yocto/
          retention-days: 7

14. Weiterführende Themen

  • Eigenes Yocto Layer erstellen

  • Eigene Recipes schreiben

  • Kernel-Änderungen und Device Tree Anpassungen

  • systemd Services integrieren

  • Ethernet konfigurieren

  • PRU-Entwicklung