forked from BPI-SINOVOIP/BPI-R2-bsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·130 lines (117 loc) · 2.88 KB
/
build.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
#!/bin/bash
# (c) 2015, 2016, Leo Xu <otakunekop@banana-pi.org.cn>
# Build script for BPI-M2U-BSP 2016.09.10
TARGET_PRODUCT="bpi-r2"
BOARD=BPI-R2-720P
board="bpi-r2"
kernel="4.4.70-BPI-R2-Kernel"
MODE=$1
BPILINUX=linux-mt
BPIPACK=mt-pack
BPISOC=mtk
RET=0
cp_download_files()
{
T="$TOPDIR"
SD="$T/SD"
U="${SD}/100MB"
B="${SD}/BPI-BOOT"
R="${SD}/BPI-ROOT"
#
## clean SD dir.
#
rm -rf $SD
#
## create SD dirs (100MB, BPI-BOOT, BPI-ROOT)
#
mkdir -p $SD
mkdir -p $U
mkdir -p $B
mkdir -p $R
#
## copy files to 100MB
#
cp -a $T/out/${TARGET_PRODUCT}/100MB/* $U
#
## copy files to BPI-BOOT
#
mkdir -p $B/bananapi/${board}
cp -a $T/${BPIPACK}/${BPISOC}/${TARGET_PRODUCT}/configs/default/linux $B/bananapi/${board}/
cp -a $T/${BPILINUX}/arch/arm/boot/uImage $B/bananapi/${board}/linux/uImage
#
## copy files to BPI-ROOT
#
mkdir -p $R/usr/lib/u-boot/bananapi/${board}
cp -a $U/*.gz $R/usr/lib/u-boot/bananapi/${board}/
rm -rf $R/lib/modules
mkdir -p $R/lib/modules
cp -a $T/${BPILINUX}/output/lib/modules/${kernel} $R/lib/modules
#
## create files for bpi-tools & bpi-migrate
#
(cd $B ; tar czvf $SD/BPI-BOOT-${board}.tgz .)
(cd $R ; tar czvf $SD/${kernel}-net.tgz lib/modules/${kernel}/kernel/net)
(cd $R ; mv lib/modules/${kernel}/kernel/net $R/net)
(cd $R ; tar czvf $SD/${kernel}.tgz lib/modules)
(cd $R ; mv $R/net lib/modules/${kernel}/kernel/net)
(cd $R ; tar czvf $SD/BOOTLOADER-${board}.tgz usr/lib/u-boot/bananapi)
return #SKIP
}
list_boards() {
cat <<-EOT
NOTICE:
new build.sh default select $BOARD and pack all boards
supported boards:
EOT
(cd ${BPIPACK}/${BPISOC}/${TARGET_PRODUCT}/configs ; ls -1d BPI* )
echo
}
list_boards
./configure $BOARD
if [ -f env.sh ] ; then
. env.sh
fi
echo "This tool support following building mode(s):"
echo "--------------------------------------------------------------------------------"
echo " 1. Build all, uboot and kernel and pack to download images."
echo " 2. Build uboot only."
echo " 3. Build kernel only."
echo " 4. kernel configure."
echo " 5. Pack the builds to target download image, this step must execute after u-boot,"
echo " kernel and rootfs build out"
echo " 6. update files for SD"
echo " 7. Clean all build."
echo "--------------------------------------------------------------------------------"
if [ -z "$MODE" ]; then
read -p "Please choose a mode(1-7): " mode
echo
else
mode=1
fi
if [ -z "$mode" ]; then
echo -e "\033[31m No build mode choose, using Build all default \033[0m"
mode=1
fi
echo -e "\033[31m Now building...\033[0m"
echo
case $mode in
1) RET=1;make &&
make pack &&
cp_download_files &&
RET=0
;;
2) make u-boot;;
3) make kernel;;
4) make kernel-config;;
5) make pack;;
6) cp_download_files;;
7) make clean;;
esac
echo
if [ "$RET" -eq "0" ];
then
echo -e "\033[32m Build success!\033[0m"
else
echo -e "\033[31m Build failed!\033[0m"
fi
echo