Merge pull request #67 from balena-os/nanopi-bt

Nanopi Neo Air enable BT
This commit is contained in:
Florin Sarbu 2019-03-23 12:39:41 +02:00 committed by GitHub
commit 34ad215a97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 131 additions and 2 deletions

@ -1 +1 @@
Subproject commit 84c60eba818d4276d449692a3084f2c20e0eaae8 Subproject commit dcb55b47395af9e2aaa6d6aed0843d31262b107a

@ -1 +1 @@
Subproject commit aa876586512dfca97fcf2e5d5ef536e9fbc41fa1 Subproject commit 64859b0669d525b046367afe5e32bccb3dcbf0b1

View file

@ -0,0 +1,25 @@
DESCRIPTION = "Broadcom Bluetooth patch utility"
SECTION = "connectivity"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
SRCREV = "6e6506eb74c918e761f9ba08a6c71897334747c1"
SRC_URI = " git://android.googlesource.com/platform/system/bluetooth.git;protocol=https"
S = "${WORKDIR}/git/brcm_patchram_plus"
do_compile() {
${CC} ${LDFLAGS} brcm_patchram_plus.c -o brcm_patchram_plus
}
do_install() {
mkdir -p ${D}/${bindir}/
install -m 0755 ${S}/brcm_patchram_plus ${D}/${bindir}
}
FILES_${PN}-dbg += "${sysconfdir}/bluetooth/.debug"
FILES_${PN} += "${bindir}/brcm_patchram_plus"
PACKAGE_ARCH = "${MACHINE_ARCH}"

View file

