@@ -152,6 +152,10 Enable IPv4/IPv6 network stack hardening settings. | |||||
152 | ##### `CHROOT_SCRIPTS`="" |
|
152 | ##### `CHROOT_SCRIPTS`="" | |
153 | Path to a directory with scripts that should be run in the chroot before the image is finally built. Every executable file in this direcory is run in lexicographical order. |
|
153 | Path to a directory with scripts that should be run in the chroot before the image is finally built. Every executable file in this direcory is run in lexicographical order. | |
154 |
|
154 | |||
|
155 | #### Kernel compilation: | |||
|
156 | ##### `BUILD_KERNEL`=false | |||
|
157 | Build and install the latest RPi2 linux kernel. Currently only the default RPi2 kernel configuration is used. Detailed configuration parameters for customizing the kernel and minor bug fixes still need to get implemented. feel free to help. | |||
|
158 | ||||
155 | ## Logging of the bootstrapping process |
|
159 | ## Logging of the bootstrapping process | |
156 | All information related to the bootstrapping process and the commands executed by the `rpi2-gen-image.sh` script can easily be saved into a logfile. The common shell command `script` can be used for this purpose: |
|
160 | All information related to the bootstrapping process and the commands executed by the `rpi2-gen-image.sh` script can easily be saved into a logfile. The common shell command `script` can be used for this purpose: | |
157 |
|
161 |
@@ -95,6 +95,9 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} | |||||
95 | ENABLE_HARDNET=${ENABLE_HARDNET:=false} |
|
95 | ENABLE_HARDNET=${ENABLE_HARDNET:=false} | |
96 | ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} |
|
96 | ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} | |
97 |
|
97 | |||
|
98 | # Kernel compilation settings | |||
|
99 | BUILD_KERNEL=${BUILD_KERNEL:=false} | |||
|
100 | ||||
98 | # Image chroot path |
|
101 | # Image chroot path | |
99 | R=${BUILDDIR}/chroot |
|
102 | R=${BUILDDIR}/chroot | |
100 | CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} |
|
103 | CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} | |
@@ -117,6 +120,11 if [ "$(id -u)" -ne "0" ] ; then | |||||
117 | exit 1 |
|
120 | exit 1 | |
118 | fi |
|
121 | fi | |
119 |
|
122 | |||
|
123 | # Add packages required for kernel cross compilation | |||
|
124 | if [ "$BUILD_KERNEL" = true ] ; then | |||
|
125 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" | |||
|
126 | fi | |||
|
127 | ||||
120 | # Check if all required packages are installed |
|
128 | # Check if all required packages are installed | |
121 | for package in $REQUIRED_PACKAGES ; do |
|
129 | for package in $REQUIRED_PACKAGES ; do | |
122 | if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then |
|
130 | if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then | |
@@ -317,14 +325,43 if [ "$ENABLE_MINBASE" = false ] ; then | |||||
317 | chroot_exec dpkg-reconfigure -f noninteractive console-setup |
|
325 | chroot_exec dpkg-reconfigure -f noninteractive console-setup | |
318 | fi |
|
326 | fi | |
319 |
|
327 | |||
|
328 | # Fetch and build latest raspberry kernel | |||
|
329 | if [ "$BUILD_KERNEL" = true ] ; then | |||
|
330 | # Fetch current raspberrypi kernel sources | |||
|
331 | git -C $R/tmp clone --depth=1 https://github.com/raspberrypi/linux | |||
|
332 | ||||
|
333 | # Load default raspberry kernel configuration | |||
|
334 | make -C $R/tmp/linux ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig | |||
|
335 | ||||
|
336 | # Cross compile kernel and modules | |||
|
337 | make -C $R/tmp/linux -j 8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs | |||
|
338 | ||||
|
339 | # Install kernel modules | |||
|
340 | make -C $R/tmp/linux ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../.. modules_install | |||
|
341 | ||||
|
342 | # Copy and rename compiled kernel to boot directory | |||
|
343 | mkdir $R/boot/firmware/ | |||
|
344 | $R/tmp/linux/scripts/mkknlimg $R/tmp/linux/arch/arm/boot/zImage $R/boot/firmware/kernel7.img | |||
|
345 | ||||
|
346 | # Copy dts and dtb device definitions | |||
|
347 | mkdir $R/boot/firmware/overlays/ | |||
|
348 | cp $R/tmp/linux/arch/arm/boot/dts/*.dtb $R/boot/firmware/ | |||
|
349 | cp $R/tmp/linux/arch/arm/boot/dts/overlays/*.dtb* $R/boot/firmware/overlays/ | |||
|
350 | cp $R/tmp/linux/arch/arm/boot/dts/overlays/README $R/boot/firmware/overlays/ | |||
|
351 | ||||
|
352 | # Install raspberry bootloader and flash-kernel | |||
|
353 | chroot_exec apt-get -qq -y --no-install-recommends install raspberrypi-bootloader-nokernel | |||
|
354 | else | |||
320 | # Kernel installation |
|
355 | # Kernel installation | |
321 | # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot |
|
|||
322 | chroot_exec apt-get -qq -y --no-install-recommends install linux-image-${KERNEL} raspberrypi-bootloader-nokernel |
|
356 | chroot_exec apt-get -qq -y --no-install-recommends install linux-image-${KERNEL} raspberrypi-bootloader-nokernel | |
|
357 | ||||
|
358 | # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot | |||
323 | chroot_exec apt-get -qq -y install flash-kernel |
|
359 | chroot_exec apt-get -qq -y install flash-kernel | |
324 |
|
360 | |||
325 | VMLINUZ="$(ls -1 $R/boot/vmlinuz-* | sort | tail -n 1)" |
|
361 | VMLINUZ="$(ls -1 $R/boot/vmlinuz-* | sort | tail -n 1)" | |
326 | [ -z "$VMLINUZ" ] && exit 1 |
|
362 | [ -z "$VMLINUZ" ] && exit 1 | |
327 | cp $VMLINUZ $R/boot/firmware/kernel7.img |
|
363 | cp $VMLINUZ $R/boot/firmware/kernel7.img | |
|
364 | fi | |||
328 |
|
365 | |||
329 | # Set up IPv4 hosts |
|
366 | # Set up IPv4 hosts | |
330 | echo ${HOSTNAME} >$R/etc/hostname |
|
367 | echo ${HOSTNAME} >$R/etc/hostname |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant