diff --git a/alarm/firmware-brcm43xx/PKGBUILD b/alarm/firmware-brcm43xx/PKGBUILD new file mode 100644 index 000000000..526d6d9a7 --- /dev/null +++ b/alarm/firmware-brcm43xx/PKGBUILD @@ -0,0 +1,55 @@ +# Maintainer: Dave H + +buildarch=4 + +pkgname=firmware-brcm43xx +pkgdesc="bluetooth firmware and firware loading utility for the bcm43xx bluetooth" +pkgver=1.0 +pkgrel=1 +arch=('armv7h') +url="https://github.com/OpenBricks/openbricks/tree/master/packages/brcm-patchram-plus" +license=('apache' 'custom') +makedepends=('') +depends=('bluez-utils') +backup=('etc/conf.d/bcm43xx') +source=('https://raw.githubusercontent.com/OpenBricks/openbricks/master/packages/firmware-wifi-brcm80211/config/bcm4329_nvram.txt' + 'https://raw.githubusercontent.com/OpenBricks/openbricks/master/packages/firmware-wifi-brcm80211/config/bcm4330_nvram.txt' + 'https://raw.githubusercontent.com/OpenBricks/openbricks/master/packages/firmware-wifi-brcm80211/config/bcm4330_nvram.txt' + 'https://github.com/OpenBricks/openbricks/raw/master/packages/brcm-patchram-plus/sources/bcm4329.hcd' + 'https://github.com/OpenBricks/openbricks/raw/master/packages/brcm-patchram-plus/sources/bcm4330.hcd' + 'https://raw.githubusercontent.com/OpenBricks/openbricks/master/packages/brcm-patchram-plus/sources/brcm_patchram_plus.c' + 'start-brcm-patchram-plus' + 'brcm43xx.service' + 'bcm43xx') +md5sums=('bf01292eec17815baa68a83d3d7722ad' + '31a9a011ce24707ed3c1024616c9005e' + '31a9a011ce24707ed3c1024616c9005e' + 'ff27325602dc223203adfdd23a89844b' + '8e32f9168aaa540467589c153129c57a' + '627e9612337e5ef6027a87a79c491446' + 'c2d65a43d3c1c5eb7e2d168440867db4' + '7e4dcf16c3def9b5a159627b25b21e1e' + '587fa5f25768380605287057924238e6') + +build() { + cd "${srcdir}/" + gcc brcm_patchram_plus.c -o brcm_patchram_plus +} + + +package() { + cd "${srcdir}/" + mkdir -p ${pkgdir}/usr/lib/firmware/brcm + mkdir -p ${pkgdir}/usr/usr/bin + mkdir -p ${pkgdir}/etc/conf.d + mkdir -p ${pkgdir}/usr/lib/systemd/scripts + install -D -m0644 bcm4329_nvram.txt "${pkgdir}/usr/lib/firmware/brcm/brcmfmac4329-sdio.txt" + install -D -m0644 bcm4330_nvram.txt "${pkgdir}/usr/lib/firmware/brcm/brcmfmac4330-sdio.txt" + install -D -m0644 bcm4329.hcd "${pkgdir}/usr/lib/firmware/brcm/bcm4329.hcd" + install -D -m0644 bcm4330.hcd "${pkgdir}/usr/lib/firmware/brcm/bcm4330.hcd" + install -D -m0755 brcm_patchram_plus "${pkgdir}/usr/bin/brcm_patchram_plus" + install -D -m0644 bcm43xx "${pkgdir}/etc/conf.d/bcm43xx" + install -D -m0644 brcm43xx.service "${pkgdir}/usr/lib/systemd/system/brcm43xx.service" + install -D -m0755 start-brcm-patchram-plus "${pkgdir}/usr/lib/systemd/scripts/start-brcm-patchram-plus" +} + diff --git a/alarm/firmware-brcm43xx/bcm43xx b/alarm/firmware-brcm43xx/bcm43xx new file mode 100644 index 000000000..985f35d31 --- /dev/null +++ b/alarm/firmware-brcm43xx/bcm43xx @@ -0,0 +1 @@ +MAC_ADDR=43:29:B1:55:01:01 diff --git a/alarm/firmware-brcm43xx/brcm43xx.service b/alarm/firmware-brcm43xx/brcm43xx.service new file mode 100644 index 000000000..56fcf2135 --- /dev/null +++ b/alarm/firmware-brcm43xx/brcm43xx.service @@ -0,0 +1,12 @@ +[Unit] +Description=Load Broadcom bluetooth firmware +Before=bluetooth.service + +[Service] +EnvironmentFile=/etc/conf.d/bcm43xx +Type=oneshot +ExecStart=/usr/lib/systemd/scripts/start-brcm-patchram-plus +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/alarm/firmware-brcm43xx/start-brcm-patchram-plus b/alarm/firmware-brcm43xx/start-brcm-patchram-plus new file mode 100644 index 000000000..7f20ee330 --- /dev/null +++ b/alarm/firmware-brcm43xx/start-brcm-patchram-plus @@ -0,0 +1,45 @@ +#!/bin/sh + +MAC_OPTIONS="" +if [ -z "$MAC_ADDR" ]; then + echo "MAC_ADDR in /etc/conf.d/bcm4329 not set, will use MAC set by device (expect this to be buggy)" +else + MAC_OPTIONS="--bd_addr $MAC_ADDR" +fi + + +a=`cat /sys/class/mmc_host/mmc0/mmc0\:0001/mmc0\:0001\:1/device` + +HCD="" +EXTRA="" + +if [ "$a" = "0x4329" ] ; then + HCD="bcm4329.hcd" +fi + +if [ "$a" = "0x4330" ] ; then + HCD="bcm4330.hcd" + EXTRA="--no2bytes --enable_lpm --tosleep=50000 " +fi + +if [ -n "$HCD" ] ; then + echo "Found chip version $a." + /usr/bin/brcm_patchram_plus -d --patchram /usr/lib/firmware/brcm/$HCD --baudrate 3000000 --use_baudrate_for_download /dev/ttymxc3 --enable_hci $EXTRA $MAC_OPTIONS & +else + echo " No device Found." + exit 1 +fi + +for i in 1 2 3 4 5 ; do + b=`hciconfig | grep UART | cut -d: -f1` + if [ -n "$b" ] ; then + hciconfig $b up + break + else + sleep $i + fi +done + + +exit 0 +