@ -0,0 +1,32 @@
SUMMARY = "Enable bluetooth on Nanopi Neo Air boards"
LICENSE="Apache-2.0"
LIC_FILES_CHKSUM = "file://${RESIN_COREBASE}/COPYING.Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
DESCRIPTION = "Package contains udev rule, systemd service and a script to init the Ampak 6212A \
bluetooth chip for the Nanopi Neo Air board"
S = "${WORKDIR}"
SRC_URI = "file://99-nanopi-air-bt.rules \
file://nanopi-air-bt@.service \
file://nanopi-air-bt-start \
"
do_install() {
mkdir -p ${D}/usr/bin
mkdir -p ${D}/lib/udev/rules.d
install -m 0644 99-nanopi-air-bt.rules ${D}/lib/udev/rules.d
install -m 0744 nanopi-air-bt-start ${D}/usr/bin
if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
install -d ${D}${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/nanopi-air-bt@.service ${D}${systemd_unitdir}/system
fi
}
FILES_${PN} = " \
/lib/udev/rules.d/99-nanopi-air-bt.rules \
/lib/systemd/system/nanopi-air-bt@.service \
/usr/bin/nanopi-air-bt-start \
"

View file

@ -0,0 +1 @@
ACTION=="add", SUBSYSTEM=="tty", ATTR{iomem_base}=="0x1C28C00", TAG+="systemd", ENV{SYSTEMD_WANTS}="nanopi-air-bt@'%E{DEVNAME}'.service"

View file

@ -0,0 +1,17 @@
#!/bin/sh
if [ $# -lt 1 ]; then
echo "Interface argument missing ... /dev/ttyX"
exit 1
fi
echo 205 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio205/direction
# Reset BT
echo "Resetting BT chip"
echo 0 > /sys/class/gpio/gpio205/value
echo 1 > /sys/class/gpio/gpio205/value
/usr/bin/brcm_patchram_plus -d --patchram /lib/firmware/brcm/bcm43438a1.hcd --no2bytes --tosleep 5000 $1 > /tmp/brcm_log 2>&1
hciattach -n $1 bcm43xx 115200 flow

View file

@ -0,0 +1,9 @@
[Unit]
Description=Ampak AP6212A Bluetooth HCI on Nanopi Neo Air
[Service]
Type=simple
ExecStart=/bin/bash /usr/bin/nanopi-air-bt-start %I
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,3 @@
RDEPENDS_${PN}_append_nanopi-neo-air = " brcm-patchram-plus \
nanopi-air-bt \
"

View file

@ -10,6 +10,8 @@ SRC_URI_append = " \
file://config.txt \ file://config.txt \
file://brcmfmac43362-sdio.txt \ file://brcmfmac43362-sdio.txt \
file://brcmfmac43430-sdio.txt \ file://brcmfmac43430-sdio.txt \
file://bcm43438a0.hcd \
file://bcm43438a1.hcd \
" "
do_install_append() { do_install_append() {
@ -26,6 +28,8 @@ do_install_append() {
do_install_append_nanopi-neo-air() { do_install_append_nanopi-neo-air() {
mkdir -p ${D}/${nonarch_base_libdir}/firmware/brcm mkdir -p ${D}/${nonarch_base_libdir}/firmware/brcm
install -m 0644 ${WORKDIR}/brcmfmac43430-sdio.txt ${D}${nonarch_base_libdir}/firmware/brcm install -m 0644 ${WORKDIR}/brcmfmac43430-sdio.txt ${D}${nonarch_base_libdir}/firmware/brcm
install -m 0644 ${WORKDIR}/bcm43438a0.hcd ${D}${nonarch_base_libdir}/firmware/brcm
install -m 0644 ${WORKDIR}/bcm43438a1.hcd ${D}${nonarch_base_libdir}/firmware/brcm
} }
PACKAGES =+ "${PN}-ap6212 ${PN}-brcm43362" PACKAGES =+ "${PN}-ap6212 ${PN}-brcm43362"
@ -37,6 +41,8 @@ FILES_${PN}-ap6212 = " \
/lib/firmware/brcm/brcmfmac43430a0-sdio.bin \ /lib/firmware/brcm/brcmfmac43430a0-sdio.bin \
/lib/firmware/brcm/brcmfmac43430a0-sdio.txt \ /lib/firmware/brcm/brcmfmac43430a0-sdio.txt \
/lib/firmware/brcm/config.txt \ /lib/firmware/brcm/config.txt \
/lib/firmware/brcm/bcm43438a0.hcd \
/lib/firmware/brcm/bcm43438a1.hcd \
" "
FILES_${PN}-brcm43362 = " \ FILES_${PN}-brcm43362 = " \

View file

@ -0,0 +1,31 @@
From b093d275ba1bec4d8ee91f18609ef0266fa5cbbb Mon Sep 17 00:00:00 2001
From: Sebastian Panceac <sebastian@balena.io>
Date: Wed, 27 Feb 2019 10:13:31 +0100
Subject: [PATCH] Enable uart3 for NanoPi Neo Air used by BT
Upstream-status: Pending
Signed-off-by: Sebastian Panceac <sebastian@balena.io>
---
arch/arm/boot/dts/sun8i-h3-nanopi-neo-air.dts | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm/boot/dts/sun8i-h3-nanopi-neo-air.dts b/arch/arm/boot/dts/sun8i-h3-nanopi-neo-air.dts
index a9331fe67..99e34f0a1 100644
--- a/arch/arm/boot/dts/sun8i-h3-nanopi-neo-air.dts
+++ b/arch/arm/boot/dts/sun8i-h3-nanopi-neo-air.dts
@@ -124,6 +124,12 @@
status = "okay";
};
+&uart3 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart3_pins>, <&uart3_rts_cts_pins>;
+ status = "okay";
+};
+
&usbphy {
/* USB VBUS is always on */
status = "okay";
--
2.17.1

View file

@ -1,5 +1,10 @@
inherit kernel-resin inherit kernel-resin
FILESEXTRAPATHS_prepend := "${THISDIR}/linux-mainline:"
SRC_URI_append = " file://0001-Enable-uart3-for-NanoPi-Neo-Air-used-by-BT.patch \
"
do_kernel_configme[depends] += "virtual/${TARGET_PREFIX}binutils:do_populate_sysroot" do_kernel_configme[depends] += "virtual/${TARGET_PREFIX}binutils:do_populate_sysroot"
do_kernel_configme[depends] += "virtual/${TARGET_PREFIX}gcc:do_populate_sysroot" do_kernel_configme[depends] += "virtual/${TARGET_PREFIX}gcc:do_populate_sysroot"
do_kernel_configme[depends] += "bc-native:do_populate_sysroot bison-native:do_populate_sysroot" do_kernel_configme[depends] += "bc-native:do_populate_sysroot bison-native:do_populate_sysroot"