@@ -1,102 +1,102 | |||
|
1 | 1 | # |
|
2 | 2 | # Kernel installation |
|
3 | 3 | # |
|
4 | 4 | |
|
5 | 5 | . ./functions.sh |
|
6 | 6 | |
|
7 | 7 | # Fetch and build latest raspberry kernel |
|
8 | 8 | if [ "$BUILD_KERNEL" = true ] ; then |
|
9 | 9 | # Fetch current raspberrypi kernel sources |
|
10 | 10 | git -C $R/usr/local/src clone --depth=1 https://github.com/raspberrypi/linux |
|
11 | 11 | |
|
12 | 12 | # Load default raspberry kernel configuration |
|
13 | 13 | make -C $R/usr/local/src/linux ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig |
|
14 | 14 | |
|
15 | 15 | # Cross compile kernel and modules |
|
16 | 16 | make -C $R/usr/local/src/linux -j$(grep -c processor /proc/cpuinfo) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs |
|
17 | 17 | |
|
18 | 18 | # Install kernel modules |
|
19 | 19 | make -C $R/usr/local/src/linux ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../.. modules_install |
|
20 | 20 | |
|
21 | 21 | # Install kernel headers |
|
22 | 22 | if [ "$KERNEL_HEADERS" = true ]; then |
|
23 | 23 | make -C $R/usr/local/src/linux ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_HDR_PATH=../../usr headers_install |
|
24 | 24 | fi |
|
25 | 25 | |
|
26 | 26 | # Copy and rename compiled kernel to boot directory |
|
27 | 27 | mkdir $R/boot/firmware/ |
|
28 | 28 | $R/usr/local/src/linux/scripts/mkknlimg $R/usr/local/src/linux/arch/arm/boot/zImage $R/boot/firmware/kernel7.img |
|
29 | 29 | |
|
30 | 30 | # Copy dts and dtb device definitions |
|
31 | 31 | mkdir $R/boot/firmware/overlays/ |
|
32 | 32 | cp $R/usr/local/src/linux/arch/arm/boot/dts/*.dtb $R/boot/firmware/ |
|
33 | 33 | cp $R/usr/local/src/linux/arch/arm/boot/dts/overlays/*.dtb* $R/boot/firmware/overlays/ |
|
34 | 34 | cp $R/usr/local/src/linux/arch/arm/boot/dts/overlays/README $R/boot/firmware/overlays/ |
|
35 | 35 | |
|
36 | 36 | # Install raspberry bootloader and flash-kernel |
|
37 | 37 | chroot_exec apt-get -qq -y --no-install-recommends install raspberrypi-bootloader-nokernel |
|
38 | 38 | else |
|
39 | 39 | # Kernel installation |
|
40 | 40 | chroot_exec apt-get -qq -y --no-install-recommends install linux-image-${KERNEL} raspberrypi-bootloader-nokernel |
|
41 | 41 | |
|
42 | 42 | # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot |
|
43 | 43 | chroot_exec apt-get -qq -y install flash-kernel |
|
44 | 44 | |
|
45 | 45 | VMLINUZ="$(ls -1 $R/boot/vmlinuz-* | sort | tail -n 1)" |
|
46 | 46 | [ -z "$VMLINUZ" ] && exit 1 |
|
47 | 47 | cp $VMLINUZ $R/boot/firmware/kernel7.img |
|
48 | 48 | fi |
|
49 | 49 | |
|
50 | 50 | # Set up firmware boot cmdline |
|
51 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait net.ifnames=1 console=tty1" | |
|
51 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait net.ifnames=1 console=tty1 ${CMDLINE}" | |
|
52 | 52 | |
|
53 | 53 | # Set up serial console support (if requested) |
|
54 | 54 | if [ "$ENABLE_CONSOLE" = true ] ; then |
|
55 | 55 | CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200" |
|
56 | 56 | fi |
|
57 | 57 | |
|
58 | 58 | # Set up IPv6 networking support |
|
59 | 59 | if [ "$ENABLE_IPV6" = false ] ; then |
|
60 | 60 | CMDLINE="${CMDLINE} ipv6.disable=1" |
|
61 | 61 | fi |
|
62 | 62 | |
|
63 | 63 | echo "${CMDLINE}" >$R/boot/firmware/cmdline.txt |
|
64 | 64 | |
|
65 | 65 | # Set up firmware config |
|
66 | 66 | install -o root -g root -m 644 files/config.txt $R/boot/firmware/config.txt |
|
67 | 67 | |
|
68 | 68 | # Load snd_bcm2835 kernel module at boot time |
|
69 | 69 | if [ "$ENABLE_SOUND" = true ] ; then |
|
70 | 70 | echo "snd_bcm2835" >>$R/etc/modules |
|
71 | 71 | fi |
|
72 | 72 | |
|
73 | 73 | # Set smallest possible GPU memory allocation size: 16MB (no X) |
|
74 | 74 | if [ "$ENABLE_MINGPU" = true ] ; then |
|
75 | 75 | echo "gpu_mem=16" >>$R/boot/firmware/config.txt |
|
76 | 76 | fi |
|
77 | 77 | |
|
78 | 78 | # Create symlinks |
|
79 | 79 | ln -sf firmware/config.txt $R/boot/config.txt |
|
80 | 80 | ln -sf firmware/cmdline.txt $R/boot/cmdline.txt |
|
81 | 81 | |
|
82 | 82 | # Prepare modules-load.d directory |
|
83 | 83 | mkdir -p $R/lib/modules-load.d/ |
|
84 | 84 | |
|
85 | 85 | # Load random module on boot |
|
86 | 86 | if [ "$ENABLE_HWRANDOM" = true ] ; then |
|
87 | 87 | cat <<EOM >$R/lib/modules-load.d/rpi2.conf |
|
88 | 88 | bcm2708_rng |
|
89 | 89 | EOM |
|
90 | 90 | fi |
|
91 | 91 | |
|
92 | 92 | # Prepare modprobe.d directory |
|
93 | 93 | mkdir -p $R/etc/modprobe.d/ |
|
94 | 94 | |
|
95 | 95 | # Blacklist sound modules |
|
96 | 96 | install -o root -g root -m 644 files/modprobe.d/raspi-blacklist.conf $R/etc/modprobe.d/raspi-blacklist.conf |
|
97 | 97 | |
|
98 | 98 | # Create default fstab |
|
99 | 99 | install -o root -g root -m 644 files/fstab $R/etc/fstab |
|
100 | 100 | |
|
101 | 101 | # Avoid swapping and increase cache sizes |
|
102 | 102 | install -o root -g root -m 644 files/sysctl.d/81-rpi-vm.conf $R/etc/sysctl.d/81-rpi-vm.conf |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant