forked from woosa-lk/Ai-Speaker-Linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·252 lines (232 loc) · 6.71 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
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
#!/bin/bash
COMMON_DIR=$(cd `dirname $0`; pwd)
if [ -h $0 ]
then
CMD=$(readlink $0)
COMMON_DIR=$(dirname $CMD)
fi
cd $COMMON_DIR
cd ../../..
TOP_DIR=$(pwd)
COMMON_DIR=$TOP_DIR/device/rockchip/common
BOARD_CONFIG=$TOP_DIR/device/rockchip/.BoardConfig.mk
source $BOARD_CONFIG
if [ ! -n "$1" ];then
echo "build all and save all as default"
BUILD_TARGET=allsave
else
BUILD_TARGET="$1"
NEW_BOARD_CONFIG=$TOP_DIR/device/rockchip/$RK_TARGET_PRODUCT/$1
fi
usage()
{
echo "====USAGE: build.sh modules===="
echo "uboot -build uboot"
echo "kernel -build kernel"
echo "rootfs -build default rootfs, currently build buildroot as default"
echo "buildroot -build buildroot rootfs"
echo "pcba -build pcba"
echo "recovery -build recovery"
echo "all -build uboot, kernel, rootfs, recovery image"
echo "cleanall -clean uboot, kernel, rootfs, recovery"
echo "firmware -pack all the image we need to boot up system"
echo "updateimg -pack update image"
echo "save -save images, patches, commands used to debug"
echo "default -build all modules"
}
function build_uboot(){
# build uboot
echo "============Start build uboot============"
echo "TARGET_UBOOT_CONFIG=$RK_UBOOT_DEFCONFIG"
echo "========================================="
if [ -f u-boot/*_loader_*.bin ]; then
rm u-boot/*_loader_*.bin
fi
cd u-boot && ./make.sh $RK_UBOOT_DEFCONFIG && cd -
if [ $? -eq 0 ]; then
echo "====Build uboot ok!===="
else
echo "====Build uboot failed!===="
exit 1
fi
}
function build_kernel(){
# build kernel
echo "============Start build kernel============"
echo "TARGET_ARCH =$RK_ARCH"
echo "TARGET_KERNEL_CONFIG =$RK_KERNEL_DEFCONFIG"
echo "TARGET_KERNEL_DTS =$RK_KERNEL_DTS"
echo "=========================================="
cd $TOP_DIR/kernel && make ARCH=$RK_ARCH $RK_KERNEL_DEFCONFIG && make ARCH=$RK_ARCH $RK_KERNEL_DTS.img -j$RK_JOBS && cd -
if [ $? -eq 0 ]; then
echo "====Build kernel ok!===="
else
echo "====Build kernel failed!===="
exit 1
fi
}
function build_buildroot(){
# build buildroot
echo "==========Start build buildroot=========="
echo "TARGET_BUILDROOT_CONFIG=$RK_CFG_BUILDROOT"
echo "========================================="
/usr/bin/time -f "you take %E to build builroot" $COMMON_DIR/mk-buildroot.sh $BOARD_CONFIG
if [ $? -eq 0 ]; then
echo "====Build buildroot ok!===="
else
echo "====Build buildroot failed!===="
exit 1
fi
}
function build_rootfs(){
build_buildroot
}
function build_recovery(){
# build recovery
echo "==========Start build recovery=========="
echo "TARGET_RECOVERY_CONFIG=$RK_CFG_RECOVERY"
echo "========================================"
/usr/bin/time -f "you take %E to build recovery" $COMMON_DIR/mk-recovery.sh $BOARD_CONFIG
if [ $? -eq 0 ]; then
echo "====Build recovery ok!===="
else
echo "====Build recovery failed!===="
exit 1
fi
}
function build_pcba(){
# build pcba
echo "==========Start build pcba=========="
echo "TARGET_PCBA_CONFIG=$RK_CFG_PCBA"
echo "===================================="
/usr/bin/time -f "you take %E to build pcba" $COMMON_DIR/mk-pcba.sh $BOARD_CONFIG
if [ $? -eq 0 ]; then
echo "====Build pcba ok!===="
else
echo "====Build pcba failed!===="
exit 1
fi
}
function build_all(){
echo "============================================"
echo "TARGET_ARCH=$RK_ARCH"
echo "TARGET_PLATFORM=$RK_TARGET_PRODUCT"
echo "TARGET_UBOOT_CONFIG=$RK_UBOOT_DEFCONFIG"
echo "TARGET_KERNEL_CONFIG=$RK_KERNEL_DEFCONFIG"
echo "TARGET_KERNEL_DTS=$RK_KERNEL_DTS"
echo "TARGET_BUILDROOT_CONFIG=$RK_CFG_BUILDROOT"
echo "TARGET_RECOVERY_CONFIG=$RK_CFG_RECOVERY"
echo "TARGET_PCBA_CONFIG=$RK_CFG_PCBA"
echo "============================================"
build_uboot
build_kernel
build_rootfs
build_recovery
}
function clean_all(){
echo "clean uboot, kernel, rootfs, recovery"
cd $TOP_DIR/u-boot/ && make distclean && cd -
cd $TOP_DIR/kernel && make distclean && cd -
rm -rf buildroot/out
}
function build_firmware(){
# mkfirmware.sh to genarate image
./mkfirmware.sh $BOARD_CONFIG
if [ $? -eq 0 ]; then
echo "Make image ok!"
else
echo "Make image failed!"
exit 1
fi
}
function build_updateimg(){
IMAGE_PATH=$TOP_DIR/rockdev
PACK_TOOL_DIR=$TOP_DIR/tools/linux/Linux_Pack_Firmware
echo "Make update.img"
cd $PACK_TOOL_DIR/rockdev && ./mkupdate.sh && cd -
mv $PACK_TOOL_DIR/rockdev/update.img $IMAGE_PATH
if [ $? -eq 0 ]; then
echo "Make update image ok!"
else
echo "Make update image failed!"
exit 1
fi
}
function build_save(){
IMAGE_PATH=$TOP_DIR/rockdev
DATE=$(date +%Y%m%d.%H%M)
STUB_PATH=Image/"$RK_KERNEL_DTS"_"$DATE"_RELEASE_TEST
STUB_PATH="$(echo $STUB_PATH | tr '[:lower:]' '[:upper:]')"
export STUB_PATH=$TOP_DIR/$STUB_PATH
export STUB_PATCH_PATH=$STUB_PATH/PATCHES
mkdir -p $STUB_PATH
#Generate patches
$TOP_DIR/.repo/repo/repo forall -c "$TOP_DIR/device/rockchip/common/gen_patches_body.sh"
#Copy stubs
$TOP_DIR/.repo/repo/repo manifest -r -o $STUB_PATH/manifest_${DATE}.xml
mkdir -p $STUB_PATCH_PATH/kernel
cp $TOP_DIR/kernel/.config $STUB_PATCH_PATH/kernel
cp $TOP_DIR/kernel/vmlinux $STUB_PATCH_PATH/kernel
mkdir -p $STUB_PATH/IMAGES/
cp $IMAGE_PATH/* $STUB_PATH/IMAGES/
#Save build command info
echo "UBOOT: defconfig: $RK_UBOOT_DEFCONFIG" >> $STUB_PATH/build_cmd_info
echo "KERNEL: defconfig: $RK_KERNEL_DEFCONFIG, dts: $RK_KERNEL_DTS" >> $STUB_PATH/build_cmd_info
echo "BUILDROOT: $RK_CFG_BUILDROOT" >> $STUB_PATH/build_cmd_info
}
function build_all_save(){
build_all
build_firmware
build_updateimg
#build_save
}
#=========================
# build target
#=========================
if [ $BUILD_TARGET == uboot ];then
build_uboot
exit 0
elif [ $BUILD_TARGET == kernel ];then
build_kernel
exit 0
elif [ $BUILD_TARGET == rootfs ];then
build_rootfs
exit 0
elif [ $BUILD_TARGET == buildroot ];then
build_buildroot
exit 0
elif [ $BUILD_TARGET == recovery ];then
build_recovery
exit 0
elif [ $BUILD_TARGET == pcba ];then
build_pcba
exit 0
elif [ $BUILD_TARGET == updateimg ];then
build_updateimg
exit 0
elif [ $BUILD_TARGET == all ];then
build_all
exit 0
elif [ $BUILD_TARGET == firmware ];then
build_firmware
exit 0
elif [ $BUILD_TARGET == save ];then
build_save
exit 0
elif [ $BUILD_TARGET == cleanall ];then
clean_all
exit 0
elif [ $BUILD_TARGET == --help ] || [ $BUILD_TARGET == help ] || [ $BUILD_TARGET == -h ];then
usage
exit 0
elif [ $BUILD_TARGET == allsave ];then
build_all_save
exit 0
elif [ -f $NEW_BOARD_CONFIG ];then
rm -f $BOARD_CONFIG
ln -s $NEW_BOARD_CONFIG $BOARD_CONFIG
else
echo "Can't found build config, please check again"
usage
exit 1
fi