##// END OF EJS Templates
Better Bluetooth and serial...
Unknown -
r443:c6c99c428cd2
parent child
Show More
@@ -0,0 +1,1
1 kernel.printk = 3 4 1 3 No newline at end of file
@@ -0,0 +1,33
1 SUBSYSTEM=="input", GROUP="input", MODE="0660"
2 SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0660"
3 SUBSYSTEM=="spidev", GROUP="spi", MODE="0660"
4 SUBSYSTEM=="bcm2835-gpiomem", GROUP="gpio", MODE="0660"
5
6 SUBSYSTEM=="gpio", GROUP="gpio", MODE="0660"
7 SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c '\
8 chown -R root:gpio /sys/class/gpio && chmod -R 770 /sys/class/gpio;\
9 chown -R root:gpio /sys/devices/virtual/gpio && chmod -R 770 /sys/devices/virtual/gpio;\
10 chown -R root:gpio /sys$devpath && chmod -R 770 /sys$devpath\
11 '"
12
13 KERNEL=="ttyAMA[01]", PROGRAM="/bin/sh -c '\
14 ALIASES=/proc/device-tree/aliases; \
15 if cmp -s $ALIASES/uart0 $ALIASES/serial0; then \
16 echo 0;\
17 elif cmp -s $ALIASES/uart0 $ALIASES/serial1; then \
18 echo 1; \
19 else \
20 exit 1; \
21 fi\
22 '", SYMLINK+="serial%c"
23
24 KERNEL=="ttyS0", PROGRAM="/bin/sh -c '\
25 ALIASES=/proc/device-tree/aliases; \
26 if cmp -s $ALIASES/uart1 $ALIASES/serial0; then \
27 echo 0; \
28 elif cmp -s $ALIASES/uart1 $ALIASES/serial1; then \
29 echo 1; \
30 else \
31 exit 1; \
32 fi \
33 '", SYMLINK+="serial%c"
@@ -153,7 +153,19 Set the IP address for the second NTP server.
153 153
154 154 #### Basic system features:
155 155 ##### `ENABLE_CONSOLE`=true
156 Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2/3. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system.
156 Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2/3. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system. On RPI `0` `3` `3P` the CPU speed is locked at lowest speed.
157
158 ##### `ENABLE_PRINTK`=false
159 Enables printing kernel messages to konsole. printk is `3 4 1 3` as in raspbian.
160
161 ##### `ENABLE_BLUETOOTH`=false
162 Enable onboard Bluetooth interface on the RPi0/3/3P. See: https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/
163
164 ##### `ENABLE_MINIUART_OVERLAY`=false
165 Enable Bluetooth to use this. Adds overlay to swap UART0 with UART1. Enabling (slower) Bluetooth and full speed serial console. - RPI `0` `3` `3P` have a fast `hardware UART0` (ttyAMA0) and a `mini UART1` (ttyS0)! RPI `1` `1P` `2` only have a `hardware UART0`. `UART0` is considered better, because is faster and more stable than `mini UART1`. By default the Bluetooth modem is mapped to the `hardware UART0` and `mini UART` is used for console. The `mini UART` is a problem for the serial console, because its baudrate depends on the cpu frequency, which is changing on runtime. Resulting in a volatile baudrate and thus in an unusable serial console.
166
167 ##### `ENABLE_TURBO`=false
168 Enable Turbo mode. This setting locks cpu at highest frequency. As setting ENABLE_CONSOLE=true locks RPI to lowest CPU speed, this is can be used additionally to lock cpu hat max speed. Need a good power supply and probably cooling for the Raspberry PI.
157 169
158 170 ##### `ENABLE_I2C`=false
159 171 Enable I2C interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
@@ -173,9 +185,6 Allow the installation of non-free Debian packages that do not comply with the D
173 185 ##### `ENABLE_WIRELESS`=false
174 186 Download and install the [closed-source firmware binary blob](https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm) that is required to run the internal wireless interface of the Raspberry Pi model `3`. This parameter is ignored if the specified `RPI_MODEL` is not `3`.
175 187
176 ##### `ENABLE_BLUETOOTH`=false
177 Enable Bluetooth interface on the RPi0/3/3P.
178
179 188 ##### `ENABLE_RSYSLOG`=true
180 189 If set to false, disable and uninstall rsyslog (so logs will be available only in journal files)
181 190
@@ -89,13 +89,8 if [ "$BUILD_KERNEL" = true ] ; then
89 89 #Switch to KERNELSRC_DIR
90 90 cd "${KERNEL_DIR}"
91 91
92 # GPL v2.0
93 #https://github.com/sakaki-/bcmrpi3-kernel-bis/blob/master/conform_config.sh
92 # enable ZSWAP see https://askubuntu.com/a/472227 or https://wiki.archlinux.org/index.php/zswap
94 93 if [ "$KERNEL_ZSWAP" = true ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
95 # enable ZSWAP support for better performance during large builds etc.
96 # requires activation via kernel parameter or sysfs
97 # see e.g. https://askubuntu.com/a/472227 for a summary of ZSWAP (vs ZRAM etc.)
98 # and e.g. https://wiki.archlinux.org/index.php/zswap for parameters etc.
99 94 set_kernel_config ZPOOL y
100 95 set_kernel_config ZSWAP y
101 96 set_kernel_config ZBUD y
@@ -103,17 +98,16 if [ "$BUILD_KERNEL" = true ] ; then
103 98 set_kernel_config ZSMALLOC y
104 99 set_kernel_config PGTABLE_MAPPING y
105 100 fi
106
101
102 # enable basic KVM support; see https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453
107 103 if [ "$KERNEL_VIRT" = true ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
108 # enable basic KVM support; see e.g.
109 # https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453
110 104 set_kernel_config VIRTUALIZATION y
111 105 set_kernel_config KVM y
112 106 set_kernel_config VHOST_NET m
113 107 set_kernel_config VHOST_CROSS_ENDIAN_LEGACY y
114 108 fi
115 #See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406
116 # Netfilter kernel support
109
110 # Netfilter kernel support See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406
117 111 if [ "$KERNEL_NF" = true ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
118 112 set_kernel_config CONFIG_NETFILTER_XTABLES m
119 113 set_kernel_config CONFIG_NF_DUP_NETDEV m
@@ -205,9 +199,7 if [ "$BUILD_KERNEL" = true ] ; then
205 199 set_kernel_config NETFILTER_XTABLES m
206 200 fi
207 201
208 #https://groups.google.com/forum/#!topic/linux.gentoo.user/_2aSc_ztGpA
209 #https://github.com/torvalds/linux/blob/master/init/Kconfig#L848
210 # Enables BPF syscall for systemd-journald
202 # Enables BPF syscall for systemd-journald see https://github.com/torvalds/linux/blob/master/init/Kconfig#L848 or https://groups.google.com/forum/#!topic/linux.gentoo.user/_2aSc_ztGpA
211 203 if [ "$KERNEL_BPF" = true ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
212 204 set_kernel_config CONFIG_BPF_SYSCALL y
213 205 set_kernel_config CONFIG_CGROUP_BPF y
@@ -51,8 +51,6 else
51 51 fi
52 52 fi
53 53
54
55
56 54 # Add encrypted root partition to cmdline.txt
57 55 if [ "$ENABLE_CRYPTFS" = true ] ; then
58 56 if [ "$ENABLE_SPLITFS" = true ] ; then
@@ -66,10 +64,97 if [ "$ENABLE_CRYPTFS" = true ] ; then
66 64 fi
67 65 fi
68 66
69 # Add serial console support
70 #if [ "$ENABLE_CONSOLE" = true ] ; then
71 # CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200"
72 #fi
67 #locks cpu at max frequency
68 if [ "$ENABLE_TURBO" = true ] ; then
69 echo "force_turbo=1" >> "${BOOT_DIR}/config.txt"
70 fi
71
72 if [ "$ENABLE_PRINTK" = true ] ; then
73 install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf"
74 fi
75
76 # Install udev rule for serial alias
77 install_readonly files/etc/99-com.rules "${ETC_DIR}/udev/rules.d/99-com.rules"
78
79 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
80
81 # RPI0,3,3P Use default ttyS0 (mini-UART)as serial interface
82 SET_SERIAL="ttyS0"
83
84 # Bluetooth enabled
85 if [ "$ENABLE_BLUETOOTH" = true ] ; then
86 # Create temporary directory for Bluetooth sources
87 temp_dir=$(as_nobody mktemp -d)
88
89 # Fetch Bluetooth sources
90 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
91
92 # Copy downloaded sources
93 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
94
95 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
96 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
97 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth
98
99 # Set permissions
100 chown -R root:root "${R}/tmp/pi-bluetooth"
101
102 # Install tools
103 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
104 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
105
106 # Install bluetooth udev rule
107 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
108
109 # Install Firmware Flash file and apropiate licence
110 mkdir "${ETC_DIR}/firmware/"
111 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx"
112 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx"
113 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
114 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
115
116 # Remove temporary directory
117 rm -fr "${temp_dir}"
118
119 # 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
120 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
121
122 # set overlay to swap ttyAMA0 and ttyS0
123 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
124
125 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
126 if [ "$ENABLE_TURBO" = false ] ; then
127 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
128 fi
129 fi
130
131 else # if ENABLE_BLUETOOTH = false
132 # set overlay to disable bluetooth
133 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
134 fi # ENABLE_BLUETOOTH end
135
136 else
137 # RPI1,1P,2 Use default ttyAMA0 (full UART) as serial interface
138 SET_SERIAL="ttyAMA0"
139 fi
140
141 # may need sudo systemctl disable hciuart
142 if [ "$ENABLE_CONSOLE" = true ] ; then
143 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
144
145 # add string to cmdline
146 CMDLINE="${CMDLINE} console=serial0,115200"
147
148 # Enable serial console systemd style
149 chroot_exec systemctl start serial-getty@"$SET_SERIAL".service
150 chroot_exec systemctl enable serial-getty@"$SET_SERIAL".service
151 else
152 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
153
154 # Enable serial console systemd style
155 chroot_exec systemctl stop serial-getty@"$SET_SERIAL".service
156 chroot_exec systemctl disable serial-getty@"$SET_SERIAL".service
157 fi
73 158
74 159 # Remove IPv6 networking support
75 160 if [ "$ENABLE_IPV6" = false ] ; then
@@ -99,53 +184,6 if [ "$ENABLE_INITRAMFS" = true ] ; then
99 184 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
100 185 fi
101 186
102 # Disable RPi3 Bluetooth and restore ttyAMA0 serial device
103 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
104 if [ "$ENABLE_CONSOLE" = true ] && [ "$ENABLE_UBOOT" = false ] ; then
105 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
106 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
107 fi
108 fi
109
110 if [ "$ENABLE_BLUETOOTH" = true ] ; then
111 # Create temporary directory for Bluetooth sources
112 temp_dir=$(as_nobody mktemp -d)
113
114 # Fetch Bluetooth sources
115 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
116
117 # Copy downloaded sources
118 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
119
120 # Raspberry-sys-mod package for /dev/serial device needed by bluetooth service
121 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/99-com.rules" https://raw.githubusercontent.com/RPi-Distro/raspberrypi-sys-mods/master/etc.armhf/udev/rules.d/99-com.rules
122 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
123 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
124 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth
125
126 # Set permissions
127 chown -R root:root "${R}/tmp/pi-bluetooth"
128
129 # Install tools
130 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
131 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
132
133 # Install bluetooth udev rule
134 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
135
136 # Install Firmware Flash file and apropiate licence
137 mkdir "${ETC_DIR}/firmware/"
138 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx"
139 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx"
140 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
141 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
142 # Install udev rule for bluetooth device
143 install_readonly "${R}/tmp/pi-bluetooth/99-com.rules" "${ETC_DIR}/udev/rules.d/99-com.rules"
144
145 # Remove temporary directory
146 rm -fr "${temp_dir}"
147 fi
148
149 187 # Create firmware configuration and cmdline symlinks
150 188 ln -sf firmware/config.txt "${R}/boot/config.txt"
151 189 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
@@ -22,8 +22,3 else
22 22 # Set no root password to disable root login
23 23 chroot_exec usermod -p \'!\' root
24 24 fi
25
26 # Enable serial console systemd style
27 if [ "$ENABLE_CONSOLE" = true ] ; then
28 chroot_exec systemctl enable serial-getty\@ttyAMA0.service
29 fi
@@ -112,7 +112,9 APT_PROXY=${APT_PROXY:=""}
112 112 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
113 113
114 114 # Feature settings
115 ENABLE_PRINTK=${ENABLE_PRINTK:=false}
115 116 ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false}
117 ENABLE_MINIUART_OVERLAY=${ENABLE_MINIUART_OVERLAY:=false}
116 118 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
117 119 ENABLE_I2C=${ENABLE_I2C:=false}
118 120 ENABLE_SPI=${ENABLE_SPI:=false}
@@ -214,7 +216,7 set +x
214 216
215 217 #Check if apt-cacher-ng has port 3142 open and set APT_PROXY
216 218 APT_CACHER_RUNNING=$(lsof -i :3142 | grep apt-cacher-ng | cut -d ' ' -f3 | uniq)
217 if [ -n ${APT_CACHER_RUNNING} ] ; then
219 if [ -n "${APT_CACHER_RUNNING}" ] ; then
218 220 APT_PROXY=http://127.0.0.1:3142/
219 221 fi
220 222
@@ -322,30 +324,26 case "$RPI_MODEL" in
322 324 ;;
323 325 esac
324 326
325 # Prepare date string for default image file name
326 DATE="$(date +%Y-%m-%d)"
327 if [ -z "$KERNEL_BRANCH" ] ; then
328 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
329 else
330 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
331 fi
332
327 # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard
333 328 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
334 329 # Include bluetooth packages on supported boards
335 330 if [ "$ENABLE_BLUETOOTH" = true ] && [ "$ENABLE_CONSOLE" = false ]; then
336 331 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
337 332 fi
338 # Check if console or bluetooth configuration is invalid on RPI 0,3,3P
339 if [ "$ENABLE_BLUETOOTH" = true ] && [ "$ENABLE_CONSOLE" = true ]; then
340 echo "error: ENABLE_BLUETOOTH and ENABLE_CONSOLE can't be active on the same time."
333 else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard
334 # Check if the internal wireless interface is not supported by the RPi model
335 if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then
336 echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth"
341 337 exit 1
342 fi
343 else # if [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ] ; then
344 # Check if the internal wireless interface is not supported by the RPi model
345 if [ "$ENABLE_WIRELESS" = true ] ; then
346 echo "error: The selected Raspberry Pi model has no internal wireless interface"
347 exit 1
348 fi
338 fi
339 fi
340
341 # Prepare date string for default image file name
342 DATE="$(date +%Y-%m-%d)"
343 if [ -z "$KERNEL_BRANCH" ] ; then
344 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
345 else
346 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
349 347 fi
350 348
351 349 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant