Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 1 | #!/bin/bash -xe |
Alanny Lopez | b24dccb | 2017-07-27 10:25:50 -0500 | [diff] [blame^] | 2 | ############################################################################### |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 3 | # Launch QEMU using the raw commands |
| 4 | # |
Alanny Lopez | b24dccb | 2017-07-27 10:25:50 -0500 | [diff] [blame^] | 5 | # 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 Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 16 | # 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 Lopez | b24dccb | 2017-07-27 10:25:50 -0500 | [diff] [blame^] | 21 | # |
| 22 | ############################################################################### |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 23 | |
| 24 | set -uo pipefail |
| 25 | |
| 26 | QEMU_ARCH=${1:-$QEMU_ARCH} |
Alanny Lopez | b24dccb | 2017-07-27 10:25:50 -0500 | [diff] [blame^] | 27 | # If QEMU_ARCH is empty exit, it is required to continue |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 28 | echo "QEMU_ARCH = $QEMU_ARCH" |
| 29 | if [[ -z $QEMU_ARCH ]]; then |
| 30 | echo "Did not pass in required QEMU arch parameter" |
| 31 | exit -1 |
| 32 | fi |
| 33 | |
| 34 | BASE_DIR=${2:-$HOME} |
Alanny Lopez | b24dccb | 2017-07-27 10:25:50 -0500 | [diff] [blame^] | 35 | # If BASE_DIR doesn't exist exit, it is required to continue |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 36 | echo "BASE_DIR = $BASE_DIR" |
| 37 | if [[ ! -d $BASE_DIR ]]; then |
| 38 | echo "No input directory and HOME not set!" |
| 39 | exit -1 |
| 40 | fi |
| 41 | |
Alanny Lopez | b24dccb | 2017-07-27 10:25:50 -0500 | [diff] [blame^] | 42 | # Enter the base directory |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 43 | cd ${BASE_DIR} |
| 44 | |
Alanny Lopez | b24dccb | 2017-07-27 10:25:50 -0500 | [diff] [blame^] | 45 | # Find the correct drive file, and save its name |
| 46 | DRIVE=$(ls ./tmp/deploy/images/qemuarm | grep rootfs.ext4) |
| 47 | |
| 48 | # Launch QEMU using the qemu-system-arm |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 49 | ./tmp/sysroots/${QEMU_ARCH}/usr/bin/qemu-system-arm \ |
Alanny Lopez | b24dccb | 2017-07-27 10:25:50 -0500 | [diff] [blame^] | 50 | -redir tcp:443::443 \ |
| 51 | -redir tcp:80::80 \ |
| 52 | -redir tcp:22::22 \ |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 53 | -machine versatilepb \ |
Alanny Lopez | b24dccb | 2017-07-27 10:25:50 -0500 | [diff] [blame^] | 54 | -m 256 \ |
| 55 | -drive file=./tmp/deploy/images/qemuarm/${DRIVE},if=virtio,format=raw \ |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 56 | -show-cursor \ |
| 57 | -usb \ |
Alanny Lopez | b24dccb | 2017-07-27 10:25:50 -0500 | [diff] [blame^] | 58 | -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 |