-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetenv.sh
More file actions
executable file
·380 lines (362 loc) · 16.1 KB
/
Copy pathsetenv.sh
File metadata and controls
executable file
·380 lines (362 loc) · 16.1 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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
#!/bin/bash
export WORK_DIR=`pwd`
export PATH="/opt/riscv/bin:$PATH"
export ARCH=riscv
export CROSS_COMPILE=riscv64-unknown-linux-gnu-
export RELEASE_TAG=EIC7X-2025.02
function make_bootchain()
{
echo "start compile bootchain"
echo "ddr name:$ddr_name"
echo "dt name:$dt_name"
mkdir -p ${WORK_DIR}/$board_name
rm -rf ${WORK_DIR}/$board_name/uboot-eswin${FEATURE}
rm -rf ${WORK_DIR}/$board_name/opensbi-eswin${FEATURE}
rm -rf ${WORK_DIR}/$board_name/firmware-eswin${FEATURE}
if [ ! -d $WORK_DIR/source/uboot-eswin${FEATURE} ] || [ -z "$(find $WORK_DIR/source/uboot-eswin${FEATURE} -type f)" ]; then
if [ -z "$release_tag" ]; then
git clone https://github.com/DC-DeepComputing/fml13v03_u-boot.git $WORK_DIR/source/uboot-eswin${FEATURE}
else
git clone -b ${RELEASE_TAG} https://github.com/DC-DeepComputing/fml13v03_u-boot.git $WORK_DIR/source/uboot-eswin${FEATURE}
fi
fi
rsync -au --chmod=u=rwX,go=rX --exclude .git --exclude .hg --exclude .bzr --exclude CVS $WORK_DIR/source/uboot-eswin${FEATURE} ${WORK_DIR}/${board_name}/
if [ ! -d $WORK_DIR/source/opensbi-eswin${FEATURE} ] || [ -z "$(find $WORK_DIR/source/opensbi-eswin${FEATURE} -type f)" ]; then
if [ -z "$release_tag" ]; then
git clone https://github.com/DC-DeepComputing/fml13v03_opensbi.git $WORK_DIR/source/opensbi-eswin${FEATURE}
else
git clone -b ${RELEASE_TAG} https://github.com/DC-DeepComputing/fml13v03_opensbi.git $WORK_DIR/source/opensbi-eswin${FEATURE}
fi
fi
rsync -au --chmod=u=rwX,go=rX --exclude .git --exclude .hg --exclude .bzr --exclude CVS $WORK_DIR/source/opensbi-eswin${FEATURE} ${WORK_DIR}/${board_name}/
rsync -au --chmod=u=rwX,go=rX --exclude .git --exclude .hg --exclude .bzr --exclude CVS $WORK_DIR/source/firmware-eswin ${WORK_DIR}/${board_name}/
#uboot
cd ${WORK_DIR}/${board_name}/uboot-eswin${FEATURE}/
make ${uboot_config}
sed -i "s#\(CONFIG_DEFAULT_FDT_FILE=\)\"[^\"]*\"#\1\"eswin/${dt_name}.dtb\"#" .config
make -j$(nproc)
mkdir -p ${WORK_DIR}/${board_name}/output/
cp -av u-boot.bin ${WORK_DIR}/${board_name}/output/
cp -av u-boot.dtb ${WORK_DIR}/${board_name}/output/
#opensbi
cd ${WORK_DIR}/${board_name}/opensbi-eswin${FEATURE}
chiplet=BR2_CHIPLET_1
chiplet_die=BR2_CHIPLET_1_DIE0_AVAILABLE
mem_mode=BR2_MEMMODE_FLAT
if [[ "$board_name" =~ "EIC7702-E-L5G5" ]];then
chiplet=BR2_CHIPLET_2
chiplet_die=BR2_CHIPLET_1_DIE1_AVAILABLE
fi
if [[ "$board_name" =~ "INTER" ]];then
mem_mode=BR2_MEMMODE_INTERLEAVE
fi
if [[ "$board_name" =~ "FML13V03" ]];then
chiplet=BR2_CHIPLET_2
chiplet_die=BR2_CHIPLET_1_DIE1_AVAILABLE
fi
make PLATFORM=eswin/eic770x FW_PAYLOAD=y \
FW_FDT_PATH=${WORK_DIR}/${board_name}/output/u-boot.dtb \
FW_PAYLOAD_PATH=${WORK_DIR}/${board_name}/output/u-boot.bin \
CHIPLET="${chiplet}" \
CHIPLET_DIE_AVAILABLE="${chiplet_die}" \
MEM_MODE="${mem_mode}" \
PLATFORM_CLUSTER_X_CORE="BR2_CLUSTER_4_CORE" \
-j $(nproc)
cp -v build/platform/eswin/eic770x/firmware/fw_payload.bin ../output/fw_payload.bin
if [ "$board_name" == "EIC7702-E-L5G5_INTER" ];then
rm -rf ${WORK_DIR}/$board_name/inter-eswin
rsync -au --chmod=u=rwX,go=rX --exclude .git --exclude .hg --exclude .bzr --exclude CVS $WORK_DIR/source/inter-eswin ${WORK_DIR}/${board_name}/
sed -i "1s#.*# RISCV_GCC_PREFIX=/opt/riscv-elf/bin/riscv64-unknown-elf-#" ${WORK_DIR}/${board_name}/inter-eswin/Makefile
sed -i 's/-march=rv64imafd_zifencei//g' ${WORK_DIR}/${board_name}/inter-eswin/Makefile
sed -i "s#../build/opensbi#opensbi-eswin${FEATURE}#g" ${WORK_DIR}/${board_name}/inter-eswin/Makefile
sed -i "s#../images#output#g" ${WORK_DIR}/${board_name}/inter-eswin/Makefile
cd ${WORK_DIR}/${board_name}/inter-eswin
make
cp -v build/*.bin ${WORK_DIR}/${board_name}/output/
fi
#nsign
cd ${WORK_DIR}/${board_name}/firmware-eswin
if [ "$board_name" == "EIC7702-E-L5G5" ] || [ "$board_name" == "FML13V03" ]; then
sed -i "s|out=.*|out=${WORK_DIR}/${board_name}/output/bootloader_${board_name}_die0.bin|" bootchain_die0.config
sed -i "s|out=.*|out=${WORK_DIR}/${board_name}/output/bootloader_${board_name}_die1.bin|" bootchain_die1.config
secboot_line=`cat -n bootchain_die0.config | grep in= | awk -F " " 'NR==1{print$1}'`
ddr_line=`cat -n bootchain_die0.config | grep in= | awk -F " " 'NR==2{print$1}'`
d2d_die0_line=`cat -n bootchain_die0.config | grep in= | awk -F " " 'NR==3{print$1}'`
d2d_die1_line=`cat -n bootchain_die1.config | grep in= | awk -F " " 'NR==3{print$1}'`
uboot_line=`cat -n bootchain_die0.config | grep in= | awk -F " " 'NR==4{print$1}'`
#die0
sed -i "${secboot_line}s#.*# in=${WORK_DIR}/${board_name}/firmware-eswin/die0_sec_fw.bin#" bootchain_die0.config
sed -i "${ddr_line}s#.*# in=${WORK_DIR}/${board_name}/firmware-eswin/${ddr_name}#" bootchain_die0.config
sed -i "${d2d_die0_line}s#.*# in=${WORK_DIR}/${board_name}/firmware-eswin/die0_d2d_init.bin#" bootchain_die0.config
sed -i "${uboot_line}s#.*# in=${WORK_DIR}/${board_name}/output/fw_payload.bin#" bootchain_die0.config
#die1
sed -i "${secboot_line}s#.*# in=${WORK_DIR}/${board_name}/firmware-eswin/die1_sec_fw.bin#" bootchain_die1.config
sed -i "${ddr_line}s#.*# in=${WORK_DIR}/${board_name}/firmware-eswin/${ddr_name}#" bootchain_die1.config
sed -i "${d2d_die1_line}s#.*# in=${WORK_DIR}/${board_name}/firmware-eswin/die1_d2d_init.bin#" bootchain_die1.config
./nsign bootchain_die0.config
./nsign bootchain_die1.config
elif [ "$board_name" == "EIC7702-E-L5G5_INTER" ];then
#interleave
sed -i "s|out=.*|out=${WORK_DIR}/${board_name}/output/bootloader_${board_name}_inter.bin|" bootchain_interleave.config
ddr_line=`cat -n bootchain_interleave.config | grep in= | awk -F " " 'NR==1{print$1}'`
d2d_die0_line=`cat -n bootchain_interleave.config | grep in= | awk -F " " 'NR==2{print$1}'`
uboot_line=`cat -n bootchain_interleave.config | grep in= | awk -F " " 'NR==3{print$1}'`
sed -i "${ddr_line}s#.*# in=${WORK_DIR}/${board_name}/firmware-eswin/${ddr_name}#" bootchain_interleave.config
sed -i "${d2d_die0_line}s#.*# in=${WORK_DIR}/${board_name}/firmware-eswin/d2d.bin#" bootchain_interleave.config
sed -i "${uboot_line}s#.*# in=${WORK_DIR}/${board_name}/output/load_interleave.bin#" bootchain_interleave.config
#die1
sed -i "s|out=.*|out=${WORK_DIR}/${board_name}/output/bootloader_${board_name}_die1.bin|" bootchain_die1.config
ddr_line=`cat -n bootchain_die1.config | grep in= | awk -F " " 'NR==2{print$1}'`
d2d_die1_line=`cat -n bootchain_die1.config | grep in= | awk -F " " 'NR==3{print$1}'`
secboot_line=`cat -n bootchain_die1.config | grep in= | awk -F " " 'NR==1{print$1}'`
sed -i "${secboot_line}s#.*# in=${WORK_DIR}/${board_name}/firmware-eswin/die1_sec_fw.bin#" bootchain_die1.config
sed -i "${ddr_line}s#.*# in=${WORK_DIR}/${board_name}/firmware-eswin/${ddr_name}#" bootchain_die1.config
sed -i "${d2d_die1_line}s#.*# in=${WORK_DIR}/${board_name}/firmware-eswin/d2d.bin#" bootchain_die1.config
./nsign bootchain_interleave.config
./nsign bootchain_die1.config
else
sed -i "s|out=.*|out=${WORK_DIR}/${board_name}/output/bootloader_${board_name}.bin|" bootchain.config
secboot_line=`cat -n bootchain.config | grep in= | awk -F " " 'NR==1{print$1}'`
ddr_line=`cat -n bootchain.config | grep in= | awk -F " " 'NR==2{print$1}'`
uboot_line=`cat -n bootchain.config | grep in= | awk -F " " 'NR==3{print$1}'`
sed -i "${secboot_line}s#.*# in=${WORK_DIR}/${board_name}/firmware-eswin/die0_sec_fw.bin#" bootchain.config
sed -i "${ddr_line}s#.*# in=${WORK_DIR}/${board_name}/firmware-eswin/${ddr_name}#" bootchain.config
sed -i "${uboot_line}s#.*# in=${WORK_DIR}/${board_name}/output/fw_payload.bin#" bootchain.config
./nsign bootchain.config
fi
cd ${WORK_DIR}/${board_name}/output
ls -l
}
function make_minimal_images()
{
if [ ! -f ${WORK_DIR}/${board_name}/output/linux-image-*.deb ];then
make_kernel
fi
echo "start compile debian_mkimg"
desktop_image=$1
mkdir -p ${WORK_DIR}/$board_name;rm -rf ${WORK_DIR}/$board_name/mkimg-eswin
if [ -d $WORK_DIR/source/mkimg-eswin ];then
rsync -au --chmod=u=rwX,go=rX --exclude .git --exclude .hg --exclude .bzr --exclude CVS $WORK_DIR/source/mkimg-eswin ${WORK_DIR}/${board_name}/
else
tar -xf $WORK_DIR/source/mkimg-eswin.tar.gz -C ${WORK_DIR}/${board_name}
fi
cd ${WORK_DIR}/$board_name/mkimg-eswin
chmod +x *.sh
if [ "$board_name" == "EIC7702-E-L5G5_INTER" ];then
sed -i 's/UUID=\$/PARTUUID=\$/' *.sh
fi
if [ ! -z ${desktop_image} ];then
sudo ./mkrootfs.sh ${board_name} ${RELEASE_TAG}
else
sudo ./mkrootfs_minimal.sh ${board_name} ${RELEASE_TAG}
fi
mkdir -p ${WORK_DIR}/${board_name}/output/
mv *.ext4 ${WORK_DIR}/${board_name}/output/
cd ${WORK_DIR}/${board_name}/output
ls -l
}
function make_desktop_images()
{
make_minimal_images "desktop"
}
function make_kernel()
{
echo "start compile kernel"
mkdir -p ${WORK_DIR}/$board_name
if [ ! -d $WORK_DIR/source/linux-eswin${FEATURE} ] || [ -z "$(find $WORK_DIR/source/linux-eswin${FEATURE} -type f)" ]; then
if [ -z "$release_tag" ]; then
git clone --depth 1 https://github.com/DC-DeepComputing/fml13v03_linux.git $WORK_DIR/source/linux-eswin${FEATURE}
else
git clone -b ${RELEASE_TAG} https://github.com/DC-DeepComputing/fml13v03_linux.git $WORK_DIR/source/linux-eswin${FEATURE}
fi
fi
rsync -au --chmod=u=rwX,go=rX --exclude .git --exclude .hg --exclude .bzr --exclude CVS $WORK_DIR/source/linux-eswin${FEATURE} ${WORK_DIR}/${board_name}/
cd ${WORK_DIR}/${board_name}/linux-eswin${FEATURE}
export KDEB_PKGVERSION="$(make kernelversion)-$(date "+%Y.%m.%d.%H.%M")+"
if [[ "$board_name" =~ "EIC7702-E-L5G5" ]];then
if [ ! -z $1 ];then
linux_defconfig=eic7702_dbg_defconfig
echo "EIC7702-E-L5G5 does not support compiling debug kernel at this time!"
exit 0
else
linux_defconfig=eic7702_defconfig
fi
elif [[ "$board_name" =~ "FML13V03" ]]; then
if [ ! -z $1 ];then
linux_defconfig=fml13v03_dbg_defconfig
echo "FML13V03 does not support compiling debug kernel at this time!"
exit 0
else
linux_defconfig=fml13v03_defconfig
fi
else
if [ ! -z $1 ];then
linux_defconfig=eic7700_dbg_defconfig
else
linux_defconfig=eic7700_defconfig
fi
fi
blk_dev_initrd=`cat ${WORK_DIR}/${board_name}/linux-eswin${FEATURE}/arch/riscv/configs/$linux_defconfig | grep 'CONFIG_BLK_DEV_INITRD=y'`
if [ "$blk_dev_initrd" == "" ];then
echo CONFIG_BLK_DEV_INITRD=y >>${WORK_DIR}/${board_name}/linux-eswin${FEATURE}/arch/riscv/configs/$linux_defconfig
fi
kernel_ver1=`cat ${WORK_DIR}/${board_name}/linux-eswin${FEATURE}/arch/riscv/configs/$linux_defconfig | grep CONFIG_LOCALVERSION= |cut -d "=" -f 2|xargs`
if [ -z $kernel_ver1 ];then
kernel_ver1="-eic7x"
fi
kernel_ver2=`echo $RELEASE_TAG | cut -d "-" -f 2| tr "A-Z" "a-z"`
kernel_ver=${kernel_ver1}-${kernel_ver2}
sed -i "/CONFIG_LOCALVERSION/d" ${WORK_DIR}/${board_name}/linux-eswin${FEATURE}/arch/riscv/configs/$linux_defconfig
make $linux_defconfig
make -j$(nproc) bindeb-pkg LOCALVERSION="$kernel_ver"
mkdir -p ${WORK_DIR}/${board_name}/output/
rm -rf ${WORK_DIR}/${board_name}/output/linux*.deb
mv -v ../*.deb ${WORK_DIR}/${board_name}/output/
cd ${WORK_DIR}/${board_name}/output
ls -l
}
function make_debug_kernel()
{
make_kernel "debug"
}
function make_secboot_fw()
{
if [ ! -d $WORK_DIR/toolchains/riscv/ ]; then
echo "Toolchain not found. Downloading..."
wget http://120.92.155.32:8082/artifactory/riscv/ESWIN/riscv64-gcc-2025.01.20.tar.xz || {
echo "Download failed!"
exit 1
}
mkdir -p "$WORK_DIR/toolchains"
tar -xvf riscv64-gcc-2025.01.20.tar.xz -C toolchains/
rm riscv64-gcc-2025.01.20.tar.xz
fi
cd ${WORK_DIR}/source/secboot_fw
make clean
make
cd ${WORK_DIR}/
}
function make_all()
{
echo "start make all"
make_bootchain
make_kernel
make_minimal_images
}
function make_os_images()
{
cd ${WORK_DIR}/deepcomputing
chmod +x *.sh
source ./make_os_image.sh
mv *.img ${WORK_DIR}/${board_name}/output/
cd ${WORK_DIR}/${board_name}/output
ls -l
}
function make_usbupdate_images()
{
cd ${WORK_DIR}/deepcomputing/mkupdatepkg
chmod +x *.sh
source ./make_updateimg.sh
mv *.img ${WORK_DIR}/${board_name}/output/
cd ${WORK_DIR}/${board_name}/output
ls -l
}
function make_recovery_bootloader()
{
cd ${WORK_DIR}/deepcomputing/pack_recovery/
chmod +x ${WORK_DIR}/deepcomputing/pack_recovery/pack_recovery.sh
cp ${WORK_DIR}/${board_name}/firmware-eswin/die*_sec_fw.bin ./
cp ${WORK_DIR}/${board_name}/firmware-eswin/ddr_fw.bin ./
${WORK_DIR}/deepcomputing/pack_recovery/pack_recovery.sh ${WORK_DIR}/${board_name}/output/bootloader_FML13V03_die0.bin ${WORK_DIR}/${board_name}/output/bootloader_FML13V03_die1.bin
mv recovery_*.bin ${WORK_DIR}/${board_name}/output/
cd ${WORK_DIR}/${board_name}/output
ls -l
}
print_comple_method()
{
echo "you chose $board_name"
echo "Use the following method to start compiling:"
echo " make_bootchain"
echo " make_kernel"
#if [ "$board_name" != "EIC7702-E-L5G5" ];then
echo " make_debug_kernel"
echo " make_desktop_images"
#fi
echo " make_minimal_images"
echo " make_all:bootchain kernel minimal_images"
}
#menu
echo "board list:"
echo [1] EIC7700FG-LP4/X-A1'(EIC7700FG-LP5-A1)'
echo [2] EIC7700FG-EVB-LP5-A2
echo [3] EIC7700-E-L5G4
echo [4] EIC7702-E-L5G5
echo [5] P550
echo [6] EIC7700-02-1154B1
echo [7] Z530
echo [8] SBC-A1
echo [9] FML13V03
echo [0] Exit
read -p "please select[0-9]:" -n 1 CHOICE
echo
export ddr_name=ddr_fw.bin
export FEATURE=
while [ 0 -eq 0 ];
do
if [ "$CHOICE" == "1" ];then
export board_name=EIC7700FG-LP5-A1
export dt_name=eic7700-evb
export uboot_config=eic7700_evb_defconfig
break
elif [ "$CHOICE" == "2" ];then
export board_name=EIC7700FG-EVB-LP5-A2
export dt_name=eic7700-evb-a2
export uboot_config=eic7700_evb_defconfig
break
elif [ "$CHOICE" == "3" ];then
export board_name=EIC7700-E-L5G4
export dt_name=eic7700-evb-a3
export uboot_config=eic7700_evb_a3_defconfig
break
elif [ "$CHOICE" == "4" ];then
export board_name=EIC7702-E-L5G5
export dt_name=eic7702-evb-a1
export uboot_config=eic7702_evb_a1_defconfig
#export RELEASE_TAG=EIC702-2024.11
#export FEATURE=-eic7702
break
elif [ "$CHOICE" == "5" ];then
export board_name=P550
export dt_name=eic7700-hifive-premier-p550
export uboot_config=hifive_premier_p550_defconfig
break
elif [ "$CHOICE" == "6" ];then
export board_name=EIC7700-02-1154B1
export dt_name=eic7700-d314
export uboot_config=eic7700_d314_defconfig
break
elif [ "$CHOICE" == "7" ];then
export board_name=Z530
export dt_name=eic7700-z530
export uboot_config=eic7700_z530_defconfig
break
elif [ "$CHOICE" == "8" ];then
export board_name=SBC-A1
export dt_name=eic7700-sbc
export uboot_config=eic7700_sbc_defconfig
break
elif [ "$CHOICE" == "9" ];then
export board_name=FML13V03
export dt_name=eic7702-deepcomputing-fml13v03
export uboot_config=deepcomputing-fml13v03_defconfig
break
elif [ "$CHOICE" == "0" ];then
echo "Exiting..."
break
else
echo "Invalid option"
read -p "please select[0-9]:" -n 1 CHOICE
echo
fi
done
print_comple_method