##// END OF EJS Templates
Added support for precompiled kernel other than collabora
Unknown -
r292:9e5bb80b1061
parent child
Show More
@@ -1,55 +1,61
1 1 #
2 2 # Setup APT repositories
3 3 #
4 4
5 5 # Load utility functions
6 6 . ./functions.sh
7 7
8 8 # Install and setup APT proxy configuration
9 9 if [ -z "$APT_PROXY" ] ; then
10 10 install_readonly files/apt/10proxy "${ETC_DIR}/apt/apt.conf.d/10proxy"
11 11 sed -i "s/\"\"/\"${APT_PROXY}\"/" "${ETC_DIR}/apt/apt.conf.d/10proxy"
12 12 fi
13 13
14 14 if [ "$BUILD_KERNEL" = false ] ; then
15 if [ RPI_MODEL = 2 ] ; then
15 16 # Install APT pinning configuration for flash-kernel package
16 17 install_readonly files/apt/flash-kernel "${ETC_DIR}/apt/preferences.d/flash-kernel"
17 18
18 19 # Install APT sources.list
19 20 install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list"
20 21 echo "deb ${COLLABORA_URL} ${RELEASE} rpi2" >> "${ETC_DIR}/apt/sources.list"
21 22
22 23 # Upgrade collabora package index and install collabora keyring
23 24 chroot_exec apt-get -qq -y update
24 25 chroot_exec apt-get -qq -y --allow-unauthenticated install collabora-obs-archive-keyring
26 # if RPI_MODEL = [0] || [1] || [1P]
27 else
28 # insert apt configuration for precompiled kernel repository for RPI 0,1,1P
29 fi
30
25 31 else # BUILD_KERNEL=true
26 32 # Install APT sources.list
27 33 install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list"
28 34
29 35 # Use specified APT server and release
30 36 sed -i "s/\/ftp.debian.org\//\/${APT_SERVER}\//" "${ETC_DIR}/apt/sources.list"
31 37 sed -i "s/ jessie/ ${RELEASE}/" "${ETC_DIR}/apt/sources.list"
32 38 fi
33 39
34 40 # Allow the installation of non-free Debian packages
35 41 if [ "$ENABLE_NONFREE" = true ] ; then
36 42 sed -i "s/ contrib/ contrib non-free/" "${ETC_DIR}/apt/sources.list"
37 43 fi
38 44
39 45 # Upgrade package index and update all installed packages and changed dependencies
40 46 chroot_exec apt-get -qq -y update
41 47 chroot_exec apt-get -qq -y -u dist-upgrade
42 48
43 49 if [ "$APT_INCLUDES_LATE" ] ; then
44 50 chroot_exec apt-get -qq -y install $(echo $APT_INCLUDES_LATE |tr , ' ')
45 51 fi
46 52
47 53 if [ -d packages ] ; then
48 54 for package in packages/*.deb ; do
49 55 cp $package ${R}/tmp
50 56 chroot_exec dpkg --unpack /tmp/$(basename $package)
51 57 done
52 58 fi
53 59 chroot_exec apt-get -qq -y -f install
54 60
55 61 chroot_exec apt-get -qq -y check
@@ -1,253 +1,266
1 1 #
2 2 # Build and Setup RPi2/3 Kernel
3 3 #
4 4
5 5 # Load utility functions
6 6 . ./functions.sh
7 7
8 8 # Fetch and build latest raspberry kernel
9 9 if [ "$BUILD_KERNEL" = true ] ; then
10 10 # Setup source directory
11 11 mkdir -p "${R}/usr/src/linux"
12 12
13 13 # Copy existing kernel sources into chroot directory
14 14 if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then
15 15 # Copy kernel sources and include hidden files
16 16 cp -r "${KERNELSRC_DIR}/". "${R}/usr/src/linux"
17 17
18 18 # Clean the kernel sources
19 19 if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then
20 20 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper
21 21 fi
22 22 else # KERNELSRC_DIR=""
23 23 # Create temporary directory for kernel sources
24 24 temp_dir=$(as_nobody mktemp -d)
25 25
26 26 # Fetch current RPi2/3 kernel sources
27 27 if [ -z "${KERNEL_BRANCH}" ] ; then
28 28 as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux
29 29 else
30 30 as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux
31 31 fi
32 32
33 33 # Copy downloaded kernel sources
34 34 cp -r "${temp_dir}/linux/"* "${R}/usr/src/linux/"
35 35
36 36 # Remove temporary directory for kernel sources
37 37 rm -fr "${temp_dir}"
38 38
39 39 # Set permissions of the kernel sources
40 40 chown -R root:root "${R}/usr/src"
41 41 fi
42 42
43 43 # Calculate optimal number of kernel building threads
44 44 if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then
45 45 KERNEL_THREADS=$(grep -c processor /proc/cpuinfo)
46 46 fi
47 47
48 48 # Configure and build kernel
49 49 if [ "$KERNELSRC_PREBUILT" = false ] ; then
50 50 # Remove device, network and filesystem drivers from kernel configuration
51 51 if [ "$KERNEL_REDUCE" = true ] ; then
52 52 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
53 53 sed -i\
54 54 -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\
55 55 -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\
56 56 -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\
57 57 -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\
58 58 -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\
59 59 -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\
60 60 -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\
61 61 -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\
62 62 -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\
63 63 -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\
64 64 -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\
65 65 -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\
66 66 -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\
67 67 -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\
68 68 -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\
69 69 -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\
70 70 -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\
71 71 -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\
72 72 -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\
73 73 -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\
74 74 -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\
75 75 -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\
76 76 -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\
77 77 -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\
78 78 -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\
79 79 -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\
80 80 -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\
81 81 -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\
82 82 -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\
83 83 "${KERNEL_DIR}/.config"
84 84 fi
85 85
86 86 if [ "$KERNELSRC_CONFIG" = true ] ; then
87 87 # Load default raspberry kernel configuration
88 88 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
89 89
90 90 # Set kernel configuration parameters to enable qemu emulation
91 91 if [ "$ENABLE_QEMU" = true ] ; then
92 92 echo "CONFIG_FHANDLE=y" >> ${KERNEL_DIR}/.config
93 93 echo "CONFIG_LBDAF=y" >> ${KERNEL_DIR}/.config
94 94
95 95 if [ "$ENABLE_CRYPTFS" = true ] ; then
96 96 echo "CONFIG_EMBEDDED=y" >> ${KERNEL_DIR}/.config
97 97 echo "CONFIG_EXPERT=y" >> ${KERNEL_DIR}/.config
98 98 echo "CONFIG_DAX=y" >> ${KERNEL_DIR}/.config
99 99 echo "CONFIG_MD=y" >> ${KERNEL_DIR}/.config
100 100 echo "CONFIG_BLK_DEV_MD=y" >> ${KERNEL_DIR}/.config
101 101 echo "CONFIG_MD_AUTODETECT=y" >> ${KERNEL_DIR}/.config
102 102 echo "CONFIG_BLK_DEV_DM=y" >> ${KERNEL_DIR}/.config
103 103 echo "CONFIG_BLK_DEV_DM_BUILTIN=y" >> ${KERNEL_DIR}/.config
104 104 echo "CONFIG_DM_CRYPT=y" >> ${KERNEL_DIR}/.config
105 105 echo "CONFIG_CRYPTO_BLKCIPHER=y" >> ${KERNEL_DIR}/.config
106 106 echo "CONFIG_CRYPTO_CBC=y" >> ${KERNEL_DIR}/.config
107 107 echo "CONFIG_CRYPTO_XTS=y" >> ${KERNEL_DIR}/.config
108 108 echo "CONFIG_CRYPTO_SHA512=y" >> ${KERNEL_DIR}/.config
109 109 echo "CONFIG_CRYPTO_MANAGER=y" >> ${KERNEL_DIR}/.config
110 110 fi
111 111 fi
112 112
113 113 # Copy custom kernel configuration file
114 114 if [ ! -z "$KERNELSRC_USRCONFIG" ] ; then
115 115 cp $KERNELSRC_USRCONFIG ${KERNEL_DIR}/.config
116 116 fi
117 117
118 118 # Set kernel configuration parameters to their default values
119 119 if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then
120 120 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig
121 121 fi
122 122
123 123 # Start menu-driven kernel configuration (interactive)
124 124 if [ "$KERNEL_MENUCONFIG" = true ] ; then
125 125 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
126 126 fi
127 127 fi
128 128
129 129 # Use ccache to cross compile the kernel
130 130 if [ "$KERNEL_CCACHE" = true ] ; then
131 131 cc="ccache ${CROSS_COMPILE}gcc"
132 132 else
133 133 cc="${CROSS_COMPILE}gcc"
134 134 fi
135 135
136 136 # Cross compile kernel and dtbs
137 137 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
138 138
139 139 # Cross compile kernel modules
140 140 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
141 141 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
142 142 fi
143 143 fi
144 144
145 145 # Check if kernel compilation was successful
146 146 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then
147 147 echo "error: kernel compilation failed! (kernel image not found)"
148 148 cleanup
149 149 exit 1
150 150 fi
151 151
152 152 # Install kernel modules
153 153 if [ "$ENABLE_REDUCE" = true ] ; then
154 154 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
155 155 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
156 156 fi
157 157 else
158 158 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
159 159 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
160 160 fi
161 161
162 162 # Install kernel firmware
163 163 if [ $(grep "^firmware_install:" "${KERNEL_DIR}/Makefile") ] ; then
164 164 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
165 165 fi
166 166 fi
167 167
168 168 # Install kernel headers
169 169 if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then
170 170 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
171 171 fi
172 172
173 173 # Prepare boot (firmware) directory
174 174 mkdir "${BOOT_DIR}"
175 175
176 176 # Get kernel release version
177 177 KERNEL_VERSION=`cat "${KERNEL_DIR}/include/config/kernel.release"`
178 178
179 179 # Copy kernel configuration file to the boot directory
180 180 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
181 181
182 182 # Prepare device tree directory
183 183 mkdir "${BOOT_DIR}/overlays"
184 184
185 185 # Ensure the proper .dtb is located
186 186 if [ "$KERNEL_ARCH" = "arm" ] ; then
187 187 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do
188 188 if [ -f "${dtb}" ] ; then
189 189 install_readonly "${dtb}" "${BOOT_DIR}/"
190 190 fi
191 191 done
192 192 else
193 193 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do
194 194 if [ -f "${dtb}" ] ; then
195 195 install_readonly "${dtb}" "${BOOT_DIR}/"
196 196 fi
197 197 done
198 198 fi
199 199
200 200 # Copy compiled dtb device tree files
201 201 if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then
202 202 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb ; do
203 203 if [ -f "${dtb}" ] ; then
204 204 install_readonly "${dtb}" "${BOOT_DIR}/overlays/"
205 205 fi
206 206 done
207 207
208 208 if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then
209 209 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
210 210 fi
211 211 fi
212 212
213 213 if [ "$ENABLE_UBOOT" = false ] ; then
214 214 # Convert and copy kernel image to the boot directory
215 215 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
216 216 else
217 217 # Copy kernel image to the boot directory
218 218 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
219 219 fi
220 220
221 221 # Remove kernel sources
222 222 if [ "$KERNEL_REMOVESRC" = true ] ; then
223 223 rm -fr "${KERNEL_DIR}"
224 224 else
225 225 # Prepare compiled kernel modules
226 226 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
227 227 if [ $(grep "^modules_prepare:" "${KERNEL_DIR}/Makefile") ] ; then
228 228 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
229 229 fi
230 230
231 231 # Create symlinks for kernel modules
232 232 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build"
233 233 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source"
234 234 fi
235 235 fi
236
237 else # BUILD_KERNEL=false
236 elif [ BUILD_KERNEL = false ]
237 # Collabora states this kernel is just for RPI 2 so better implement a check.
238 #From https://repositories.collabora.co.uk/debian/dists/jessie/rpi2/binary-armhf/Packages
239 #"The Linux kernel "${COLLABORA_KERNEL}" and modules for use on ARMv7 kernel for Raspberry pi 2 model B+"
240 # nested if to be easily extended for more precompiled kernels
241 if [ "$SET_ARCH" = 32 ] ; then
242 if [ RPI_MODEL = 2 ] ; then
238 243 # Kernel installation
239 244 chroot_exec apt-get -qq -y --no-install-recommends install linux-image-"${COLLABORA_KERNEL}" raspberrypi-bootloader-nokernel
240 245
241 246 # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot
242 247 chroot_exec apt-get -qq -y install flash-kernel
243 248
244 249 # Check if kernel installation was successful
245 250 VMLINUZ="$(ls -1 ${R}/boot/vmlinuz-* | sort | tail -n 1)"
246 251 if [ -z "$VMLINUZ" ] ; then
247 252 echo "error: kernel installation failed! (/boot/vmlinuz-* not found)"
248 253 cleanup
249 254 exit 1
250 255 fi
251 256 # Copy vmlinuz kernel to the boot directory
252 257 install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}"
253 258 fi
259 if [ RPI_MODEL = 0 ] || [ RPI_MODEL = 1 ] || [ RPI_MODEL = 1P ] ; then
260 # insert precompiled Kernel here
261 fi
262 #if [ "$SET_ARCH" = 64 ]
263 else
264 # inset precompiled 64 bit kernel here
265 fi
266 fi
1 NO CONTENT: modified file
1 NO CONTENT: modified file
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant