PKGBUILDs/alarm/firmware-brcm43xx/start-brcm-patchram-plus

80 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/bin/sh
CACHE=/var/cache/brcm43xx-mac
MAC_OPTIONS=""
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/brcm43xx."
else
[ -f "$CACHE" ] && rm "$CACHE"
fi
MAC_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
a="$DEV"
fi
done
if [ -z "$a" ]; then
echo "Failed: Unable to locate bluetooth device"
exit 1
fi
if [ "$a" = "0x4329" ] ; then
HCD="bcm4329.hcd"
fi
if [ "$a" = "0x4330" ] ; then
HCD="bcm4330.hcd"
fi
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
if [ "$HCD" = "bcm4330.hcd" ]; then
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 ${TTY} --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