We're hiring!
*

Quick hack: Building ChromiumOS for QEMU

Robert Foss avatar

Robert Foss
December 01, 2017

Share this post:

Getting ChromiumOS building is reasonably easy, but running it under QEMU requires some work.

Alt text

So let's start off by covering how ChromiumOS relates to ChromeOS. The ChromiumOS project is essentially ChromeOS minus branding and some packages for things like the media digital restrictions management.

But on the whole, almost everything is there, and the pieces that aren't, you don't need.

ChromiumOS

Depot tools

In order to check out ChromiumOS and other large Google projects, you'll need depot tools.

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$PATH:$(PWD)/depot_tools

Maybe you'd want to add the PATH export to your .bashrc.

Building ChromiumOS

mkdir chromiumos
cd chromiumos
repo init -u https://chromium.googlesource.com/chromiumos/manifest.git --repo-url https://chromium.googlesource.com/external/repo.git [-g minilayout]
repo sync -j75
cros_sdk
export BOARD=amd64-generic
./setup_board --board=${BOARD}
./build_packages --board=${BOARD}
./build_image --board=${BOARD} --boot_args "earlyprintk=serial,keep console=tty0" --noenable_rootfs_verification test
./image_to_vm.sh --board=${BOARD} --test_image

How to (not) boot ChromiumOS

So, this is a command baked into ChromiumOS using the cros_start_vm command, but at least on my machine it does not seem to boot properly. I have as of yet not been able to get any graphical output (over VNC).

cros_sdk
./bin/cros_start_vm --image_path=../build/images/${BOARD}/latest/chromiumos_qemu_image.bin --board=${BOARD}

Running QEMU ourselves

So if the intended tools don't work, we'll just have to roll up our sleeves and do it ourselves. This is how I got ChromiumOS booting.

Install build dependencies

These dependencies were available on Ubuntu 17.10, some alternative packages might be needed for your distributions.

sudo apt install autoconf libaio-dev libbluetooth-dev libbrlapi-dev libbz2-dev libcap-dev libcap-ng-dev libcurl4-gnutls-dev libepoxy-dev libfdt-dev libgbm-dev libgles2-mesa-dev libglib2.0-dev libgtk-3-dev libibverbs-dev libjpeg8-dev liblzo2-dev libncurses5-dev libnuma-dev librbd-dev librdmacm-dev libsasl2-dev libsdl1.2-dev libsdl2-dev libseccomp-dev libsnappy-dev libssh2-1-dev libspice-server-dev libspice-server1 libtool libusb-1.0-0 libusb-1.0-0-dev libvde-dev libvdeplug-dev libvte-dev libxen-dev valgrind xfslibs-dev xutils-dev zlib1g-dev libusbredirhost-dev usbredirserver

Virglrenderer

Virglrenderer creates a virtual 3D GPU, that allows the QEMU guest to use the graphics capabilities of the host machine.

This step is optional, but allows for hardware accelerated OpenGL support on the guest system. If you don't want to use Virgl, remove it from the QEMU configure step and the QEMU runtime flags.

git clone git://git.freedesktop.org/git/virglrenderer
cd virglrenderer
./autogen.sh
make -j7
sudo make install

QEMU

QEMU is a full system emulator, and supports a multitude of machine architectures. We're going to to use x86_64.

git clone git://git.qemu-project.org/qemu.git
mkdir -p qemu/build
cd qemu/build
../configure --target-list=x86_64-softmmu --enable-gtk --with-gtkabi=3.0 --enable-kvm --enable-spice --enable-usb-redir --enable-libusb --enable-virglrenderer --enable-opengl
make -j7
sudo make install

Run image

Now you can boot the image using QEMU.

Note that running QEMU with the virtio options requires that your host machine is running a Linux kernel which was built with the kconfig options CONFIG_DRM_VIRTIO, CONFIG_VIRT_DRIVERS and CONFIG_VIRTIO_XXXX.

cd chromiumos
/usr/local/bin/qemu-system-x86_64 \
    -enable-kvm \
    -m 2G \
    -smp 4 \
    -hda src/build/images/amd64-generic/latest/chromiumos_qemu_image.bin \
    -vga virtio \
    -net nic,model=virtio \
    -net user,hostfwd=tcp:127.0.0.1:9222-:22 \
    -usb -usbdevice keyboard \
    -usbdevice mouse \
    -device virtio-gpu-pci,virgl \
    -display gtk,gl=on

Conclusion

Hopefully this guide will have helped you to build all of the software needed to boot your very own ChromiumOS.

