mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2025-01-17 23:34:07 +00:00
Merge pull request #851 from h0tw1r3/wandboard
alarm/firmware-brcm43xx Bluetooth firmware loading improvements
This commit is contained in:
commit
c512b214e7
6 changed files with 109 additions and 58 deletions
|
@ -4,7 +4,7 @@ buildarch=4
|
|||
|
||||
pkgname=firmware-brcm43xx
|
||||
pkgdesc="bluetooth firmware and firware loading utility for the bcm43xx bluetooth"
|
||||
pkgver=1.0
|
||||
pkgver=1.1
|
||||
pkgrel=1
|
||||
arch=('armv7h')
|
||||
url="https://github.com/OpenBricks/openbricks/tree/master/packages/brcm-patchram-plus"
|
||||
|
@ -18,7 +18,8 @@ source=('https://raw.githubusercontent.com/OpenBricks/openbricks/master/packages
|
|||
'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-firmware-update'
|
||||
'brcm43xx-firmware.service'
|
||||
'brcm43xx.service'
|
||||
'bcm43xx')
|
||||
md5sums=('bf01292eec17815baa68a83d3d7722ad'
|
||||
|
@ -27,9 +28,10 @@ md5sums=('bf01292eec17815baa68a83d3d7722ad'
|
|||
'ff27325602dc223203adfdd23a89844b'
|
||||
'8e32f9168aaa540467589c153129c57a'
|
||||
'627e9612337e5ef6027a87a79c491446'
|
||||
'c2d65a43d3c1c5eb7e2d168440867db4'
|
||||
'7e4dcf16c3def9b5a159627b25b21e1e'
|
||||
'587fa5f25768380605287057924238e6')
|
||||
'2c2d2288e519e605a7f0d04c4e0dc720'
|
||||
'a1bd492bdafced5b41abe4bdebbb07e2'
|
||||
'cb3cbf6ee612e711d4b2c578d93fdae5'
|
||||
'f21bddcbe8c4e1dedaf31e2959b284d9')
|
||||
|
||||
build() {
|
||||
cd "${srcdir}/"
|
||||
|
@ -50,6 +52,7 @@ package() {
|
|||
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"
|
||||
install -D -m0644 brcm43xx-firmware.service "${pkgdir}/usr/lib/systemd/system/brcm43xx-firmware.service"
|
||||
install -D -m0755 brcm43xx-firmware-update "${pkgdir}/usr/lib/systemd/scripts/brcm43xx-firmware-update"
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
MAC_ADDR=43:29:B1:55:01:01
|
||||
MAC_ADDR=
|
||||
HCD=
|
||||
TTY=
|
||||
OPTIONS=
|
||||
|
|
70
alarm/firmware-brcm43xx/brcm43xx-firmware-update
Normal file
70
alarm/firmware-brcm43xx/brcm43xx-firmware-update
Normal file
|
@ -0,0 +1,70 @@
|
|||
#!/bin/sh
|
||||
|
||||
CACHE=/var/cache/brcm43xx-mac
|
||||
if [ -z "$MAC_ADDR" ]; then
|
||||
if [ ! -f "$CACHE" ]; then
|
||||
echo 43:29:B1$(od -txC -An -N3 /dev/random|tr \ : | tr '[:lower:]' '[:upper:]') >"$CACHE"
|
||||
fi
|
||||
MAC_ADDR=`cat "$CACHE"`
|
||||
echo "Warning: Using self generated MAC address! MAC_ADDR should be defined in /etc/conf.d/bcm43xx."
|
||||
else
|
||||
[ -f "$CACHE" ] && rm "$CACHE"
|
||||
fi
|
||||
OPTIONS="$OPTIONS --bd_addr $MAC_ADDR"
|
||||
|
||||
# Find chip version
|
||||
if [ -z "$HCD" ]; then
|
||||
DEVS=($( cat /sys/class/mmc_host/mmc*/mmc?\:0001/mmc?\:0001:?/device ))
|
||||
for DEV in "${DEVS[@]}"; do
|
||||
if [ "${DEV:0:4}" = "0x43" ]; then
|
||||
HCD="bcm${DEV:2}.hcd"
|
||||
fi
|
||||
done
|
||||
if [ -z "$HCD" ]; then
|
||||
echo "Failed: Unable to locate bluetooth device"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
HCD_BASE=$(basename "$HCD")
|
||||
|
||||
# Device specific options
|
||||
[ "$HCD_BASE" = "bcm4330.hcd" ] && OPTIONS="--no2bytes --enable_lpm --tosleep=50000 $OPTIONS"
|
||||
|
||||
[ ! -e "$HCD" ] && HCD="/lib/firmware/brcm/${HCD_BASE}"
|
||||
if [ ! -e "$HCD" ]; then
|
||||
echo "Failed: $HCD does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# UART TTY can be different for each board
|
||||
# FIXME: Possibly test each port with hciattach (-n)?
|
||||
# For now, just use the highest port as it works for current boards
|
||||
if [ -z "$TTY" ]; then
|
||||
TTYS=($( ls -r1 /dev/ttymxc? ))
|
||||
for t in "${TTYS[@]}" ; do
|
||||
ttynum=${t:0-1}
|
||||
if [ $ttynum -eq 0 ]; then
|
||||
echo "Abort: UART ttymcx0 does not seem right."
|
||||
exit 1
|
||||
else
|
||||
TTY=$t
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
[ ! -e "$TTY" ] && TTY="/dev/$(basename $TTY)"
|
||||
if [ ! -e "$TTY" ]; then
|
||||
echo "Failed: $TTY does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Updating bluetooth firmware via $TTY from $HCD."
|
||||
/usr/bin/brcm_patchram_plus --patchram $HCD --baudrate 3000000 --use_baudrate_for_download $TTY $OPTIONS
|
||||
|
||||
# Create a symlink to TTY for hci service
|
||||
if [ $? -eq 0 ]; then
|
||||
ln -sr "$TTY" /dev/brcm43xx
|
||||
else
|
||||
exit 1
|
||||
fi
|
19
alarm/firmware-brcm43xx/brcm43xx-firmware.service
Normal file
19
alarm/firmware-brcm43xx/brcm43xx-firmware.service
Normal file
|
@ -0,0 +1,19 @@
|
|||
[Unit]
|
||||
Description=Broadcom 43xx firmware update
|
||||
DefaultDependencies=no
|
||||
Wants=local-fs.target
|
||||
Conflicts=shutdown.target
|
||||
After=systemd-modules-load.service local-fs.target
|
||||
Before=sysinit.target shutdown.target
|
||||
RefuseManualStart=yes
|
||||
RefuseManualStop=yes
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
EnvironmentFile=-/etc/conf.d/bcm43xx
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/lib/systemd/scripts/brcm43xx-firmware-update
|
||||
TimeoutSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=sysinit.target
|
|
@ -1,12 +1,13 @@
|
|||
[Unit]
|
||||
Description=Load Broadcom bluetooth firmware
|
||||
Description=Broadcom 43xx bluetooth HCI
|
||||
Requires=brcm43xx-firmware.service
|
||||
After=brcm43xx-firmware.service
|
||||
Before=bluetooth.service
|
||||
ConditionPathExists=/dev/brcm43xx
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=/etc/conf.d/bcm43xx
|
||||
Type=oneshot
|
||||
ExecStart=/usr/lib/systemd/scripts/start-brcm-patchram-plus
|
||||
RemainAfterExit=yes
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/hciattach -n /dev/brcm43xx any 3000000
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
WantedBy=bluetooth.target
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
#!/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
|
||||
|
Loading…
Reference in a new issue