Link Search Menu Expand Document

Yocto QEMU Build

This get started guide will show you an example project to build a sample project with Thistle Yocto Build. This sample project will build a full system image, using safe defaults, that we will be able to execute with QEMU.

We designed Thistle Yocto Build to make it easier to package custom Linux image for your embedded device with Yocto Linux. It is a wrapper around the Yocto project, and dependencies will be downloaded and managed at runtime. Basic features are enabled to enhance quality of life while using Yocto, such as disk space monitoring, and usage of sccache to improve build-time.

Tools needed

To get started you need to obtain a few dependencies and the Thistle Yocto Build binary. Note that the build system only supports x86_64 hosts.

# Ubuntu (22.10 onwards)
$ apt install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint xterm python3-subunit mesa-common-dev zstd lz4 file

# Arch - also requires `sdl` from the AUR
$ pacman -S base-devel git diffstat unzip texinfo python chrpath wget xterm rpcsvc-proto socat cpio inetutils

$ curl -L -o thistle-yocto-build https://downloads.thistle.tech/thistle-yocto-build/2.0.4/thistle-yocto-build-x86_64-unknown-linux-musl
$ chmod +x thistle-yocto-build

Build the sample project

Only two simple steps are required, the first one will generate the sample configuration file. Feel free to explore the generated conf.yml file - the complete list of options can be found here.

$ ./thistle-yocto-build gen-config qemu
Generated default thistle-yocto-build config file at conf.yml
[...]

The second step will build the image. Building this image takes approximately 45 minutes on a Ryzen5 3600, and requires ~50GB of free storage. This build will be performed in debug mode, with SSH enabled.

$ ./thistle-yocto-build build --debug conf.yml
~~ Thistle Yocto Build Starting  ~~
WARNING: Building in insecure debug mode
Please enter a value for the username: a
Please enter a value for the password:
Fetching remote repo meta-openembedded
Fetching remote repo openembedded-core
Fetching remote repo meta-thistle
Fetching bitbake from upstream git repo at commit 2022-04.6-kirkstone
Fetching remote repo bitbake
Found oe-init-build-env at "/home/user/rpi/build/layers/openembedded-core/oe-init-build-env"
Generating bitbake config files
Enabling ccache
Setting up disk monitoring system
Detected 12 CPUs, will configure build accordingly

Build starting - 2023-03-15T14:24:34.522041821+01:00

[...]

Build done in 2825s
WARNING: Build successful
Build artifact folder: "/home/user/rpi/build/deploy"
Analyzing build for security issues...
No issues detected

Launch Image

To boot the image use the following command to launch QEMU with U-Boot as the bootloader and the built image as the main rootfs and kernel.

$ qemu-system-aarch64 -machine virt -nographic -cpu cortex-a57 \
    -bios build/deploy/images/qemuarm64-thistle/u-boot.bin \
    -drive if=none,file=build/deploy/images/qemuarm64-thistle/base-qemuarm64-thistle.wic,id=disk0,format=raw \
    -device ich9-ahci,id=ahci -device ide-hd,drive=disk0,bus=ahci.0 -m 256M

Next Steps

  • Have a look at the configuration page to explore all the possible options
  • Use the Thistle Update Client to update the images directly on your device