-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathrun.sh
executable file
·227 lines (209 loc) · 5.58 KB
/
run.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/bin/bash
# Copyright 2023-2025 Arm Limited and/or its affiliates
# SPDX-License-Identifier: MIT
HERE="$(dirname "$0")"
ROOT="$(realpath $HERE/../..)"
EXAMPLE=""
BUILD_PATH="$(realpath $ROOT/build)"
TARGET="corstone320"
AUDIO_SOURCE="ROM"
NPU_ID=""
FVP_BIN="FVP_Corstone_SSE-320"
FRAMES=""
OPTIONS=""
DISPLAY=true
DISPLAY_OPTIONS=""
set -e
function show_usage {
cat <<EOF
Usage: $0 [options] example
Run an example.
Options:
-h,--help Show this help
-p,--path Build path
-t,--target Target to run
-s,--audio Audio source (ROM, VSI)
-n,--npu-id NPU ID to use (U55, U65)
-f,--frames Path to camera frames for the ISP to stream
-d,--debug Path to debugger plugin to start FVP
-D,--display Is display (GUI) available
Examples:
blinky, keyword-detection, speech-recognition, object-detection
EOF
}
SHORT=t:,n:,s:,h,p:,f:,d:,D:
LONG=target:,npu-id:,audio:,help,path:,frames:,debug:,display:
OPTS=$(getopt -n run --options $SHORT --longoptions $LONG -- "$@")
eval set -- "$OPTS"
while :
do
case "$1" in
-h | --help )
show_usage
exit 0
;;
-p | --path )
BUILD_PATH=$(realpath "$2")
shift 2
;;
-t | --target )
TARGET=$2
shift 2
;;
-n | --npu-id )
NPU_ID=$2
shift 2
;;
-s | --audio )
AUDIO_SOURCE=$2
shift 2
;;
-f | --frames )
FRAMES=$(realpath "$2")
shift 2
;;
-d | --debug )
GDB_PLUGIN=$(realpath "$2")
if [ ! -f $GDB_PLUGIN ]; then
echo "Error: Please provide the path to a `GDBRemoteConnection.so` file"
exit 2
fi
shift 2
;;
-D | --display )
DISPLAY=$2
shift 2
;;
--)
shift;
break
;;
*)
echo "Unexpected option: $1"
show_usage
exit 2
;;
esac
done
case "$TARGET" in
corstone300 )
if [ "$NPU_ID" == "" ] || [ "$NPU_ID" == "U55" ]; then
FVP_BIN="FVP_Corstone_SSE-300_Ethos-U55"
elif [ "$NPU_ID" == "U65" ]; then
FVP_BIN="FVP_Corstone_SSE-300_Ethos-U65"
else
echo "Invalid NPU ID <U55|U65>"
show_usage
exit 2
fi
;;
corstone310 )
if [ "$NPU_ID" == "" ] || [ "$NPU_ID" == "U55" ]; then
FVP_BIN="FVP_Corstone_SSE-310"
elif [ "$NPU_ID" == "U65" ]; then
FVP_BIN="FVP_Corstone_SSE-310_Ethos-U65"
else
echo "Invalid NPU ID <U55|U65>"
show_usage
exit 2
fi
;;
corstone315 )
FVP_BIN="FVP_Corstone_SSE-315"
;;
corstone320 )
FVP_BIN="FVP_Corstone_SSE-320"
;;
*)
echo "Invalid target <corstone300 | corstone310 | corstone315 | corstone320>"
show_usage
exit 2
;;
esac
case "$1" in
blinky)
EXAMPLE="$1"
MERGED_IMAGE_PATH="$BUILD_PATH/blinky_merged.elf"
;;
keyword-detection)
EXAMPLE="$1"
MERGED_IMAGE_PATH="$BUILD_PATH/keyword-detection_merged.elf"
;;
speech-recognition)
EXAMPLE="$1"
MERGED_IMAGE_PATH="$BUILD_PATH/speech-recognition_merged.elf"
;;
object-detection)
EXAMPLE="$1"
MERGED_IMAGE_PATH="$BUILD_PATH/object-detection_merged.elf"
;;
*)
show_usage
exit 1
;;
esac
case "$AUDIO_SOURCE" in
ROM )
;;
VSI )
if [ "$EXAMPLE" == "speech-recognition" ] || [ "$EXAMPLE" == "keyword-detection" ]; then
export APP_UNDERSCORED=$(echo ${EXAMPLE} | tr '-' '_')
export AVH_AUDIO_FILE=$ROOT/applications/$APP_UNDERSCORED/resources/test.wav
fi
case "$TARGET" in
corstone300 | corstone310 )
AVH_AUDIO_OPTIONS="-C mps3_board.v_path=$ROOT/tools/scripts/"
;;
corstone315 )
AVH_AUDIO_OPTIONS="-C mps4_board.v_path=$ROOT/tools/scripts/"
;;
esac
export PYTHONHOME="/opt/python/3.9.18"
;;
*)
echo "Invalid audio source <ROM | VSI>"
show_usage
exit 2
;;
esac
if [ -f "$GDB_PLUGIN" ]; then
OPTIONS="--allow-debug-plugin --plugin $GDB_PLUGIN"
fi
if [ "$DISPLAY" = false ]; then
DISPLAY_OPTIONS="-C vis_hdlcd.disable_visualisation=1"
fi
case "$TARGET" in
corstone300 | corstone310 )
OPTIONS="$OPTIONS \
-C mps3_board.visualisation.disable-visualisation=1 \
-C core_clk.mul=200000000 \
-C mps3_board.smsc_91c111.enabled=1 \
-C mps3_board.hostbridge.userNetworking=1 \
-C mps3_board.telnetterminal0.start_telnet=0 \
-C mps3_board.uart0.out_file="-" \
-C mps3_board.uart0.unbuffered_output=1 \
--stat \
-C mps3_board.DISABLE_GATING=1"
;;
corstone315 | corstone320 )
OPTIONS="$OPTIONS $DISPLAY_OPTIONS \
-C mps4_board.visualisation.disable-visualisation=1 \
-C core_clk.mul=200000000 \
-C mps4_board.smsc_91c111.enabled=1 \
-C mps4_board.hostbridge.userNetworking=1 \
-C mps4_board.telnetterminal0.start_telnet=0 \
-C mps4_board.uart0.out_file="-" \
-C mps4_board.uart0.unbuffered_output=1 \
-C mps4_board.isp_c55_capture_ds.do_capture=0 \
-C mps4_board.isp_c55_capture_fr.do_capture=0 \
-C mps4_board.isp_c55_camera.image_file=${FRAMES} \
--stat"
;;
esac
if [ "$EXAMPLE" == "object-detection" ] && [ "$TARGET" != "corstone315" ] && [ "$TARGET" != "corstone320" ]; then
echo "Error: Invalid combination of example and target. object-detection only supports corstone315 and corstone320" >&2
exit 2
fi
# Start the FVP
$FVP_BIN -a $MERGED_IMAGE_PATH $OPTIONS $AVH_AUDIO_OPTIONS