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