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