diff --git a/board/common/overlay/etc/init.d/S37bluetooth b/board/common/overlay/etc/init.d/S37bluetooth index 3d82b6dfc0..647e921e17 100755 --- a/board/common/overlay/etc/init.d/S37bluetooth +++ b/board/common/overlay/etc/init.d/S37bluetooth @@ -10,6 +10,7 @@ PROG="/usr/libexec/bluetooth/bluetoothd" PROG_HC="/usr/bin/hciconfig" DATA_DIR="/var/lib/bluetooth" RUN_DATA_DIR="/data/bluetooth" +NO_ON_BOARD_BT="/tmp/.no_on_board_bt" # used by RPi to explicitly indicate that no on-board BT was detected test -x ${PROG} || exit 0 @@ -40,14 +41,16 @@ start() { # wait up to 10 seconds for device count=0 while ! ${PROG_HC} ${ADAPTER} &>/dev/null; do - sleep 1 - count=$((${count} + 1)) - if [[ ${count} -ge 10 ]]; then + # on RPi boards, the absence of an on-board BT can be detected earlier, preventing 10s timeout + + count=$((count + 1)) + if [[ ${count} -ge 10 ]] || [[ -f "${NO_ON_BOARD_BT}" ]]; then msg_fail "no device" - logger -t bluetooth "bluetooth device not available, calling panic action" - panic_action bluetooth - return 1 + logger -t bluetooth "bluetooth device not available" + return 0 fi + + sleep 1 done if configure; then diff --git a/board/raspberrypi/overlay/etc/init.d/S13btuart b/board/raspberrypi/overlay/etc/init.d/S13btuart index 0ad4deda81..aa2d0f431e 100755 --- a/board/raspberrypi/overlay/etc/init.d/S13btuart +++ b/board/raspberrypi/overlay/etc/init.d/S13btuart @@ -3,44 +3,46 @@ SYS_CONF="/etc/bluetooth.conf" BOOT_CONF="/boot/bluetooth.conf" CONF="/data/etc/bluetooth.conf" +NO_ON_BOARD_BT="/tmp/.no_on_board_bt" # used by RPi to explicitly indicate that no on-board BT was detected test -f ${CONF} || test -f ${BOOT_CONF} || test -f ${SYS_CONF} || exit 0 -test -d "/proc/device-tree/soc/gpio@7e200000/uart0_pins" || exit 0 # no rpi bluetooth detected +if ! [ -d "/proc/device-tree/soc/gpio@7e200000/uart0_pins" ]; then + touch ${NO_ON_BOARD_BT} + exit 0 # no rpi bluetooth detected +fi test -n "${OS_VERSION}" || source /etc/init.d/base function start() { if [[ "$(cat /proc/device-tree/aliases/uart0)" = "$(cat /proc/device-tree/aliases/serial1)" ]] ; then - if [[ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = " 16" ]] ; then - /usr/bin/hciattach -t5 /dev/serial1 bcm43xx 3000000 flow - &>/dev/null + if [[ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = "16" ]]; then + /usr/bin/hciattach -t 10 /dev/serial1 bcm43xx 3000000 flow - &>/dev/null else - /usr/bin/hciattach -t5 /dev/serial1 bcm43xx 921600 noflow - &>/dev/null + /usr/bin/hciattach -t 10 /dev/serial1 bcm43xx 921600 noflow - &>/dev/null fi else - /usr/bin/hciattach -t5 /dev/serial1 bcm43xx 460800 noflow - &>/dev/null + /usr/bin/hciattach -t 10 /dev/serial1 bcm43xx 460800 noflow - &>/dev/null fi } case "$1" in start) - msg_begin "Attaching UART bluetooth modem" - # for some reason, sometimes the hciattach command needs to be run twice - (start || start) &>/dev/null & + msg_begin "Attaching UART bluetooth device" + start &>/dev/null & msg_background ;; stop) - msg_begin "Detaching UART bluetooth modem" + msg_begin "Detaching UART bluetooth device" killall hciattach &>/dev/null test $? == 0 && msg_done || msg_fail ;; *) - echo $"Usage: $0 {start}" + echo $"Usage: $0 {start|stop}" exit 1 esac exit $? - diff --git a/board/raspberrypi3/overlay/etc/init.d/S13btuart b/board/raspberrypi3/overlay/etc/init.d/S13btuart index 0ad4deda81..aa2d0f431e 100755 --- a/board/raspberrypi3/overlay/etc/init.d/S13btuart +++ b/board/raspberrypi3/overlay/etc/init.d/S13btuart @@ -3,44 +3,46 @@ SYS_CONF="/etc/bluetooth.conf" BOOT_CONF="/boot/bluetooth.conf" CONF="/data/etc/bluetooth.conf" +NO_ON_BOARD_BT="/tmp/.no_on_board_bt" # used by RPi to explicitly indicate that no on-board BT was detected test -f ${CONF} || test -f ${BOOT_CONF} || test -f ${SYS_CONF} || exit 0 -test -d "/proc/device-tree/soc/gpio@7e200000/uart0_pins" || exit 0 # no rpi bluetooth detected +if ! [ -d "/proc/device-tree/soc/gpio@7e200000/uart0_pins" ]; then + touch ${NO_ON_BOARD_BT} + exit 0 # no rpi bluetooth detected +fi test -n "${OS_VERSION}" || source /etc/init.d/base function start() { if [[ "$(cat /proc/device-tree/aliases/uart0)" = "$(cat /proc/device-tree/aliases/serial1)" ]] ; then - if [[ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = " 16" ]] ; then - /usr/bin/hciattach -t5 /dev/serial1 bcm43xx 3000000 flow - &>/dev/null + if [[ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = "16" ]]; then + /usr/bin/hciattach -t 10 /dev/serial1 bcm43xx 3000000 flow - &>/dev/null else - /usr/bin/hciattach -t5 /dev/serial1 bcm43xx 921600 noflow - &>/dev/null + /usr/bin/hciattach -t 10 /dev/serial1 bcm43xx 921600 noflow - &>/dev/null fi else - /usr/bin/hciattach -t5 /dev/serial1 bcm43xx 460800 noflow - &>/dev/null + /usr/bin/hciattach -t 10 /dev/serial1 bcm43xx 460800 noflow - &>/dev/null fi } case "$1" in start) - msg_begin "Attaching UART bluetooth modem" - # for some reason, sometimes the hciattach command needs to be run twice - (start || start) &>/dev/null & + msg_begin "Attaching UART bluetooth device" + start &>/dev/null & msg_background ;; stop) - msg_begin "Detaching UART bluetooth modem" + msg_begin "Detaching UART bluetooth device" killall hciattach &>/dev/null test $? == 0 && msg_done || msg_fail ;; *) - echo $"Usage: $0 {start}" + echo $"Usage: $0 {start|stop}" exit 1 esac exit $? - diff --git a/board/raspberrypi4/overlay/etc/init.d/S13btuart b/board/raspberrypi4/overlay/etc/init.d/S13btuart index 0ad4deda81..aa2d0f431e 100755 --- a/board/raspberrypi4/overlay/etc/init.d/S13btuart +++ b/board/raspberrypi4/overlay/etc/init.d/S13btuart @@ -3,44 +3,46 @@ SYS_CONF="/etc/bluetooth.conf" BOOT_CONF="/boot/bluetooth.conf" CONF="/data/etc/bluetooth.conf" +NO_ON_BOARD_BT="/tmp/.no_on_board_bt" # used by RPi to explicitly indicate that no on-board BT was detected test -f ${CONF} || test -f ${BOOT_CONF} || test -f ${SYS_CONF} || exit 0 -test -d "/proc/device-tree/soc/gpio@7e200000/uart0_pins" || exit 0 # no rpi bluetooth detected +if ! [ -d "/proc/device-tree/soc/gpio@7e200000/uart0_pins" ]; then + touch ${NO_ON_BOARD_BT} + exit 0 # no rpi bluetooth detected +fi test -n "${OS_VERSION}" || source /etc/init.d/base function start() { if [[ "$(cat /proc/device-tree/aliases/uart0)" = "$(cat /proc/device-tree/aliases/serial1)" ]] ; then - if [[ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = " 16" ]] ; then - /usr/bin/hciattach -t5 /dev/serial1 bcm43xx 3000000 flow - &>/dev/null + if [[ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = "16" ]]; then + /usr/bin/hciattach -t 10 /dev/serial1 bcm43xx 3000000 flow - &>/dev/null else - /usr/bin/hciattach -t5 /dev/serial1 bcm43xx 921600 noflow - &>/dev/null + /usr/bin/hciattach -t 10 /dev/serial1 bcm43xx 921600 noflow - &>/dev/null fi else - /usr/bin/hciattach -t5 /dev/serial1 bcm43xx 460800 noflow - &>/dev/null + /usr/bin/hciattach -t 10 /dev/serial1 bcm43xx 460800 noflow - &>/dev/null fi } case "$1" in start) - msg_begin "Attaching UART bluetooth modem" - # for some reason, sometimes the hciattach command needs to be run twice - (start || start) &>/dev/null & + msg_begin "Attaching UART bluetooth device" + start &>/dev/null & msg_background ;; stop) - msg_begin "Detaching UART bluetooth modem" + msg_begin "Detaching UART bluetooth device" killall hciattach &>/dev/null test $? == 0 && msg_done || msg_fail ;; *) - echo $"Usage: $0 {start}" + echo $"Usage: $0 {start|stop}" exit 1 esac exit $? -