diff --git a/extras/tools.sh b/extras/tools.sh index 880cab03e7..9a8a8fd06e 100644 --- a/extras/tools.sh +++ b/extras/tools.sh @@ -47,9 +47,12 @@ compile_tools() # brcm cp $tmpdir/brcm/{brcm_bt_reset,brcm_patchram_plus} $tmpdir/armbian-tools-${RELEASE}_${REVISION}_${ARCH}/usr/bin # brcm configs and service - install -m 644 $SRC/lib/scripts/brcm40183 $tmpdir/armbian-tools-${RELEASE}_${REVISION}_${ARCH}/etc/default + install -m 644 $SRC/lib/scripts/brcm40183 $tmpdir/armbian-tools-${RELEASE}_${REVISION}_${ARCH}/etc/default install -m 755 $SRC/lib/scripts/brcm40183-patch $tmpdir/armbian-tools-${RELEASE}_${REVISION}_${ARCH}/etc/init.d + # ap6212 BT + install -m 644 $SRC/lib/scripts/ap6212-bluetooth $tmpdir/armbian-tools-${RELEASE}_${REVISION}_${ARCH}/etc/init.d + cd $tmpdir/armbian-tools-${RELEASE}_${REVISION}_${ARCH} find . -type f ! -regex '.*.hg.*' ! -regex '.*?debian-binary.*' ! -regex '.*?DEBIAN.*' -printf '%P ' | xargs md5sum > DEBIAN/md5sums cd $tmpdir diff --git a/scripts/ap6212-bluetooth b/scripts/ap6212-bluetooth new file mode 100644 index 0000000000..b7af5b6510 --- /dev/null +++ b/scripts/ap6212-bluetooth @@ -0,0 +1,61 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: ap6212-bluetooth +# Required-Start: $local_fs +# Required-Stop: +# X-Start-Before: bluetooth +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Patch firmware for ap6212 adapter +# Description: Patch firmware for ap6212 adapter +### END INIT INFO + +# exit if bluetooth utils are not installed +[ -f "/bin/hciconfig" ] || exit 0 + +# copy firmware + +if [ -f "/lib/firmware/ap6212/bcm43438a0.hcd" ] && [ ! -f /etc/firmware/ap6212/4343A0.hcd ]; then + mkdir -p /etc/firmware/ap6212 + cp /lib/firmware/ap6212/bcm43438a0.hcd /etc/firmware/ap6212/4343A0.hcd +fi + + +. /lib/lsb/init-functions + +do_start () { + +if [ ! -z $(hciconfig | /bin/grep UART | /usr/bin/cut -d: -f1) ] +then + echo "ap6212 BT device allready initialized" + hcitool dev + else + # Start patching + rfkill unblock all + echo "0" > /sys/class/rfkill/rfkill0/state + echo "1" > /sys/class/rfkill/rfkill0/state + echo " " > /dev/ttyS1 + hciattach /dev/ttyS1 bcm43xx 115200 + hciconfig hci0 up +fi +} + +case "$1" in + start) + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + # No-op + ;; + status) + hcitool dev + ;; + *) + echo "Usage: ap6212-bluetooth [start|stop|status]" >&2 + exit 3 + ;; +esac \ No newline at end of file diff --git a/scripts/firstrun b/scripts/firstrun index 0a5852f6e5..7b699fe447 100644 --- a/scripts/firstrun +++ b/scripts/firstrun @@ -84,6 +84,9 @@ collect_information() { # enable BT on cubietruck [[ "$BOARD" == "cubietruck" ]] && update-rc.d brcm40183-patch defaults + + # enable BT on Banana M2+ + [[ "$BOARD" == "bananapim2plus" ]] && update-rc.d ap6212-bluetooth defaults # enable BT on Solidrun boards [[ "$BOARD" == "Cubox i2eX/i4" ]] && update-rc.d brcm4330-patch defaults && /etc/init.d/brcm4330-patch start