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