-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-qemu.sh
executable file
·76 lines (64 loc) · 1.95 KB
/
run-qemu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# QEMU Invocation
# see https://www.qemu.org/docs/master/system/invocation.html
set -o nounset
set -o errexit
TARGET=Application.elf
IMAGE=./build/debug/$TARGET
QEMU_PATH="xpack-qemu-arm-2.8.0-9/bin/qemu-system-gnuarmeclipse"
QEMU_DIRS=". $HOME /opt"
function usage {
cat <<EOT
Usage: ${0#.*/} [qemu-options] [diag] [gdb] [serial] [elf-image]
Launch QEMU from either local sub-directory, home or /opt directory.
Starts up with diagnostic port 8888 open ready for remote GUI.
Options:
serial - start USART3 server on port 7777
gdb - start GDB server on port 1234
--nographic - switch off graphic support
--sdl2 - use built-in graphics instead of remote port 8888
--help -- this help information also -h -?
Use Ctrl-A X to quit QEMU if using --nographic.
EOT
exit 1
}
DIAG='-serial telnet:localhost:8888,server,nodelay'
GRAPHIC=
GDB=
SERIAL=
OPTIONS=
for arg; do
case "$arg" in
--help|-h|-\?) usage ;;
gdb) GDB='-S -gdb tcp::1234' ;;
serial) SERIAL='-serial tcp::7777,server,nodelay' ;;
*.ELF|*.elf) IMAGE="$arg" ;;
--nographic|-nographic)
GRAPHIC=; DIAG= ;;
--sdl2) GRAPHIC=y; DIAG= ;;
-*) OPTIONS="$OPTIONS $arg" ;;
*) echo "Unrecognised command argument: $arg" >&2
usage ;;
esac
done
for dir in $QEMU_DIRS; do
QEMU="$dir/$QEMU_PATH"
[[ -x $QEMU ]] && break
QEMU=
done
if [[ -z "$QEMU" ]]; then
echo "Cannot find QEMU in standard locations: $QEMU_DIRS" >&2
exit 1
fi
if [[ ! -f "$IMAGE" ]]; then
echo "Missing image file: $IMAGE" >&2
exit 1
fi
if [[ -z "$GRAPHIC" ]]; then
OPTIONS="$OPTIONS -nographic --chardev file,path=/dev/null,mux=on,id=c0 -mon chardev=c0 -serial chardev:c0"
fi
set -x
"$QEMU" --verbose --board Feabhas-WMS -d unimp,guest_errors \
--semihosting-config enable=on,target=native \
$OPTIONS $GDB $SERIAL $DIAG \
--image "$IMAGE"