blob: 4f8d2df3fd3b04a0e1e50fd1882222d71259e3c2 [file] [log] [blame]
Andrew Geissler0205e8d2016-08-10 07:46:19 -05001#!/bin/bash -xe
Alanny Lopezb24dccb2017-07-27 10:25:50 -05002###############################################################################
Andrew Geissler0205e8d2016-08-10 07:46:19 -05003# Launch QEMU using the raw commands
4#
Alanny Lopezb24dccb2017-07-27 10:25:50 -05005# Can be run by specifying the BASE_DIR and QEMU_ARCH when the script is
6# called. Additionally, this script is automatically called by running the
7# run-robot-qemu-test.sh, it's used to launch the QEMU test container.
8#
9###############################################################################
10#
11# Variables BASE_DIR and QEMU_ARCH are both required but can be optionally
12# input as parameters following the initial script call. Alternatively, they
13# can be input by exporting them or sourcing the script into an environment
14# that has them declared.
15#
Andrew Geissler0205e8d2016-08-10 07:46:19 -050016# Parameters:
17# parm1: <optional, QEMU architecture to use >
18# default is ${QEMU_ARCH} - ppc64le-linux or x86_64-linux
19# parm2: <optional, full path to base directory of qemu binary and images >
20# default is ${HOME}
Alanny Lopezb24dccb2017-07-27 10:25:50 -050021#
22###############################################################################
Andrew Geissler0205e8d2016-08-10 07:46:19 -050023
24set -uo pipefail
25
26QEMU_ARCH=${1:-$QEMU_ARCH}
Alanny Lopezb24dccb2017-07-27 10:25:50 -050027# If QEMU_ARCH is empty exit, it is required to continue
Andrew Geissler0205e8d2016-08-10 07:46:19 -050028echo "QEMU_ARCH = $QEMU_ARCH"
29if [[ -z $QEMU_ARCH ]]; then
30 echo "Did not pass in required QEMU arch parameter"
31 exit -1
32fi
33
34BASE_DIR=${2:-$HOME}
Alanny Lopezb24dccb2017-07-27 10:25:50 -050035# If BASE_DIR doesn't exist exit, it is required to continue
Andrew Geissler0205e8d2016-08-10 07:46:19 -050036echo "BASE_DIR = $BASE_DIR"
37if [[ ! -d $BASE_DIR ]]; then
38 echo "No input directory and HOME not set!"
39 exit -1
40fi
41
Alanny Lopezb24dccb2017-07-27 10:25:50 -050042# Enter the base directory
Andrew Geissler0205e8d2016-08-10 07:46:19 -050043cd ${BASE_DIR}
44
Alanny Lopezb24dccb2017-07-27 10:25:50 -050045# Find the correct drive file, and save its name
46DRIVE=$(ls ./tmp/deploy/images/qemuarm | grep rootfs.ext4)
47
48# Launch QEMU using the qemu-system-arm
Andrew Geissler0205e8d2016-08-10 07:46:19 -050049./tmp/sysroots/${QEMU_ARCH}/usr/bin/qemu-system-arm \
Alanny Lopezb24dccb2017-07-27 10:25:50 -050050 -redir tcp:443::443 \
51 -redir tcp:80::80 \
52 -redir tcp:22::22 \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050053 -machine versatilepb \
Alanny Lopezb24dccb2017-07-27 10:25:50 -050054 -m 256 \
55 -drive file=./tmp/deploy/images/qemuarm/${DRIVE},if=virtio,format=raw \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050056 -show-cursor \
57 -usb \
Alanny Lopezb24dccb2017-07-27 10:25:50 -050058 -usbdevice tablet \
59 -device virtio-rng-pci \
60 -serial mon:vc \
61 -serial mon:stdio \
62 -serial null \
63 -kernel ./tmp/deploy/images/qemuarm/zImage \
64 -append 'root=/dev/vda rw highres=off console=ttyS0 mem=256M ip=dhcp console=ttyAMA0,115200 console=tty'\
65 -dtb ./tmp/deploy/images/qemuarm/zImage-versatile-pb.dtb