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