rpi0w also has bluetooth support

This commit is contained in:
Calin Crisan 2017-04-09 20:45:09 +03:00
parent 1ff84730d7
commit 016c3407dd
4 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,43 @@
#!/bin/bash
sys_conf="/etc/bluetooth.conf"
boot_conf="/boot/bluetooth.conf"
conf="/data/etc/bluetooth.conf"
test -f $conf || test -f $boot_conf || test -f $sys_conf || exit 0
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
else
/usr/bin/hciattach -t5 /dev/serial1 bcm43xx 921600 noflow - &>/dev/null
fi
else
/usr/bin/hciattach -t5 /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_background
;;
stop)
msg_begin "Detaching UART bluetooth modem"
killall hciattach &>/dev/null
test $? == 0 && msg_done || msg_fail
;;
*)
echo $"Usage: $0 {start}"
exit 1
esac
exit $?

View File

@ -0,0 +1,32 @@
SUBSYSTEM=="input", GROUP="input", MODE="0660"
SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0660"
SUBSYSTEM=="spidev", GROUP="spi", MODE="0660"
SUBSYSTEM=="bcm2835-gpiomem", GROUP="gpio", MODE="0660"
SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c '\
chown -R root:gpio /sys/class/gpio && chmod -R 770 /sys/class/gpio;\
chown -R root:gpio /sys/devices/virtual/gpio && chmod -R 770 /sys/devices/virtual/gpio;\
chown -R root:gpio /sys$devpath && chmod -R 770 /sys$devpath\
'"
KERNEL=="ttyAMA[01]", PROGRAM="/bin/sh -c '\
ALIASES=/proc/device-tree/aliases; \
if cmp -s $ALIASES/uart0 $ALIASES/serial0; then \
echo 0;\
elif cmp -s $ALIASES/uart0 $ALIASES/serial1; then \
echo 1; \
else \
exit 1; \
fi\
'", SYMLINK+="serial%c"
KERNEL=="ttyS0", PROGRAM="/bin/sh -c '\
ALIASES=/proc/device-tree/aliases; \
if cmp -s $ALIASES/uart1 $ALIASES/serial0; then \
echo 0; \
elif cmp -s $ALIASES/uart1 $ALIASES/serial1; then \
echo 1; \
else \
exit 1; \
fi \
'", SYMLINK+="serial%c"

Binary file not shown.

Binary file not shown.