OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 2 # Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
4 # BSD-style license that can be found in the LICENSE.md file. | 4 # BSD-style license that can be found in the LICENSE.md file. |
5 | 5 |
6 if [ "$1" == "-m" ]; then | 6 if [ "$1" == "-m" ]; then |
7 DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | 7 DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) |
8 (cd ${DIR}/../../third_party/lk; make -j4 DEBUG=1) | 8 (cd ${DIR}/../../third_party/lk; make -j4 DEBUG=1) |
9 shift | 9 shift |
10 fi | 10 fi |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 cleanup_file() { | 31 cleanup_file() { |
32 echo "Removing '$PIPEDIR'" | 32 echo "Removing '$PIPEDIR'" |
33 rm -rf "$PIPEDIR" | 33 rm -rf "$PIPEDIR" |
34 } | 34 } |
35 trap cleanup_file EXIT | 35 trap cleanup_file EXIT |
36 | 36 |
37 mkfifo "$PIPEDIR/qemu.in" "$PIPEDIR/qemu.out" | 37 mkfifo "$PIPEDIR/qemu.in" "$PIPEDIR/qemu.out" |
38 | 38 |
39 echo "Starting qemu..." | 39 echo "Starting qemu..." |
40 ./third_party/qemu/linux/qemu/bin/qemu-system-arm -machine virt -cpu cortex-a15
-m 16 -kernel third_party/lk/out/build-qemu-virt-fletch/lk.elf -nographic -seria
l pipe:$PIPEDIR/qemu & | 40 ./third_party/qemu/linux/qemu/bin/qemu-system-arm -machine virt -cpu cortex-a15
-m 16 -kernel third_party/lk/out/build-qemu-virt-dartino/lk.elf -nographic -seri
al pipe:$PIPEDIR/qemu & |
41 PID=$! | 41 PID=$! |
42 cleanup() { | 42 cleanup() { |
43 echo "Killing $PID" | 43 echo "Killing $PID" |
44 kill $PID | 44 kill $PID |
45 cleanup_file | 45 cleanup_file |
46 } | 46 } |
47 trap cleanup EXIT | 47 trap cleanup EXIT |
48 | 48 |
49 echo "Started with PID $PID" | 49 echo "Started with PID $PID" |
50 | 50 |
51 echo "Waiting for qemu to come up..." | 51 echo "Waiting for qemu to come up..." |
52 grep -qe "entering main console loop" $PIPEDIR/qemu.out | 52 grep -qe "entering main console loop" $PIPEDIR/qemu.out |
53 | 53 |
54 echo "Starting fletch..." | 54 echo "Starting dartino..." |
55 echo "fletch" > $PIPEDIR/qemu.in | 55 echo "dartino" > $PIPEDIR/qemu.in |
56 | 56 |
57 echo "Waiting for size..." | 57 echo "Waiting for size..." |
58 grep -qe "STEP1" $PIPEDIR/qemu.out | 58 grep -qe "STEP1" $PIPEDIR/qemu.out |
59 | 59 |
60 echo "Sending size ($SIZE)..." | 60 echo "Sending size ($SIZE)..." |
61 echo $SIZE >$PIPEDIR/qemu.in | 61 echo $SIZE >$PIPEDIR/qemu.in |
62 | 62 |
63 echo "Waiting for snapshot request..." | 63 echo "Waiting for snapshot request..." |
64 grep -qe "STEP2" $PIPEDIR/qemu.out | 64 grep -qe "STEP2" $PIPEDIR/qemu.out |
65 | 65 |
66 echo "Sending snapshot..." | 66 echo "Sending snapshot..." |
67 cat $1 >$PIPEDIR/qemu.in | 67 cat $1 >$PIPEDIR/qemu.in |
68 | 68 |
69 while IFS='' read -r line; do | 69 while IFS='' read -r line; do |
70 echo "$line" | 70 echo "$line" |
71 if [ "$line" = $'TEARING DOWN fletch-vm...\r' ]; then | 71 if [ "$line" = $'TEARING DOWN dartino-vm...\r' ]; then |
72 break; | 72 break; |
73 fi | 73 fi |
74 if [ "$line" = $'Aborted (immediate)\r' ]; then | 74 if [ "$line" = $'Aborted (immediate)\r' ]; then |
75 exit 253; | 75 exit 253; |
76 fi | 76 fi |
77 if [ "$line" = $'Aborted (scheduled)\r' ]; then | 77 if [ "$line" = $'Aborted (scheduled)\r' ]; then |
78 exit 253; | 78 exit 253; |
79 fi | 79 fi |
80 if [[ "$line" =~ "HALT: spinning forever..."* ]]; then | 80 if [[ "$line" =~ "HALT: spinning forever..."* ]]; then |
81 exit 253; | 81 exit 253; |
82 fi | 82 fi |
83 if [[ "$line" =~ "CRASH: starting debug shell..."* ]]; then | 83 if [[ "$line" =~ "CRASH: starting debug shell..."* ]]; then |
84 exit 253; | 84 exit 253; |
85 fi | 85 fi |
86 done < $PIPEDIR/qemu.out | 86 done < $PIPEDIR/qemu.out |
87 | 87 |
88 read -r line< $PIPEDIR/qemu.out | 88 read -r line< $PIPEDIR/qemu.out |
89 echo "$line" | 89 echo "$line" |
90 | 90 |
91 exit ${line:11:-1} | 91 exit ${line:11:-1} |
OLD | NEW |