##// END OF EJS Templates
proposal to copy fixup4* and start4* from kernel resources site into...
vidal -
r709:cf0a04eeec4b
parent child
Show More
@@ -1,316 +1,332
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 <<<<<<< HEAD
131 <<<<<<< HEAD
116 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
132 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
117 =======
133 =======
118 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
134 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
119 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ]; then
135 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ]; then
120
136
121 # Bluetooth enabled
137 # Bluetooth enabled
122 if [ "$ENABLE_BLUETOOTH" = true ] ; then
138 if [ "$ENABLE_BLUETOOTH" = true ] ; then
123 # Create temporary directory for Bluetooth sources
139 # Create temporary directory for Bluetooth sources
124 temp_dir=$(as_nobody mktemp -d)
140 temp_dir=$(as_nobody mktemp -d)
125
141
126 # Fetch Bluetooth sources
142 # Fetch Bluetooth sources
127 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
143 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
128
144
129 # Copy downloaded sources
145 # Copy downloaded sources
130 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
146 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
131
147
132 # Set permissions
148 # Set permissions
133 chown -R root:root "${R}/tmp/pi-bluetooth"
149 chown -R root:root "${R}/tmp/pi-bluetooth"
134
150
135 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
151 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
136 wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
152 wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
137 wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/master/broadcom/BCM43430A1.hcd
153 wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/master/broadcom/BCM43430A1.hcd
138
154
139 # Install tools
155 # Install tools
140 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
156 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
141 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
157 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
142
158
143 # make scripts executable
159 # make scripts executable
144 chmod +x "${R}/usr/bin/bthelper"
160 chmod +x "${R}/usr/bin/bthelper"
145 chmod +x "${R}/usr/bin/btuart"
161 chmod +x "${R}/usr/bin/btuart"
146
162
147 # Install bluetooth udev rule
163 # Install bluetooth udev rule
148 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
164 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
149
165
150 # Install Firmware Flash file and apropiate licence
166 # Install Firmware Flash file and apropiate licence
151 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
167 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
152 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
168 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
153 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/BCM43430A1.hcd"
169 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/BCM43430A1.hcd"
154 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
170 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
155 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
171 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
156
172
157 # Remove temporary directories
173 # Remove temporary directories
158 rm -fr "${temp_dir}"
174 rm -fr "${temp_dir}"
159 rm -fr "${R}"/tmp/pi-bluetooth
175 rm -fr "${R}"/tmp/pi-bluetooth
160
176
161 # 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
177 # 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
162 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
178 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
163 # set overlay to swap ttyAMA0 and ttyS0
179 # set overlay to swap ttyAMA0 and ttyS0
164 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
180 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
165
181
166 if [ "$ENABLE_TURBO" = false ] ; then
182 if [ "$ENABLE_TURBO" = false ] ; then
167 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
183 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
168 fi
184 fi
169
185
170 fi
186 fi
171
187
172 # Activate services
188 # Activate services
173 chroot_exec systemctl enable pi-bluetooth.hciuart.service
189 chroot_exec systemctl enable pi-bluetooth.hciuart.service
174
190
175 else # if ENABLE_BLUETOOTH = false
191 else # if ENABLE_BLUETOOTH = false
176 # set overlay to disable bluetooth
192 # set overlay to disable bluetooth
177 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
193 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
178 fi # ENABLE_BLUETOOTH end
194 fi # ENABLE_BLUETOOTH end
179 fi
195 fi
180
196
181 # may need sudo systemctl disable hciuart
197 # may need sudo systemctl disable hciuart
182 if [ "$ENABLE_CONSOLE" = true ] ; then
198 if [ "$ENABLE_CONSOLE" = true ] ; then
183 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
199 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
184 # add string to cmdline
200 # add string to cmdline
185 CMDLINE="${CMDLINE} console=serial0,115200"
201 CMDLINE="${CMDLINE} console=serial0,115200"
186
202
187 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]|| [ "$RPI_MODEL" = 0 ]; then
203 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]|| [ "$RPI_MODEL" = 0 ]; then
188 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
204 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
189 if [ "$ENABLE_TURBO" = false ] ; then
205 if [ "$ENABLE_TURBO" = false ] ; then
190 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
206 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
191 fi
207 fi
192 fi
208 fi
193
209
194 # Enable serial console systemd style
210 # Enable serial console systemd style
195 chroot_exec systemctl enable serial-getty@serial0.service
211 chroot_exec systemctl enable serial-getty@serial0.service
196 else
212 else
197 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
213 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
198 fi
214 fi
199
215
200 # Disable dphys-swapfile service. Will get enabled on first boot
216 # Disable dphys-swapfile service. Will get enabled on first boot
201 if [ "$ENABLE_DPHYSSWAP" = true ] ; then
217 if [ "$ENABLE_DPHYSSWAP" = true ] ; then
202 chroot_exec systemctl disable dphys-swapfile
218 chroot_exec systemctl disable dphys-swapfile
203 fi
219 fi
204
220
205 if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then
221 if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then
206 # Create temporary directory for systemd-swap sources
222 # Create temporary directory for systemd-swap sources
207 temp_dir=$(as_nobody mktemp -d)
223 temp_dir=$(as_nobody mktemp -d)
208
224
209 # Fetch systemd-swap sources
225 # Fetch systemd-swap sources
210 as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}"
226 as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}"
211
227
212 # Copy downloaded systemd-swap sources
228 # Copy downloaded systemd-swap sources
213 mv "${temp_dir}/systemd-swap" "${R}/tmp/"
229 mv "${temp_dir}/systemd-swap" "${R}/tmp/"
214
230
215 # Change into downloaded src dir
231 # Change into downloaded src dir
216 cd "${R}/tmp/systemd-swap" || exit
232 cd "${R}/tmp/systemd-swap" || exit
217 <<<<<<< HEAD
233 <<<<<<< HEAD
218
234
219 =======
235 =======
220 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
236 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
221
237
222 # Get Verion
238 # Get Verion
223 VERSION=$(git tag | tail -n 1)
239 VERSION=$(git tag | tail -n 1)
224 #sed -i "s/DEB_NAME=.*/DEB_NAME=systemd-swap_all/g" "${R}/tmp/systemd-swap/package.sh"
240 #sed -i "s/DEB_NAME=.*/DEB_NAME=systemd-swap_all/g" "${R}/tmp/systemd-swap/package.sh"
225
241
226 # Build package
242 # Build package
227 bash ./package.sh debian
243 bash ./package.sh debian
228
244
229 # Change back into script root dir
245 # Change back into script root dir
230 cd "${WORKDIR}" || exit
246 cd "${WORKDIR}" || exit
231
247
232 # Set permissions of the systemd-swap sources
248 # Set permissions of the systemd-swap sources
233 chown -R root:root "${R}/tmp/systemd-swap"
249 chown -R root:root "${R}/tmp/systemd-swap"
234
250
235 # Install package - IMPROVE AND MAKE IT POSSIBLE WITHOUT VERSION NR.
251 # Install package - IMPROVE AND MAKE IT POSSIBLE WITHOUT VERSION NR.
236 <<<<<<< HEAD
252 <<<<<<< HEAD
237 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_4.0.1_any.deb
253 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_4.0.1_any.deb
238 =======
254 =======
239 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
255 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
240 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_"$VERSION"_all.deb
256 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_"$VERSION"_all.deb
241
257
242 # Enable service
258 # Enable service
243 chroot_exec systemctl enable systemd-swap
259 chroot_exec systemctl enable systemd-swap
244
260
245 # Remove temporary directory for systemd-swap sources
261 # Remove temporary directory for systemd-swap sources
246 rm -fr "${temp_dir}"
262 rm -fr "${temp_dir}"
247 else
263 else
248 # Enable ZSWAP in cmdline if systemd-swap is not used
264 # Enable ZSWAP in cmdline if systemd-swap is not used
249 if [ "$KERNEL_ZSWAP" = true ] ; then
265 if [ "$KERNEL_ZSWAP" = true ] ; then
250 CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4"
266 CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4"
251 fi
267 fi
252 fi
268 fi
253 if [ "$KERNEL_SECURITY" = true ] ; then
269 if [ "$KERNEL_SECURITY" = true ] ; then
254 CMDLINE="${CMDLINE} apparmor=1 security=apparmor"
270 CMDLINE="${CMDLINE} apparmor=1 security=apparmor"
255 fi
271 fi
256
272
257 # Install firmware boot cmdline
273 # Install firmware boot cmdline
258 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
274 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
259
275
260 # Setup minimal GPU memory allocation size: 16MB (no X)
276 # Setup minimal GPU memory allocation size: 16MB (no X)
261 if [ "$ENABLE_MINGPU" = true ] ; then
277 if [ "$ENABLE_MINGPU" = true ] ; then
262 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
278 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
263 fi
279 fi
264
280
265 # Setup boot with initramfs
281 # Setup boot with initramfs
266 if [ "$ENABLE_INITRAMFS" = true ] ; then
282 if [ "$ENABLE_INITRAMFS" = true ] ; then
267 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
283 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
268 fi
284 fi
269
285
270 # Create firmware configuration and cmdline symlinks
286 # Create firmware configuration and cmdline symlinks
271 ln -sf firmware/config.txt "${R}/boot/config.txt"
287 ln -sf firmware/config.txt "${R}/boot/config.txt"
272 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
288 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
273
289
274 # Install and setup kernel modules to load at boot
290 # Install and setup kernel modules to load at boot
275 mkdir -p "${LIB_DIR}/modules-load.d/"
291 mkdir -p "${LIB_DIR}/modules-load.d/"
276 install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf"
292 install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf"
277
293
278 # Load hardware random module at boot
294 # Load hardware random module at boot
279 if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then
295 if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then
280 sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf"
296 sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf"
281 fi
297 fi
282
298
283 # Load sound module at boot
299 # Load sound module at boot
284 if [ "$ENABLE_SOUND" = true ] ; then
300 if [ "$ENABLE_SOUND" = true ] ; then
285 sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
301 sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
286 else
302 else
287 echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt"
303 echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt"
288 fi
304 fi
289
305
290 # Enable I2C interface
306 # Enable I2C interface
291 if [ "$ENABLE_I2C" = true ] ; then
307 if [ "$ENABLE_I2C" = true ] ; then
292 echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt"
308 echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt"
293 sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf"
309 sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf"
294 sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf"
310 sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf"
295 fi
311 fi
296
312
297 # Enable SPI interface
313 # Enable SPI interface
298 if [ "$ENABLE_SPI" = true ] ; then
314 if [ "$ENABLE_SPI" = true ] ; then
299 echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt"
315 echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt"
300 echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf"
316 echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf"
301 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then
317 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then
302 sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
318 sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
303 fi
319 fi
304 fi
320 fi
305
321
306 # Disable RPi2/3 under-voltage warnings
322 # Disable RPi2/3 under-voltage warnings
307 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
323 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
308 echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt"
324 echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt"
309 fi
325 fi
310
326
311 # Install kernel modules blacklist
327 # Install kernel modules blacklist
312 mkdir -p "${ETC_DIR}/modprobe.d/"
328 mkdir -p "${ETC_DIR}/modprobe.d/"
313 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
329 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
314
330
315 # Install sysctl.d configuration files
331 # Install sysctl.d configuration files
316 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf"
332 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