forked from sipeed/LicheeRV-Nano-Build
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild-licheervnano.sh
executable file
·152 lines (134 loc) · 4.05 KB
/
build-licheervnano.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
#!/bin/bash -e
export SG_BOARD_FAMILY=sg200x
export SG_BOARD_LINK=sg2002_licheervnano_sd
maixcdk=n
tailscale=n
tpudemo=c
tpusdk=y
while [ "$#" -gt 0 ]; do
case "$1" in
--board=*|--board-link=*)
export SG_BOARD_LINK=`echo $1 | cut -d '=' -f 2-`
shift
;;
--maix-cdk|--maixcdk)
shift
maixcdk=y
;;
--no-maix-cdk|--no-maixcdk)
shift
maixcdk=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
;;
*)
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
bash -e 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 "panel=st7701_hd228001c31" >> ${output_dir}/input/board|g' tools/common/sd_tools/sd_gen_burn_image_rootless.sh
fi
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}
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
cd ..
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
build_all
# build other variant
cp -p build/boards/${SG_BOARD_FAMILY}/${SG_BOARD_LINK}/${SG_BOARD_LINK}_defconfig bak.config
# 2.8inch
cat bak.config | sed -e 's/CONFIG_MIPI_PANEL_ZCT2133V1/CONFIG_MIPI_PANEL_ST7701_HD228001C31/g' > build/boards/${SG_BOARD_FAMILY}/${SG_BOARD_LINK}/${SG_BOARD_LINK}_defconfig
defconfig ${SG_BOARD_LINK}
clean_uboot
clean_opensbi
clean_fsbl
build_fsbl
cp -v install/soc_${SG_BOARD_LINK}/fip.bin install/soc_${SG_BOARD_LINK}/hd228001c31.bin
# 3inch
cat bak.config | sed -e 's/CONFIG_MIPI_PANEL_ZCT2133V1/CONFIG_MIPI_PANEL_ST7701_D300FPC9307A/g' > build/boards/${SG_BOARD_FAMILY}/${SG_BOARD_LINK}/${SG_BOARD_LINK}_defconfig
defconfig ${SG_BOARD_LINK}
clean_uboot
clean_opensbi
clean_fsbl
build_fsbl
cp -v install/soc_${SG_BOARD_LINK}/fip.bin install/soc_${SG_BOARD_LINK}/d300fpc9307a.bin
# 5inch
cat bak.config | sed -e 's/CONFIG_MIPI_PANEL_ZCT2133V1/CONFIG_MIPI_PANEL_ST7701_DXQ5D0019B480854/g' > build/boards/${SG_BOARD_FAMILY}/${SG_BOARD_LINK}/${SG_BOARD_LINK}_defconfig
defconfig ${SG_BOARD_LINK}
clean_uboot
clean_opensbi
clean_fsbl
build_fsbl
cp -v install/soc_${SG_BOARD_LINK}/fip.bin install/soc_${SG_BOARD_LINK}/dxq5d0019b480854.bin
mv bak.config build/boards/${SG_BOARD_FAMILY}/${SG_BOARD_LINK}/${SG_BOARD_LINK}_defconfig
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 ..
cd buildroot
git restore configs/${BR_DEFCONFIG}
cd ..
echo OK