summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlias Apalodimas <ilias.apalodimas@linaro.org>2020-03-11 15:41:45 +0200
committerIlias Apalodimas <ilias.apalodimas@linaro.org>2020-03-11 15:41:45 +0200
commit3b4c5c51b98d66206c4f6b0ceafe5ff8bc555e60 (patch)
tree77ce3177bf73d8eb5e319f596bc80f6103a8159e
parentad28771ef67b8a706aef44e950bebcd803eae6c9 (diff)
scripts: add non debugged version of qemu script
Add a qemu script that handles all supported architectures. Not debugged yet a lot are still missing Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
-rwxr-xr-xqemu/run_qemu.sh94
1 files changed, 94 insertions, 0 deletions
diff --git a/qemu/run_qemu.sh b/qemu/run_qemu.sh
new file mode 100755
index 0000000..936ee59
--- /dev/null
+++ b/qemu/run_qemu.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+arch="$1"
+disk_image="$2"
+firmware="$3"
+supported_arch='x86_64, arm, aarch64'
+common_args='-nographic -m 4096 -smp 2 -device virtio-rng-pci -show-cursor'
+extra_args=''
+qemu_prefix='qemu-system-'
+efi_keys='ledge-kernel-uefi-certs.ext4.img'
+ovmf_file='QEMU_EFI.fd'
+
+print_help () {
+ echo "$0 <arch> <file> [firmware_type]"
+ echo "arch: Supported architectures $supported_arch"
+ echo "file: raw image file"
+ echo "firmware_type: optional. ovmf/u-boot. Defaults to U-boot"
+ exit 1
+}
+
+[ $# -lt 2 ] && print_help
+
+# setup common network
+common_args+=' -device virtio-net-pci,netdev=net0,mac=52:54:00:12:34:02 '
+common_args+=' -netdev tap,id=net0,ifname=tap0,script=no,downscript=no '
+
+# Setup common image arguments
+common_args+=" -drive id=disk0,file=$disk_image,if=none,format=raw "
+common_args+=' -device virtio-blk-device,drive=disk0 '
+
+case "$arch" in
+ x86_64)
+ extra_args+=' -cpu host -enable-kvm '
+ if [ "$firmware" = 'ovmf' ]; then
+ extra_args+=" -drive if=pflash,format=raw,file=$ovmf_file "
+ else
+ echo "U-Boot on x86-64 not supported"
+ exit 1
+ fi
+ ;;
+ aarch64)
+ extra_args+=' -cpu cortex-a57 '
+ extra_args+=' -bios bl1.bin '
+
+ if [ "$firmware" = 'ovmf' ]; then
+ extra_args+=' -machine virt'
+ else
+ extra_args+=' -machine virt,secure=on '
+ extra_args+=' -d unimp -semihosting-config enable,target=native'
+ #extra_args+=" -drive id=disk1,file=$efi_keys,if=none,format=raw"
+ #extra_args+=' -device virtio-blk-device,drive=disk1 '
+ fi
+ ;;
+ arm)
+ extra_args+=' -cpu cortex-a15 '
+ extra_args+=' -bios bl1.bin '
+
+ if [ "$firmware" = 'ovmf' ]; then
+ echo "OVMF on armv7 not supported yet"
+ exit 1
+ else
+ extra_args+=' -no-reboot'
+ extra_args+=' -machine virt,secure=on '
+ extra_args+=' -d unimp -semihosting-config enable,target=native'
+ extra_args+=' -dtb ledge-qemuarm.dtb '
+ extra_args+=" -drive id=disk1,file=$efi_keys,if=none,format=raw"
+ extra_args+=' -device virtio-blk-device,drive=disk1 '
+ extra_args+=' -serial mon:stdio '
+ fi
+ ;;
+ *)
+ echo "Unknown arhcitecture $arch"
+ echo "Supported: $supported_arch"
+ exit 1
+ ;;
+esac
+qemu_bin="$qemu_prefix""$arch"
+
+# echo "Binary: $qemu_bin"
+echo "Run: $qemu_bin $common_args $extra_args "
+# $(sudo $qemu_bin $common_args $extra_args)
+
+#${QEMU} \
+ #-serial mon:stdio -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0
+
+#qemu-system-arm \
+ # -device virtio-serial-device \
+ #-chardev null,id=virtcon -device virtconsole,chardev=virtcon
+
+# OVMF
+#qemu-system-aarch64 \
+ #-bios ${OVMF} -drive id=disk0,file=${DISK},if=none,format=raw -device virtio-blk-device,drive=disk0
+# U-Boot
+#qemu-system-aarch64 \