##// END OF EJS Templates
Disable dphys-swapfile for the first boot
Yannick Schinko -
r577:f84ed4876ca0
parent child
Show More
@@ -1,280 +1,285
1 #
1 #
2 # Setup RPi2/3 config and cmdline
2 # Setup RPi2/3 config and cmdline
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then
8 if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then
9 # Install boot binaries from local directory
9 # Install boot binaries from local directory
10 cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin
10 cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin
11 cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat
11 cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat
12 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat
12 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat
13 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat
13 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat
14 cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf
14 cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf
15 cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf
15 cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf
16 cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf
16 cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf
17 else
17 else
18 # Create temporary directory for boot binaries
18 # Create temporary directory for boot binaries
19 temp_dir=$(as_nobody mktemp -d)
19 temp_dir=$(as_nobody mktemp -d)
20
20
21 # Install latest boot binaries from raspberry/firmware github
21 # Install latest boot binaries from raspberry/firmware github
22 as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
22 as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
23 as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
23 as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
24 as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
24 as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
25 as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
25 as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
26 as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf"
26 as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf"
27 as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
27 as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
28 as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
28 as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
29
29
30 # Move downloaded boot binaries
30 # Move downloaded boot binaries
31 mv "${temp_dir}/"* "${BOOT_DIR}/"
31 mv "${temp_dir}/"* "${BOOT_DIR}/"
32
32
33 # Remove temporary directory for boot binaries
33 # Remove temporary directory for boot binaries
34 rm -fr "${temp_dir}"
34 rm -fr "${temp_dir}"
35
35
36 # Set permissions of the boot binaries
36 # Set permissions of the boot binaries
37 chown -R root:root "${BOOT_DIR}"
37 chown -R root:root "${BOOT_DIR}"
38 chmod -R 600 "${BOOT_DIR}"
38 chmod -R 600 "${BOOT_DIR}"
39 fi
39 fi
40
40
41 # Setup firmware boot cmdline
41 # Setup firmware boot cmdline
42 if [ "$ENABLE_SPLITFS" = true ] ; then
42 if [ "$ENABLE_SPLITFS" = true ] ; then
43 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
43 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
44 else
44 else
45 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
45 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
46 fi
46 fi
47
47
48 # Add encrypted root partition to cmdline.txt
48 # Add encrypted root partition to cmdline.txt
49 if [ "$ENABLE_CRYPTFS" = true ] ; then
49 if [ "$ENABLE_CRYPTFS" = true ] ; then
50 if [ "$ENABLE_SPLITFS" = true ] ; then
50 if [ "$ENABLE_SPLITFS" = true ] ; then
51 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/")
51 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/")
52 else
52 else
53 CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/")
53 CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/")
54 fi
54 fi
55 fi
55 fi
56
56
57 # Enable Kernel messages on standard output
57 # Enable Kernel messages on standard output
58 if [ "$ENABLE_PRINTK" = true ] ; then
58 if [ "$ENABLE_PRINTK" = true ] ; then
59 install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf"
59 install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf"
60 fi
60 fi
61
61
62 # Install udev rule for serial alias - serial0 = console serial1=bluetooth
62 # Install udev rule for serial alias - serial0 = console serial1=bluetooth
63 install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules"
63 install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules"
64
64
65 # Remove IPv6 networking support
65 # Remove IPv6 networking support
66 if [ "$ENABLE_IPV6" = false ] ; then
66 if [ "$ENABLE_IPV6" = false ] ; then
67 CMDLINE="${CMDLINE} ipv6.disable=1"
67 CMDLINE="${CMDLINE} ipv6.disable=1"
68 fi
68 fi
69
69
70 # Automatically assign predictable network interface names
70 # Automatically assign predictable network interface names
71 if [ "$ENABLE_IFNAMES" = false ] ; then
71 if [ "$ENABLE_IFNAMES" = false ] ; then
72 CMDLINE="${CMDLINE} net.ifnames=0"
72 CMDLINE="${CMDLINE} net.ifnames=0"
73 else
73 else
74 CMDLINE="${CMDLINE} net.ifnames=1"
74 CMDLINE="${CMDLINE} net.ifnames=1"
75 fi
75 fi
76
76
77 # Disable Raspberry Pi console logo
77 # Disable Raspberry Pi console logo
78 if [ "$ENABLE_LOGO" = false ] ; then
78 if [ "$ENABLE_LOGO" = false ] ; then
79 CMDLINE="${CMDLINE} logo.nologo"
79 CMDLINE="${CMDLINE} logo.nologo"
80 fi
80 fi
81
81
82 # Strictly limit verbosity of boot up console messages
82 # Strictly limit verbosity of boot up console messages
83 if [ "$ENABLE_SILENT_BOOT" = true ] ; then
83 if [ "$ENABLE_SILENT_BOOT" = true ] ; then
84 CMDLINE="${CMDLINE} quiet loglevel=0 rd.systemd.show_status=auto rd.udev.log_priority=0"
84 CMDLINE="${CMDLINE} quiet loglevel=0 rd.systemd.show_status=auto rd.udev.log_priority=0"
85 fi
85 fi
86
86
87 # Install firmware config
87 # Install firmware config
88 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
88 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
89
89
90 # Disable Raspberry Pi console logo
90 # Disable Raspberry Pi console logo
91 if [ "$ENABLE_SLASH" = false ] ; then
91 if [ "$ENABLE_SLASH" = false ] ; then
92 echo "disable_splash=1" >> "${BOOT_DIR}/config.txt"
92 echo "disable_splash=1" >> "${BOOT_DIR}/config.txt"
93 fi
93 fi
94
94
95 # Locks CPU frequency at maximum
95 # Locks CPU frequency at maximum
96 if [ "$ENABLE_TURBO" = true ] ; then
96 if [ "$ENABLE_TURBO" = true ] ; then
97 echo "force_turbo=1" >> "${BOOT_DIR}/config.txt"
97 echo "force_turbo=1" >> "${BOOT_DIR}/config.txt"
98 # helps to avoid sdcard corruption when force_turbo is enabled.
98 # helps to avoid sdcard corruption when force_turbo is enabled.
99 echo "boot_delay=1" >> "${BOOT_DIR}/config.txt"
99 echo "boot_delay=1" >> "${BOOT_DIR}/config.txt"
100 fi
100 fi
101
101
102 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
102 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
103
103
104 # Bluetooth enabled
104 # Bluetooth enabled
105 if [ "$ENABLE_BLUETOOTH" = true ] ; then
105 if [ "$ENABLE_BLUETOOTH" = true ] ; then
106 # Create temporary directory for Bluetooth sources
106 # Create temporary directory for Bluetooth sources
107 temp_dir=$(as_nobody mktemp -d)
107 temp_dir=$(as_nobody mktemp -d)
108
108
109 # Fetch Bluetooth sources
109 # Fetch Bluetooth sources
110 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
110 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
111
111
112 # Copy downloaded sources
112 # Copy downloaded sources
113 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
113 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
114
114
115 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
115 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
116 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
116 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
117 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth
117 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth
118
118
119 # Set permissions
119 # Set permissions
120 chown -R root:root "${R}/tmp/pi-bluetooth"
120 chown -R root:root "${R}/tmp/pi-bluetooth"
121
121
122 # Install tools
122 # Install tools
123 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
123 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
124 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
124 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
125
125
126 # make scripts executable
126 # make scripts executable
127 chmod +x "${R}/usr/bin/bthelper"
127 chmod +x "${R}/usr/bin/bthelper"
128 chmod +x "${R}/usr/bin/btuart"
128 chmod +x "${R}/usr/bin/btuart"
129
129
130 # Install bluetooth udev rule
130 # Install bluetooth udev rule
131 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
131 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
132
132
133 # Install Firmware Flash file and apropiate licence
133 # Install Firmware Flash file and apropiate licence
134 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
134 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
135 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
135 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
136 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
136 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
137 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
137 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
138 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
138 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
139
139
140 # Remove temporary directories
140 # Remove temporary directories
141 rm -fr "${temp_dir}"
141 rm -fr "${temp_dir}"
142 rm -fr "${R}"/tmp/pi-bluetooth
142 rm -fr "${R}"/tmp/pi-bluetooth
143
143
144 # Switch Pi3 Bluetooth function to use the mini-UART (ttyS0) and restore UART0/ttyAMA0 over GPIOs 14 & 15. Slow Bluetooth and slow cpu. Use /dev/ttyS0 instead of /dev/ttyAMA0
144 # Switch Pi3 Bluetooth function to use the mini-UART (ttyS0) and restore UART0/ttyAMA0 over GPIOs 14 & 15. Slow Bluetooth and slow cpu. Use /dev/ttyS0 instead of /dev/ttyAMA0
145 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
145 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
146
146
147 # set overlay to swap ttyAMA0 and ttyS0
147 # set overlay to swap ttyAMA0 and ttyS0
148 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
148 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
149
149
150 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
150 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
151 if [ "$ENABLE_TURBO" = false ] ; then
151 if [ "$ENABLE_TURBO" = false ] ; then
152 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
152 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
153 fi
153 fi
154 fi
154 fi
155
155
156 # Activate services
156 # Activate services
157 chroot_exec systemctl enable pi-bluetooth.hciuart.service
157 chroot_exec systemctl enable pi-bluetooth.hciuart.service
158
158
159 else # if ENABLE_BLUETOOTH = false
159 else # if ENABLE_BLUETOOTH = false
160 # set overlay to disable bluetooth
160 # set overlay to disable bluetooth
161 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
161 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
162 fi # ENABLE_BLUETOOTH end
162 fi # ENABLE_BLUETOOTH end
163 fi
163 fi
164
164
165 # may need sudo systemctl disable hciuart
165 # may need sudo systemctl disable hciuart
166 if [ "$ENABLE_CONSOLE" = true ] ; then
166 if [ "$ENABLE_CONSOLE" = true ] ; then
167 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
167 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
168 # add string to cmdline
168 # add string to cmdline
169 CMDLINE="${CMDLINE} console=serial0,115200"
169 CMDLINE="${CMDLINE} console=serial0,115200"
170
170
171 # Enable serial console systemd style
171 # Enable serial console systemd style
172 chroot_exec systemctl enable serial-getty\@serial0.service
172 chroot_exec systemctl enable serial-getty\@serial0.service
173 else
173 else
174 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
174 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
175
175
176 # disable serial console systemd style
176 # disable serial console systemd style
177 chroot_exec systemctl disable serial-getty\@"$SET_SERIAL".service
177 chroot_exec systemctl disable serial-getty\@"$SET_SERIAL".service
178 fi
178 fi
179
179
180 # Disable dphys-swapfile service. Will get enabled on first boot
181 if [ "$ENABLE_DPHYSSWAP" = true ] ; then
182 chroot_exec systemctl disable dphys-swapfile
183 fi
184
180 if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then
185 if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then
181 # Create temporary directory for systemd-swap sources
186 # Create temporary directory for systemd-swap sources
182 temp_dir=$(as_nobody mktemp -d)
187 temp_dir=$(as_nobody mktemp -d)
183
188
184 # Fetch systemd-swap sources
189 # Fetch systemd-swap sources
185 as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}"
190 as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}"
186
191
187 # Copy downloaded systemd-swap sources
192 # Copy downloaded systemd-swap sources
188 mv "${temp_dir}/systemd-swap" "${R}/tmp/"
193 mv "${temp_dir}/systemd-swap" "${R}/tmp/"
189
194
190 # Set permissions of the systemd-swap sources
195 # Set permissions of the systemd-swap sources
191 chown -R root:root "${R}/tmp/systemd-swap"
196 chown -R root:root "${R}/tmp/systemd-swap"
192
197
193 # Remove temporary directory for systemd-swap sources
198 # Remove temporary directory for systemd-swap sources
194 rm -fr "${temp_dir}"
199 rm -fr "${temp_dir}"
195
200
196 # Change into downloaded src dir
201 # Change into downloaded src dir
197 cd "${R}/tmp/systemd-swap" || exit
202 cd "${R}/tmp/systemd-swap" || exit
198
203
199 # Build package
204 # Build package
200 . ./package.sh debian
205 . ./package.sh debian
201
206
202 # Install package
207 # Install package
203 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap-*any.deb
208 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap-*any.deb
204
209
205 # Enable service
210 # Enable service
206 chroot_exec systemctl enable systemd-swap
211 chroot_exec systemctl enable systemd-swap
207
212
208 # Change back into script root dir
213 # Change back into script root dir
209 cd "${WORKDIR}" || exit
214 cd "${WORKDIR}" || exit
210 else
215 else
211 # Enable ZSWAP in cmdline if systemd-swap is not used
216 # Enable ZSWAP in cmdline if systemd-swap is not used
212 if [ "$KERNEL_ZSWAP" = true ] ; then
217 if [ "$KERNEL_ZSWAP" = true ] ; then
213 CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4"
218 CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4"
214 fi
219 fi
215 fi
220 fi
216
221
217 if [ "$KERNEL_SECURITY" = true ] ; then
222 if [ "$KERNEL_SECURITY" = true ] ; then
218 CMDLINE="${CMDLINE} apparmor=1 security=apparmor"
223 CMDLINE="${CMDLINE} apparmor=1 security=apparmor"
219 fi
224 fi
220
225
221 # Install firmware boot cmdline
226 # Install firmware boot cmdline
222 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
227 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
223
228
224 # Setup minimal GPU memory allocation size: 16MB (no X)
229 # Setup minimal GPU memory allocation size: 16MB (no X)
225 if [ "$ENABLE_MINGPU" = true ] ; then
230 if [ "$ENABLE_MINGPU" = true ] ; then
226 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
231 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
227 fi
232 fi
228
233
229 # Setup boot with initramfs
234 # Setup boot with initramfs
230 if [ "$ENABLE_INITRAMFS" = true ] ; then
235 if [ "$ENABLE_INITRAMFS" = true ] ; then
231 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
236 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
232 fi
237 fi
233
238
234 # Create firmware configuration and cmdline symlinks
239 # Create firmware configuration and cmdline symlinks
235 ln -sf firmware/config.txt "${R}/boot/config.txt"
240 ln -sf firmware/config.txt "${R}/boot/config.txt"
236 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
241 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
237
242
238 # Install and setup kernel modules to load at boot
243 # Install and setup kernel modules to load at boot
239 mkdir -p "${LIB_DIR}/modules-load.d/"
244 mkdir -p "${LIB_DIR}/modules-load.d/"
240 install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf"
245 install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf"
241
246
242 # Load hardware random module at boot
247 # Load hardware random module at boot
243 if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then
248 if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then
244 sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf"
249 sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf"
245 fi
250 fi
246
251
247 # Load sound module at boot
252 # Load sound module at boot
248 if [ "$ENABLE_SOUND" = true ] ; then
253 if [ "$ENABLE_SOUND" = true ] ; then
249 sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
254 sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
250 else
255 else
251 echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt"
256 echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt"
252 fi
257 fi
253
258
254 # Enable I2C interface
259 # Enable I2C interface
255 if [ "$ENABLE_I2C" = true ] ; then
260 if [ "$ENABLE_I2C" = true ] ; then
256 echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt"
261 echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt"
257 sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf"
262 sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf"
258 sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf"
263 sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf"
259 fi
264 fi
260
265
261 # Enable SPI interface
266 # Enable SPI interface
262 if [ "$ENABLE_SPI" = true ] ; then
267 if [ "$ENABLE_SPI" = true ] ; then
263 echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt"
268 echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt"
264 echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf"
269 echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf"
265 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then
270 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then
266 sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
271 sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
267 fi
272 fi
268 fi
273 fi
269
274
270 # Disable RPi2/3 under-voltage warnings
275 # Disable RPi2/3 under-voltage warnings
271 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
276 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
272 echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt"
277 echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt"
273 fi
278 fi
274
279
275 # Install kernel modules blacklist
280 # Install kernel modules blacklist
276 mkdir -p "${ETC_DIR}/modprobe.d/"
281 mkdir -p "${ETC_DIR}/modprobe.d/"
277 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
282 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
278
283
279 # Install sysctl.d configuration files
284 # Install sysctl.d configuration files
280 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf"
285 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf"
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant