Merge branch 'thingos' into dev

This commit is contained in:
Calin Crisan 2017-05-07 21:02:55 +03:00
commit 452b71f9e2
18 changed files with 317 additions and 3 deletions

View File

@ -33,8 +33,6 @@ rm -rf $TARGET/usr/share/ffmpeg/
rm -rf $TARGET/usr/share/perl5/
rm -rf $TARGET/usr/share/common-lisp/
find $TARGET -name '*libmount*' | xargs rm -rf
# various binaries
rm -f $TARGET/bin/more
rm -f $TARGET/bin/wdctl

View File

@ -50,7 +50,7 @@ mkdir -p $BOOT
mount -o loop $loop_dev $BOOT
msg "copying boot filesystem contents"
cp $BOOT_SRC/* $BOOT
cp -r $BOOT_SRC/* $BOOT
sync
msg "unmounting boot filesystem"

View File

@ -0,0 +1 @@
/var/lib/bluetooth.conf

View File

@ -0,0 +1,9 @@
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<type>system</type>
<policy context="default">
<allow send_type="*"></allow>
<allow own="*"/>
</policy>
</busconfig>

View File

@ -0,0 +1 @@
/lib/firmware

View File

@ -0,0 +1 @@
/data/etc/hostname

View File

@ -0,0 +1,53 @@
#!/bin/bash
sys_btconf="/etc/bluetooth.conf"
boot_btconf="/boot/bluetooth.conf"
btconf="/data/etc/bluetooth.conf"
# dbus is only used by bluez
test -f $btconf || test -f $boot_btconf || test -f $sys_btconf || exit 0
test -n "$os_version" || source /etc/init.d/base
start() {
mkdir -p /tmp/dbus
msg_begin "Starting dbus"
dbus-uuidgen --ensure
dbus-daemon --system
test $? == 0 && msg_done || msg_fail
}
stop() {
msg_begin "Stopping dbus"
udevadm control --stop-exec-queue
killall dbus-daemon &>/dev/null
test $? == 0 && msg_done || msg_fail
rm -f /var/run/messagebus.pid
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $?

View File

@ -0,0 +1,95 @@
#!/bin/bash
sys_conf="/etc/bluetooth.conf"
boot_conf="/boot/bluetooth.conf"
conf="/data/etc/bluetooth.conf"
if ! [ -f $conf ]; then
if [ -f $boot_conf ]; then
cp $boot_conf $conf
elif [ -f $sys_conf ]; then
cp $sys_conf $conf
fi
fi
test -f $conf || exit 0
test -n "$os_version" || source /etc/init.d/base
hci=hci0
bluetoothd=/usr/libexec/bluetooth/bluetoothd
run_conf="/var/lib/bluetooth.conf"
configure() {
cp $conf $run_conf
# if no specific name configured, use hostname
if ! grep -E 'Name\s*=' $run_conf &>/dev/null; then
sed -ri "s/(\[General\])/\1\nName = $(hostname)/" $run_conf
fi
# bring adapter up
hciconfig $hci up
}
start() {
msg_begin "Configuring bluetooth"
# wait up to 10 seconds for device
count=0
while ! hciconfig $hci &>/dev/null; do
sleep 1
count=$(($count + 1))
if [ $count -ge 10 ]; then
msg_fail "no device"
logger -t bluetooth -s "bluetooth device not available, rebooting"
reboot
return 1
fi
done
if configure; then
msg_done
else
msg_fail
return 1
fi
msg_begin "Starting bluetoothd"
$bluetoothd &>/dev/null &
msg_done
# if DiscoverableTimeout is set to 0, make adapter discoverable from boot time
if grep -E '^DiscoverableTimeout\s*=\s*0$' $run_conf &>/dev/null; then
sleep 1
hciconfig $hci piscan
fi
}
stop() {
msg_begin "Stopping bluetoothd"
killall bluetoothd &>/dev/null
test $? == 0 && msg_done || msg_fail
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?

View File

@ -16,3 +16,7 @@ msg_fail() {
test -n "$1" && echo $1 || echo "failed"
}
msg_background() {
test -n "$1" && echo $1 || echo "pending"
}

View File

@ -0,0 +1,45 @@
#!/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 -d "/proc/device-tree/soc/gpio@7e200000/uart0_pins" || exit 0 # no rpi bluetooth detected
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.

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.