2 title: Building for x86 (Emulation and Hardware)
5 Building an image for emulation allows you to simulate your
6 image without actual target hardware.
8 This section describes the steps you need to take to build the
9 AGL demo image for emulation using either Quick EMUlator (QEMU) or
10 VirtualBox, and later the same image can be used to boot any hardware.
12 ## 1. Making Sure Your Build Environment is Correct
15 "[Initializing Your Build Environment](./04_Initializing_Your_Build_Environment.md)"
16 section presented generic information for setting up your build environment
17 using the `aglsetup.sh` script.
18 If you are building the AGL demo image for emulation, you need to specify some
19 specific options when you run the script:
21 **Sample Qt based IVI demo :**
24 $ source meta-agl/scripts/aglsetup.sh -f -m qemux86-64 -b qemux86-64 agl-demo agl-devel
25 $ echo "# reuse download directories" >> $AGL_TOP/site.conf
26 $ echo "DL_DIR = \"$HOME/downloads/\"" >> $AGL_TOP/site.conf
27 $ echo "SSTATE_DIR = \"$AGL_TOP/sstate-cache/\"" >> $AGL_TOP/site.conf
28 $ ln -sf $AGL_TOP/site.conf conf/
31 **Sample HTML5 based IVI demo :**
34 $ source meta-agl/scripts/aglsetup.sh -f -m qemux86-64 -b qemux86-64 agl-demo agl-devel agl-profile-graphical-html5
35 $ echo "# reuse download directories" >> $AGL_TOP/site.conf
36 $ echo "DL_DIR = \"$HOME/downloads/\"" >> $AGL_TOP/site.conf
37 $ echo "SSTATE_DIR = \"$AGL_TOP/sstate-cache/\"" >> $AGL_TOP/site.conf
38 $ ln -sf $AGL_TOP/site.conf conf/
41 **IVI-EG Flutter based demo :**
44 $ source meta-agl/scripts/aglsetup.sh -f -m qemux86-64 -b qemux86-64 agl-flutter agl-devel
45 $ echo "# reuse download directories" >> $AGL_TOP/site.conf
46 $ echo "DL_DIR = \"$HOME/downloads/\"" >> $AGL_TOP/site.conf
47 $ echo "SSTATE_DIR = \"$AGL_TOP/sstate-cache/\"" >> $AGL_TOP/site.conf
48 $ ln -sf $AGL_TOP/site.conf conf/
51 **IC-EG container image :**
56 **Virt-EG demo image :**
61 The "-m" option specifies the "qemux86-64" machine.
62 The list of AGL features used with script are appropriate for development of
63 the AGL demo image suited for either QEMU or VirtualBox.
67 Start the build using the `bitbake` command.
69 **NOTE:** An initial build can take many hours depending on your
70 CPU and and Internet connection speeds.
71 The build also takes approximately 100G-bytes of free disk space.
73 **Sample Qt based IVI demo :**
74 The target is `agl-ivi-demo-qt`.
77 $ time bitbake agl-ivi-demo-qt
80 By default, the build process puts the resulting image in the Build Directory and further exporting that as `$IMAGE_NAME`:
83 <build_directory>/tmp/deploy/images/qemux86-64/agl-ivi-demo-qt-qemux86-64.vmdk.xz
85 $ export IMAGE_NAME=agl-ivi-demo-qt-qemux86-64.vmdk.xz
88 **Sample HTML5 based IVI demo :**
89 The target is `agl-ivi-demo-html5`.
92 $ time bitbake agl-ivi-demo-html5
95 By default, the build process puts the resulting image in the Build Directory and further exporting that as `$IMAGE_NAME`:
98 <build_directory>/tmp/deploy/images/qemux86-64/agl-ivi-demo-html5-qemux86-64.vmdk.xz
100 $ export IMAGE_NAME=agl-ivi-demo-html5-qemux86-64.vmdk.xz
103 **IVI-EG Flutter based demo :**
104 The target is `agl-image-flutter`.
107 $ time bitbake agl-image-flutter
110 **IC-EG container image :**
115 **Virt-EG demo image :**
120 ## 3. Deploying the AGL Demo Image
122 Deploying the image consists of decompressing the image and then
123 booting it using either QEMU, VirtualBox or physical system.
124 The examples below are usually for the 'agl-ivi-demo-qt' target.
125 Please adapt accordingly to your target image.
129 Depending on your Linux distribution, use these commands to install QEMU:
131 If you built your image with bitbake, you can now just use the ``runqemu`` wrapper, after sourcing `agl-init-build-env` inside the build-dir :
136 $ source $AGL_TOP/master/qemux86-64/agl-init-build-env
142 $ source $AGL_TOP/<release-branch-name>/<build-dir>/
145 And further use `runqemu` to boot the image :
148 $ runqemu tmp/deploy/images/qemux86-64/agl-ivi-demo-qt-qemux86-64.qemuboot.conf kvm serialstdio slirp publicvnc audio
151 If you need to run it outside of the bitbake environment or need special settings for
152 hardware pass-through using `qemu` :
155 **NOTE:** if you have created an AGL crosssdk, it will contain a
156 QEMU binary for the build host.
157 This SDK QEMU binary does not support graphics.
158 Consequently, you cannot use it to boot the AGL image and
159 need to call your host's qemu binary instead.
161 **NOTE:** the VM images need UEFI in the emulator to boot. Thus you need
162 to install the necessary files with below commands (ovmf).
164 If your build host is running
165 [Arch Linux](https://www.archlinux.org/), use the following commands:
168 sudo pacman -S qemu ovmf
169 export OVMF_PATH=/usr/share/ovmf/x64/OVMF_CODE.fd
172 If your build host is running Debian or Ubuntu, use the following commands:
175 sudo apt-get install qemu-system-x86 ovmf
176 export OVMF_PATH=/usr/share/ovmf/OVMF.fd
179 If you build host is running Fedora, use the following commands:
182 sudo yum install qemu qemu-kvm edk2-ovmf
183 export OVMF_PATH=/usr/share/edk2/ovmf/OVMF_CODE.fd
188 Once QEMU is installed, boot the image with KVM support:
191 qemu-system-x86_64 -enable-kvm -m 2048 \
194 -cpu kvm64 -cpu qemu64,+ssse3,+sse4.1,+sse4.2,+popcnt \
195 -vga virtio -show-cursor \
196 -device virtio-rng-pci \
197 -serial mon:stdio -serial null \
200 -net user,hostfwd=tcp::2222-:22
203 **NOTE:** KVM may not be supported within a virtualized environment such as
204 VirtualBox. This is indicated by the qemu command above giving the error
205 message `Could not access KVM kernel module: No such file or directory` or
206 the kernel log output contains the error message `kvm: no hardware support`.
207 The image can be booted in such an environment by removing `-enable-kvm` from
208 the qemu command line, however this will result in lower perfromance within
213 Once VirtualBox is installed, follow these steps to boot the image:
215 1. Install and set up [Virtual Box](https://www.virtualbox.org/wiki/Linux_Downloads).
217 2. Extract the vmdk file :
220 cd tmp/deploy/images/qemux86-64
224 3. Configure virtual box for AGL :
225 - Click on `New` or `Add`.
226 - Enter Name as `agl-demo`.
228 - Version as `Other Linux (64-bit)`, click on `Next`.
229 
230 - Select Memory size. Recommended is `2048 MB`, click on `Next`.
231 
232 - Click on `Use an existing virtual hard disk file`, and select the extracted `agl-ivi-demo-qt-qemux86-64.vmdk.xz` or `<html5-image?>` file, click on `Create`.
233 
234 - Go to `Settings`, and into `System`. Select `Chipset : IHC9`. Check on `Enable EFI (special OSes only)` and click on `OK`.
235 
236 - Go to `Storage`, and change the attribute to `Type : AHCI` and click on `OK`.
237 
239 - For troubleshooting, you can refer [here](https://lists.automotivelinux.org/g/agl-dev-community/message/8474).
241 **3.3 x86 physical system**
243 **NOTE :** UEFI enabled system is required.
245 1. Extract the image into USB drive :
248 $ cd tmp/deploy/images/qemux86-64
250 $ sudo umount <usb_device_name>
251 $ xzcat agl-ivi-demo-qt-qemux86-64.wic.xz | sudo dd of=<usb_device_name> bs=4M
255 2. Boot from USB drive on the x86 system.