QEMU Board emulation helper scripts update

QEMU Board emulation helper scripts update

The QEMU Board emulation part 1 and part 2 posts were the first posts on MistraSolutions back in March 2024. They were a detailed instructions on how to start emulation using QEMU Cubieboard, with all the steps needed to build both QEMU, as well as how to use U-Boot, Linux kernel and Ubuntu root filesystem to make a bootable SD card image and run it inside QEMU.

Additionally, helper scripts were also introduced, which included all the steps highlighted in the blog posts, needed to build required binaries and to run the example. The scripts provided an easy way to make a reproducible build and to have a starting system which could then be further customized.

For further customization Yocto has also been covered, but the goal of the scripts was to have a simple functional system from ready building blocks.

Helper scripts

The scripts are designed to be run in certain order, and each script has certain role to play.

install-qemu.bash

The script that is run first, downloads all the required artifacts and compiles them for Cubieboard

  • QEMU - built with arm-softmmu target only
  • arm-none-linux-gnueabihf toolchain
  • U-Boot - using Cubieboard_defconfig
  • Linux kernel - using multi_v7_defconfig with sun4i-a10-cubieboard.dtb device tree

Additionally, this script also downloads Ubuntu base root filesystem archive.

prepare-qemu.bash

The second script used to configure the base Ubuntu root filesystem and then assemble the SD card image using previously built artifacts and the configured Ubuntu root filesystem.

The Ubuntu root filesystem configuration is done using QEMU binfmt and chroot, where additional packages are installed to the base root filesystem, and configuration of accounts and default static network interface is performed.

Once root filesystem is created, the SD card image is created, partitioned and all files needed for boot are copied

  • bootloader - SPL and U-Boot binary
  • Linux kernel zImage and device tree
  • Ubuntu root filesystem, together with generated Linux device drivers

enable-networking.bash

Once SD card image is built and before the QEMU emulation can be started, the networking configuration on the host needs to be performed.

The network script will make a qemu-tap0 interface on the host on 192.168.123.0/24 subnet and assign 192.168.123.1 to the host. It will also enable IPv4 packet forwarding and NAT translation with masquerading, so QEMU emulated board will be able to access both host and internet.

run-qemu.bash

Script used to run QEMU Cubieboard with the assmbled SD card image, with enabled network access.

mount-sd-card.bash and umount-sd-card.bash

These are support scripts that can be used to mount/umount the rootfs partition from the SD card image and edit the contents of the filesystem between QEMU runs. This way additional packages can be installed, or prebuilt binaries can be copied for testing.

Update

In order to test the latest updates, like Linux kernel v7.0+, the scripts have been updated, so they are now using

  • Linux kernel 7.0.3
  • U-boot 2026.04
  • Ubuntu 26.04
  • QEMU 11.0.0

Additionally, the original scripts supported only Ubuntu as host, now Fedora is also supported.

Warn

I tested the scripts on Ubuntu 26.04 and Fedora 44 only. There is no plan to make them backwards compatible as this is meant to be used as a quick-start only. For more in-depth support and customization I would always recommend using a BSP build system like Yocto or Buildroot.

After running all the scripts in order, the following output can be observed, showing that Linux v7.0+ and Ubuntu 26.04 are runnig on QEMU Cubieboard.

Subscribe
If you would like to get information as soon as new content is published, please subscribe to the "MistraSolutions newsletter".