2 title: Building for virtio
5 Virtio is a standartized interface for implementing virtual I/O devices:
7 * Russell, Rusty. "virtio: towards a de-facto standard for virtual I/O devices." ACM SIGOPS Operating Systems Review 42.5 (2008): 95-103.
9 This section describes the steps you need to take to build the AGL demo image
10 for virtio "platform". Later, the same image can be run on various emulators or
11 hypervisors that provide virtio devices, for example, QEMU aarch64 emulation on
12 PC, QEMU/KVM aarch64 virtualization on AGL Reference Hardware, etc.
14 Below, AGL minimal image and Qt based IVI demo are used as example, but
15 similiarly one can run HTML5 based demos, cluster demo, or other AGL images.
17 ## 1. Making Sure Your Build Environment is Correct
20 "[Initializing Your Build Environment](./3_Initializing_Your_Build_Environment.md)"
21 section presented generic information for setting up your build environment
22 using the `aglsetup.sh` script.
23 If you are building the AGL demo image for virtio platform, you need to specify
24 some specific options when you run the script:
27 $ source meta-agl/scripts/aglsetup.sh -m virtio-aarch64 -b build-virtio-aarch64 agl-demo
30 The "-m" option specifies the "virtio-aarch64" machine.
32 The "-b" option sets custom build directory instead of default "build".
34 The "-f" option might be added to override previously available configuration.
35 By default, if there were already configuration files in build directory, they
36 will not be overriden, as result, aglsetup.sh might not have desired effect.
40 This section shows the `bitbake` command used to build the AGL image.
42 Start the build using the `bitbake` command.
44 **AGL minimal image :**
45 The target is `agl-image-minimal`.
48 $ bitbake agl-image-minimal
51 **Qt Based IVI demo :**
52 The target is `agl-demo-platform`.
55 $ bitbake agl-demo-platform
58 ## 3. Deploying the AGL Demo Image
60 This subsection describes AGL virtio-aarch64 image deployment under virtio
61 platform provided by QEMU aarch64 emulator on PC, or QEMU/KVM hypervisor on AGL
62 Reference Hardware board.
66 If shell from which AGL was built is closed, or new shell is opened, then it is
67 needed to re-initialize build environment:
70 $ source $AGL_TOP/build-virtio-aarch64/agl-init-build-env
73 And further use `runqemu` to boot the image :
79 **3.2 QEMU/KVM on AGL Reference Hardware**
81 Follow these steps to run virtual AGL on bare-metal AGL (AGL-in-AGL) on AGL Reference Hardware board:
83 1. Partition eMMC or SD-Card to have two partitions, at least 1 GiB each.
84 Actually, can be less but just rounded up to have a nice number.
86 2. Flash AGL minimal image root file system to the second partition on SD-Card
89 3. Build AGL minimal image for AGL Reference Hardware.
92 source meta-agl/scripts/aglsetup.sh -m h3ulcb -b build-h3ulcb agl-refhw-h3
95 In `build-h3ulcb/conf/local.conf` add
98 AGL_DEFAULT_IMAGE_FSTYPES = "ext4"
99 IMAGE_INSTALL_append = "qemu"
102 CAUTION: Calling aglsetup.sh with "-f" flag will remove above modification
103 in "local.conf", so they will be needed to be re-applied.
108 bitbake agl-image-minimal
111 Add virtio kernel to the AGL Reference Hardware Linux rootfs:
114 cp build-virtio-aarch64/tmp/deploy/images/virtio-aarch64/Image build-h3ulcb/tmp/work/h3ulcb-agl-linux/agl-image-minimal/1.0-r0/rootfs/linux2
115 bitbake agl-image-minimal -c image_ext4 -f
116 bitbake agl-image-minimal -c image_complete
119 Flash root file system to the first partition on SD-Card or eMMC.
121 4. Boot AGL Reference Hardware board using Linux located on the first partition of SD-Card or eMMC.
123 5. Run QEMU from Linux 1 command line
126 qemu-system-aarch64 \
131 -global virtio-mmio.force-legacy=false \
132 -drive id=disk0,file=/dev/mmcblk0p2,if=none,format=raw \
133 -device virtio-blk-device,drive=disk0 \
134 -object rng-random,filename=/dev/urandom,id=rng0 \
135 -device virtio-rng-device,rng=rng0 \
138 -append 'root=/dev/vda rw mem=2048M'
141 NOTE: mmcblk0p2 above is used for when root file system is flashed on eMMC.
142 In case of SD-Card, mmcblk1p2 has to be used.
144 6. It is possible to exit from QEMU using monitor commands. Enter "Ctrl+a h" for help.
146 Know issue: to enable hardware virtualization using KVM, option `-enable-kvm`
147 could be added to QEMU command line, but it fails with:
150 qemu-system-aarch64: kvm_init_vcpu failed: Invalid argument