forked from cvetaevvitaliy/stm32mp1-ubuntu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-linux.sh
executable file
·182 lines (135 loc) · 4.77 KB
/
build-linux.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
#!/bin/bash
export LC_ALL=C
DIR=$PWD
git_bin=$(which git)
BUILD="5.10.61"
mkdir -p "${DIR}/deploy/"
/bin/sh -e "${DIR}/gcc.sh" || { exit 1 ; }
. "${DIR}/.CC"
. "${DIR}/version.sh"
echo "CROSS_COMPILE=${CC}"
if [ ! "${CORES}" ] ; then
CORES=$(($(getconf _NPROCESSORS_ONLN) * 2)) # cores and thread
fi
#/bin/sh -e "${DIR}/build-uboot.sh" || { exit 1 ; }
apply_patch() {
cd "${DIR}/linux" || exit
git apply -v --whitespace=fix ${DIR}/00001-add-stm32mp157a-sodimm2-mx.patch || { cd "${DIR}/" ; return 1 ; }
git apply -v --whitespace=fix ${DIR}/00002-add-panel-simle-o4_lcd5_800_480.patch || { cd "${DIR}/" ; return 1 ; }
git apply -v --whitespace=fix ${DIR}/00003-remove-plus-from-kernel-version.patch || { cd "${DIR}/" ; return 1 ; }
git diff arch/arm/boot/dts/Makefile
cd "${DIR}/" || exit
}
copy_defconfig () {
cd "${DIR}/linux" || exit
#make ARCH=${KERNEL_ARCH} CROSS_COMPILE="${CC}" distclean
#make ARCH=${KERNEL_ARCH} CROSS_COMPILE="${CC}" "${config}"
cp -v "${DIR}/defconfig_${config}" .config
cd "${DIR}/" || exit
}
make_menuconfig () {
cd "${DIR}/linux" || exit
#make ARCH=${KERNEL_ARCH} CROSS_COMPILE="${CC}" oldconfig
#make ARCH=${KERNEL_ARCH} CROSS_COMPILE="${CC}" menuconfig
cp -v .config "${DIR}/defconfig_${config}"
cd "${DIR}/" || exit
}
make_gpu_driver() {
cd ${DIR}/gcnano-driver-6.4.3
make KERNEL_DIR=${DIR}/linux CROSS_COMPILE="${CC}" clean
make KERNEL_DIR=${DIR}/linux CROSS_COMPILE="${CC}" all
#cp -v galcore.ko ${DIR}/linux/lib/modules/5.10.61/extra/
cd "${DIR}/linux"
}
make_kernel () {
image="zImage"
cd "${DIR}/linux" || exit
echo "Build Kernel: $(git branch --show-current)"
echo "-----------------------------"
echo "make -j${CORES} ARCH=${KERNEL_ARCH} CROSS_COMPILE=\"${CC}\" ${image} modules"
echo "-----------------------------"
make -j${CORES} ARCH=${KERNEL_ARCH} CROSS_COMPILE="${CC}" ${image} modules
echo "-----------------------------"
echo "make -j${CORES} ARCH=${KERNEL_ARCH} CROSS_COMPILE=\"${CC}\" dtbs"
echo "-----------------------------"
make -j${CORES} ARCH=${KERNEL_ARCH} CROSS_COMPILE="${CC}" dtbs
echo "-----------------------------"
# make_gpu_driver
KERNEL_UTS=$(cat "${DIR}/linux/include/generated/utsrelease.h" | awk '{print $3}' | sed 's/\"//g' )
echo "${KERNEL_UTS}"
if [ -f "${DIR}/deploy/${KERNEL_UTS}.${image}" ] ; then
rm -rf "${DIR}/deploy/${KERNEL_UTS}.${image}" || true
rm -rf "${DIR}/deploy/config-${KERNEL_UTS}" || true
fi
if [ -f ./arch/${KERNEL_ARCH}/boot/${image} ] ; then
cp -v arch/${KERNEL_ARCH}/boot/${image} "${DIR}/deploy/${KERNEL_UTS}.${image}"
cp -v arch/${KERNEL_ARCH}/boot/${image} "${DIR}/deploy/${image}"
cp -v .config "${DIR}/deploy/config-${KERNEL_UTS}"
fi
cd "${DIR}/" || exit
if [ ! -f "${DIR}/deploy/${KERNEL_UTS}.${image}" ] ; then
export ERROR_MSG="File Generation Failure: [${KERNEL_UTS}.${image}]"
/bin/sh -e "${DIR}/error.sh" && { exit 1 ; }
else
ls -lh "${DIR}/deploy/${KERNEL_UTS}.${image}"
ls -lh "${DIR}/deploy/${image}"
fi
}
make_pkg () {
cd "${DIR}/linux" || exit
#KERNEL_UTS=${BUILD}
branch=$(git branch --show-current)
deployfile="-${pkg}.tar.gz"
tar_options="--create --gzip --file"
#tar_options="-czvf"
if [ -f "${DIR}/deploy/${KERNEL_UTS}${deployfile}" ] ; then
rm -rf "${DIR}/deploy/${KERNEL_UTS}${deployfile}" || true
fi
if [ -d "${DIR}/deploy/tmp" ] ; then
rm -rf "${DIR}/deploy/tmp" || true
fi
mkdir -p "${DIR}/deploy/tmp"
echo "-----------------------------"
echo "Building ${pkg} archive..."
case "${pkg}" in
modules)
echo "make -s ARCH=${KERNEL_ARCH} CROSS_COMPILE=\"${CC}\" modules_install INSTALL_MOD_PATH=\"${DIR}/deploy/tmp\""
echo "-----------------------------"
make -s ARCH=${KERNEL_ARCH} CROSS_COMPILE="${CC}" modules_install INSTALL_MOD_PATH="${DIR}/deploy/tmp"
;;
dtbs)
make -s ARCH=${KERNEL_ARCH} CROSS_COMPILE="${CC}" dtbs_install INSTALL_DTBS_PATH="${DIR}/deploy/tmp"
;;
esac
echo "Compressing ${KERNEL_UTS}${deployfile}..."
cd "${DIR}/deploy/tmp" || true
tar ${tar_options} "${DIR}/deploy/${KERNEL_UTS}${deployfile}" ./*
cd "${DIR}/" || exit
rm -rf "${DIR}/deploy/tmp" || true
if [ ! -f "${DIR}/deploy/${KERNEL_UTS}${deployfile}" ] ; then
export ERROR_MSG="File Generation Failure: [${KERNEL_UTS}${deployfile}] branch: ${branch}"
/bin/sh -e "${DIR}/error.sh" && { exit 1 ; }
else
ls -lh "${DIR}/deploy/${KERNEL_UTS}${deployfile}"
fi
}
make_modules_pkg () {
pkg="modules"
make_pkg
}
make_dtbs_pkg () {
pkg="dtbs"
make_pkg
}
apply_patch
copy_defconfig
make_menuconfig
make_kernel
make_modules_pkg
make_dtbs_pkg
echo "-----------------------------"
echo "Script Complete"
echo "${KERNEL_UTS}" > kernel_version
echo "[user@localhost:~$ export kernel_version=${KERNEL_UTS}]"
echo "-----------------------------"
#/bin/sh -e "${DIR}/create-rootfs.sh" || { exit 1 ; }