@@ -1,270 +1,271 | |||||
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 [ "$BUILD_KERNEL" = true ] ; then |
|
8 | #if [ "$BUILD_KERNEL" = true ] ; then | |
9 | if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then |
|
9 | if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then | |
10 | # Install boot binaries from local directory |
|
10 | # Install boot binaries from local directory | |
11 | cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin |
|
11 | cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin | |
12 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat |
|
12 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat | |
13 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat |
|
13 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat | |
14 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat |
|
14 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat | |
15 | cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf |
|
15 | cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf | |
16 | cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf |
|
16 | cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf | |
17 | cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf |
|
17 | cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf | |
18 | else |
|
18 | else | |
19 | # Create temporary directory for boot binaries |
|
19 | # Create temporary directory for boot binaries | |
20 | temp_dir=$(as_nobody mktemp -d) |
|
20 | temp_dir=$(as_nobody mktemp -d) | |
21 |
|
21 | |||
22 | # Install latest boot binaries from raspberry/firmware github |
|
22 | # Install latest boot binaries from raspberry/firmware github | |
23 | as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" |
|
23 | as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" | |
24 | as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" |
|
24 | as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" | |
25 | as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" |
|
25 | as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" | |
26 | as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" |
|
26 | as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" | |
27 | as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" |
|
27 | as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" | |
28 | as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" |
|
28 | as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" | |
29 | as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" |
|
29 | as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" | |
30 |
|
30 | |||
31 | # Move downloaded boot binaries |
|
31 | # Move downloaded boot binaries | |
32 | mv "${temp_dir}/"* "${BOOT_DIR}/" |
|
32 | mv "${temp_dir}/"* "${BOOT_DIR}/" | |
33 |
|
33 | |||
34 | # Remove temporary directory for boot binaries |
|
34 | # Remove temporary directory for boot binaries | |
35 | rm -fr "${temp_dir}" |
|
35 | rm -fr "${temp_dir}" | |
36 |
|
36 | |||
37 | # Set permissions of the boot binaries |
|
37 | # Set permissions of the boot binaries | |
38 | chown -R root:root "${BOOT_DIR}" |
|
38 | chown -R root:root "${BOOT_DIR}" | |
39 | chmod -R 600 "${BOOT_DIR}" |
|
39 | chmod -R 600 "${BOOT_DIR}" | |
40 | fi |
|
40 | fi | |
41 | #fi |
|
41 | #fi | |
42 |
|
42 | |||
43 | # Setup firmware boot cmdline |
|
43 | # Setup firmware boot cmdline | |
44 | if [ "$ENABLE_UBOOTUSB" = true ] ; then |
|
44 | if [ "$ENABLE_UBOOTUSB" = true ] ; then | |
45 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd" |
|
45 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd" | |
46 | else |
|
46 | else | |
47 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
47 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
48 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd" |
|
48 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd" | |
49 | else |
|
49 | else | |
50 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd" |
|
50 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd" | |
51 | fi |
|
51 | fi | |
52 | fi |
|
52 | fi | |
53 |
|
53 | |||
54 | # Add encrypted root partition to cmdline.txt |
|
54 | # Add encrypted root partition to cmdline.txt | |
55 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
55 | if [ "$ENABLE_CRYPTFS" = true ] ; then | |
56 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
56 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
57 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") |
|
57 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") | |
58 | else |
|
58 | else | |
59 | if [ "$ENABLE_UBOOTUSB" = true ] ; then |
|
59 | if [ "$ENABLE_UBOOTUSB" = true ] ; then | |
60 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/") |
|
60 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/") | |
61 | else |
|
61 | else | |
62 | CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") |
|
62 | CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") | |
63 | fi |
|
63 | fi | |
64 | fi |
|
64 | fi | |
65 | fi |
|
65 | fi | |
66 |
|
66 | |||
67 | if [ "$ENABLE_PRINTK" = true ] ; then |
|
67 | if [ "$ENABLE_PRINTK" = true ] ; then | |
68 | install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf" |
|
68 | install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf" | |
69 | fi |
|
69 | fi | |
70 |
|
70 | |||
71 | # Install udev rule for serial alias - serial0 = console serial1=bluetooth |
|
71 | # Install udev rule for serial alias - serial0 = console serial1=bluetooth | |
72 | install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules" |
|
72 | install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules" | |
73 |
|
73 | |||
74 | # Remove IPv6 networking support |
|
74 | # Remove IPv6 networking support | |
75 | if [ "$ENABLE_IPV6" = false ] ; then |
|
75 | if [ "$ENABLE_IPV6" = false ] ; then | |
76 | CMDLINE="${CMDLINE} ipv6.disable=1" |
|
76 | CMDLINE="${CMDLINE} ipv6.disable=1" | |
77 | fi |
|
77 | fi | |
78 |
|
78 | |||
79 | # Automatically assign predictable network interface names |
|
79 | # Automatically assign predictable network interface names | |
80 | if [ "$ENABLE_IFNAMES" = false ] ; then |
|
80 | if [ "$ENABLE_IFNAMES" = false ] ; then | |
81 | CMDLINE="${CMDLINE} net.ifnames=0" |
|
81 | CMDLINE="${CMDLINE} net.ifnames=0" | |
82 | else |
|
82 | else | |
83 | CMDLINE="${CMDLINE} net.ifnames=1" |
|
83 | CMDLINE="${CMDLINE} net.ifnames=1" | |
84 | fi |
|
84 | fi | |
85 |
|
85 | |||
86 | # Install firmware config |
|
86 | # Install firmware config | |
87 | install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt" |
|
87 | install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt" | |
88 |
|
88 | |||
89 | #locks cpu at max frequency |
|
89 | #locks cpu at max frequency | |
90 | if [ "$ENABLE_TURBO" = true ] ; then |
|
90 | if [ "$ENABLE_TURBO" = true ] ; then | |
91 | echo "force_turbo=1" >> "${BOOT_DIR}/config.txt" |
|
91 | echo "force_turbo=1" >> "${BOOT_DIR}/config.txt" | |
92 | # helps to avoid sdcard corruption when force_turbo is enabled. |
|
92 | # helps to avoid sdcard corruption when force_turbo is enabled. | |
93 | echo "boot_delay=1" >> "${BOOT_DIR}/config.txt" |
|
93 | echo "boot_delay=1" >> "${BOOT_DIR}/config.txt" | |
94 | fi |
|
94 | fi | |
95 |
|
95 | |||
96 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then |
|
96 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then | |
97 |
|
97 | |||
98 | # Bluetooth enabled |
|
98 | # Bluetooth enabled | |
99 | if [ "$ENABLE_BLUETOOTH" = true ] ; then |
|
99 | if [ "$ENABLE_BLUETOOTH" = true ] ; then | |
100 | # Create temporary directory for Bluetooth sources |
|
100 | # Create temporary directory for Bluetooth sources | |
101 | temp_dir=$(as_nobody mktemp -d) |
|
101 | temp_dir=$(as_nobody mktemp -d) | |
102 |
|
102 | |||
103 | # Fetch Bluetooth sources |
|
103 | # Fetch Bluetooth sources | |
104 | as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}" |
|
104 | as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}" | |
105 |
|
105 | |||
106 | # Copy downloaded sources |
|
106 | # Copy downloaded sources | |
107 | mv "${temp_dir}/pi-bluetooth" "${R}/tmp/" |
|
107 | mv "${temp_dir}/pi-bluetooth" "${R}/tmp/" | |
108 |
|
108 | |||
109 | # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/ |
|
109 | # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/ | |
110 | as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth |
|
110 | as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth | |
111 | as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth |
|
111 | as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth | |
112 |
|
112 | |||
113 | # Set permissions |
|
113 | # Set permissions | |
114 | chown -R root:root "${R}/tmp/pi-bluetooth" |
|
114 | chown -R root:root "${R}/tmp/pi-bluetooth" | |
115 |
|
115 | |||
116 | # Install tools |
|
116 | # Install tools | |
117 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart" |
|
117 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart" | |
118 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper" |
|
118 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper" | |
119 |
|
119 | |||
120 | # Install bluetooth udev rule |
|
120 | # Install bluetooth udev rule | |
121 | install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules" |
|
121 | install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules" | |
122 |
|
122 | |||
123 | # Install Firmware Flash file and apropiate licence |
|
123 | # Install Firmware Flash file and apropiate licence | |
124 | mkdir -p "$BLUETOOTH_FIRMWARE_DIR" |
|
124 | mkdir -p "$BLUETOOTH_FIRMWARE_DIR" | |
125 | install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx" |
|
125 | install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx" | |
126 | install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx" |
|
126 | install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx" | |
127 | install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service" |
|
127 | install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service" | |
128 | install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service" |
|
128 | install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service" | |
129 |
|
129 | |||
130 |
# Remove temporary director |
|
130 | # Remove temporary directories | |
131 | rm -fr "${temp_dir}" |
|
131 | rm -fr "${temp_dir}" | |
|
132 | rm -fr "${R}"/tmp/pi-bluetooth | |||
132 |
|
133 | |||
133 | # 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 |
|
134 | # 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 | |
134 | if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then |
|
135 | if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then | |
135 |
|
136 | |||
136 | # set overlay to swap ttyAMA0 and ttyS0 |
|
137 | # set overlay to swap ttyAMA0 and ttyS0 | |
137 | echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt" |
|
138 | echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt" | |
138 |
|
139 | |||
139 | # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken |
|
140 | # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken | |
140 | if [ "$ENABLE_TURBO" = false ] ; then |
|
141 | if [ "$ENABLE_TURBO" = false ] ; then | |
141 | echo "core_freq=250" >> "${BOOT_DIR}/config.txt" |
|
142 | echo "core_freq=250" >> "${BOOT_DIR}/config.txt" | |
142 | fi |
|
143 | fi | |
143 | fi |
|
144 | fi | |
144 |
|
145 | |||
145 | # Activate services |
|
146 | # Activate services | |
146 | chroot_exec systemctl enable pi-bluetooth.hciuart.service |
|
147 | chroot_exec systemctl enable pi-bluetooth.hciuart.service | |
147 | chroot_exec systemctl enable pi-bluetooth.bthelper@serial1.service |
|
148 | chroot_exec systemctl enable pi-bluetooth.bthelper@serial1.service | |
148 |
|
149 | |||
149 | else # if ENABLE_BLUETOOTH = false |
|
150 | else # if ENABLE_BLUETOOTH = false | |
150 | # set overlay to disable bluetooth |
|
151 | # set overlay to disable bluetooth | |
151 | echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" |
|
152 | echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" | |
152 | fi # ENABLE_BLUETOOTH end |
|
153 | fi # ENABLE_BLUETOOTH end | |
153 | fi |
|
154 | fi | |
154 |
|
155 | |||
155 | # may need sudo systemctl disable hciuart |
|
156 | # may need sudo systemctl disable hciuart | |
156 | if [ "$ENABLE_CONSOLE" = true ] ; then |
|
157 | if [ "$ENABLE_CONSOLE" = true ] ; then | |
157 | echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" |
|
158 | echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" | |
158 | # add string to cmdline |
|
159 | # add string to cmdline | |
159 | CMDLINE="${CMDLINE} console=serial0,115200" |
|
160 | CMDLINE="${CMDLINE} console=serial0,115200" | |
160 |
|
161 | |||
161 | # Enable serial console systemd style |
|
162 | # Enable serial console systemd style | |
162 | chroot_exec systemctl enable serial-getty@serial0.service |
|
163 | chroot_exec systemctl enable serial-getty@serial0.service | |
163 | else |
|
164 | else | |
164 | echo "enable_uart=0" >> "${BOOT_DIR}/config.txt" |
|
165 | echo "enable_uart=0" >> "${BOOT_DIR}/config.txt" | |
165 | # disable serial console systemd style |
|
166 | # disable serial console systemd style | |
166 | #chroot_exec systemctl disable serial-getty@serial0.service |
|
167 | #chroot_exec systemctl disable serial-getty@serial0.service | |
167 | fi |
|
168 | fi | |
168 |
|
169 | |||
169 | # Remove cmdline.txt entry of starting zswap |
|
170 | # Remove cmdline.txt entry of starting zswap | |
170 | if [ "$KERNEL_ZSWAP" = true ] ; then |
|
171 | if [ "$KERNEL_ZSWAP" = true ] ; then | |
171 | CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4" |
|
172 | CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4" | |
172 | fi |
|
173 | fi | |
173 |
|
174 | |||
174 | if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then |
|
175 | if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then | |
175 |
|
176 | |||
176 | # Remove cmdline.txt entry of starting zswap |
|
177 | # Remove cmdline.txt entry of starting zswap | |
177 | if [ "$KERNEL_ZSWAP" = true ] ; then |
|
178 | if [ "$KERNEL_ZSWAP" = true ] ; then | |
178 | sed -i 's|zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4||g' |
|
179 | sed -i 's|zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4||g' | |
179 | fi |
|
180 | fi | |
180 | # Create temporary directory for systemd-swap sources |
|
181 | # Create temporary directory for systemd-swap sources | |
181 | temp_dir=$(as_nobody mktemp -d) |
|
182 | temp_dir=$(as_nobody mktemp -d) | |
182 |
|
183 | |||
183 | # Fetch systemd-swap sources |
|
184 | # Fetch systemd-swap sources | |
184 | as_nobody git -C "${temp_dir}" clone "${ZSWAP_URL}" |
|
185 | as_nobody git -C "${temp_dir}" clone "${ZSWAP_URL}" | |
185 |
|
186 | |||
186 | # Copy downloaded systemd-swap sources |
|
187 | # Copy downloaded systemd-swap sources | |
187 | mv "${temp_dir}/systemd-swap" "${R}/tmp/" |
|
188 | mv "${temp_dir}/systemd-swap" "${R}/tmp/" | |
188 |
|
189 | |||
189 | # Set permissions of the systemd-swap sources |
|
190 | # Set permissions of the systemd-swap sources | |
190 | chown -R root:root "${R}/tmp/systemd-swap" |
|
191 | chown -R root:root "${R}/tmp/systemd-swap" | |
191 |
|
192 | |||
192 | # Remove temporary directory for systemd-swap sources |
|
193 | # Remove temporary directory for systemd-swap sources | |
193 | rm -fr "${temp_dir}" |
|
194 | rm -fr "${temp_dir}" | |
194 |
|
195 | |||
195 | # Change into downloaded src dir |
|
196 | # Change into downloaded src dir | |
196 | cd "${R}/tmp/systemd-swap" || exit |
|
197 | cd "${R}/tmp/systemd-swap" || exit | |
197 |
|
198 | |||
198 | # Build package |
|
199 | # Build package | |
199 | . ./systemd-swap/package.sh debian |
|
200 | . ./systemd-swap/package.sh debian | |
200 |
|
201 | |||
201 | # Install package |
|
202 | # Install package | |
202 | chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap-*any.deb |
|
203 | chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap-*any.deb | |
203 |
|
204 | |||
204 | # Enable service |
|
205 | # Enable service | |
205 | chroot_exec systemctl enable systemd-swap |
|
206 | chroot_exec systemctl enable systemd-swap | |
206 |
|
207 | |||
207 | # Change back into script root dir |
|
208 | # Change back into script root dir | |
208 | cd "${WORKDIR}" || exit |
|
209 | cd "${WORKDIR}" || exit | |
209 | fi |
|
210 | fi | |
210 |
|
211 | |||
211 | # Install firmware boot cmdline |
|
212 | # Install firmware boot cmdline | |
212 | echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" |
|
213 | echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" | |
213 |
|
214 | |||
214 | # Setup minimal GPU memory allocation size: 16MB (no X) |
|
215 | # Setup minimal GPU memory allocation size: 16MB (no X) | |
215 | if [ "$ENABLE_MINGPU" = true ] ; then |
|
216 | if [ "$ENABLE_MINGPU" = true ] ; then | |
216 | echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" |
|
217 | echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" | |
217 | fi |
|
218 | fi | |
218 |
|
219 | |||
219 | # Setup boot with initramfs |
|
220 | # Setup boot with initramfs | |
220 | if [ "$ENABLE_INITRAMFS" = true ] ; then |
|
221 | if [ "$ENABLE_INITRAMFS" = true ] ; then | |
221 | echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt" |
|
222 | echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt" | |
222 | fi |
|
223 | fi | |
223 |
|
224 | |||
224 | # Create firmware configuration and cmdline symlinks |
|
225 | # Create firmware configuration and cmdline symlinks | |
225 | ln -sf firmware/config.txt "${R}/boot/config.txt" |
|
226 | ln -sf firmware/config.txt "${R}/boot/config.txt" | |
226 | ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt" |
|
227 | ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt" | |
227 |
|
228 | |||
228 | # Install and setup kernel modules to load at boot |
|
229 | # Install and setup kernel modules to load at boot | |
229 | mkdir -p "${LIB_DIR}/modules-load.d/" |
|
230 | mkdir -p "${LIB_DIR}/modules-load.d/" | |
230 | install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
231 | install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf" | |
231 |
|
232 | |||
232 | # Load hardware random module at boot |
|
233 | # Load hardware random module at boot | |
233 | if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then |
|
234 | if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then | |
234 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
235 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
235 | fi |
|
236 | fi | |
236 |
|
237 | |||
237 | # Load sound module at boot |
|
238 | # Load sound module at boot | |
238 | if [ "$ENABLE_SOUND" = true ] ; then |
|
239 | if [ "$ENABLE_SOUND" = true ] ; then | |
239 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
240 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
240 | else |
|
241 | else | |
241 | echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt" |
|
242 | echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt" | |
242 | fi |
|
243 | fi | |
243 |
|
244 | |||
244 | # Enable I2C interface |
|
245 | # Enable I2C interface | |
245 | if [ "$ENABLE_I2C" = true ] ; then |
|
246 | if [ "$ENABLE_I2C" = true ] ; then | |
246 | echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" |
|
247 | echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" | |
247 | sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
248 | sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
248 | sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
249 | sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
249 | fi |
|
250 | fi | |
250 |
|
251 | |||
251 | # Enable SPI interface |
|
252 | # Enable SPI interface | |
252 | if [ "$ENABLE_SPI" = true ] ; then |
|
253 | if [ "$ENABLE_SPI" = true ] ; then | |
253 | echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" |
|
254 | echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" | |
254 | echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
255 | echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf" | |
255 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then |
|
256 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then | |
256 | sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
257 | sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
257 | fi |
|
258 | fi | |
258 | fi |
|
259 | fi | |
259 |
|
260 | |||
260 | # Disable RPi2/3 under-voltage warnings |
|
261 | # Disable RPi2/3 under-voltage warnings | |
261 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then |
|
262 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then | |
262 | echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" |
|
263 | echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" | |
263 | fi |
|
264 | fi | |
264 |
|
265 | |||
265 | # Install kernel modules blacklist |
|
266 | # Install kernel modules blacklist | |
266 | mkdir -p "${ETC_DIR}/modprobe.d/" |
|
267 | mkdir -p "${ETC_DIR}/modprobe.d/" | |
267 | install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" |
|
268 | install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" | |
268 |
|
269 | |||
269 | # Install sysctl.d configuration files |
|
270 | # Install sysctl.d configuration files | |
270 | install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" |
|
271 | install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" |
@@ -1,53 +1,56 | |||||
1 | # |
|
1 | # | |
2 | # Setup videocore - Raspberry Userland |
|
2 | # Setup videocore - Raspberry Userland | |
3 | # |
|
3 | # | |
4 |
|
4 | |||
5 | # Load utility functions |
|
5 | # Load utility functions | |
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | if [ "$ENABLE_VIDEOCORE" = true ] ; then |
|
8 | if [ "$ENABLE_VIDEOCORE" = true ] ; then | |
9 | # Copy existing videocore sources into chroot directory |
|
9 | # Copy existing videocore sources into chroot directory | |
10 | if [ -n "$VIDEOCORESRC_DIR" ] && [ -d "$VIDEOCORESRC_DIR" ] ; then |
|
10 | if [ -n "$VIDEOCORESRC_DIR" ] && [ -d "$VIDEOCORESRC_DIR" ] ; then | |
11 | # Copy local videocore sources |
|
11 | # Copy local videocore sources | |
12 | cp -r "${VIDEOCORESRC_DIR}" "${R}/tmp/userland" |
|
12 | cp -r "${VIDEOCORESRC_DIR}" "${R}/tmp/userland" | |
13 | else |
|
13 | else | |
14 | # Create temporary directory for videocore sources |
|
14 | # Create temporary directory for videocore sources | |
15 | temp_dir=$(as_nobody mktemp -d) |
|
15 | temp_dir=$(as_nobody mktemp -d) | |
16 |
|
16 | |||
17 | # Fetch videocore sources |
|
17 | # Fetch videocore sources | |
18 | as_nobody git -C "${temp_dir}" clone "${VIDEOCORE_URL}" |
|
18 | as_nobody git -C "${temp_dir}" clone "${VIDEOCORE_URL}" | |
19 |
|
19 | |||
20 | # Copy downloaded videocore sources |
|
20 | # Copy downloaded videocore sources | |
21 | mv "${temp_dir}/userland" "${R}/tmp/" |
|
21 | mv "${temp_dir}/userland" "${R}/tmp/" | |
22 |
|
22 | |||
23 | # Set permissions of the U-Boot sources |
|
23 | # Set permissions of the U-Boot sources | |
24 | chown -R root:root "${R}/tmp/userland" |
|
24 | chown -R root:root "${R}/tmp/userland" | |
25 |
|
25 | |||
26 | # Remove temporary directory for U-Boot sources |
|
26 | # Remove temporary directory for U-Boot sources | |
27 | rm -fr "${temp_dir}" |
|
27 | rm -fr "${temp_dir}" | |
28 | fi |
|
28 | fi | |
29 |
|
29 | |||
30 | # Create build dir |
|
30 | # Create build dir | |
31 | mkdir "${R}"/tmp/userland/build |
|
31 | mkdir "${R}"/tmp/userland/build | |
32 |
|
32 | |||
33 | # push us to build directory |
|
33 | # push us to build directory | |
34 | cd "${R}"/tmp/userland/build |
|
34 | cd "${R}"/tmp/userland/build | |
35 |
|
35 | |||
36 | if [ "$RELEASE_ARCH" = "arm64" ] ; then |
|
36 | if [ "$RELEASE_ARCH" = "arm64" ] ; then | |
37 | cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DARM64=ON -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_ASM_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE" -DCMAKE_ASM_FLAGS="${CMAKE_ASM_FLAGS} -c" -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland" |
|
37 | cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DARM64=ON -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_ASM_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE" -DCMAKE_ASM_FLAGS="${CMAKE_ASM_FLAGS} -c" -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland" | |
38 | fi |
|
38 | fi | |
39 |
|
39 | |||
40 | if [ "$RELEASE_ARCH" = "armel" ] ; then |
|
40 | if [ "$RELEASE_ARCH" = "armel" ] ; then | |
41 | cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabi-g++ -DCMAKE_ASM_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE" -DCMAKE_ASM_FLAGS="${CMAKE_ASM_FLAGS} -c" -DCMAKE_SYSTEM_PROCESSOR="arm" -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland" |
|
41 | cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabi-g++ -DCMAKE_ASM_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE" -DCMAKE_ASM_FLAGS="${CMAKE_ASM_FLAGS} -c" -DCMAKE_SYSTEM_PROCESSOR="arm" -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland" | |
42 | fi |
|
42 | fi | |
43 |
|
43 | |||
44 | if [ "$RELEASE_ARCH" = "armhf" ] ; then |
|
44 | if [ "$RELEASE_ARCH" = "armhf" ] ; then | |
45 | cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE="${R}"/tmp/userland/makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland" |
|
45 | cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE="${R}"/tmp/userland/makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland" | |
46 | fi |
|
46 | fi | |
47 |
|
47 | |||
48 | #build userland |
|
48 | #build userland | |
49 | make -j "$(nproc)" |
|
49 | make -j "$(nproc)" | |
50 |
|
50 | |||
51 | #back to root of scriptdir |
|
51 | #back to root of scriptdir | |
52 | cd "${WORKDIR}" |
|
52 | cd "${WORKDIR}" | |
|
53 | ||||
|
54 | # Remove videocore sources | |||
|
55 | rm -fr "${R}"/tmp/userland/ | |||
53 | fi |
|
56 | fi |
@@ -1,104 +1,107 | |||||
1 | #!/bin/sh |
|
1 | #!/bin/sh | |
2 | # |
|
2 | # | |
3 | # Build and Setup nexmon with monitor mode patch |
|
3 | # Build and Setup nexmon with monitor mode patch | |
4 | # |
|
4 | # | |
5 |
|
5 | |||
6 | # Load utility functions |
|
6 | # Load utility functions | |
7 | . ./functions.sh |
|
7 | . ./functions.sh | |
8 |
|
8 | |||
9 | if [ "$ENABLE_NEXMON" = true ] && [ "$ENABLE_WIRELESS" = true ]; then |
|
9 | if [ "$ENABLE_NEXMON" = true ] && [ "$ENABLE_WIRELESS" = true ]; then | |
10 | # Copy existing nexmon sources into chroot directory |
|
10 | # Copy existing nexmon sources into chroot directory | |
11 | if [ -n "$NEXMONSRC_DIR" ] && [ -d "$NEXMONSRC_DIR" ] ; then |
|
11 | if [ -n "$NEXMONSRC_DIR" ] && [ -d "$NEXMONSRC_DIR" ] ; then | |
12 | # Copy local U-Boot sources |
|
12 | # Copy local U-Boot sources | |
13 | cp -r "${NEXMONSRC_DIR}" "${R}/tmp" |
|
13 | cp -r "${NEXMONSRC_DIR}" "${R}/tmp" | |
14 | else |
|
14 | else | |
15 | # Create temporary directory for nexmon sources |
|
15 | # Create temporary directory for nexmon sources | |
16 | temp_dir=$(as_nobody mktemp -d) |
|
16 | temp_dir=$(as_nobody mktemp -d) | |
17 |
|
17 | |||
18 | # Fetch nexmon sources |
|
18 | # Fetch nexmon sources | |
19 | as_nobody git -C "${temp_dir}" clone "${NEXMON_URL}" |
|
19 | as_nobody git -C "${temp_dir}" clone "${NEXMON_URL}" | |
20 |
|
20 | |||
21 | # Copy downloaded nexmon sources |
|
21 | # Copy downloaded nexmon sources | |
22 | mv "${temp_dir}/nexmon" "${R}"/tmp/ |
|
22 | mv "${temp_dir}/nexmon" "${R}"/tmp/ | |
23 |
|
23 | |||
24 | # Set permissions of the nexmon sources |
|
24 | # Set permissions of the nexmon sources | |
25 | chown -R root:root "${R}"/tmp/nexmon |
|
25 | chown -R root:root "${R}"/tmp/nexmon | |
26 |
|
26 | |||
27 | # Remove temporary directory for nexmon sources |
|
27 | # Remove temporary directory for nexmon sources | |
28 | rm -fr "${temp_dir}" |
|
28 | rm -fr "${temp_dir}" | |
29 | fi |
|
29 | fi | |
30 |
|
30 | |||
31 | # Set script Root |
|
31 | # Set script Root | |
32 | export NEXMON_ROOT="${R}"/tmp/nexmon |
|
32 | export NEXMON_ROOT="${R}"/tmp/nexmon | |
33 |
|
33 | |||
34 | # Build nexmon firmware outside the build system, if we can. |
|
34 | # Build nexmon firmware outside the build system, if we can. | |
35 | cd "${NEXMON_ROOT}" || exit |
|
35 | cd "${NEXMON_ROOT}" || exit | |
36 |
|
36 | |||
37 | # Make ancient isl build |
|
37 | # Make ancient isl build | |
38 | cd buildtools/isl-0.10 || exit |
|
38 | cd buildtools/isl-0.10 || exit | |
39 | ./configure |
|
39 | ./configure | |
40 | make |
|
40 | make | |
41 | cd ../.. || exit |
|
41 | cd ../.. || exit | |
42 |
|
42 | |||
43 | # Disable statistics |
|
43 | # Disable statistics | |
44 | touch DISABLE_STATISTICS |
|
44 | touch DISABLE_STATISTICS | |
45 |
|
45 | |||
46 | # Setup Enviroment: see https://github.com/NoobieDog/nexmon/blob/master/setup_env.sh |
|
46 | # Setup Enviroment: see https://github.com/NoobieDog/nexmon/blob/master/setup_env.sh | |
47 | #ARCH="${KERNEL_ARCH}" |
|
47 | #ARCH="${KERNEL_ARCH}" | |
48 | #SUBARCH="${KERNEL_ARCH}" |
|
48 | #SUBARCH="${KERNEL_ARCH}" | |
49 | export KERNEL="${KERNEL_IMAGE}" |
|
49 | export KERNEL="${KERNEL_IMAGE}" | |
50 | export ARCH=arm |
|
50 | export ARCH=arm | |
51 | export SUBARCH=arm |
|
51 | export SUBARCH=arm | |
52 | export CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- |
|
52 | export CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- | |
53 | export CC="${CC}"gcc |
|
53 | export CC="${CC}"gcc | |
54 | export CCPLUGIN="${NEXMON_ROOT}"/buildtools/gcc-nexmon-plugin/nexmon.so |
|
54 | export CCPLUGIN="${NEXMON_ROOT}"/buildtools/gcc-nexmon-plugin/nexmon.so | |
55 | export ZLIBFLATE="zlib-flate -compress" |
|
55 | export ZLIBFLATE="zlib-flate -compress" | |
56 | export Q=@ |
|
56 | export Q=@ | |
57 | export NEXMON_SETUP_ENV=1 |
|
57 | export NEXMON_SETUP_ENV=1 | |
58 | export HOSTUNAME=$(uname -s) |
|
58 | export HOSTUNAME=$(uname -s) | |
59 | export PLATFORMUNAME=$(uname -m) |
|
59 | export PLATFORMUNAME=$(uname -m) | |
60 | #. ./setup_env.sh |
|
60 | #. ./setup_env.sh | |
61 |
|
61 | |||
62 | # Make nexmon |
|
62 | # Make nexmon | |
63 | make |
|
63 | make | |
64 |
|
64 | |||
65 | # Backup stock broadcom wlan driver - "${LIB_DIR}"/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko |
|
65 | # Backup stock broadcom wlan driver - "${LIB_DIR}"/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko | |
66 | #brcmfmac_path=$(modinfo brcmfmac | grep -m 1 -oP "^filename:(\s*?)(.*)$" | sed -e 's/^filename:\(\s*\)\(.*\)$/\2/g') |
|
66 | #brcmfmac_path=$(modinfo brcmfmac | grep -m 1 -oP "^filename:(\s*?)(.*)$" | sed -e 's/^filename:\(\s*\)\(.*\)$/\2/g') | |
67 | #brcmfmac_path="${LIB_DIR}"/modules/"${KERNEL_VERSION}"/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko |
|
67 | #brcmfmac_path="${LIB_DIR}"/modules/"${KERNEL_VERSION}"/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko | |
68 | #mv "${brcmfmac_path}" "${brcmfmac_path}".orig |
|
68 | #mv "${brcmfmac_path}" "${brcmfmac_path}".orig | |
69 |
|
69 | |||
70 | # |
|
70 | # | |
71 |
|
71 | |||
72 | # build patches |
|
72 | # build patches | |
73 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] ; then |
|
73 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] ; then | |
74 | cd "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon || exit |
|
74 | cd "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon || exit | |
75 | make clean |
|
75 | make clean | |
76 |
|
76 | |||
77 | # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. |
|
77 | # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. | |
78 | LD_LIBRARY_PATH="${NEXMON_ROOT}"/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- |
|
78 | LD_LIBRARY_PATH="${NEXMON_ROOT}"/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- | |
79 |
|
79 | |||
80 | # copy RPi0W & RPi3 firmware |
|
80 | # copy RPi0W & RPi3 firmware | |
81 | mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.org.bin |
|
81 | mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.org.bin | |
82 | cp "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.nexmon.bin |
|
82 | cp "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.nexmon.bin | |
83 | cp -f "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin |
|
83 | cp -f "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin | |
84 |
|
84 | |||
85 | cp "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac_4.14.y-nexmon/brcmfmac.ko "${brcmfmac_path}" |
|
85 | cp "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac_4.14.y-nexmon/brcmfmac.ko "${brcmfmac_path}" | |
86 | fi |
|
86 | fi | |
87 |
|
87 | |||
88 | if [ "$RPI_MODEL" = 3P ] ; then |
|
88 | if [ "$RPI_MODEL" = 3P ] ; then | |
89 | cd "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon || exit |
|
89 | cd "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon || exit | |
90 | make clean |
|
90 | make clean | |
91 |
|
91 | |||
92 | # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. |
|
92 | # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. | |
93 | LD_LIBRARY_PATH=${NEXMON_ROOT}/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- |
|
93 | LD_LIBRARY_PATH=${NEXMON_ROOT}/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- | |
94 |
|
94 | |||
95 | # RPi3B+ firmware |
|
95 | # RPi3B+ firmware | |
96 | mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.org.bin |
|
96 | mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.org.bin | |
97 | cp "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.nexmon.bin |
|
97 | cp "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.nexmon.bin | |
98 | cp -f "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin |
|
98 | cp -f "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin | |
99 | fi |
|
99 | fi | |
100 |
|
100 | |||
101 | #Revert to previous directory |
|
101 | #Revert to previous directory | |
102 | cd "${WORKDIR}" || exit |
|
102 | cd "${WORKDIR}" || exit | |
103 |
|
103 | |||
|
104 | # Remove nexmon sources | |||
|
105 | rm -fr "${NEXMON_ROOT}" | |||
|
106 | ||||
104 | fi |
|
107 | fi |
@@ -1,97 +1,108 | |||||
1 | #!/bin/sh |
|
1 | #!/bin/sh | |
2 | # This file contains utility functions used by rpi23-gen-image.sh |
|
2 | # This file contains utility functions used by rpi23-gen-image.sh | |
3 |
|
3 | |||
4 | cleanup (){ |
|
4 | cleanup (){ | |
5 | set +x |
|
5 | set +x | |
6 | set +e |
|
6 | set +e | |
|
7 | ||||
|
8 | # Remove exports from nexmon | |||
|
9 | unset KERNEL | |||
|
10 | unset ARCH | |||
|
11 | unset SUBARCH | |||
|
12 | unset CCPLUGIN | |||
|
13 | unset ZLIBFLATE | |||
|
14 | unset Q | |||
|
15 | unset NEXMON_SETUP_ENV | |||
|
16 | unset HOSTUNAME | |||
|
17 | unset PLATFORMUNAME | |||
7 |
|
18 | |||
8 | # Identify and kill all processes still using files |
|
19 | # Identify and kill all processes still using files | |
9 | echo "killing processes using mount point ..." |
|
20 | echo "killing processes using mount point ..." | |
10 | fuser -k "${R}" |
|
21 | fuser -k "${R}" | |
11 | sleep 3 |
|
22 | sleep 3 | |
12 | fuser -9 -k -v "${R}" |
|
23 | fuser -9 -k -v "${R}" | |
13 |
|
24 | |||
14 | # Clean up temporary .password file |
|
25 | # Clean up temporary .password file | |
15 | if [ -r ".password" ] ; then |
|
26 | if [ -r ".password" ] ; then | |
16 | shred -zu .password |
|
27 | shred -zu .password | |
17 | fi |
|
28 | fi | |
18 |
|
29 | |||
19 | # Clean up all temporary mount points |
|
30 | # Clean up all temporary mount points | |
20 | echo "removing temporary mount points ..." |
|
31 | echo "removing temporary mount points ..." | |
21 | umount -l "${R}/proc" 2> /dev/null |
|
32 | umount -l "${R}/proc" 2> /dev/null | |
22 | umount -l "${R}/sys" 2> /dev/null |
|
33 | umount -l "${R}/sys" 2> /dev/null | |
23 | umount -l "${R}/dev/pts" 2> /dev/null |
|
34 | umount -l "${R}/dev/pts" 2> /dev/null | |
24 | umount "$BUILDDIR/mount/boot/firmware" 2> /dev/null |
|
35 | umount "$BUILDDIR/mount/boot/firmware" 2> /dev/null | |
25 | umount "$BUILDDIR/mount" 2> /dev/null |
|
36 | umount "$BUILDDIR/mount" 2> /dev/null | |
26 | cryptsetup close "${CRYPTFS_MAPPING}" 2> /dev/null |
|
37 | cryptsetup close "${CRYPTFS_MAPPING}" 2> /dev/null | |
27 | losetup -d "$ROOT_LOOP" 2> /dev/null |
|
38 | losetup -d "$ROOT_LOOP" 2> /dev/null | |
28 | losetup -d "$FRMW_LOOP" 2> /dev/null |
|
39 | losetup -d "$FRMW_LOOP" 2> /dev/null | |
29 | trap - 0 1 2 3 6 |
|
40 | trap - 0 1 2 3 6 | |
30 | } |
|
41 | } | |
31 |
|
42 | |||
32 | chroot_exec() { |
|
43 | chroot_exec() { | |
33 | # Exec command in chroot |
|
44 | # Exec command in chroot | |
34 | LANG=C LC_ALL=C DEBIAN_FRONTEND=noninteractive chroot "${R}" "$@" |
|
45 | LANG=C LC_ALL=C DEBIAN_FRONTEND=noninteractive chroot "${R}" "$@" | |
35 | } |
|
46 | } | |
36 |
|
47 | |||
37 | as_nobody() { |
|
48 | as_nobody() { | |
38 | # Exec command as user nobody |
|
49 | # Exec command as user nobody | |
39 | sudo -E -u nobody LANG=C LC_ALL=C "$@" |
|
50 | sudo -E -u nobody LANG=C LC_ALL=C "$@" | |
40 | } |
|
51 | } | |
41 |
|
52 | |||
42 | install_readonly() { |
|
53 | install_readonly() { | |
43 | # Install file with user read-only permissions |
|
54 | # Install file with user read-only permissions | |
44 | install -o root -g root -m 644 "$@" |
|
55 | install -o root -g root -m 644 "$@" | |
45 | } |
|
56 | } | |
46 |
|
57 | |||
47 | install_exec() { |
|
58 | install_exec() { | |
48 | # Install file with root exec permissions |
|
59 | # Install file with root exec permissions | |
49 | install -o root -g root -m 744 "$@" |
|
60 | install -o root -g root -m 744 "$@" | |
50 | } |
|
61 | } | |
51 |
|
62 | |||
52 | use_template () { |
|
63 | use_template () { | |
53 | # Test if configuration template file exists |
|
64 | # Test if configuration template file exists | |
54 | if [ ! -r "./templates/${CONFIG_TEMPLATE}" ] ; then |
|
65 | if [ ! -r "./templates/${CONFIG_TEMPLATE}" ] ; then | |
55 | echo "error: configuration template ${CONFIG_TEMPLATE} not found" |
|
66 | echo "error: configuration template ${CONFIG_TEMPLATE} not found" | |
56 | exit 1 |
|
67 | exit 1 | |
57 | fi |
|
68 | fi | |
58 |
|
69 | |||
59 | # Load template configuration parameters |
|
70 | # Load template configuration parameters | |
60 | . "./templates/${CONFIG_TEMPLATE}" |
|
71 | . "./templates/${CONFIG_TEMPLATE}" | |
61 | } |
|
72 | } | |
62 |
|
73 | |||
63 | chroot_install_cc() { |
|
74 | chroot_install_cc() { | |
64 | # Install c/c++ build environment inside the chroot |
|
75 | # Install c/c++ build environment inside the chroot | |
65 | if [ -z "${COMPILER_PACKAGES}" ] ; then |
|
76 | if [ -z "${COMPILER_PACKAGES}" ] ; then | |
66 | COMPILER_PACKAGES=$(chroot_exec apt-get -s install g++ make bc | grep "^Inst " | awk -v ORS=" " '{ print $2 }') |
|
77 | COMPILER_PACKAGES=$(chroot_exec apt-get -s install g++ make bc | grep "^Inst " | awk -v ORS=" " '{ print $2 }') | |
67 | # Install COMPILER_PACKAGES in chroot |
|
78 | # Install COMPILER_PACKAGES in chroot | |
68 | chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install "${COMPILER_PACKAGES}" |
|
79 | chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install "${COMPILER_PACKAGES}" | |
69 | fi |
|
80 | fi | |
70 | } |
|
81 | } | |
71 |
|
82 | |||
72 | chroot_remove_cc() { |
|
83 | chroot_remove_cc() { | |
73 | # Remove c/c++ build environment from the chroot |
|
84 | # Remove c/c++ build environment from the chroot | |
74 | if [ -n "${COMPILER_PACKAGES}" ] ; then |
|
85 | if [ -n "${COMPILER_PACKAGES}" ] ; then | |
75 | chroot_exec apt-get -qq -y --auto-remove purge "${COMPILER_PACKAGES}" |
|
86 | chroot_exec apt-get -qq -y --auto-remove purge "${COMPILER_PACKAGES}" | |
76 | COMPILER_PACKAGES="" |
|
87 | COMPILER_PACKAGES="" | |
77 | fi |
|
88 | fi | |
78 | } |
|
89 | } | |
79 | #GPL v2.0 |
|
90 | #GPL v2.0 | |
80 | #https://github.com/sakaki-/bcmrpi3-kernel-bis/blob/master/conform_config.sh |
|
91 | #https://github.com/sakaki-/bcmrpi3-kernel-bis/blob/master/conform_config.sh | |
81 | set_kernel_config() { |
|
92 | set_kernel_config() { | |
82 | # flag as $1, value to set as $2, config must exist at "./.config" |
|
93 | # flag as $1, value to set as $2, config must exist at "./.config" | |
83 | TGT="CONFIG_${1#CONFIG_}" |
|
94 | TGT="CONFIG_${1#CONFIG_}" | |
84 | REP="${2}" |
|
95 | REP="${2}" | |
85 | if grep -q "^${TGT}[^_]" .config; then |
|
96 | if grep -q "^${TGT}[^_]" .config; then | |
86 | sed -i "s/^\(${TGT}=.*\|# ${TGT} is not set\)/${TGT}=${REP}/" .config |
|
97 | sed -i "s/^\(${TGT}=.*\|# ${TGT} is not set\)/${TGT}=${REP}/" .config | |
87 | else |
|
98 | else | |
88 | echo "${TGT}"="${2}" >> .config |
|
99 | echo "${TGT}"="${2}" >> .config | |
89 | fi |
|
100 | fi | |
90 | } |
|
101 | } | |
91 |
|
102 | |||
92 | unset_kernel_config() { |
|
103 | unset_kernel_config() { | |
93 | # unsets flag with the value of $1, config must exist at "./.config" |
|
104 | # unsets flag with the value of $1, config must exist at "./.config" | |
94 | TGT="CONFIG_${1#CONFIG_}" |
|
105 | TGT="CONFIG_${1#CONFIG_}" | |
95 | sed -i "s/^${TGT}=.*/# ${TGT} is not set/" .config |
|
106 | sed -i "s/^${TGT}=.*/# ${TGT} is not set/" .config | |
96 | } |
|
107 | } | |
97 | # No newline at end of file |
|
108 | # |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant