-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild-t23.sh
More file actions
executable file
·166 lines (150 loc) · 6.17 KB
/
Copy pathbuild-t23.sh
File metadata and controls
executable file
·166 lines (150 loc) · 6.17 KB
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
#!/bin/sh
set -eu
project_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
output_dir=${T23_OUTPUT_DIR:-"$project_dir/build/t23"}
firmware_dir=${THINGINO_DIR:-}
if [ -z "$firmware_dir" ]; then
for candidate in \
"$project_dir/../thingino-firmware-opensensor" \
"$project_dir/../thingino-firmware" \
"$project_dir/../../thingino-firmware-opensensor" \
"$project_dir/../../thingino-firmware"
do
if [ -d "$candidate/output/master" ]; then
firmware_dir=$(CDPATH= cd -- "$candidate" && pwd)
break
fi
done
fi
: "${firmware_dir:?set THINGINO_DIR to a Thingino firmware checkout}"
target_name=${T23_TARGET:-cinnado_d1_t23n_sc2336_atbm6012bx-3.10.14-uclibc}
target_dir=${T23_TARGET_DIR:-"$firmware_dir/output/master/$target_name"}
toolchain_prefix=${TOOLCHAIN_PREFIX:-"$target_dir/host/bin/mipsel-linux"}
compiler="${toolchain_prefix}-gcc"
stripper="${toolchain_prefix}-strip"
test -x "$compiler"
mkdir -p "$output_dir"
base_flags="-std=gnu99 -O2 -mabi=32 -march=mips32r2 -mabicalls"
base_flags="$base_flags -fPIC -G0 -fno-stack-protector -DPLATFORM_T23"
repo_includes="-I$project_dir/include -I$project_dir/src"
compile()
{
object=$1
source=$2
shift 2
"$compiler" $base_flags $repo_includes -Wall -Wextra "$@" \
-c "$project_dir/$source" -o "$output_dir/$object.o"
}
# The T23 public ABI feeds the recovered AVPU backend through the T-series
# stock-driver seam. Audio remains in the OEM libimp used by RAD.
compile openimp_p0 src/t40/openimp_p0.c -Werror
compile openimp_profile src/openimp_profile.c -Werror
compile openimp_tuning src/openimp_tuning.c -Werror
compile openimp_p2_encoder src/t40/openimp_p2_encoder.c -Werror
compile openimp_avc src/t40/openimp_avc.c -Werror
compile t40_ep1 src/t40/t40_ep1.c -Werror
compile enc_hw_scaling src/alcodec/EncHwScalingList.c
compile codec src/t40/codec-t40.c -Wno-stringop-overflow
compile al_avpu src/al_avpu.c -Wno-stringop-overflow
compile device_pool src/device_pool.c -Wno-stringop-overflow
compile fifo src/fifo.c -Wno-stringop-overflow
compile hw_encoder src/hw_encoder.c -Wno-stringop-overflow
compile time64_shim src/time64_shim.c
compile kernel_interface src/kernel_interface.c
compile dma_alloc src/dma_alloc.c
compile core_device src/core/device.c
compile core_group src/core/group.c
compile core_module src/core/module.c
compile framesource src/framesource/framesource_tseries.c
compile isp src/isp/isp_tseries.c
compile t23_compat src/t31/openimp_t31_compat.c
compile t23_state src/t31/openimp_t31_state.c -Werror
compile t23_services src/t31/openimp_t31_services.c -Werror
compile t23_platform_services src/t23/openimp_t23_services.c -Werror
compile t23_helix_bridge src/t23/openimp_t23_helix_bridge.c -Werror
compile t23_persist src/t23/openimp_t23_persist.c -Werror
"$compiler" -shared -nostartfiles \
-Wl,-soname,libimp.so \
-Wl,--version-script="$project_dir/src/t40/libimp.map" \
-o "$output_dir/libimp.so" \
"$output_dir/openimp_p0.o" \
"$output_dir/openimp_profile.o" \
"$output_dir/openimp_tuning.o" \
"$output_dir/openimp_p2_encoder.o" \
"$output_dir/openimp_avc.o" \
"$output_dir/t40_ep1.o" \
"$output_dir/enc_hw_scaling.o" \
"$output_dir/codec.o" \
"$output_dir/al_avpu.o" \
"$output_dir/device_pool.o" \
"$output_dir/fifo.o" \
"$output_dir/hw_encoder.o" \
"$output_dir/time64_shim.o" \
"$output_dir/kernel_interface.o" \
"$output_dir/dma_alloc.o" \
"$output_dir/core_device.o" \
"$output_dir/core_group.o" \
"$output_dir/core_module.o" \
"$output_dir/framesource.o" \
"$output_dir/isp.o" \
"$output_dir/t23_compat.o" \
"$output_dir/t23_state.o" \
"$output_dir/t23_services.o" \
"$output_dir/t23_platform_services.o" \
"$output_dir/t23_helix_bridge.o" \
"$output_dir/t23_persist.o" \
-ldl -lpthread -lrt
"$compiler" $base_flags $repo_includes -Wall -Wextra -Werror \
"$project_dir/tools/openimp-tuningd.c" "$output_dir/openimp_tuning.o" \
-lpthread -o "$output_dir/openimp-tuningd"
"$stripper" --strip-unneeded "$output_dir/libimp.so"
if readelf -d "$output_dir/libimp.so" |
grep -q 'Shared library: \[libimp.so'
then
echo "T23 build has an OEM libimp dependency" >&2
exit 1
fi
if readelf --dyn-syms --wide "$output_dir/libimp.so" |
awk '$7 != "UND" && $8 ~ /^IMP_(AI|AO|AENC|ADEC|DMIC)_/ {found=1} END {exit !found}'
then
echo "T23 build exports audio APIs" >&2
exit 1
fi
rvd=${T23_RVD:-"$target_dir/target/usr/bin/rvd"}
if [ -f "$rvd" ]; then
readelf --dyn-syms --wide "$rvd" |
awk '$7 == "UND" && $8 ~ /^IMP_/ {
sub(/@.*/, "", $8)
print $8
}' | sort -u >"$output_dir/rvd-imp-imports.txt"
readelf --dyn-syms --wide "$output_dir/libimp.so" |
awk '$7 != "UND" && $5 == "GLOBAL" && $8 ~ /^IMP_/ {print $8}' |
sort -u >"$output_dir/libimp-exports.txt"
comm -23 "$output_dir/rvd-imp-imports.txt" \
"$output_dir/libimp-exports.txt" >"$output_dir/rvd-imp-missing.txt"
echo "RVD IMP coverage: $(comm -12 "$output_dir/rvd-imp-imports.txt" "$output_dir/libimp-exports.txt" | wc -l)/$(wc -l <"$output_dir/rvd-imp-imports.txt")"
if [ -s "$output_dir/rvd-imp-missing.txt" ]; then
echo "T23 build is missing RVD IMP imports:" >&2
cat "$output_dir/rvd-imp-missing.txt" >&2
exit 1
fi
fi
sha256sum "$output_dir/libimp.so"
readelf -d "$output_dir/libimp.so" | grep -E 'SONAME|NEEDED'
# Keep the proprietary T23 Helix implementation in a clean process. RVD loads
# OpenIMP, while this small worker resolves libimp from /usr/lib and exchanges
# raw frames through tmpfs-backed shared memory.
"$compiler" $base_flags $repo_includes -Wall -Wextra -Werror \
"$project_dir/src/t23/openimp_t23_helix_worker.c" \
-L"$target_dir/target/usr/lib" \
-Wl,-rpath,/usr/lib -Wl,-rpath-link,"$target_dir/target/usr/lib" \
-limp -lalog -lpthread -ldl \
-o "$output_dir/openimp-t23-helixd"
"$stripper" --strip-unneeded "$output_dir/openimp-t23-helixd"
if ! readelf -d "$output_dir/openimp-t23-helixd" |
grep -q 'Shared library: \[libimp.so\]'
then
echo "T23 Helix worker is not linked to the OEM libimp ABI" >&2
exit 1
fi
ls -l "$output_dir/openimp-t23-helixd"