This post has been a part of work undertaken by my employer Collabora.

 

Original post

Comments (9)

  1. Dr sus:
    Dec 01, 2017 at 10:08 PM

    Can I have download link for that qemu image

    Reply to this comment

    Reply to this comment

    1. Robert Foss:
      Dec 06, 2017 at 02:57 PM

      Hey Dr sus,

      Nope!
      We don't host that kind stuff anywhere publicly, but given the guide,
      building your own image should be a matter of copy&pasting commands.


      Rob.

      Reply to this comment

      Reply to this comment

  2. Luciano Augusto:
    Dec 05, 2017 at 10:14 PM

    What a wonderful Robert tip, I have been using QEMU to emulate systems for some time, but I have always had difficulties with Chromium, which is my favorite browser for some functions.

    Strong regards and congratulations on the quality of the content.

    Reply to this comment

    Reply to this comment

    1. Robert Foss:
      Dec 06, 2017 at 03:37 PM

      Hey Luciano,

      i'm glad you like. I hope it comes in handy for you!


      Rob.

      Reply to this comment

      Reply to this comment

  3. tanya stawicki:
    Jan 27, 2020 at 10:16 PM

    Hey Rob,

    Are you still there? Can you do an 2020 update please? The above command don't work anymore ( At least not for me)

    Reply to this comment

    Reply to this comment

    1. Gustavo Padovan:
      Jan 28, 2020 at 06:24 PM

      Hello, which part of the instructions doesn't work for you anymore? Would be kind to clarify it, please?

      Reply to this comment

      Reply to this comment

  4. Ravishankar S:
    Apr 22, 2021 at 06:29 AM

    Do these instructions work on arm64 ?
    I have downloaded pre-built imgaes from:

    https://chromium.arnoldthebat.co.uk/?dir=daily

    But when try to boot on my arach64 system (jetson-nano) , I am not able to do so.


    qemu-system-aarch64 -M virt -m 2048 -smp 2 -cpu host -enable-kvm \
    -device usb-ehci -device usb-kbd -device usb-mouse -usb -serial stdio \
    -device virtio-gpu-pci,virgl=on,xres=1600,yres=900 -display sdl,gl=on \
    -device virtio-blk-device,drive=hd \
    -drive if=none,file=chromiumos_image.bin,format=raw,id=hd \
    -netdev user,id=mynet \
    -device virtio-net-device,netdev=mynet \
    -bios edk2-aarch64-code.fd -no-reboot

    Any hints or tips are welcome. Thanks

    Reply to this comment

    Reply to this comment

    1. Mark Filion:
      Apr 22, 2021 at 02:57 PM

      This guide only works if you follow the instructions step by step. If you download the Chromium images without following the instructions, and try using it on another CPU architecture, I'm not sure it can work.

      Reply to this comment

      Reply to this comment

  5. JustinKJChen:
    Jun 08, 2021 at 03:40 AM

    I follow up above instruction, but stucking at booting kernel.

    What's additional setting that is my miss?

    Reply to this comment

    Reply to this comment


Add a Comment






Allowed tags: <b><i><br>Add a new comment:


Search the newsroom

Latest Blog Posts

Adding secondary command buffers to PanVk

15/06/2022

Getting PanVk, an open source driver for Arm Mali Midgard and Bifrost GPUs, closer to conformancy by implementing one of the core Vulkan…

Bridging the synchronization gap on Linux

09/06/2022

After fighting with the divide between implicit and explicit synchronization with Vulkan on Linux for over seven years, we may finally have…

Monado's hand tracking: hand-waving our way towards a first attempt

31/05/2022

Optical hand tracking for XR has a bit of a reputation - getting training data, training neural nets, and deploying them in real-time, low-latency…

Visual-inertial tracking for Monado

05/04/2022

Monado now has initial support for 6DoF ("inside-out") tracking for devices with cameras and an IMU! Three free and open source SLAM/VIO…

Spotlight on Meson's full-featured developer environment

30/03/2022

When developing an application or a library, it is very common to want to run it without installing it, or to install it into a custom prefix…

How to write a Vulkan driver in 2022

23/03/2022

An incredible amount has changed in Mesa and in the Vulkan ecosystems since we wrote the first Vulkan driver in Mesa for Intel hardware…

Open Since 2005 logo

We use cookies on this website to ensure that you get the best experience. By continuing to use this website you are consenting to the use of these cookies. To find out more please follow this link.

Collabora Ltd © 2005-2022. All rights reserved. Privacy Notice. Sitemap.