##// 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,47 +56,24 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_CONSOLE" = true ] ; then
60 if [ "$ENABLE_TURBO" = true ] ; then
61 CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200"
61 echo "force_turbo=1" >> "${BOOT_DIR}/config.txt"
62 fi
62 fi
63
63
64 # Remove IPv6 networking support
64 if [ "$ENABLE_PRINTK" = true ] ; then
65 if [ "$ENABLE_IPV6" = false ] ; then
65 install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf"
66 CMDLINE="${CMDLINE} ipv6.disable=1"
67 fi
66 fi
68
67
69 # Automatically assign predictable network interface names
68 # Install udev rule for serial alias
70 if [ "$ENABLE_IFNAMES" = false ] ; then
69 install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules"
71 CMDLINE="${CMDLINE} net.ifnames=0"
72 else
73 CMDLINE="${CMDLINE} net.ifnames=1"
74 fi
75
76 # Install firmware boot cmdline
77 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
78
79 # Install firmware config
80 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
81
82 # Setup minimal GPU memory allocation size: 16MB (no X)
83 if [ "$ENABLE_MINGPU" = true ] ; then
84 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
85 fi
86
70
87 # Setup boot with initramfs
71 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
88 if [ "$ENABLE_INITRAMFS" = true ] ; then
89 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
90 fi
91
72
92 # Disable RPi3 Bluetooth and restore ttyAMA0 serial device
73 # RPI0,3,3P Use default ttyS0 (mini-UART)as serial interface
93 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
74 SET_SERIAL="ttyS0"
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
75
76 # Bluetooth enabled
100 if [ "$ENABLE_BLUETOOTH" = true ] ; then
77 if [ "$ENABLE_BLUETOOTH" = true ] ; then
101 # Create temporary directory for Bluetooth sources
78 # Create temporary directory for Bluetooth sources
102 temp_dir=$(as_nobody mktemp -d)
79 temp_dir=$(as_nobody mktemp -d)
@@ -107,8 +84,6 if [ "$ENABLE_BLUETOOTH" = true ] ; then
107 # Copy downloaded sources
84 # Copy downloaded sources
108 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
85 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
109
86
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/
87 # 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
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
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
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
@@ -124,16 +99,85 if [ "$ENABLE_BLUETOOTH" = true ] ; then
124 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
99 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
125
100
126 # Install Firmware Flash file and apropiate licence
101 # Install Firmware Flash file and apropiate licence
127 mkdir "${ETC_DIR}/firmware/"
102 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
128 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx"
103 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
129 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx"
104 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
130 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
105 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"
106 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
107
135 # Remove temporary directory
108 # Remove temporary directory
136 rm -fr "${temp_dir}"
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
142 if [ "$ENABLE_CONSOLE" = true ] ; then
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
153 fi
154
155 # Remove IPv6 networking support
156 if [ "$ENABLE_IPV6" = false ] ; then
157 CMDLINE="${CMDLINE} ipv6.disable=1"
158 fi
159
160 # Automatically assign predictable network interface names
161 if [ "$ENABLE_IFNAMES" = false ] ; then
162 CMDLINE="${CMDLINE} net.ifnames=0"
163 else
164 CMDLINE="${CMDLINE} net.ifnames=1"
165 fi
166
167 # Install firmware boot cmdline
168 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
169
170 # Install firmware config
171 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
172
173 # Setup minimal GPU memory allocation size: 16MB (no X)
174 if [ "$ENABLE_MINGPU" = true ] ; then
175 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
176 fi
177
178 # Setup boot with initramfs
179 if [ "$ENABLE_INITRAMFS" = true ] ; then
180 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
137 fi
181 fi
138
182
139 # Create firmware configuration and cmdline symlinks
183 # Create firmware configuration and cmdline symlinks
@@ -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