##// END OF EJS Templates
fixes
Unknown -
r669:682120bd8eb1
parent child
Show More
@@ -1,887 +1,888
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 # Need to use kali kernel src if nexmon is enabled
9 9 if [ "$ENABLE_NEXMON" = true ] ; then
10 10 KERNEL_URL="${KALI_KERNEL_URL}"
11 11 # Clear Branch and KernelSRC_DIR if using nexmon. Everyone will forget to clone kali kernel instead of nomrla kernel
12 12 KERNEL_BRANCH=""
13 13 KERNELSRC_DIR=""
14 14 fi
15 15
16 16 # Fetch and build latest raspberry kernel
17 17 if [ "$BUILD_KERNEL" = true ] ; then
18 18 # Setup source directory
19 19 mkdir -p "${KERNEL_DIR}"
20 20
21 21 # Copy existing kernel sources into chroot directory
22 22 if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then
23 23 # Copy kernel sources and include hidden files
24 24 cp -r "${KERNELSRC_DIR}/". "${KERNEL_DIR}"
25 25
26 26 # Clean the kernel sources
27 27 if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then
28 28 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper
29 29 fi
30 30 else # KERNELSRC_DIR=""
31 31 # Create temporary directory for kernel sources
32 32 temp_dir=$(as_nobody mktemp -d)
33 33
34 34 # Fetch current RPi2/3 kernel sources
35 35 if [ -z "${KERNEL_BRANCH}" ] ; then
36 36 as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux
37 37 else
38 38 as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux
39 39 fi
40 40
41 41 # Copy downloaded kernel sources
42 42 cp -r "${temp_dir}/linux/"* "${KERNEL_DIR}"
43 43
44 44 # Remove temporary directory for kernel sources
45 45 rm -fr "${temp_dir}"
46 46
47 47 # Set permissions of the kernel sources
48 48 chown -R root:root "${R}/usr/src"
49 49 fi
50 50
51 51 # Calculate optimal number of kernel building threads
52 52 if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then
53 53 KERNEL_THREADS=$(grep -c processor /proc/cpuinfo)
54 54 fi
55 55
56 56 if [ "$ENABLE_QEMU" = true ] && [ "$KERNEL_ARCH" = arm64 ]; then
57 57 cp "${KERNEL_DIR}"/arch/arm/configs/vexpress_defconfig "${KERNEL_DIR}"/arch/arm64/configs/
58 58 fi
59 59
60 60 # Configure and build kernel
61 61 if [ "$KERNELSRC_PREBUILT" = false ] ; then
62 62 # Remove device, network and filesystem drivers from kernel configuration
63 63 if [ "$KERNEL_REDUCE" = true ] ; then
64 64 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
65 65 sed -i\
66 66 -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\
67 67 -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\
68 68 -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\
69 69 -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\
70 70 -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\
71 71 -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\
72 72 -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\
73 73 -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\
74 74 -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\
75 75 -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\
76 76 -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\
77 77 -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\
78 78 -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\
79 79 -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\
80 80 -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\
81 81 -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\
82 82 -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\
83 83 -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\
84 84 -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\
85 85 -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\
86 86 -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\
87 87 -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\
88 88 -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\
89 89 -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\
90 90 -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\
91 91 -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\
92 92 -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\
93 93 -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\
94 94 -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\
95 95 "${KERNEL_DIR}/.config"
96 96 fi
97 97
98 98 if [ "$KERNELSRC_CONFIG" = true ] ; then
99 99 # Load default raspberry kernel configuration
100 100 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
101 101
102 102 #Switch to KERNELSRC_DIR so we can use set_kernel_config
103 103 cd "${KERNEL_DIR}" || exit
104 104
105 105 # Enable RPI POE HAT fan
106 106 if [ "$KERNEL_POEHAT" = true ]; then
107 107 set_kernel_config CONFIG_SENSORS_RPI_POE_FAN m
108 108 fi
109 109
110 110 # Enable per-interface network priority control
111 111 # (for systemd-nspawn)
112 112 if [ "$KERNEL_NSPAN" = true ]; then
113 113 set_kernel_config CONFIG_CGROUP_NET_PRIO y
114 114 fi
115 115
116 116 # Compile in BTRFS
117 117 if [ "$KERNEL_BTRFS" = true ]; then
118 118 set_kernel_config CONFIG_BTRFS_FS y
119 119 set_kernel_config CONFIG_BTRFS_FS_POSIX_ACL y
120 120 set_kernel_config CONFIG_BTRFS_FS_REF_VERIFY y
121 121 fi
122 122
123 123 # Diffie-Hellman operations on retained keys
124 124 # (required for >keyutils-1.6)
125 125 if [ "$KERNEL_DHKEY" = true ]; then
126 126 set_kernel_config CONFIG_KEY_DH_OPERATIONS y
127 127 fi
128 128
129 129 if [ "$KERNEL_ARCH" = arm64 ] && [ "$ENABLE_QEMU" = false ]; then
130 130 # Mask this temporarily during switch to rpi-4.19.y
131 131 #Fix SD_DRIVER upstream and downstream mess in 64bit RPIdeb_config
132 132 # use correct driver MMC_BCM2835_MMC instead of MMC_BCM2835_SDHOST - see https://www.raspberrypi.org/forums/viewtopic.php?t=210225
133 133 #set_kernel_config CONFIG_MMC_BCM2835 n
134 134 #set_kernel_config CONFIG_MMC_SDHCI_IPROC n
135 135 #set_kernel_config CONFIG_USB_DWC2 n
136 136 #sed -i "s|depends on MMC_BCM2835_MMC && MMC_BCM2835_DMA|depends on MMC_BCM2835_MMC|" "${KERNEL_DIR}"/drivers/mmc/host/Kconfig
137 137
138 138 #VLAN got disabled without reason in arm64bit
139 139 set_kernel_config CONFIG_IPVLAN m
140 140 fi
141 141
142 142 # enable ZSWAP see https://askubuntu.com/a/472227 or https://wiki.archlinux.org/index.php/zswap
143 143 if [ "$KERNEL_ZSWAP" = true ] ; then
144 144 set_kernel_config CONFIG_ZPOOL y
145 145 set_kernel_config CONFIG_ZSWAP y
146 146 set_kernel_config CONFIG_ZBUD y
147 147 set_kernel_config CONFIG_Z3FOLD y
148 148 set_kernel_config CONFIG_ZSMALLOC y
149 149 set_kernel_config CONFIG_PGTABLE_MAPPING y
150 150 set_kernel_config CONFIG_LZO_COMPRESS y
151 151 fi
152 152
153 if [ RPI_MODEL = 4 ] ; then
153 if [ "$RPI_MODEL" = 4 ] ; then
154 154 # Following are set in current 32-bit LPAE kernel
155 155 set_kernel_config CONFIG_CGROUP_PIDS y
156 156 set_kernel_config CONFIG_NET_IPVTI m
157 157 set_kernel_config CONFIG_NF_TABLES_SET m
158 158 set_kernel_config CONFIG_NF_TABLES_INET y
159 159 set_kernel_config CONFIG_NF_TABLES_NETDEV y
160 160 set_kernel_config CONFIG_NF_FLOW_TABLE m
161 161 set_kernel_config CONFIG_NFT_FLOW_OFFLOAD m
162 162 set_kernel_config CONFIG_NFT_CONNLIMIT m
163 163 set_kernel_config CONFIG_NFT_TUNNEL m
164 164 set_kernel_config CONFIG_NFT_OBJREF m
165 165 set_kernel_config CONFIG_NFT_FIB_IPV4 m
166 166 set_kernel_config CONFIG_NFT_FIB_IPV6 m
167 167 set_kernel_config CONFIG_NFT_FIB_INET m
168 168 set_kernel_config CONFIG_NFT_SOCKET m
169 169 set_kernel_config CONFIG_NFT_OSF m
170 170 set_kernel_config CONFIG_NFT_TPROXY m
171 171 set_kernel_config CONFIG_NF_DUP_NETDEV m
172 172 set_kernel_config CONFIG_NFT_DUP_NETDEV m
173 173 set_kernel_config CONFIG_NFT_FWD_NETDEV m
174 174 set_kernel_config CONFIG_NFT_FIB_NETDEV m
175 175 set_kernel_config CONFIG_NF_FLOW_TABLE_INET m
176 176 set_kernel_config CONFIG_NF_FLOW_TABLE m
177 177 set_kernel_config CONFIG_NETFILTER_XT_MATCH_SOCKET m
178 178 set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV6 m
179 179 set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV6 m
180 180 set_kernel_config CONFIG_NFT_MASQ_IPV6 m
181 181 set_kernel_config CONFIG_NFT_REDIR_IPV6 m
182 182 set_kernel_config CONFIG_NFT_REJECT_IPV6 m
183 183 set_kernel_config CONFIG_NFT_DUP_IPV6 m
184 184 set_kernel_config CONFIG_NFT_FIB_IPV6 m
185 185 set_kernel_config CONFIG_NF_FLOW_TABLE_IPV6 m
186 186 set_kernel_config CONFIG_NF_TABLES_BRIDGE m
187 187 set_kernel_config CONFIG_NFT_BRIDGE_REJECT m
188 188 set_kernel_config CONFIG_NF_LOG_BRIDGE m
189 189 set_kernel_config CONFIG_MT76_CORE m
190 190 set_kernel_config CONFIG_MT76_LEDS m
191 191 set_kernel_config CONFIG_MT76_USB m
192 192 set_kernel_config CONFIG_MT76x2_COMMON m
193 193 set_kernel_config CONFIG_MT76x0U m
194 194 set_kernel_config CONFIG_MT76x2U m
195 195 set_kernel_config CONFIG_TOUCHSCREEN_ILI210X m
196 196 set_kernel_config CONFIG_BCM_VC_SM m
197 197 set_kernel_config CONFIG_BCM2835_SMI_DEV m
198 198 set_kernel_config CONFIG_RPIVID_MEM m
199 199 set_kernel_config CONFIG_HW_RANDOM_BCM2835 y
200 200 set_kernel_config CONFIG_TCG_TPM m
201 201 set_kernel_config CONFIG_HW_RANDOM_TPM y
202 202 set_kernel_config CONFIG_TCG_TIS m
203 203 set_kernel_config CONFIG_TCG_TIS_SPI m
204 204 set_kernel_config CONFIG_I2C_MUX m
205 205 set_kernel_config CONFIG_I2C_MUX_GPMUX m
206 206 set_kernel_config CONFIG_I2C_MUX_PCA954x m
207 207 set_kernel_config CONFIG_SPI_GPIO m
208 208 set_kernel_config CONFIG_BATTERY_MAX17040 m
209 209 set_kernel_config CONFIG_SENSORS_GPIO_FAN m
210 210 set_kernel_config CONFIG_SENSORS_RASPBERRYPI_HWMON m
211 211 set_kernel_config CONFIG_BCM2835_THERMAL y
212 212 set_kernel_config CONFIG_RC_CORE y
213 213 set_kernel_config CONFIG_RC_MAP y
214 214 set_kernel_config CONFIG_LIRC y
215 215 set_kernel_config CONFIG_RC_DECODERS y
216 216 set_kernel_config CONFIG_IR_NEC_DECODER m
217 217 set_kernel_config CONFIG_IR_RC5_DECODER m
218 218 set_kernel_config CONFIG_IR_RC6_DECODER m
219 219 set_kernel_config CONFIG_IR_JVC_DECODER m
220 220 set_kernel_config CONFIG_IR_SONY_DECODER m
221 221 set_kernel_config CONFIG_IR_SANYO_DECODER m
222 222 set_kernel_config CONFIG_IR_SHARP_DECODER m
223 223 set_kernel_config CONFIG_IR_MCE_KBD_DECODER m
224 224 set_kernel_config CONFIG_IR_XMP_DECODER m
225 225 set_kernel_config CONFIG_IR_IMON_DECODER m
226 226 set_kernel_config CONFIG_RC_DEVICES y
227 227 set_kernel_config CONFIG_RC_ATI_REMOTE m
228 228 set_kernel_config CONFIG_IR_IMON m
229 229 set_kernel_config CONFIG_IR_MCEUSB m
230 230 set_kernel_config CONFIG_IR_REDRAT3 m
231 231 set_kernel_config CONFIG_IR_STREAMZAP m
232 232 set_kernel_config CONFIG_IR_IGUANA m
233 233 set_kernel_config CONFIG_IR_TTUSBIR m
234 234 set_kernel_config CONFIG_RC_LOOPBACK m
235 235 set_kernel_config CONFIG_IR_GPIO_CIR m
236 236 set_kernel_config CONFIG_IR_GPIO_TX m
237 237 set_kernel_config CONFIG_IR_PWM_TX m
238 238 set_kernel_config CONFIG_VIDEO_V4L2_SUBDEV_API y
239 239 set_kernel_config CONFIG_VIDEO_AU0828_RC y
240 240 set_kernel_config CONFIG_VIDEO_CX231XX m
241 241 set_kernel_config CONFIG_VIDEO_CX231XX_RC y
242 242 set_kernel_config CONFIG_VIDEO_CX231XX_ALSA m
243 243 set_kernel_config CONFIG_VIDEO_CX231XX_DVB m
244 244 set_kernel_config CONFIG_VIDEO_TM6000 m
245 245 set_kernel_config CONFIG_VIDEO_TM6000_ALSA m
246 246 set_kernel_config CONFIG_VIDEO_TM6000_DVB m
247 247 set_kernel_config CONFIG_DVB_USB m
248 248 set_kernel_config CONFIG_DVB_USB_DIB3000MC m
249 249 set_kernel_config CONFIG_DVB_USB_A800 m
250 250 set_kernel_config CONFIG_DVB_USB_DIBUSB_MB m
251 251 set_kernel_config CONFIG_DVB_USB_DIBUSB_MB_FAULTY y
252 252 set_kernel_config CONFIG_DVB_USB_DIBUSB_MC m
253 253 set_kernel_config CONFIG_DVB_USB_DIB0700 m
254 254 set_kernel_config CONFIG_DVB_USB_UMT_010 m
255 255 set_kernel_config CONFIG_DVB_USB_CXUSB m
256 256 set_kernel_config CONFIG_DVB_USB_M920X m
257 257 set_kernel_config CONFIG_DVB_USB_DIGITV m
258 258 set_kernel_config CONFIG_DVB_USB_VP7045 m
259 259 set_kernel_config CONFIG_DVB_USB_VP702X m
260 260 set_kernel_config CONFIG_DVB_USB_GP8PSK m
261 261 set_kernel_config CONFIG_DVB_USB_NOVA_T_USB2 m
262 262 set_kernel_config CONFIG_DVB_USB_TTUSB2 m
263 263 set_kernel_config CONFIG_DVB_USB_DTT200U m
264 264 set_kernel_config CONFIG_DVB_USB_OPERA1 m
265 265 set_kernel_config CONFIG_DVB_USB_AF9005 m
266 266 set_kernel_config CONFIG_DVB_USB_AF9005_REMOTE m
267 267 set_kernel_config CONFIG_DVB_USB_PCTV452E m
268 268 set_kernel_config CONFIG_DVB_USB_DW2102 m
269 269 set_kernel_config CONFIG_DVB_USB_CINERGY_T2 m
270 270 set_kernel_config CONFIG_DVB_USB_DTV5100 m
271 271 set_kernel_config CONFIG_DVB_USB_AZ6027 m
272 272 set_kernel_config CONFIG_DVB_USB_TECHNISAT_USB2 m
273 273 set_kernel_config CONFIG_DVB_USB_AF9015 m
274 274 set_kernel_config CONFIG_DVB_USB_LME2510 m
275 275 set_kernel_config CONFIG_DVB_USB_RTL28XXU m
276 276 set_kernel_config CONFIG_VIDEO_EM28XX_RC m
277 277 set_kernel_config CONFIG_SMS_SIANO_RC m
278 278 set_kernel_config CONFIG_VIDEO_IR_I2C m
279 279 set_kernel_config CONFIG_VIDEO_ADV7180 m
280 280 set_kernel_config CONFIG_VIDEO_TC358743 m
281 281 set_kernel_config CONFIG_VIDEO_OV5647 m
282 282 set_kernel_config CONFIG_DVB_M88DS3103 m
283 283 set_kernel_config CONFIG_DVB_AF9013 m
284 284 set_kernel_config CONFIG_DVB_RTL2830 m
285 285 set_kernel_config CONFIG_DVB_RTL2832 m
286 286 set_kernel_config CONFIG_DVB_SI2168 m
287 287 set_kernel_config CONFIG_DVB_GP8PSK_FE m
288 288 set_kernel_config CONFIG_DVB_USB m
289 289 set_kernel_config CONFIG_DVB_LGDT3306A m
290 290 set_kernel_config CONFIG_FB_SIMPLE y
291 291 set_kernel_config CONFIG_SND_BCM2708_SOC_IQAUDIO_CODEC m
292 292 set_kernel_config CONFIG_SND_BCM2708_SOC_I_SABRE_Q2M m
293 293 set_kernel_config CONFIG_SND_AUDIOSENSE_PI m
294 294 set_kernel_config CONFIG_SND_SOC_AD193X m
295 295 set_kernel_config CONFIG_SND_SOC_AD193X_SPI m
296 296 set_kernel_config CONFIG_SND_SOC_AD193X_I2C m
297 297 set_kernel_config CONFIG_SND_SOC_CS4265 m
298 298 set_kernel_config CONFIG_SND_SOC_DA7213 m
299 299 set_kernel_config CONFIG_SND_SOC_ICS43432 m
300 300 set_kernel_config CONFIG_SND_SOC_TLV320AIC32X4 m
301 301 set_kernel_config CONFIG_SND_SOC_TLV320AIC32X4_I2C m
302 302 set_kernel_config CONFIG_SND_SOC_I_SABRE_CODEC m
303 303 set_kernel_config CONFIG_HID_BIGBEN_FF m
304 304 #set_kernel_config CONFIG_USB_XHCI_PLATFORM y
305 305 set_kernel_config CONFIG_USB_TMC m
306 306 set_kernel_config CONFIG_USB_UAS y
307 307 set_kernel_config CONFIG_USBIP_VUDC m
308 308 set_kernel_config CONFIG_USB_CONFIGFS m
309 309 set_kernel_config CONFIG_USB_CONFIGFS_SERIAL y
310 310 set_kernel_config CONFIG_USB_CONFIGFS_ACM y
311 311 set_kernel_config CONFIG_USB_CONFIGFS_OBEX y
312 312 set_kernel_config CONFIG_USB_CONFIGFS_NCM y
313 313 set_kernel_config CONFIG_USB_CONFIGFS_ECM y
314 314 set_kernel_config CONFIG_USB_CONFIGFS_ECM_SUBSET y
315 315 set_kernel_config CONFIG_USB_CONFIGFS_RNDIS y
316 316 set_kernel_config CONFIG_USB_CONFIGFS_EEM y
317 317 set_kernel_config CONFIG_USB_CONFIGFS_MASS_STORAGE y
318 318 set_kernel_config CONFIG_USB_CONFIGFS_F_LB_SS y
319 319 set_kernel_config CONFIG_USB_CONFIGFS_F_FS y
320 320 set_kernel_config CONFIG_USB_CONFIGFS_F_UAC1 y
321 321 set_kernel_config CONFIG_USB_CONFIGFS_F_UAC2 y
322 322 set_kernel_config CONFIG_USB_CONFIGFS_F_MIDI y
323 323 set_kernel_config CONFIG_USB_CONFIGFS_F_HID y
324 324 set_kernel_config CONFIG_USB_CONFIGFS_F_UVC y
325 325 set_kernel_config CONFIG_USB_CONFIGFS_F_PRINTER y
326 326 set_kernel_config CONFIG_LEDS_PCA963X m
327 327 set_kernel_config CONFIG_LEDS_IS31FL32XX m
328 328 set_kernel_config CONFIG_LEDS_TRIGGER_NETDEV m
329 329 set_kernel_config CONFIG_RTC_DRV_RV3028 m
330 330 set_kernel_config CONFIG_AUXDISPLAY y
331 331 set_kernel_config CONFIG_HD44780 m
332 332 set_kernel_config CONFIG_FB_TFT_SH1106 m
333 333 set_kernel_config CONFIG_VIDEO_CODEC_BCM2835 m
334 334 set_kernel_config CONFIG_BCM2835_POWER y
335 335 set_kernel_config CONFIG_INV_MPU6050_IIO m
336 336 set_kernel_config CONFIG_INV_MPU6050_I2C m
337 337 set_kernel_config CONFIG_SECURITYFS y
338 338
339 339 # Safer to build this in
340 340 set_kernel_config CONFIG_BINFMT_MISC y
341 341
342 342 # pulseaudio wants a buffer of at least this size
343 343 set_kernel_config CONFIG_SND_HDA_PREALLOC_SIZE 2048
344 344
345 345 # PR#3063: enable 3D acceleration with 64-bit kernel on RPi4
346 346 # set the appropriate kernel configs unlocked by this PR
347 347 set_kernel_config CONFIG_ARCH_BCM y
348 348 set_kernel_config CONFIG_ARCH_BCM2835 y
349 349 set_kernel_config CONFIG_DRM_V3D m
350 350 set_kernel_config CONFIG_DRM_VC4 m
351 351 set_kernel_config CONFIG_DRM_VC4_HDMI_CEC y
352 352
353 353 # PR#3144: add arm64 pcie bounce buffers; enables 4GiB on RPi4
354 354 # required by PR#3144; should already be applied, but just to be safe
355 355 set_kernel_config CONFIG_PCIE_BRCMSTB y
356 356 set_kernel_config CONFIG_BCM2835_MMC y
357 357
358 358 # Snap needs squashfs. The ubuntu eoan-preinstalled-server image at
359 359 # http://cdimage.ubuntu.com/ubuntu-server/daily-preinstalled/current/ uses snap
360 360 # during cloud-init setup at first boot. Without this the login accounts are not
361 361 # created and the user can not login.
362 362 set_kernel_config CONFIG_SQUASHFS y
363 363
364 364 # Ceph support for Block Device (RBD) and Filesystem (FS)
365 365 # https://docs.ceph.com/docs/master/
366 366 set_kernel_config CONFIG_CEPH_LIB m
367 367 set_kernel_config CONFIG_CEPH_LIB_USE_DNS_RESOLVER y
368 368 set_kernel_config CONFIG_CEPH_FS m
369 369 set_kernel_config CONFIG_CEPH_FSCACHE y
370 370 set_kernel_config CONFIG_CEPH_FS_POSIX_ACL y
371 371 set_kernel_config CONFIG_BLK_DEV_RBD m
372 fi
372 373
373 374 # enable basic KVM support; see https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453
374 375 if [ "$KERNEL_VIRT" = true ] && { [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ]; } ; then
375 376 set_kernel_config CONFIG_HAVE_KVM y
376 377 set_kernel_config CONFIG_HIGH_RES_TIMERS y
377 378 set_kernel_config CONFIG_HAVE_KVM_IRQCHIP y
378 379 set_kernel_config CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL y
379 380 set_kernel_config CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT y
380 381 set_kernel_config CONFIG_HAVE_KVM_EVENTFD y
381 382 set_kernel_config CONFIG_HAVE_KVM_IRQFD y
382 383 set_kernel_config CONFIG_HAVE_KVM_IRQ_ROUTING y
383 384 set_kernel_config CONFIG_HAVE_KVM_MSI y
384 385 set_kernel_config CONFIG_KVM y
385 386 set_kernel_config CONFIG_KVM_ARM_HOST y
386 387 set_kernel_config CONFIG_KVM_ARM_PMU y
387 388 set_kernel_config CONFIG_KVM_COMPAT y
388 389 set_kernel_config CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT y
389 390 set_kernel_config CONFIG_KVM_MMIO y
390 391 set_kernel_config CONFIG_KVM_VFIO y
391 392 set_kernel_config CONFIG_KVM_MMU_AUDIT y
392 393 set_kernel_config CONFIG_VHOST m
393 394 set_kernel_config CONFIG_VHOST_CROSS_ENDIAN_LEGACY y
394 395 set_kernel_config CONFIG_VHOST_NET m
395 396 set_kernel_config CONFIG_VIRTUALIZATION y
396 397 set_kernel_config CONFIG_MMU_NOTIFIER y
397 398
398 399 set_kernel_config CONFIG_SLAB_FREELIST_RANDOM=y
399 400 set_kernel_config CONFIG_SLAB_FREELIST_HARDENED=y
400 401
401 402 # erratum
402 403 set_kernel_config ARM64_ERRATUM_834220 y
403 404 # https://sourceforge.net/p/kvm/mailman/message/18440797/
404 405 set_kernel_config CONFIG_PREEMPT_NOTIFIERS y
405 406 fi
406 407
407 408 # enable apparmor,integrity audit,
408 409 if [ "$KERNEL_SECURITY" = true ] ; then
409 410
410 411 # security filesystem, security models and audit
411 412 set_kernel_config CONFIG_SECURITYFS y
412 413 set_kernel_config CONFIG_SECURITY y
413 414 set_kernel_config CONFIG_AUDIT y
414 415
415 416 # harden strcpy and memcpy
416 417 set_kernel_config CONFIG_HARDENED_USERCOPY y
417 418 set_kernel_config CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR y
418 419 set_kernel_config CONFIG_FORTIFY_SOURCE y
419 420
420 421 # integrity sub-system
421 422 set_kernel_config CONFIG_INTEGRITY y
422 423 set_kernel_config CONFIG_INTEGRITY_ASYMMETRIC_KEYS y
423 424 set_kernel_config CONFIG_INTEGRITY_AUDIT y
424 425 set_kernel_config CONFIG_INTEGRITY_SIGNATURE y
425 426 set_kernel_config CONFIG_INTEGRITY_TRUSTED_KEYRING y
426 427
427 428 # This option provides support for retaining authentication tokens and access keys in the kernel.
428 429 set_kernel_config CONFIG_KEYS y
429 430 set_kernel_config CONFIG_KEYS_COMPAT y
430 431
431 432 # Apparmor
432 433 set_kernel_config CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE 0
433 434 set_kernel_config CONFIG_SECURITY_APPARMOR_HASH_DEFAULT y
434 435 set_kernel_config CONFIG_DEFAULT_SECURITY_APPARMOR y
435 436 set_kernel_config CONFIG_SECURITY_APPARMOR y
436 437 set_kernel_config CONFIG_SECURITY_APPARMOR_HASH y
437 438 set_kernel_config CONFIG_DEFAULT_SECURITY "apparmor"
438 439
439 440 # restrictions on unprivileged users reading the kernel
440 441 set_kernel_config CONFIG_SECURITY_DMESG_RESTRICT y
441 442
442 443 # network security hooks
443 444 set_kernel_config CONFIG_SECURITY_NETWORK y
444 445 set_kernel_config CONFIG_SECURITY_NETWORK_XFRM y
445 446 set_kernel_config CONFIG_SECURITY_PATH y
446 447 set_kernel_config CONFIG_SECURITY_YAMA n
447 448
448 449 set_kernel_config CONFIG_SECURITY_SELINUX n
449 450 set_kernel_config CONFIG_SECURITY_SMACK n
450 451 set_kernel_config CONFIG_SECURITY_TOMOYO n
451 452 set_kernel_config CONFIG_SECURITY_APPARMOR_DEBUG n
452 453 set_kernel_config CONFIG_SECURITY_LOADPIN n
453 454 set_kernel_config CONFIG_HARDENED_USERCOPY_PAGESPAN n
454 455 set_kernel_config CONFIG_IMA n
455 456 set_kernel_config CONFIG_EVM n
456 457 set_kernel_config CONFIG_FANOTIFY_ACCESS_PERMISSIONS y
457 458 set_kernel_config CONFIG_NFSD_V4_SECURITY_LABEL y
458 459 set_kernel_config CONFIG_PKCS7_MESSAGE_PARSER y
459 460 set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYRING y
460 461 set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE y
461 462 set_kernel_config CONFIG_SECONDARY_TRUSTED_KEYRING y
462 463 set_kernel_config CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY n
463 464 set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS m
464 465 set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE 4096
465 466
466 467 set_kernel_config CONFIG_ARM64_CRYPTO y
467 468 set_kernel_config CONFIG_CRYPTO_SHA256_ARM64 m
468 469 set_kernel_config CONFIG_CRYPTO_SHA512_ARM64 m
469 470 set_kernel_config CONFIG_CRYPTO_SHA1_ARM64_CE m
470 471 set_kernel_config CRYPTO_GHASH_ARM64_CE m
471 472 set_kernel_config CRYPTO_SHA2_ARM64_CE m
472 473 set_kernel_config CONFIG_CRYPTO_CRCT10DIF_ARM64_CE m
473 474 set_kernel_config CONFIG_CRYPTO_CRC32_ARM64_CE m
474 475 set_kernel_config CONFIG_CRYPTO_AES_ARM64 m
475 476 set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE m
476 477 set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_CCM y
477 478 set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_BLK y
478 479 set_kernel_config CONFIG_CRYPTO_AES_ARM64_NEON_BLK m
479 480 set_kernel_config CONFIG_CRYPTO_CHACHA20_NEON m
480 481 set_kernel_config CONFIG_CRYPTO_AES_ARM64_BS m
481 482 fi
482 483
483 484 # Netfilter kernel support See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406
484 485 if [ "$KERNEL_NF" = true ] ; then
485 486 set_kernel_config CONFIG_IP_NF_SECURITY m
486 487 set_kernel_config CONFIG_NETLABEL y
487 488 set_kernel_config CONFIG_IP6_NF_SECURITY m
488 489 set_kernel_config CONFIG_IP_NF_TARGET_SYNPROXY m
489 490 set_kernel_config CONFIG_NETFILTER_XT_TARGET_AUDIT m
490 491 set_kernel_config CONFIG_NETFILTER_XT_MATCH_CGROUP m
491 492 set_kernel_config CONFIG_NETFILTER_XT_MATCH_IPCOMP m
492 493 set_kernel_config CONFIG_NETFILTER_XT_MATCH_SOCKET m
493 494 set_kernel_config CONFIG_NFT_FIB_INET m
494 495 set_kernel_config CONFIG_NFT_FIB_IPV4 m
495 496 set_kernel_config CONFIG_NFT_FIB_IPV6 m
496 497 set_kernel_config CONFIG_NFT_FIB_NETDEV m
497 498 set_kernel_config CONFIG_NFT_OBJREF m
498 499 set_kernel_config CONFIG_NFT_RT m
499 500 set_kernel_config CONFIG_NFT_SET_BITMAP m
500 501 set_kernel_config CONFIG_NF_CONNTRACK_TIMEOUT y
501 502 set_kernel_config CONFIG_NF_LOG_ARP m
502 503 set_kernel_config CONFIG_NF_SOCKET_IPV4 m
503 504 set_kernel_config CONFIG_NF_SOCKET_IPV6 m
504 505 set_kernel_config CONFIG_BRIDGE_EBT_BROUTE m
505 506 set_kernel_config CONFIG_BRIDGE_EBT_T_FILTER m
506 507 set_kernel_config CONFIG_BRIDGE_NF_EBTABLES m
507 508 set_kernel_config CONFIG_IP6_NF_IPTABLES m
508 509 set_kernel_config CONFIG_IP6_NF_MATCH_AH m
509 510 set_kernel_config CONFIG_IP6_NF_MATCH_EUI64 m
510 511 set_kernel_config CONFIG_IP6_NF_NAT m
511 512 set_kernel_config CONFIG_IP6_NF_TARGET_MASQUERADE m
512 513 set_kernel_config CONFIG_IP6_NF_TARGET_NPT m
513 514 set_kernel_config CONFIG_IP_SET_BITMAP_IPMAC m
514 515 set_kernel_config CONFIG_IP_SET_BITMAP_PORT m
515 516 set_kernel_config CONFIG_IP_SET_HASH_IP m
516 517 set_kernel_config CONFIG_IP_SET_HASH_IPMARK m
517 518 set_kernel_config CONFIG_IP_SET_HASH_IPPORT m
518 519 set_kernel_config CONFIG_IP_SET_HASH_IPPORTIP m
519 520 set_kernel_config CONFIG_IP_SET_HASH_IPPORTNET m
520 521 set_kernel_config CONFIG_IP_SET_HASH_MAC m
521 522 set_kernel_config CONFIG_IP_SET_HASH_NET m
522 523 set_kernel_config CONFIG_IP_SET_HASH_NETIFACE m
523 524 set_kernel_config CONFIG_IP_SET_HASH_NETNET m
524 525 set_kernel_config CONFIG_IP_SET_HASH_NETPORT m
525 526 set_kernel_config CONFIG_IP_SET_HASH_NETPORTNET m
526 527 set_kernel_config CONFIG_IP_SET_LIST_SET m
527 528 set_kernel_config CONFIG_NETFILTER_XTABLES m
528 529 set_kernel_config CONFIG_NETFILTER_XTABLES m
529 530 set_kernel_config CONFIG_NFT_BRIDGE_META m
530 531 set_kernel_config CONFIG_NFT_BRIDGE_REJECT m
531 532 set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV4 m
532 533 set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV6 m
533 534 set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV4 m
534 535 set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV6 m
535 536 set_kernel_config CONFIG_NFT_COMPAT m
536 537 set_kernel_config CONFIG_NFT_COUNTER m
537 538 set_kernel_config CONFIG_NFT_CT m
538 539 set_kernel_config CONFIG_NFT_DUP_IPV4 m
539 540 set_kernel_config CONFIG_NFT_DUP_IPV6 m
540 541 set_kernel_config CONFIG_NFT_DUP_NETDEV m
541 542 set_kernel_config CONFIG_NFT_EXTHDR m
542 543 set_kernel_config CONFIG_NFT_FWD_NETDEV m
543 544 set_kernel_config CONFIG_NFT_HASH m
544 545 set_kernel_config CONFIG_NFT_LIMIT m
545 546 set_kernel_config CONFIG_NFT_LOG m
546 547 set_kernel_config CONFIG_NFT_MASQ m
547 548 set_kernel_config CONFIG_NFT_MASQ_IPV4 m
548 549 set_kernel_config CONFIG_NFT_MASQ_IPV6 m
549 550 set_kernel_config CONFIG_NFT_META m
550 551 set_kernel_config CONFIG_NFT_NAT m
551 552 set_kernel_config CONFIG_NFT_NUMGEN m
552 553 set_kernel_config CONFIG_NFT_QUEUE m
553 554 set_kernel_config CONFIG_NFT_QUOTA m
554 555 set_kernel_config CONFIG_NFT_REDIR m
555 556 set_kernel_config CONFIG_NFT_REDIR_IPV4 m
556 557 set_kernel_config CONFIG_NFT_REDIR_IPV6 m
557 558 set_kernel_config CONFIG_NFT_REJECT m
558 559 set_kernel_config CONFIG_NFT_REJECT_INET m
559 560 set_kernel_config CONFIG_NFT_REJECT_IPV4 m
560 561 set_kernel_config CONFIG_NFT_REJECT_IPV6 m
561 562 set_kernel_config CONFIG_NFT_SET_HASH m
562 563 set_kernel_config CONFIG_NFT_SET_RBTREE m
563 564 set_kernel_config CONFIG_NF_CONNTRACK_IPV4 m
564 565 set_kernel_config CONFIG_NF_CONNTRACK_IPV6 m
565 566 set_kernel_config CONFIG_NF_DEFRAG_IPV4 m
566 567 set_kernel_config CONFIG_NF_DEFRAG_IPV6 m
567 568 set_kernel_config CONFIG_NF_DUP_IPV4 m
568 569 set_kernel_config CONFIG_NF_DUP_IPV6 m
569 570 set_kernel_config CONFIG_NF_DUP_NETDEV m
570 571 set_kernel_config CONFIG_NF_LOG_BRIDGE m
571 572 set_kernel_config CONFIG_NF_LOG_IPV4 m
572 573 set_kernel_config CONFIG_NF_LOG_IPV6 m
573 574 set_kernel_config CONFIG_NF_NAT_IPV4 m
574 575 set_kernel_config CONFIG_NF_NAT_IPV6 m
575 576 set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV4 y
576 577 set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV6 y
577 578 set_kernel_config CONFIG_NF_NAT_PPTP m
578 579 set_kernel_config CONFIG_NF_NAT_PROTO_GRE m
579 580 set_kernel_config CONFIG_NF_NAT_REDIRECT y
580 581 set_kernel_config CONFIG_NF_NAT_SIP m
581 582 set_kernel_config CONFIG_NF_NAT_SNMP_BASIC m
582 583 set_kernel_config CONFIG_NF_NAT_TFTP m
583 584 set_kernel_config CONFIG_NF_REJECT_IPV4 m
584 585 set_kernel_config CONFIG_NF_REJECT_IPV6 m
585 586 set_kernel_config CONFIG_NF_TABLES m
586 587 set_kernel_config CONFIG_NF_TABLES_ARP m
587 588 set_kernel_config CONFIG_NF_TABLES_BRIDGE m
588 589 set_kernel_config CONFIG_NF_TABLES_INET m
589 590 set_kernel_config CONFIG_NF_TABLES_IPV4 y
590 591 set_kernel_config CONFIG_NF_TABLES_IPV6 y
591 592 set_kernel_config CONFIG_NF_TABLES_NETDEV m
592 593 set_kernel_config CONFIG_NF_TABLES_SET m
593 594 set_kernel_config CONFIG_NF_TABLES_INET y
594 595 set_kernel_config CONFIG_NF_TABLES_NETDEV y
595 596 set_kernel_config CONFIG_NFT_CONNLIMIT m
596 597 set_kernel_config CONFIG_NFT_TUNNEL m
597 598 set_kernel_config CONFIG_NFT_SOCKET m
598 599 set_kernel_config CONFIG_NFT_TPROXY m
599 600 set_kernel_config CONFIG_NF_FLOW_TABLE m
600 601 set_kernel_config CONFIG_NFT_FLOW_OFFLOAD m
601 602 set_kernel_config CONFIG_NF_FLOW_TABLE_INET m
602 603 set_kernel_config CONFIG_NF_TABLES_ARP y
603 604 set_kernel_config CONFIG_NF_FLOW_TABLE_IPV4 y
604 605 set_kernel_config CONFIG_NF_FLOW_TABLE_IPV6 y
605 606 set_kernel_config CONFIG_NF_TABLES_BRIDGE y
606 607 set_kernel_config CONFIG_NF_CT_NETLINK_TIMEOUT m
607 608 set_kernel_config CONFIG_NFT_OSF m
608 609
609 610 fi
610 611
611 612 # Enables BPF syscall for systemd-journald see https://github.com/torvalds/linux/blob/master/init/Kconfig#L848 or https://groups.google.com/forum/#!topic/linux.gentoo.user/_2aSc_ztGpA
612 613 if [ "$KERNEL_BPF" = true ] ; then
613 614 set_kernel_config CONFIG_BPF_SYSCALL y
614 615 set_kernel_config CONFIG_BPF_EVENTS y
615 616 set_kernel_config CONFIG_BPF_STREAM_PARSER y
616 617 set_kernel_config CONFIG_CGROUP_BPF y
617 618 set_kernel_config CONFIG_XDP_SOCKETS y
618 619 fi
619 620
620 621 # KERNEL_DEFAULT_GOV was set by user
621 622 if [ "$KERNEL_DEFAULT_GOV" != powersave ] && [ -n "$KERNEL_DEFAULT_GOV" ] ; then
622 623
623 624 case "$KERNEL_DEFAULT_GOV" in
624 625 performance)
625 626 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE y
626 627 ;;
627 628 userspace)
628 629 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE y
629 630 ;;
630 631 ondemand)
631 632 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND y
632 633 ;;
633 634 conservative)
634 635 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE y
635 636 ;;
636 637 shedutil)
637 638 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL y
638 639 ;;
639 640 *)
640 641 echo "error: unsupported default cpu governor"
641 642 exit 1
642 643 ;;
643 644 esac
644 645
645 646 # unset previous default governor
646 647 unset_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE
647 648 fi
648 649
649 650 #Revert to previous directory
650 651 cd "${WORKDIR}" || exit
651 652
652 653 # Set kernel configuration parameters to enable qemu emulation
653 654 if [ "$ENABLE_QEMU" = true ] ; then
654 655 echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config
655 656 echo "CONFIG_LBDAF=y" >> "${KERNEL_DIR}"/.config
656 657
657 658 if [ "$KERNEL_CRYPTFS" = true ] ; then
658 659 {
659 660 echo "CONFIG_EMBEDDED=y"
660 661 echo "CONFIG_EXPERT=y"
661 662 echo "CONFIG_DAX=y"
662 663 echo "CONFIG_MD=y"
663 664 echo "CONFIG_BLK_DEV_MD=y"
664 665 echo "CONFIG_MD_AUTODETECT=y"
665 666 echo "CONFIG_BLK_DEV_DM=y"
666 667 echo "CONFIG_BLK_DEV_DM_BUILTIN=y"
667 668 echo "CONFIG_DM_CRYPT=y"
668 669 echo "CONFIG_CRYPTO_BLKCIPHER=y"
669 670 echo "CONFIG_CRYPTO_CBC=y"
670 671 echo "CONFIG_CRYPTO_XTS=y"
671 672 echo "CONFIG_CRYPTO_SHA512=y"
672 673 echo "CONFIG_CRYPTO_MANAGER=y"
673 674 } >> "${KERNEL_DIR}"/.config
674 675 fi
675 676 fi
676 677
677 678 # Copy custom kernel configuration file
678 679 if [ -n "$KERNELSRC_USRCONFIG" ] ; then
679 680 cp "$KERNELSRC_USRCONFIG" "${KERNEL_DIR}"/.config
680 681 fi
681 682
682 683 # Set kernel configuration parameters to their default values
683 684 if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then
684 685 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig
685 686 fi
686 687
687 688 # Start menu-driven kernel configuration (interactive)
688 689 if [ "$KERNEL_MENUCONFIG" = true ] ; then
689 690 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
690 691 fi
691 692 # end if "$KERNELSRC_CONFIG" = true
692 693 fi
693 694
694 695 # Use ccache to cross compile the kernel
695 696 if [ "$KERNEL_CCACHE" = true ] ; then
696 697 cc="ccache ${CROSS_COMPILE}gcc"
697 698 else
698 699 cc="${CROSS_COMPILE}gcc"
699 700 fi
700 701
701 702 # Cross compile kernel and dtbs
702 703 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
703 704
704 705 # Cross compile kernel modules
705 706 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
706 707 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
707 708 fi
708 709 # end if "$KERNELSRC_PREBUILT" = false
709 710 fi
710 711
711 712 # Check if kernel compilation was successful
712 713 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then
713 714 echo "error: kernel compilation failed! (kernel image not found)"
714 715 cleanup
715 716 exit 1
716 717 fi
717 718
718 719 # Install kernel modules
719 720 if [ "$ENABLE_REDUCE" = true ] ; then
720 721 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
721 722 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
722 723 fi
723 724 else
724 725 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
725 726 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
726 727 fi
727 728
728 729 # Install kernel firmware
729 730 if grep -q "^firmware_install:" "${KERNEL_DIR}/Makefile" ; then
730 731 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
731 732 fi
732 733 fi
733 734
734 735 # Install kernel headers
735 736 if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then
736 737 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
737 738 fi
738 739
739 740 # Prepare boot (firmware) directory
740 741 mkdir "${BOOT_DIR}"
741 742
742 743 # Get kernel release version
743 744 KERNEL_VERSION=$(cat "${KERNEL_DIR}/include/config/kernel.release")
744 745
745 746 # Copy kernel configuration file to the boot directory
746 747 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
747 748
748 749 # Prepare device tree directory
749 750 mkdir "${BOOT_DIR}/overlays"
750 751
751 752 # Ensure the proper .dtb is located
752 753 if [ "$KERNEL_ARCH" = "arm" ] ; then
753 754 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do
754 755 if [ -f "${dtb}" ] ; then
755 756 install_readonly "${dtb}" "${BOOT_DIR}/"
756 757 fi
757 758 done
758 759 else
759 760 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do
760 761 if [ -f "${dtb}" ] ; then
761 762 install_readonly "${dtb}" "${BOOT_DIR}/"
762 763 fi
763 764 done
764 765 fi
765 766
766 767 # Copy compiled dtb device tree files
767 768 if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then
768 769 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtbo ; do
769 770 if [ -f "${dtb}" ] ; then
770 771 install_readonly "${dtb}" "${BOOT_DIR}/overlays/"
771 772 fi
772 773 done
773 774
774 775 if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then
775 776 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
776 777 fi
777 778 fi
778 779
779 780 if [ "$ENABLE_UBOOT" = false ] ; then
780 781 # Convert and copy kernel image to the boot directory
781 782 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
782 783 else
783 784 # Copy kernel image to the boot directory
784 785 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
785 786 fi
786 787
787 788 # Remove kernel sources
788 789 if [ "$KERNEL_REMOVESRC" = true ] ; then
789 790 rm -fr "${KERNEL_DIR}"
790 791 else
791 792 # Prepare compiled kernel modules
792 793 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
793 794 if grep -q "^modules_prepare:" "${KERNEL_DIR}/Makefile" ; then
794 795 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
795 796 fi
796 797
797 798 # Create symlinks for kernel modules
798 799 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build"
799 800 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source"
800 801 fi
801 802 fi
802 803
803 804 else # BUILD_KERNEL=false
804 805 if [ "$SET_ARCH" = 64 ] ; then
805 806 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
806 807 # Use Sakakis modified kernel if ZSWAP is active
807 808 if [ "$KERNEL_ZSWAP" = true ] || [ "$KERNEL_VIRT" = true ] || [ "$KERNEL_NF" = true ] || [ "$KERNEL_BPF" = true ] ; then
808 809 RPI3_64_KERNEL_URL="${RPI3_64_BIS_KERNEL_URL}"
809 810 fi
810 811
811 812 # Create temporary directory for dl
812 813 temp_dir=$(as_nobody mktemp -d)
813 814
814 815 # Fetch kernel dl
815 816 as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL"
816 817 fi
817 818 if [ "$SET_ARCH" = 64 ] && [ "$RPI_MODEL" = 4 ] ; then
818 819 # Create temporary directory for dl
819 820 temp_dir=$(as_nobody mktemp -d)
820 821
821 822 # Fetch kernel dl
822 823 as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI4_64_KERNEL_URL"
823 824 fi
824 825
825 826 #extract download
826 827 tar -xJf "${temp_dir}"/kernel.tar.xz -C "${temp_dir}"
827 828
828 829 #move extracted kernel to /boot/firmware
829 830 mkdir "${R}/boot/firmware"
830 831 cp "${temp_dir}"/boot/* "${R}"/boot/firmware/
831 832 cp -r "${temp_dir}"/lib/* "${R}"/lib/
832 833
833 834 # Remove temporary directory for kernel sources
834 835 rm -fr "${temp_dir}"
835 836
836 837 # Set permissions of the kernel sources
837 838 chown -R root:root "${R}/boot/firmware"
838 839 chown -R root:root "${R}/lib/modules"
839 840 fi
840 841
841 842 # Install Kernel from hypriot comptabile with all Raspberry PI (dunno if its compatible with RPI4 - better compile your own kernel)
842 843 if [ "$SET_ARCH" = 32 ] && [ "$RPI_MODEL" != 4 ] ; then
843 844 # Create temporary directory for dl
844 845 temp_dir=$(as_nobody mktemp -d)
845 846
846 847 # Fetch kernel
847 848 as_nobody wget -O "${temp_dir}"/kernel.deb -c "$RPI_32_KERNEL_URL"
848 849
849 850 # Copy downloaded kernel package
850 851 mv "${temp_dir}"/kernel.deb "${R}"/tmp/kernel.deb
851 852
852 853 # Set permissions
853 854 chown -R root:root "${R}"/tmp/kernel.deb
854 855
855 856 # Install kernel
856 857 chroot_exec dpkg -i /tmp/kernel.deb
857 858
858 859 # move /boot to /boot/firmware to fit script env.
859 860 #mkdir "${BOOT_DIR}"
860 861 mkdir "${temp_dir}"/firmware
861 862 mv "${R}"/boot/* "${temp_dir}"/firmware/
862 863 mv "${temp_dir}"/firmware "${R}"/boot/
863 864
864 865 #same for kernel headers
865 866 if [ "$KERNEL_HEADERS" = true ] ; then
866 867 # Fetch kernel header
867 868 as_nobody wget -O "${temp_dir}"/kernel-header.deb -c "$RPI_32_KERNELHEADER_URL"
868 869 mv "${temp_dir}"/kernel-header.deb "${R}"/tmp/kernel-header.deb
869 870 chown -R root:root "${R}"/tmp/kernel-header.deb
870 871 # Install kernel header
871 872 chroot_exec dpkg -i /tmp/kernel-header.deb
872 873 rm -f "${R}"/tmp/kernel-header.deb
873 874 fi
874 875
875 876 # Remove temporary directory and files
876 877 rm -fr "${temp_dir}"
877 878 rm -f "${R}"/tmp/kernel.deb
878 879 fi
879 880
880 881 # Check if kernel installation was successful
881 882 KERNEL="$(ls -1 "${R}"/boot/firmware/kernel* | sort | tail -n 1)"
882 883 if [ -z "$KERNEL" ] ; then
883 884 echo "error: kernel installation failed! (/boot/kernel* not found)"
884 885 cleanup
885 886 exit 1
886 887 fi
887 888 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant