Skip to content

Commit 9b998eb

Browse files
author
Srinivas Kandagatla
committed
Dockerfile: add script to setup hexagon binaries
Add script to setup qnn dependencies which includes copying correct hexagon binaries that match with linux firmware. This requires host to do a bind mount of https://github.com/linux-msm/hexagon-dsp-binaries.git to /root/hexagon-binaries/ Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
1 parent 65a4475 commit 9b998eb

3 files changed

Lines changed: 121 additions & 7 deletions

File tree

Dockerfile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,6 @@ RUN cd ~/build ; \
119119
cp ~/build/qairt/*/lib/hexagon-v* /usr/share/qcom/ -rf; \
120120
rm ~/build/qairt -rf
121121

122-
# Install hexagon binaries and copy binaries for RB3Gen2 : TODO add for others
123-
RUN cd ~/build; \
124-
mkdir -p /usr/lib/dsp/cdsp ; \
125-
git clone https://github.com/linux-msm/hexagon-dsp-binaries.git ; \
126-
cp -v hexagon-dsp-binaries/qcm6490/Thundercomm/RB3gen2/CDSP.HT.2.5.c3-00077-KODIAK-1/* /usr/lib/dsp/cdsp/ ; \
127-
rm ~/build/hexagon-dsp-binaries -rf
128-
129122
# Remove build folder
130123
RUN rm -rf ~/build
131124

@@ -225,9 +218,11 @@ COPY --from=build /root/tensorflow /root/tensorflow
225218
COPY run-tflite.sh /
226219
COPY benchmark-tflite.sh /
227220
COPY install-gstreamer.sh /
221+
COPY install-hexagon-bins.sh /
228222
RUN chmod +x /*.sh
229223
RUN mkdir /usr/share/qcom/conf.d -p
230224
COPY fastrpc_config.yaml /usr/share/qcom/conf.d/
225+
COPY devices.yaml /
231226

232227
# Remove cached files
233228
RUN rm ~/.cache -rf

devices.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# source: device-tree and https://workbench.aihub.qualcomm.com/devices/
2+
devices:
3+
- device_name: Dragonwing RB3 Gen 2 Vision Kit
4+
device_dt_model:
5+
- Qualcomm Technologies, Inc. Robotics RB3gen2
6+
chipset: "Qualcomm® Dragonwing™ RB3 Gen 2 | QCS6490"
7+
runtime_support:
8+
tensorflow_lite: true
9+
onnx_runtime: true
10+
ai_engine_direct_qnn: false
11+
hexagon_tensor_processor:
12+
fp16_precision: true
13+
version: v68
14+
soc_model: "35"
15+
soc_ids:
16+
- "497"
17+
- "498"
18+
hexagon_bin_dir: qcm6490/Thundercomm/RB3gen2/
19+
hexagon_bin_dir_prefix: ""
20+
21+
- device_name: Arduino Monza
22+
device_dt_model:
23+
- Arduino Monza
24+
chipset: "Qualcomm® QCS8275"
25+
runtime_support:
26+
tensorflow_lite: true
27+
onnx_runtime: true
28+
ai_engine_direct_qnn: true
29+
hexagon_tensor_processor:
30+
fp16_precision: true
31+
version: v75
32+
soc_model: "67"
33+
soc_ids:
34+
- "675"
35+
- "674"
36+
hexagon_bin_dir: qcs8300/Qualcomm/QCS8300-RIDE/
37+
hexagon_bin_dir_prefix: cdsp-
38+

install-hexagon-bins.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
DEVICES_YAML="devices.yaml"
5+
6+
CDSP_DIRS=(
7+
"/sys/kernel/debug/qcom_socinfo/cdsp"
8+
"/sys/kernel/debug/qcom_socinfo/cdsp1"
9+
"/sys/kernel/debug/qcom_socinfo/cdsp2"
10+
"/sys/kernel/debug/qcom_socinfo/cdsp3"
11+
)
12+
13+
read_soc_id() {
14+
if [[ -f /sys/devices/soc0/soc_id ]]; then
15+
tr -d '\0' < /sys/devices/soc0/soc_id | xargs
16+
fi
17+
}
18+
19+
read_device_model() {
20+
if [[ -f /sys/firmware/devicetree/base/model ]]; then
21+
tr -d '\0' < /sys/firmware/devicetree/base/model | xargs
22+
fi
23+
}
24+
25+
get_cdsp_firmware_version() {
26+
for dir in "${CDSP_DIRS[@]}"; do
27+
file="$dir/name"
28+
if [[ -f "$file" ]]; then
29+
line=$(cat "$file")
30+
if [[ -n "$line" ]]; then
31+
echo "$line" | awk -F: '{print $2}' | xargs
32+
return
33+
fi
34+
fi
35+
done
36+
}
37+
38+
get_hexagon_version_by_soc() {
39+
local soc_id="$1"
40+
yq -r ".devices[] | select(.soc_ids[] == \"$soc_id\") | .hexagon_tensor_processor.version" "$DEVICES_YAML"
41+
}
42+
43+
get_hexagon_bin_dir_by_model() {
44+
local model="$1"
45+
yq -r ".devices[] | select(.device_dt_model[] == \"$model\") | .hexagon_bin_dir" "$DEVICES_YAML"
46+
}
47+
48+
get_hexagon_prefix_by_model() {
49+
local model="$1"
50+
yq -r ".devices[] | select(.device_dt_model[] == \"$model\") | .hexagon_bin_dir_prefix" "$DEVICES_YAML"
51+
}
52+
53+
get_hexagon_src_dir() {
54+
model=$(read_device_model)
55+
bin_dir=$(get_hexagon_bin_dir_by_model "$model")
56+
prefix=$(get_hexagon_prefix_by_model "$model")
57+
fw_name=$(get_cdsp_firmware_version)
58+
59+
echo "/root/hexagon-binaries/${bin_dir}${prefix}${fw_name}/"
60+
}
61+
62+
get_hexagon_dest_dir() {
63+
soc_id=$(read_soc_id)
64+
hex_ver=$(get_hexagon_version_by_soc "$soc_id")
65+
echo "/usr/share/qcom/hexagon-${hex_ver}/"
66+
}
67+
68+
copy_hexagon_bins() {
69+
src=$(get_hexagon_src_dir)
70+
dst=$(get_hexagon_dest_dir)
71+
72+
echo "Copying Hexagon bins:"
73+
echo "SRC: $src"
74+
echo "DST: $dst"
75+
76+
mkdir -p "$dst"
77+
cp -r "$src"* "$dst"
78+
}
79+
80+
copy_hexagon_bins
81+

0 commit comments

Comments
 (0)