-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathbuild-licheervnano.sh
More file actions
executable file
·281 lines (259 loc) · 8.14 KB
/
Copy pathbuild-licheervnano.sh
File metadata and controls
executable file
·281 lines (259 loc) · 8.14 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
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
#!/bin/bash -e
export SG_BOARD_FAMILY=sg200x
export SG_BOARD_LINK=sg2002_licheervnano_sd
sdkver=keep
maixcdk=n
maixpy=n
osstar=y
qt5=y
tailscale=n
tpudemo=c
tpusdk=y
panelvariants=n
while [ "$#" -gt 0 ]; do
case "$1" in
--board=*|--board-link=*)
export SG_BOARD_LINK=`echo $1 | cut -d '=' -f 2-`
shift
;;
--sdk-ver=*|--sdkver=*)
sdkver=`echo $1 | cut -d '=' -f 2-`
shift
;;
--maix-cdk|--maixcdk)
shift
maixcdk=y
;;
--no-maix-cdk|--no-maixcdk)
shift
maixcdk=n
maixpy=n
;;
--maix-py|--maixpy)
shift
maixcdk=y
maixpy=y
;;
--no-maix-py|--no-maixpy)
shift
maixpy=n
;;
--qt5)
shift
qt5=y
;;
--no-qt5)
shift
qt5=n
;;
--oss-tar|--osstar)
shift
osstar=y
;;
--no-oss-tar|--no-osstar)
shift
osstar=n
;;
--tailscale)
shift
tailscale=y
;;
--no-tailscale)
shift
tailscale=n
;;
--tpu-demo|--tpudemo)
shift
tpudemo=y
;;
--no-tpu-demo|--no-tpudemo)
shift
tpudemo=n
;;
--tpu-sdk|--tpusdk)
shift
tpusdk=y
;;
--no-tpu-sdk|--no-tpusdk)
shift
tpusdk=n
;;
--panel-variants)
shift
panelvariants=y
;;
*)
break
;;
esac
done
for p in / /usr/ /usr/local/ ; do
if echo $PATH | grep -q ${p}bin ; then
if ! echo $PATH | grep -q ${p}sbin ; then
export PATH=${p}sbin:$PATH
fi
fi
done
if echo ${SG_BOARD_LINK} | grep -q -E '^cv180' ; then
export SG_BOARD_FAMILY=cv180x
fi
if echo ${SG_BOARD_LINK} | grep -q -E '^sg200' ; then
export SG_BOARD_FAMILY=sg200x
fi
if [ -e prepare-licheesgnano.sh ]; then
. ./prepare-licheesgnano.sh
fi
cd build
# board config for maixcdk
if [ $maixcdk = y ]; then
if ! grep -q "board" tools/common/sd_tools/genimage_rootless.cfg ; then
sed -i s/'\t\t\t"usb.dev",'/'\t\t\t"usb.dev",\n\t\t\t"board",'/g tools/common/sd_tools/genimage_rootless.cfg
fi
if ! grep -q "board" tools/common/sd_tools/sd_gen_burn_image_rootless.sh ; then
sed -i 's| \${output_dir}/input/usb.dev$| ${output_dir}/input/usb.dev\necho "id=maixcam" > ${output_dir}/input/board\necho "name=MaixCAM" >> ${output_dir}/input/board\necho "panel=st7701_hd228001c31" >> ${output_dir}/input/board|g' tools/common/sd_tools/sd_gen_burn_image_rootless.sh
fi
fi
# set mipi sensor flag
if echo ${SG_BOARD_LINK} | grep -q lichee ; then
sed -i /epsilon/d tools/common/sd_tools/genimage_rootless.cfg
sed -i /epsilon/d tools/common/sd_tools/sd_gen_burn_image_rootless.sh
else
if ! grep -q "epsilon" tools/common/sd_tools/genimage_rootless.cfg ; then
sed -i s/'\t\t\t"usb.dev",'/'\t\t\t"usb.dev",\n\t\t\t"epsilon",'/g tools/common/sd_tools/genimage_rootless.cfg
fi
if ! grep -q "epsilon" tools/common/sd_tools/sd_gen_burn_image_rootless.sh ; then
sed -i 's| \${output_dir}/input/usb.dev$| ${output_dir}/input/usb.dev\ntouch ${output_dir}/input/epsilon|g' tools/common/sd_tools/sd_gen_burn_image_rootless.sh
fi
fi
# reduce sd/wifi frequency
if echo ${SG_BOARD_LINK} | grep -q lichee ; then
sed -i 's|max-frequency = <50000000>;|max-frequency = <25000000>;|g' boards/${SG_BOARD_FAMILY}/${SG_BOARD_LINK}/dts*/*.dts
sed -i /'sd-uhs-ddr50;'/d boards/${SG_BOARD_FAMILY}/${SG_BOARD_LINK}/dts*/*.dts
sed -i /'sd-uhs-sdr104;'/d boards/${SG_BOARD_FAMILY}/${SG_BOARD_LINK}/dts*/*.dts
fi
cd ..
source build/cvisetup.sh
defconfig ${SG_BOARD_LINK}
cd buildroot
if [ $maixcdk = y ]; then
sed -i s/'^BR2_PACKAGE_PARTED=y'/'BR2_PACKAGE_MAIX_CDK=y\nBR2_PACKAGE_PARTED=y'/g configs/${BR_DEFCONFIG}
sed -i s/'^BR2_PACKAGE_PARTED=y'/'BR2_PACKAGE_MAIXCAM_SG200X=y\nBR2_PACKAGE_PARTED=y'/g configs/${BR_DEFCONFIG}
fi
if [ $maixpy = y ]; then
sed -i s/'^BR2_PACKAGE_PARTED=y'/'BR2_PACKAGE_MAIX_PY=y\nBR2_PACKAGE_PARTED=y'/g configs/${BR_DEFCONFIG}
fi
if [ $tailscale = y ]; then
sed -i s/'^BR2_PACKAGE_PARTED=y'/'BR2_PACKAGE_TAILSCALE_RISCV64=y\nBR2_PACKAGE_PARTED=y'/g configs/${BR_DEFCONFIG}
fi
if [ $tpudemo = y ]; then
sed -i s/'^# BR2_PACKAGE_TPUDEMO_SG200X is not set'/'BR2_PACKAGE_TPUDEMO_SG200X=y'/g configs/${BR_DEFCONFIG}
elif [ $tpudemo = n ]; then
sed -i s/'^BR2_PACKAGE_TPUDEMO_SG200X=y'/'# BR2_PACKAGE_TPUDEMO_SG200X is not set'/g configs/${BR_DEFCONFIG}
fi
if [ $tpusdk = y ]; then
sed -i s/'^# BR2_PACKAGE_SOPHGO_LIBRARY is not set'/'BR2_PACKAGE_SOPHGO_LIBRARY=y'/g configs/${BR_DEFCONFIG}
elif [ $tpusdk = n ]; then
sed -i s/'^BR2_PACKAGE_SOPHGO_LIBRARY=y'/'# BR2_PACKAGE_SOPHGO_LIBRARY is not set'/g configs/${BR_DEFCONFIG}
fi
if [ $qt5 = n ]; then
sed -i /'BR2_PACKAGE_QT5'/d configs/${BR_DEFCONFIG}
fi
cd ..
if [ -e cvi_rtsp ]; then
# fix "fatal error: Can't find suitable multilib set"
sed -i s/'-march=rv64imafdcvxthead -mcmodel=medany -mabi=lp64dv'/'-march=rv64imafdcv0p7xthead -mcmodel=medany -mabi=lp64d'/g cvi_rtsp/Makefile.inc
fi
if [ -e cviruntime -a -e flatbuffers ]; then
# small fix to keep fork of flatbuffers repository optional
sed -i s/'-Werror=unused-parameter"'/'-Werror=unused-parameter -Wno-class-memaccess"'/g flatbuffers/CMakeLists.txt
[ $tpusdk = y ] && export TPU_REL=1
fi
if [ $osstar = y ]; then
export OSS_TARBALL_REL=1
fi
build_uboot
build_fsbl
# build other variant
mkdir -p install/soc_${SG_BOARD_LINK}/configs
cp -p build/boards/${SG_BOARD_FAMILY}/${SG_BOARD_LINK}/${SG_BOARD_LINK}_defconfig bak.config
cp -v install/soc_${SG_BOARD_LINK}/fip.bin bak.fip
cp -v install/soc_${SG_BOARD_LINK}/fip_spl.bin bak.fip_spl
build_fip_variant() {
panelconfig=`echo $1 | tr a-z A-Z`
panelfip=`echo $1 | tr A-Z a-z | sed s/'^mipi_panel_'/''/g | sed s/'^st7701_'/''/g | sed s/'_60hz$'/''/g`
cat bak.config | sed -e 's/CONFIG_MIPI_PANEL_ZCT2133V1/CONFIG_'${panelconfig}'/g' > build/boards/${SG_BOARD_FAMILY}/${SG_BOARD_LINK}/${SG_BOARD_LINK}_defconfig
grep -E '^CONFIG_MIPI_PANEL_.*=y' build/boards/${SG_BOARD_FAMILY}/${SG_BOARD_LINK}/${SG_BOARD_LINK}_defconfig
defconfig ${SG_BOARD_LINK}
grep -E '^CONFIG_MIPI_PANEL_.*=y' build/.config
clean_uboot
clean_opensbi
clean_fsbl
build_fsbl
cp -v install/soc_${SG_BOARD_LINK}/fip.bin install/soc_${SG_BOARD_LINK}/${panelfip}.bin
cp -p build/.config install/soc_${SG_BOARD_LINK}/configs/${panelfip}-build-config
}
grep -E '^CONFIG_MIPI_PANEL_.*=y' build/boards/${SG_BOARD_FAMILY}/${SG_BOARD_LINK}/${SG_BOARD_LINK}_defconfig || true
if ! grep -q -E 'CONFIG_MIPI_PANEL_ZCT2133V1=y' bak.config ; then
if grep -q -E '^CONFIG_MIPI_PANEL_.*=y' bak.config ; then
sed -i s/'^CONFIG_MIPI_PANEL_.*=y'/'CONFIG_MIPI_PANEL_ZCT2133V1=y'/g bak.config
else
echo 'CONFIG_MIPI_PANEL_ZCT2133V1=y' >> bak.config
fi
build_fip_variant MIPI_PANEL_ZCT2133V1
fi
cp -v install/soc_${SG_BOARD_LINK}/fip.bin install/soc_${SG_BOARD_LINK}/zct2133v1.bin
if [ $panelvariants = y ]; then
# 7inch
build_fip_variant MIPI_PANEL_MTD700920B
# 2.8inch
build_fip_variant MIPI_PANEL_ST7701_HD228001C31
# 2.8inch alt0
build_fip_variant MIPI_PANEL_ST7701_HD228001C31_ALT0
# 2.28 inch lhcm
build_fip_variant MIPI_PANEL_ST7701_LHCM228TS003A
# 3inch
build_fip_variant MIPI_PANEL_ST7701_D300FPC9307A
# 3.1inch
build_fip_variant MIPI_PANEL_ST7701_D310T9362V1
# 5inch
build_fip_variant MIPI_PANEL_ST7701_DXQ5D0019B480854
# 5inch new
build_fip_variant MIPI_PANEL_ST7701_DXQ5D0019_V0
# 2.4inch
build_fip_variant MIPI_PANEL_D240SI31
# dsi to hdmi
build_fip_variant MIPI_PANEL_LT9611_1024X768_60HZ
# dsi to hdmi
build_fip_variant MIPI_PANEL_LT9611_1280X720_60HZ
if echo ${SG_BOARD_LINK} | grep -q milkv_duos ; then
# 8inch
build_fip_variant MIPI_PANEL_MILKV_8HD
# 8inch 2lane
build_fip_variant MIPI_PANEL_MILKV_8HD_2LANE
# 4inch
build_fip_variant MIPI_PANEL_MILKV_ST7796S
fi
fi
mv bak.config build/boards/${SG_BOARD_FAMILY}/${SG_BOARD_LINK}/${SG_BOARD_LINK}_defconfig
mv bak.fip install/soc_${SG_BOARD_LINK}/fip.bin
mv bak.fip_spl install/soc_${SG_BOARD_LINK}/fip_spl.bin
build_all
cd build
git restore boards/${SG_BOARD_FAMILY}/${SG_BOARD_LINK}/${SG_BOARD_LINK}_defconfig
git restore tools/common/sd_tools/genimage_rootless.cfg
git restore tools/common/sd_tools/sd_gen_burn_image_rootless.sh
cd ..
installdir=`pwd`/install/soc_${SG_BOARD_LINK}
cd buildroot
cd ${BR_OUTPUT_DIR}/target
if [ -e maixapp/apps/app.info ]; then
rm -f ${installdir}/maixcam-latest.zip
zip -r --symlinks ${installdir}/maixcam-latest.zip \
maixapp/* \
usr/lib/python3*/*-packages/maix* \
usr/lib/python3*/*-packages/Maix*
fi
cd -
git restore configs/${BR_DEFCONFIG}
cd ..
echo OK