-
Notifications
You must be signed in to change notification settings - Fork 0
/
pack_deb.sh
executable file
·89 lines (78 loc) · 2.01 KB
/
pack_deb.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
#!/bin/bash -e
LOCALPATH=$(pwd)
OUT=${LOCALPATH}/out
TOOLPATH=${LOCALPATH}/rkbin/tools
EXTLINUXPATH=${LOCALPATH}/build/extlinux
TARGET=${OUT}/debian/rockchip-firmware
CHIP=""
DEVICE=""
ROOTFS_PATH=""
source $LOCALPATH/build/partitions.sh
usage() {
echo -e "\nUsage: build/pack-deb.sh -c rk3288 -d /dev/mmcblk0(mmc index in target device, not host) (-r rk-rootfs-build/linaro-rootfs.img)\n"
}
finish() {
echo -e "\e[31m PACK DEB FAILED.\e[0m"
exit -1
}
trap finish ERR
OLD_OPTIND=$OPTIND
while getopts "c:d:r:h" flag; do
case $flag in
c)
CHIP="$OPTARG"
;;
d)
DEVICE="$OPTARG"
;;
r)
ROOTFS_PATH="$OPTARG"
;;
esac
done
OPTIND=$OLD_OPTIND
if [ ! $CHIP ] || [ ! $DEVICE ]; then
usage
exit
fi
if [ ! -f "${ROOTFS_PATH}" ]; then
ROOTFS_PATH="build/pack_deb.sh" # fake
fi
mkdir -p ${TARGET}
cp -rf ${LOCALPATH}/build/debian/rockchip-firmware ${OUT}/debian/
########### u-boot #############
DIR=/usr/lib/u-boot-rockchip
if [ "$CHIP" == "rk3288" ] || [ "$CHIP" == "rk322x" ] || [ "$CHIP" == "rk3036" ]; then
cat >${TARGET}/u-boot_install.sh <<EOF
dd if=${DIR}/idbloader.img of=${DEVICE} seek=${LOADER1_START}
sync
EOF
elif [ "$CHIP" == "rk3399" ] || [ "$CHIP" == "rk3328" ]; then
cat >${TARGET}/u-boot_install.sh <<EOF
dd if=${DIR}/idbloader.img of=${DEVICE} seek=${LOADER1_START}
dd if=${DIR}/uboot.img of=${DEVICE} seek=${LOADER2_START}
dd if=${DIR}/trust.img of=${DEVICE} seek=${ATF_START}
sync
EOF
fi
########### kernel #############
DIR=/usr/lib/kernel-rockchip
cat >${TARGET}/kernel_install.sh <<EOF
dd if=${DIR}/boot.img of=${DEVICE} seek=${BOOT_START}
echo "delete kernel image to save space"
rm -f ${DIR}/boot.img
sync
EOF
########### rootfs #############
sed -i -e "s:@ROOTFS@:${ROOTFS_PATH}:" ${TARGET}/Makefile
DIR=/usr/lib/rootfs-rockchip
cat >${TARGET}/rootfs_install.sh <<EOF
dd if=${DIR}/rootfs.img of=${DEVICE} seek=${ROOTFS_START}
echo "delete rootfs image to save space"
rm -f ${DIR}/rootfs.img
sync
EOF
########### build #############
cd ${TARGET}
dpkg-buildpackage -rfakeroot -b -uc -us
rm -rf ${TARGET}