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