##// END OF EJS Templates
Make symlinks in /lib/modules/
Michal Svamberg -
r105:a38e66ced2d0
parent child
Show More
@@ -1,314 +1,319
1 #
1 #
2 # Build and Setup RPi2/3 Kernel
2 # Build and Setup RPi2/3 Kernel
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Fetch and build latest raspberry kernel
8 # Fetch and build latest raspberry kernel
9 if [ "$BUILD_KERNEL" = true ] ; then
9 if [ "$BUILD_KERNEL" = true ] ; then
10 # Setup source directory
10 # Setup source directory
11 mkdir -p "${R}/usr/src"
11 mkdir -p "${R}/usr/src"
12
12
13 # Copy existing kernel sources into chroot directory
13 # Copy existing kernel sources into chroot directory
14 if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then
14 if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then
15 # Copy kernel sources
15 # Copy kernel sources
16 cp -r "${KERNELSRC_DIR}" "${R}/usr/src"
16 cp -r "${KERNELSRC_DIR}" "${R}/usr/src"
17
17
18 # Clean the kernel sources
18 # Clean the kernel sources
19 if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then
19 if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then
20 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper
20 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper
21 fi
21 fi
22 else # KERNELSRC_DIR=""
22 else # KERNELSRC_DIR=""
23 # Fetch current raspberrypi kernel sources
23 # Fetch current raspberrypi kernel sources
24 git -C "${R}/usr/src" clone --depth=1 "${KERNEL_URL}"
24 git -C "${R}/usr/src" clone --depth=1 "${KERNEL_URL}"
25 fi
25 fi
26
26
27 # Calculate optimal number of kernel building threads
27 # Calculate optimal number of kernel building threads
28 if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then
28 if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then
29 KERNEL_THREADS=$(grep -c processor /proc/cpuinfo)
29 KERNEL_THREADS=$(grep -c processor /proc/cpuinfo)
30 fi
30 fi
31
31
32 # Configure and build kernel
32 # Configure and build kernel
33 if [ "$KERNELSRC_PREBUILT" = false ] ; then
33 if [ "$KERNELSRC_PREBUILT" = false ] ; then
34 # Remove device, network and filesystem drivers from kernel configuration
34 # Remove device, network and filesystem drivers from kernel configuration
35 if [ "$KERNEL_REDUCE" = true ] ; then
35 if [ "$KERNEL_REDUCE" = true ] ; then
36 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
36 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
37 sed -i\
37 sed -i\
38 -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\
38 -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\
39 -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\
39 -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\
40 -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\
40 -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\
41 -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\
41 -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\
42 -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\
42 -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\
43 -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\
43 -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\
44 -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\
44 -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\
45 -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\
45 -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\
46 -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\
46 -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\
47 -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\
47 -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\
48 -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\
48 -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\
49 -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\
49 -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\
50 -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\
50 -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\
51 -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\
51 -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\
52 -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\
52 -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\
53 -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\
53 -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\
54 -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\
54 -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\
55 -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\
55 -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\
56 -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\
56 -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\
57 -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\
57 -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\
58 -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\
58 -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\
59 -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\
59 -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\
60 -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\
60 -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\
61 -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\
61 -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\
62 -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\
62 -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\
63 -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\
63 -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\
64 -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\
64 -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\
65 -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\
65 -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\
66 -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\
66 -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\
67 "${KERNEL_DIR}/.config"
67 "${KERNEL_DIR}/.config"
68 fi
68 fi
69
69
70 if [ "$KERNELSRC_CONFIG" = true ] ; then
70 if [ "$KERNELSRC_CONFIG" = true ] ; then
71 # Load default raspberry kernel configuration
71 # Load default raspberry kernel configuration
72 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
72 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
73
73
74 if [ ! -z "$KERNELSRC_USRCONFIG" ] ; then
74 if [ ! -z "$KERNELSRC_USRCONFIG" ] ; then
75 cp $KERNELSRC_USRCONFIG ${KERNEL_DIR}/.config
75 cp $KERNELSRC_USRCONFIG ${KERNEL_DIR}/.config
76 fi
76 fi
77
77
78 # Start menu-driven kernel configuration (interactive)
78 # Start menu-driven kernel configuration (interactive)
79 if [ "$KERNEL_MENUCONFIG" = true ] ; then
79 if [ "$KERNEL_MENUCONFIG" = true ] ; then
80 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
80 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
81 fi
81 fi
82 fi
82 fi
83
83
84 # Cross compile kernel and modules
84 # Cross compile kernel and modules
85 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" zImage modules dtbs
85 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" zImage modules dtbs
86 fi
86 fi
87
87
88 # Check if kernel compilation was successful
88 # Check if kernel compilation was successful
89 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" ] ; then
89 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" ] ; then
90 echo "error: kernel compilation failed! (zImage not found)"
90 echo "error: kernel compilation failed! (zImage not found)"
91 cleanup
91 cleanup
92 exit 1
92 exit 1
93 fi
93 fi
94
94
95 # Install kernel modules
95 # Install kernel modules
96 if [ "$ENABLE_REDUCE" = true ] ; then
96 if [ "$ENABLE_REDUCE" = true ] ; then
97 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
97 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
98 else
98 else
99 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
99 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
100
100
101 # Install kernel firmware
101 # Install kernel firmware
102 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
102 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
103 fi
103 fi
104
104
105 # Install kernel headers
105 # Install kernel headers
106 if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then
106 if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then
107 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
107 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
108 fi
108 fi
109
109
110 # Prepare boot (firmware) directory
110 # Prepare boot (firmware) directory
111 mkdir "${BOOT_DIR}"
111 mkdir "${BOOT_DIR}"
112
112
113 # Get kernel release version
113 # Get kernel release version
114 KERNEL_VERSION=`cat "${KERNEL_DIR}/include/config/kernel.release"`
114 KERNEL_VERSION=`cat "${KERNEL_DIR}/include/config/kernel.release"`
115
115
116 # Copy kernel configuration file to the boot directory
116 # Copy kernel configuration file to the boot directory
117 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
117 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
118
118
119 # Copy dts and dtb device tree sources and binaries
119 # Copy dts and dtb device tree sources and binaries
120 mkdir "${BOOT_DIR}/overlays"
120 mkdir "${BOOT_DIR}/overlays"
121 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb "${BOOT_DIR}/"
121 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb "${BOOT_DIR}/"
122 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb* "${BOOT_DIR}/overlays/"
122 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb* "${BOOT_DIR}/overlays/"
123 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
123 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
124
124
125 if [ "$ENABLE_UBOOT" = false ] ; then
125 if [ "$ENABLE_UBOOT" = false ] ; then
126 # Convert and copy zImage kernel to the boot directory
126 # Convert and copy zImage kernel to the boot directory
127 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}"
127 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}"
128 else
128 else
129 # Copy zImage kernel to the boot directory
129 # Copy zImage kernel to the boot directory
130 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}"
130 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}"
131 fi
131 fi
132
132
133 # Remove kernel sources
133 # Remove kernel sources
134 if [ "$KERNEL_REMOVESRC" = true ] ; then
134 if [ "$KERNEL_REMOVESRC" = true ] ; then
135 rm -fr "${KERNEL_DIR}"
135 rm -fr "${KERNEL_DIR}"
136 else
136 else
137 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper
137 #make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" oldconfig
138 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" oldconfig
139 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
138 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
139 #make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper
140 fi
140 fi
141
141
142 if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then
142 if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then
143 # Install boot binaries from local directory
143 # Install boot binaries from local directory
144 cp ${RPI_FIRMWARE_DIR}/boot/bootcode.bin ${BOOT_DIR}/bootcode.bin
144 cp ${RPI_FIRMWARE_DIR}/boot/bootcode.bin ${BOOT_DIR}/bootcode.bin
145 cp ${RPI_FIRMWARE_DIR}/boot/fixup.dat ${BOOT_DIR}/fixup.dat
145 cp ${RPI_FIRMWARE_DIR}/boot/fixup.dat ${BOOT_DIR}/fixup.dat
146 cp ${RPI_FIRMWARE_DIR}/boot/fixup_cd.dat ${BOOT_DIR}/fixup_cd.dat
146 cp ${RPI_FIRMWARE_DIR}/boot/fixup_cd.dat ${BOOT_DIR}/fixup_cd.dat
147 cp ${RPI_FIRMWARE_DIR}/boot/fixup_x.dat ${BOOT_DIR}/fixup_x.dat
147 cp ${RPI_FIRMWARE_DIR}/boot/fixup_x.dat ${BOOT_DIR}/fixup_x.dat
148 cp ${RPI_FIRMWARE_DIR}/boot/start.elf ${BOOT_DIR}/start.elf
148 cp ${RPI_FIRMWARE_DIR}/boot/start.elf ${BOOT_DIR}/start.elf
149 cp ${RPI_FIRMWARE_DIR}/boot/start_cd.elf ${BOOT_DIR}/start_cd.elf
149 cp ${RPI_FIRMWARE_DIR}/boot/start_cd.elf ${BOOT_DIR}/start_cd.elf
150 cp ${RPI_FIRMWARE_DIR}/boot/start_x.elf ${BOOT_DIR}/start_x.elf
150 cp ${RPI_FIRMWARE_DIR}/boot/start_x.elf ${BOOT_DIR}/start_x.elf
151 else
151 else
152 # Install latest boot binaries from raspberry/firmware github
152 # Install latest boot binaries from raspberry/firmware github
153 wget -q -O "${BOOT_DIR}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
153 wget -q -O "${BOOT_DIR}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
154 wget -q -O "${BOOT_DIR}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
154 wget -q -O "${BOOT_DIR}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
155 wget -q -O "${BOOT_DIR}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
155 wget -q -O "${BOOT_DIR}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
156 wget -q -O "${BOOT_DIR}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
156 wget -q -O "${BOOT_DIR}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
157 wget -q -O "${BOOT_DIR}/start.elf" "${FIRMWARE_URL}/start.elf"
157 wget -q -O "${BOOT_DIR}/start.elf" "${FIRMWARE_URL}/start.elf"
158 wget -q -O "${BOOT_DIR}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
158 wget -q -O "${BOOT_DIR}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
159 wget -q -O "${BOOT_DIR}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
159 wget -q -O "${BOOT_DIR}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
160 fi
160 fi
161
161
162 else # BUILD_KERNEL=false
162 else # BUILD_KERNEL=false
163 # Kernel installation
163 # Kernel installation
164 chroot_exec apt-get -qq -y --no-install-recommends install linux-image-"${COLLABORA_KERNEL}" raspberrypi-bootloader-nokernel
164 chroot_exec apt-get -qq -y --no-install-recommends install linux-image-"${COLLABORA_KERNEL}" raspberrypi-bootloader-nokernel
165
165
166 # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot
166 # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot
167 chroot_exec apt-get -qq -y install flash-kernel
167 chroot_exec apt-get -qq -y install flash-kernel
168
168
169 # Check if kernel installation was successful
169 # Check if kernel installation was successful
170 VMLINUZ="$(ls -1 ${R}/boot/vmlinuz-* | sort | tail -n 1)"
170 VMLINUZ="$(ls -1 ${R}/boot/vmlinuz-* | sort | tail -n 1)"
171 if [ -z "$VMLINUZ" ] ; then
171 if [ -z "$VMLINUZ" ] ; then
172 echo "error: kernel installation failed! (/boot/vmlinuz-* not found)"
172 echo "error: kernel installation failed! (/boot/vmlinuz-* not found)"
173 cleanup
173 cleanup
174 exit 1
174 exit 1
175 fi
175 fi
176 # Copy vmlinuz kernel to the boot directory
176 # Copy vmlinuz kernel to the boot directory
177 install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}"
177 install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}"
178 fi
178 fi
179
179
180 # Setup firmware boot cmdline
180 # Setup firmware boot cmdline
181 if [ "$ENABLE_SPLITFS" = true ] ; then
181 if [ "$ENABLE_SPLITFS" = true ] ; then
182 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1"
182 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1"
183 else
183 else
184 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1"
184 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1"
185 fi
185 fi
186
186
187 # Add encrypted root partition to cmdline.txt
187 # Add encrypted root partition to cmdline.txt
188 if [ "$ENABLE_CRYPTFS" = true ] ; then
188 if [ "$ENABLE_CRYPTFS" = true ] ; then
189 if [ "$ENABLE_SPLITFS" = true ] ; then
189 if [ "$ENABLE_SPLITFS" = true ] ; then
190 CMDLINE=$(echo ${CMDLINE} | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/")
190 CMDLINE=$(echo ${CMDLINE} | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/")
191 else
191 else
192 CMDLINE=$(echo ${CMDLINE} | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/")
192 CMDLINE=$(echo ${CMDLINE} | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/")
193 fi
193 fi
194 fi
194 fi
195
195
196 # Add serial console support
196 # Add serial console support
197 if [ "$ENABLE_CONSOLE" = true ] ; then
197 if [ "$ENABLE_CONSOLE" = true ] ; then
198 CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200"
198 CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200"
199 fi
199 fi
200
200
201 # Remove IPv6 networking support
201 # Remove IPv6 networking support
202 if [ "$ENABLE_IPV6" = false ] ; then
202 if [ "$ENABLE_IPV6" = false ] ; then
203 CMDLINE="${CMDLINE} ipv6.disable=1"
203 CMDLINE="${CMDLINE} ipv6.disable=1"
204 fi
204 fi
205
205
206 # Automatically assign predictable network interface names
206 # Automatically assign predictable network interface names
207 if [ "$ENABLE_IFNAMES" = false ] ; then
207 if [ "$ENABLE_IFNAMES" = false ] ; then
208 CMDLINE="${CMDLINE} net.ifnames=0"
208 CMDLINE="${CMDLINE} net.ifnames=0"
209 else
209 else
210 CMDLINE="${CMDLINE} net.ifnames=1"
210 CMDLINE="${CMDLINE} net.ifnames=1"
211 fi
211 fi
212
212
213 # Set init to systemd if required by Debian release
213 # Set init to systemd if required by Debian release
214 if [ "$RELEASE" = "stretch" ] ; then
214 if [ "$RELEASE" = "stretch" ] ; then
215 CMDLINE="${CMDLINE} init=/bin/systemd"
215 CMDLINE="${CMDLINE} init=/bin/systemd"
216 fi
216 fi
217
217
218 # Install firmware boot cmdline
218 # Install firmware boot cmdline
219 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
219 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
220
220
221 # Install firmware config
221 # Install firmware config
222 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
222 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
223
223
224 # Setup minimal GPU memory allocation size: 16MB (no X)
224 # Setup minimal GPU memory allocation size: 16MB (no X)
225 if [ "$ENABLE_MINGPU" = true ] ; then
225 if [ "$ENABLE_MINGPU" = true ] ; then
226 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
226 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
227 fi
227 fi
228
228
229 # Setup boot with initramfs
229 # Setup boot with initramfs
230 if [ "$ENABLE_INITRAMFS" = true ] ; then
230 if [ "$ENABLE_INITRAMFS" = true ] ; then
231 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
231 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
232 fi
232 fi
233
233
234 # Disable RPi3 Bluetooth and restore ttyAMA0 serial device
234 # Disable RPi3 Bluetooth and restore ttyAMA0 serial device
235 if [ "$RPI_MODEL" = 3 ] ; then
235 if [ "$RPI_MODEL" = 3 ] ; then
236 if [ "$ENABLE_CONSOLE" = true ] ; then
236 if [ "$ENABLE_CONSOLE" = true ] ; then
237 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
237 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
238 fi
238 fi
239 fi
239 fi
240
240
241 # Create firmware configuration and cmdline symlinks
241 # Create firmware configuration and cmdline symlinks
242 ln -sf firmware/config.txt "${R}/boot/config.txt"
242 ln -sf firmware/config.txt "${R}/boot/config.txt"
243 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
243 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
244
244
245 # Install and setup kernel modules to load at boot
245 # Install and setup kernel modules to load at boot
246 mkdir -p "${R}/lib/modules-load.d/"
246 mkdir -p "${R}/lib/modules-load.d/"
247 install_readonly files/modules/rpi2.conf "${R}/lib/modules-load.d/rpi2.conf"
247 install_readonly files/modules/rpi2.conf "${R}/lib/modules-load.d/rpi2.conf"
248
248
249 # Load hardware random module at boot
249 # Load hardware random module at boot
250 if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then
250 if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then
251 sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${R}/lib/modules-load.d/rpi2.conf"
251 sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${R}/lib/modules-load.d/rpi2.conf"
252 fi
252 fi
253
253
254 # Load sound module at boot
254 # Load sound module at boot
255 if [ "$ENABLE_SOUND" = true ] ; then
255 if [ "$ENABLE_SOUND" = true ] ; then
256 sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${R}/lib/modules-load.d/rpi2.conf"
256 sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${R}/lib/modules-load.d/rpi2.conf"
257 fi
257 fi
258
258
259 # Install kernel modules blacklist
259 # Install kernel modules blacklist
260 mkdir -p "${ETC_DIR}/modprobe.d/"
260 mkdir -p "${ETC_DIR}/modprobe.d/"
261 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
261 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
262
262
263 # Install and setup fstab
263 # Install and setup fstab
264 install_readonly files/mount/fstab "${ETC_DIR}/fstab"
264 install_readonly files/mount/fstab "${ETC_DIR}/fstab"
265
265
266 # Add usb/sda disk root partition to fstab
266 # Add usb/sda disk root partition to fstab
267 if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_CRYPTFS" = false ] ; then
267 if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_CRYPTFS" = false ] ; then
268 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab"
268 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab"
269 fi
269 fi
270
270
271 # Add encrypted root partition to fstab and crypttab
271 # Add encrypted root partition to fstab and crypttab
272 if [ "$ENABLE_CRYPTFS" = true ] ; then
272 if [ "$ENABLE_CRYPTFS" = true ] ; then
273 # Replace fstab root partition with encrypted partition mapping
273 # Replace fstab root partition with encrypted partition mapping
274 sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETC_DIR}/fstab"
274 sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETC_DIR}/fstab"
275
275
276 # Add encrypted partition to crypttab and fstab
276 # Add encrypted partition to crypttab and fstab
277 install_readonly files/mount/crypttab "${ETC_DIR}/crypttab"
277 install_readonly files/mount/crypttab "${ETC_DIR}/crypttab"
278 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks" >> "${ETC_DIR}/crypttab"
278 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks" >> "${ETC_DIR}/crypttab"
279
279
280 if [ "$ENABLE_SPLITFS" = true ] ; then
280 if [ "$ENABLE_SPLITFS" = true ] ; then
281 # Add usb/sda disk to crypttab
281 # Add usb/sda disk to crypttab
282 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab"
282 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab"
283 fi
283 fi
284 fi
284 fi
285
285
286 # Generate initramfs file
286 # Generate initramfs file
287 if [ "$ENABLE_INITRAMFS" = true ] ; then
287 if [ "$ENABLE_INITRAMFS" = true ] ; then
288 if [ "$ENABLE_CRYPTFS" = true ] ; then
288 if [ "$ENABLE_CRYPTFS" = true ] ; then
289 # Include initramfs scripts to auto expand encrypted root partition
289 # Include initramfs scripts to auto expand encrypted root partition
290 if [ "$EXPANDROOT" = true ] ; then
290 if [ "$EXPANDROOT" = true ] ; then
291 install_exec files/initramfs/expand_encrypted_rootfs "${ETC_DIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs"
291 install_exec files/initramfs/expand_encrypted_rootfs "${ETC_DIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs"
292 install_exec files/initramfs/expand-premount "${ETC_DIR}/initramfs-tools/scripts/local-premount/expand-premount"
292 install_exec files/initramfs/expand-premount "${ETC_DIR}/initramfs-tools/scripts/local-premount/expand-premount"
293 install_exec files/initramfs/expand-tools "${ETC_DIR}/initramfs-tools/hooks/expand-tools"
293 install_exec files/initramfs/expand-tools "${ETC_DIR}/initramfs-tools/hooks/expand-tools"
294 fi
294 fi
295
295
296 # Disable SSHD inside initramfs
296 # Disable SSHD inside initramfs
297 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
297 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
298
298
299 # Dummy mapping required by mkinitramfs
299 # Dummy mapping required by mkinitramfs
300 echo "0 1 crypt $(echo ${CRYPTFS_CIPHER} | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
300 echo "0 1 crypt $(echo ${CRYPTFS_CIPHER} | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
301
301
302 # Generate initramfs with encrypted root partition support
302 # Generate initramfs with encrypted root partition support
303 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
303 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
304
304
305 # Remove dummy mapping
305 # Remove dummy mapping
306 chroot_exec cryptsetup close "${CRYPTFS_MAPPING}"
306 chroot_exec cryptsetup close "${CRYPTFS_MAPPING}"
307 else
307 else
308 # Generate initramfs without encrypted root partition support
308 # Generate initramfs without encrypted root partition support
309 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
309 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
310 fi
310 fi
311 fi
311 fi
312
312
313 # Install sysctl.d configuration files
313 # Install sysctl.d configuration files
314 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf"
314 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf"
315
316 # make symlinks
317 ln -sf "${KERNEL_DIR}" "${R}/lib/modules/${KERNEL_VERSION}/build"
318 ln -sf "${KERNEL_DIR}" "${R}/lib/modules/${KERNEL_VERSION}/source"
319
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant