##// END OF EJS Templates
Bluetooth and serial...
Unknown -
r451:7dc74afc7302
parent child
Show More
@@ -63,13 +63,13 If you want to change e.g. cross-compiler -> Templates always override defaults
63
63
64 ##### `RPI_MODEL`=2
64 ##### `RPI_MODEL`=2
65 Specifiy the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models:
65 Specifiy the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models:
66 `0` = Used for Raspberry Pi 0 and Raspberry Pi 0 W
66 - `0` = Used for Raspberry Pi 0 and Raspberry Pi 0 W
67 `1` = Used for Pi 1 model A and B
67 - `1` = Used for Pi 1 model A and B
68 `1P` = Used for Pi 1 model B+ and A+
68 - `1P` = Used for Pi 1 model B+ and A+
69 `2` = Used for Pi 2 model B
69 - `2` = Used for Pi 2 model B
70 `3` = Used for Pi 3 model B
70 - `3` = Used for Pi 3 model B
71 `3P` = Used for Pi 3 model B+
71 - `3P` = Used for Pi 3 model B+
72 `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` or `3P` is used.
72 - `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` or `3P` is used.
73
73
74 ##### `RELEASE`="buster"
74 ##### `RELEASE`="buster"
75 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases `stretch` and `buster`.
75 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases `stretch` and `buster`.
@@ -153,7 +153,19 Set the IP address for the second NTP server.
153
153
154 #### Basic system features:
154 #### Basic system features:
155 ##### `ENABLE_CONSOLE`=true
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 ##### `ENABLE_I2C`=false
170 ##### `ENABLE_I2C`=false
159 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.
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 ##### `ENABLE_WIRELESS`=false
185 ##### `ENABLE_WIRELESS`=false
174 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`.
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.
178
179 ##### `ENABLE_RSYSLOG`=true
188 ##### `ENABLE_RSYSLOG`=true
180 If set to false, disable and uninstall rsyslog (so logs will be available only in journal files)
189 If set to false, disable and uninstall rsyslog (so logs will be available only in journal files)
181
190
@@ -56,9 +56,100 if [ "$ENABLE_CRYPTFS" = true ] ; then
56 fi
56 fi
57 fi
57 fi
58
58
59 # Add serial console support
59 #locks cpu at max frequency
60 if [ "$ENABLE_TURBO" = true ] ; then
61 echo "force_turbo=1" >> "${BOOT_DIR}/config.txt"
62 fi
63
64 if [ "$ENABLE_PRINTK" = true ] ; then
65 install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf"
66 fi
67
68 # Install udev rule for serial alias
69 install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules"
70
71 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
72
73 # RPI0,3,3P Use default ttyS0 (mini-UART)as serial interface
74 SET_SERIAL="ttyS0"
75
76 # Bluetooth enabled
77 if [ "$ENABLE_BLUETOOTH" = true ] ; then
78 # Create temporary directory for Bluetooth sources
79 temp_dir=$(as_nobody mktemp -d)
80
81 # Fetch Bluetooth sources
82 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
83
84 # Copy downloaded sources
85 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
86
87 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
88 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
89 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth
90
91 # Set permissions
92 chown -R root:root "${R}/tmp/pi-bluetooth"
93
94 # Install tools
95 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
96 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
97
98 # Install bluetooth udev rule
99 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
100
101 # Install Firmware Flash file and apropiate licence
102 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
103 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
104 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
105 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
106 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
107
108 # Remove temporary directory
109 rm -fr "${temp_dir}"
110
111 # 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
112 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
113 SET_SERIAL="ttyAMA0"
114
115 # set overlay to swap ttyAMA0 and ttyS0
116 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
117
118 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
119 if [ "$ENABLE_TURBO" = false ] ; then
120 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
121 fi
122
123 # Activate services
124 chroot_exec systemctl enable pi-bluetooth.hciuart.service
125 #chroot_exec systemctl enable pi-bluetooth.bthelper@.service
126 else
127 chroot_exec systemctl enable pi-bluetooth.hciuart.service
128 #chroot_exec systemctl enable pi-bluetooth.bthelper@.service
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
60 if [ "$ENABLE_CONSOLE" = true ] ; then
142 if [ "$ENABLE_CONSOLE" = true ] ; then
61 CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200"
143 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
144 # add string to cmdline
145 CMDLINE="${CMDLINE} console=serial0,115200"
146
147 # Enable serial console systemd style
148 chroot_exec systemctl enable serial-getty\@"$SET_SERIAL".service
149 else
150 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
151 # disable serial console systemd style
152 chroot_exec systemctl disable serial-getty\@"$SET_SERIAL".service
62 fi
153 fi
63
154
64 # Remove IPv6 networking support
155 # Remove IPv6 networking support
@@ -89,53 +180,6 if [ "$ENABLE_INITRAMFS" = true ] ; then
89 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
180 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
90 fi
181 fi
91
182
92 # Disable RPi3 Bluetooth and restore ttyAMA0 serial device
93 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
94 if [ "$ENABLE_CONSOLE" = true ] && [ "$ENABLE_UBOOT" = false ] ; then
95 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
96 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
97 fi
98 fi
99
100 if [ "$ENABLE_BLUETOOTH" = true ] ; then
101 # Create temporary directory for Bluetooth sources
102 temp_dir=$(as_nobody mktemp -d)
103
104 # Fetch Bluetooth sources
105 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
106
107 # Copy downloaded sources
108 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
109
110 # Raspberry-sys-mod package for /dev/serial device needed by bluetooth service
111 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
112 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
113 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
114 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth
115
116 # Set permissions
117 chown -R root:root "${R}/tmp/pi-bluetooth"
118
119 # Install tools
120 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
121 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
122
123 # Install bluetooth udev rule
124 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
125
126 # Install Firmware Flash file and apropiate licence
127 mkdir "${ETC_DIR}/firmware/"
128 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx"
129 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx"
130 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
131 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
132 # Install udev rule for bluetooth device
133 install_readonly "${R}/tmp/pi-bluetooth/99-com.rules" "${ETC_DIR}/udev/rules.d/99-com.rules"
134
135 # Remove temporary directory
136 rm -fr "${temp_dir}"
137 fi
138
139 # Create firmware configuration and cmdline symlinks
183 # Create firmware configuration and cmdline symlinks
140 ln -sf firmware/config.txt "${R}/boot/config.txt"
184 ln -sf firmware/config.txt "${R}/boot/config.txt"
141 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
185 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
@@ -70,6 +70,7 LIB_DIR="${R}/lib"
70 BOOT_DIR="${R}/boot/firmware"
70 BOOT_DIR="${R}/boot/firmware"
71 KERNEL_DIR="${R}/usr/src/linux"
71 KERNEL_DIR="${R}/usr/src/linux"
72 WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm"
72 WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm"
73 BLUETOOTH_FIRMWARE_DIR="${ETC_DIR}/firmware/bt"
73
74
74 # Firmware directory: Blank if download from github
75 # Firmware directory: Blank if download from github
75 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
76 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
@@ -106,7 +107,9 APT_PROXY=${APT_PROXY:=""}
106 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
107 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
107
108
108 # Feature settings
109 # Feature settings
110 ENABLE_PRINTK=${ENABLE_PRINTK:=false}
109 ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false}
111 ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false}
112 ENABLE_MINIUART_OVERLAY=${ENABLE_MINIUART_OVERLAY:=false}
110 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
113 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
111 ENABLE_I2C=${ENABLE_I2C:=false}
114 ENABLE_I2C=${ENABLE_I2C:=false}
112 ENABLE_SPI=${ENABLE_SPI:=false}
115 ENABLE_SPI=${ENABLE_SPI:=false}
@@ -204,7 +207,7 set +x
204
207
205 #Check if apt-cacher-ng has port 3142 open and set APT_PROXY
208 #Check if apt-cacher-ng has port 3142 open and set APT_PROXY
206 APT_CACHER_RUNNING=$(lsof -i :3142 | grep apt-cacher-ng | cut -d ' ' -f3 | uniq)
209 APT_CACHER_RUNNING=$(lsof -i :3142 | grep apt-cacher-ng | cut -d ' ' -f3 | uniq)
207 if [ -n ${APT_CACHER_RUNNING} ] ; then
210 if [ -n "${APT_CACHER_RUNNING}" ] ; then
208 APT_PROXY=http://127.0.0.1:3142/
211 APT_PROXY=http://127.0.0.1:3142/
209 fi
212 fi
210
213
@@ -292,6 +295,20 case "$RPI_MODEL" in
292 ;;
295 ;;
293 esac
296 esac
294
297
298 # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard
299 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
300 # Include bluetooth packages on supported boards
301 if [ "$ENABLE_BLUETOOTH" = true ] && [ "$ENABLE_CONSOLE" = false ]; then
302 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
303 fi
304 else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard
305 # Check if the internal wireless interface is not supported by the RPi model
306 if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then
307 echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth"
308 exit 1
309 fi
310 fi
311
295 # Prepare date string for default image file name
312 # Prepare date string for default image file name
296 DATE="$(date +%Y-%m-%d)"
313 DATE="$(date +%Y-%m-%d)"
297 if [ -z "$KERNEL_BRANCH" ] ; then
314 if [ -z "$KERNEL_BRANCH" ] ; then
@@ -300,14 +317,6 else
300 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
317 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
301 fi
318 fi
302
319
303 # Check if the internal wireless interface is supported by the RPi model
304 if [ "$ENABLE_WIRELESS" = true ] ; then
305 if [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ] ; then
306 echo "error: The selected Raspberry Pi model has no internal wireless interface"
307 exit 1
308 fi
309 fi
310
311 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
320 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
312 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
321 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
313 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
322 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant