|
@@
-25,9
+25,9
if [ "$BUILD_KERNEL" = true ] ; then
|
|
25
|
|
|
25
|
|
|
26
|
# Fetch current RPi2/3 kernel sources
|
|
26
|
# Fetch current RPi2/3 kernel sources
|
|
27
|
if [ -z "${KERNEL_BRANCH}" ] ; then
|
|
27
|
if [ -z "${KERNEL_BRANCH}" ] ; then
|
|
28
|
as_nobody git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux
|
|
28
|
as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux
|
|
29
|
else
|
|
29
|
else
|
|
30
|
as_nobody git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux
|
|
30
|
as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux
|
|
31
|
fi
|
|
31
|
fi
|
|
32
|
|
|
32
|
|
|
33
|
# Copy downloaded kernel sources
|
|
33
|
# Copy downloaded kernel sources
|
|
@@
-87,18
+87,36
if [ "$BUILD_KERNEL" = true ] ; then
|
|
87
|
# Load default raspberry kernel configuration
|
|
87
|
# Load default raspberry kernel configuration
|
|
88
|
make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
|
|
88
|
make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
|
|
89
|
|
|
89
|
|
|
|
|
|
90
|
# Copy custom kernel configuration file
|
|
90
|
if [ ! -z "$KERNELSRC_USRCONFIG" ] ; then
|
|
91
|
if [ ! -z "$KERNELSRC_USRCONFIG" ] ; then
|
|
91
|
cp $KERNELSRC_USRCONFIG ${KERNEL_DIR}/.config
|
|
92
|
cp $KERNELSRC_USRCONFIG ${KERNEL_DIR}/.config
|
|
92
|
fi
|
|
93
|
fi
|
|
93
|
|
|
94
|
|
|
|
|
|
95
|
# Set kernel configuration parameters to their default values
|
|
|
|
|
96
|
if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then
|
|
|
|
|
97
|
make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig
|
|
|
|
|
98
|
fi
|
|
|
|
|
99
|
|
|
94
|
# Start menu-driven kernel configuration (interactive)
|
|
100
|
# Start menu-driven kernel configuration (interactive)
|
|
95
|
if [ "$KERNEL_MENUCONFIG" = true ] ; then
|
|
101
|
if [ "$KERNEL_MENUCONFIG" = true ] ; then
|
|
96
|
make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
|
|
102
|
make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
|
|
97
|
fi
|
|
103
|
fi
|
|
98
|
fi
|
|
104
|
fi
|
|
99
|
|
|
105
|
|
|
100
|
# Cross compile kernel and modules
|
|
106
|
# Use ccache to cross compile the kernel
|
|
101
|
make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_BIN_IMAGE}" modules dtbs
|
|
107
|
if [ "$KERNEL_CCACHE" = true ] ; then
|
|
|
|
|
108
|
cc="ccache ${CROSS_COMPILE}gcc"
|
|
|
|
|
109
|
else
|
|
|
|
|
110
|
cc="${CROSS_COMPILE}gcc"
|
|
|
|
|
111
|
fi
|
|
|
|
|
112
|
|
|
|
|
|
113
|
# Cross compile kernel and dtbs
|
|
|
|
|
114
|
make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
|
|
|
|
|
115
|
|
|
|
|
|
116
|
# Cross compile kernel modules
|
|
|
|
|
117
|
if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
|
|
|
|
|
118
|
make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
|
|
|
|
|
119
|
fi
|
|
102
|
fi
|
|
120
|
fi
|
|
103
|
|
|
121
|
|
|
104
|
# Check if kernel compilation was successful
|
|
122
|
# Check if kernel compilation was successful
|
|
@@
-110,12
+128,16
if [ "$BUILD_KERNEL" = true ] ; then
|
|
110
|
|
|
128
|
|
|
111
|
# Install kernel modules
|
|
129
|
# Install kernel modules
|
|
112
|
if [ "$ENABLE_REDUCE" = true ] ; then
|
|
130
|
if [ "$ENABLE_REDUCE" = true ] ; then
|
|
113
|
make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
|
|
131
|
if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
|
|
|
|
|
132
|
make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
|
|
|
|
|
133
|
fi
|
|
114
|
else
|
|
134
|
else
|
|
115
|
make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
|
|
135
|
if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
|
|
|
|
|
136
|
make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
|
|
|
|
|
137
|
fi
|
|
116
|
|
|
138
|
|
|
117
|
# Install kernel firmware
|
|
139
|
# Install kernel firmware
|
|
118
|
if [ $(cat ./Makefile | grep "^firmware_install:") ] ; then
|
|
140
|
if [ $(grep "^firmware_install:" "${KERNEL_DIR}/Makefile") ] ; then
|
|
119
|
make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
|
|
141
|
make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
|
|
120
|
fi
|
|
142
|
fi
|
|
121
|
fi
|
|
143
|
fi
|
|
@@
-134,18
+156,36
if [ "$BUILD_KERNEL" = true ] ; then
|
|
134
|
# Copy kernel configuration file to the boot directory
|
|
156
|
# Copy kernel configuration file to the boot directory
|
|
135
|
install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
|
|
157
|
install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
|
|
136
|
|
|
158
|
|
|
137
|
# Copy dts and dtb device tree sources and binaries
|
|
159
|
# Prepare device tree directory
|
|
138
|
mkdir "${BOOT_DIR}/overlays"
|
|
160
|
mkdir "${BOOT_DIR}/overlays"
|
|
139
|
|
|
161
|
|
|
140
|
# Ensure the proper .dtb is located
|
|
162
|
# Ensure the proper .dtb is located
|
|
141
|
if [ "$KERNEL_ARCH" = "arm" ] ; then
|
|
163
|
if [ "$KERNEL_ARCH" = "arm" ] ; then
|
|
142
|
install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb "${BOOT_DIR}/"
|
|
164
|
for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do
|
|
|
|
|
165
|
if [ -f "${dtb}" ] ; then
|
|
|
|
|
166
|
install_readonly "${dtb}" "${BOOT_DIR}/"
|
|
|
|
|
167
|
fi
|
|
|
|
|
168
|
done
|
|
143
|
else
|
|
169
|
else
|
|
144
|
install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb "${BOOT_DIR}/"
|
|
170
|
for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do
|
|
|
|
|
171
|
if [ -f "${dtb}" ] ; then
|
|
|
|
|
172
|
install_readonly "${dtb}" "${BOOT_DIR}/"
|
|
|
|
|
173
|
fi
|
|
|
|
|
174
|
done
|
|
145
|
fi
|
|
175
|
fi
|
|
146
|
|
|
176
|
|
|
147
|
install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb* "${BOOT_DIR}/overlays/"
|
|
177
|
# Copy compiled dtb device tree files
|
|
148
|
install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
|
|
178
|
if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then
|
|
|
|
|
179
|
for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb ; do
|
|
|
|
|
180
|
if [ -f "${dtb}" ] ; then
|
|
|
|
|
181
|
install_readonly "${dtb}" "${BOOT_DIR}/overlays/"
|
|
|
|
|
182
|
fi
|
|
|
|
|
183
|
done
|
|
|
|
|
184
|
|
|
|
|
|
185
|
if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then
|
|
|
|
|
186
|
install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
|
|
|
|
|
187
|
fi
|
|
|
|
|
188
|
fi
|
|
149
|
|
|
189
|
|
|
150
|
if [ "$ENABLE_UBOOT" = false ] ; then
|
|
190
|
if [ "$ENABLE_UBOOT" = false ] ; then
|
|
151
|
# Convert and copy kernel image to the boot directory
|
|
191
|
# Convert and copy kernel image to the boot directory
|
|
@@
-159,11
+199,16
if [ "$BUILD_KERNEL" = true ] ; then
|
|
159
|
if [ "$KERNEL_REMOVESRC" = true ] ; then
|
|
199
|
if [ "$KERNEL_REMOVESRC" = true ] ; then
|
|
160
|
rm -fr "${KERNEL_DIR}"
|
|
200
|
rm -fr "${KERNEL_DIR}"
|
|
161
|
else
|
|
201
|
else
|
|
162
|
make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
|
|
202
|
# Prepare compiled kernel modules
|
|
|
|
|
203
|
if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
|
|
|
|
|
204
|
if [ $(grep "^modules_prepare:" "${KERNEL_DIR}/Makefile") ] ; then
|
|
|
|
|
205
|
make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
|
|
|
|
|
206
|
fi
|
|
163
|
|
|
207
|
|
|
164
|
# Create symlinks for kernel modules
|
|
208
|
# Create symlinks for kernel modules
|
|
165
|
chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build"
|
|
209
|
chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build"
|
|
166
|
chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source"
|
|
210
|
chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source"
|
|
|
|
|
211
|
fi
|
|
167
|
fi
|
|
212
|
fi
|
|
168
|
|
|
213
|
|
|
169
|
else # BUILD_KERNEL=false
|
|
214
|
else # BUILD_KERNEL=false
|