1#!/bin/bash -xe
2#
3# Launch QEMU using the raw commands
4#
5#  Parameters:
6#   parm1:  <optional, QEMU architecture to use >
7#            default is ${QEMU_ARCH} - ppc64le-linux or x86_64-linux
8#   parm2:  <optional, full path to base directory of qemu binary and images >
9#            default is ${HOME}
10
11set -uo pipefail
12
13QEMU_ARCH=${1:-$QEMU_ARCH}
14echo "QEMU_ARCH = $QEMU_ARCH"
15if [[ -z $QEMU_ARCH ]]; then
16    echo "Did not pass in required QEMU arch parameter"
17    exit -1
18fi
19
20BASE_DIR=${2:-$HOME}
21echo "BASE_DIR = $BASE_DIR"
22if [[ ! -d $BASE_DIR ]]; then
23    echo "No input directory and HOME not set!"
24    exit -1
25fi
26
27cd ${BASE_DIR}
28
29./tmp/sysroots/${QEMU_ARCH}/usr/bin/qemu-system-arm \
30    -nographic \
31    -kernel ./tmp/deploy/images/qemuarm/zImage-qemuarm.bin \
32    -machine versatilepb \
33    -drive file=./tmp/deploy/images/qemuarm/obmc-phosphor-image-qemuarm.ext4,format=raw \
34    -no-reboot \
35    -show-cursor \
36    -usb \
37    -usbdevice wacom-tablet \
38    -no-reboot -m 128 \
39    -redir tcp:22::22 \
40    -redir tcp:443::443 \
41    --append \
42    "root=/dev/sda rw console=ttyAMA0,115200 console=tty mem=128M highres=off \
43    rootfstype=ext4 console=ttyS0"
44