forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 14
/
build_a13.sh
executable file
·171 lines (138 loc) · 4.09 KB
/
build_a13.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
#!/bin/bash
set -e
#Setup common variables
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
export AS=${CROSS_COMPILE}as
export LD=${CROSS_COMPILE}ld
export CC=${CROSS_COMPILE}gcc
export AR=${CROSS_COMPILE}ar
export NM=${CROSS_COMPILE}nm
export STRIP=${CROSS_COMPILE}strip
export OBJCOPY=${CROSS_COMPILE}objcopy
export OBJDUMP=${CROSS_COMPILE}objdump
KERNEL_VERSION="3.0"
LICHEE_KDIR=`pwd`
LICHEE_MOD_DIR=${LICHEE_KDIR}/output/lib/modules/${KERNEL_VERSION}
CONFIG_CHIP_ID=1125
update_kern_ver()
{
if [ -r include/generated/utsrelease.h ]; then
KERNEL_VERSION=`cat include/generated/utsrelease.h |awk -F\" '{print $2}'`
fi
LICHEE_MOD_DIR=${LICHEE_KDIR}/output/lib/modules/${KERNEL_VERSION}
}
show_help()
{
printf "
Build script for Lichee platform
Invalid Options:
help - show this help
kernel - build kernel
modules - build kernel module in modules dir
clean - clean kernel and modules
"
}
build_kernel()
{
if [ ! -e .config ]; then
echo -e "\n\t\tUsing default config... ...!\n"
cp arch/arm/configs/a13_defconfig .config
fi
make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -j8 uImage modules
update_kern_ver
if [ -d output ]; then
rm -rf output
fi
mkdir -p $LICHEE_MOD_DIR
${OBJCOPY} -R .note.gnu.build-id -S -O binary vmlinux output/bImage
cp -vf arch/arm/boot/[zu]Image output/
cp .config output/
cp rootfs/sun5i_rootfs.cpio.gz output/
mkbootimg --kernel output/bImage \
--ramdisk output/sun5i_rootfs.cpio.gz \
--board 'sun5i' \
--base 0x40000000 \
-o output/boot.img
mkbootimg --kernel output/bImage \
--ramdisk output/sun5i_rootfs.cpio.gz \
--board 'sun5i' \
--base 0x40000000 \
-o output/boot.img
for file in $(find drivers sound crypto block fs security net -name "*.ko"); do
cp $file ${LICHEE_MOD_DIR}
done
cp -f Module.symvers ${LICHEE_MOD_DIR}
#copy bcm4330 firmware and nvram.txt
cp drivers/net/wireless/bcm4330/firmware/bcm4330.bin ${LICHEE_MOD_DIR}
cp drivers/net/wireless/bcm4330/firmware/bcm4330.hcd ${LICHEE_MOD_DIR}
cp drivers/net/wireless/bcm4330/firmware/nvram.txt ${LICHEE_MOD_DIR}/bcm4330_nvram.txt
}
build_modules()
{
echo "Building modules"
if [ ! -f include/generated/utsrelease.h ]; then
printf "Please build kernel first!\n"
exit 1
fi
update_kern_ver
make -C modules/example LICHEE_MOD_DIR=${LICHEE_MOD_DIR} LICHEE_KDIR=${LICHEE_KDIR} \
CONFIG_CHIP_ID=${CONFIG_CHIP_ID} install
(
export LANG=en_US.UTF-8
unset LANGUAGE
make -C modules/mali LICHEE_MOD_DIR=${LICHEE_MOD_DIR} LICHEE_KDIR=${LICHEE_KDIR} \
CONFIG_CHIP_ID=${CONFIG_CHIP_ID} install
)
#build usi-bmc4329 sdio wifi module
make -C modules/wifi/usi-bcm4329/v4.218.248.15/open-src/src/dhd/linux \
CROSS_COMPILE=${CROSS_COMPILE} ARCH=arm LINUXVER=${KERNEL_VERSION} \
LICHEE_MOD_DIR=${LICHEE_MOD_DIR} LINUXDIR=${LICHEE_KDIR} CONFIG_CHIP_ID=${CONFIG_CHIP_ID} \
INSTALL_DIR=${LICHEE_MOD_DIR} dhd-cdc-sdmmc-gpl
}
clean_kernel()
{
make clean
rm -rf output/*
(
export LANG=en_US.UTF-8
unset LANGUAGE
make -C modules/mali LICHEE_MOD_DIR=${LICHEE_MOD_DIR} LICHEE_KDIR=${LICHEE_KDIR} clean
)
#build usi-bmc4329 sdio wifi module
make -C modules/wifi/usi-bcm4329/v4.218.248.15/open-src/src/dhd/linux \
CROSS_COMPILE=${CROSS_COMPILE} ARCH=arm LINUXVER=${KERNEL_VERSION} \
LICHEE_MOD_DIR=${LICHEE_MOD_DIR} LINUXDIR=${LICHEE_KDIR} CONFIG_CHIP_ID=${CONFIG_CHIP_ID} \
INSTALL_DIR=${LICHEE_MOD_DIR} clean
}
clean_modules()
{
echo "Cleaning modules"
make -C modules/example LICHEE_MOD_DIR=${LICHEE_MOD_DIR} LICHEE_KDIR=${LICHEE_KDIR} clean
}
#####################################################################
#
# Main Runtine
#
#####################################################################
LICHEE_ROOT=`(cd ${LICHEE_KDIR}/..; pwd)`
export PATH=${LICHEE_ROOT}/buildroot/output/external-toolchain/bin:${LICHEE_ROOT}/tools/pack/pctools/linux/android:$PATH
case "$1" in
kernel)
build_kernel
;;
modules)
build_modules
;;
clean)
clean_kernel
clean_modules
;;
all)
build_kernel
build_modules
;;
*)
show_help
;;
esac