alarm/firmware-brcm43xx to 1.2

This commit is contained in:
Alejandro Ojeda Gutiérrez 2024-07-01 19:57:57 +02:00 committed by graysky
parent 397024cff5
commit fda0ff63c0
7 changed files with 50 additions and 145 deletions

View file

@ -0,0 +1,19 @@
################################################################################
# udev rules file for loading brcmfmac_sdio-firmware
################################################################################
ACTION!="add", GOTO="end"
SUBSYSTEMS=="sdio", ATTRS{vendor}=="0x02d0", ATTRS{device}=="0x4329", GOTO="begin"
SUBSYSTEMS=="sdio", ATTRS{vendor}=="0x02d0", ATTRS{device}=="0x4330", GOTO="begin"
GOTO="end"
LABEL="begin"
### Broadcom bcm4330 bluetooth device
ATTRS{vendor}=="0x02d0", ATTRS{device}=="0x4330", \
ENV{brcm_device}="bcm4330"
### Broadcom bcm4329 bluetooth device
ATTRS{vendor}=="0x02d0", ATTRS{device}=="0x4329", \
ENV{brcm_device}="bcm4329"
ENV{brcm_device}=="bcm43*", ACTION=="add", \
TAG+="systemd", ENV{SYSTEMD_WANTS}+="brcm43xx-firmware@$env{brcm_device}.service"
LABEL="end"

View file

@ -3,55 +3,39 @@
buildarch=4 buildarch=4
pkgname=firmware-brcm43xx pkgname=firmware-brcm43xx
pkgdesc="bluetooth firmware and firware loading utility for the bcm43xx bluetooth" pkgdesc="wifi and bluetooth firmware for the bcm43xx"
pkgver=1.1 pkgver=1.2
pkgrel=5 pkgrel=1
arch=('armv7h') arch=('armv7h')
url="https://github.com/OpenBricks/openbricks/tree/master/packages/brcm-patchram-plus" url="https://github.com/OpenBricks/openbricks/"
license=('apache' 'custom') license=('apache' 'custom')
depends=('bluez-utils') _commit=194b51d7f61cb05ec735c8afc9854beb692d0d6d
backup=('etc/conf.d/bcm43xx') _url="https://raw.githubusercontent.com/OpenBricks/openbricks/$_commit/packages"
source=('https://raw.githubusercontent.com/OpenBricks/openbricks/master/packages/firmware/firmware-wifi-brcm80211/config/bcm4329_nvram.txt' source=("$_url/firmware/firmware-wifi-brcm80211/config/bcm4329_nvram.txt"
'https://raw.githubusercontent.com/OpenBricks/openbricks/master/packages/firmware/firmware-wifi-brcm80211/config/bcm4330_nvram.txt' "$_url/firmware/firmware-wifi-brcm80211/config/bcm4330_nvram.txt"
'https://raw.githubusercontent.com/OpenBricks/openbricks/master/packages/firmware/firmware-wifi-brcm80211/config/bcm4330_nvram.txt' "$_url/net/brcm-patchram-plus/sources/bcm4329.hcd"
'https://github.com/OpenBricks/openbricks/raw/master/packages/net/brcm-patchram-plus/sources/bcm4329.hcd' "$_url/net/brcm-patchram-plus/sources/bcm4330.hcd"
'https://github.com/OpenBricks/openbricks/raw/master/packages/net/brcm-patchram-plus/sources/bcm4330.hcd' "$_url/net/brcm-patchram-plus/sources/brcm_patchram_plus.c"
'https://raw.githubusercontent.com/OpenBricks/openbricks/master/packages/net/brcm-patchram-plus/sources/brcm_patchram_plus.c' '80-brcm43xx-firmware.rules'
'brcm43xx-firmware-update' 'brcm43xx-firmware@.service')
'brcm43xx-firmware.service'
'brcm43xx.service'
'bcm43xx')
md5sums=('bf01292eec17815baa68a83d3d7722ad' md5sums=('bf01292eec17815baa68a83d3d7722ad'
'31a9a011ce24707ed3c1024616c9005e'
'31a9a011ce24707ed3c1024616c9005e' '31a9a011ce24707ed3c1024616c9005e'
'ff27325602dc223203adfdd23a89844b' 'ff27325602dc223203adfdd23a89844b'
'8e32f9168aaa540467589c153129c57a' '8e32f9168aaa540467589c153129c57a'
'627e9612337e5ef6027a87a79c491446' '627e9612337e5ef6027a87a79c491446'
'c318d1d7cc65e89d5238e7c9ec0f4bfc' 'b4ca6a6085eb1c2dd4560a15a178cf0e'
'a1bd492bdafced5b41abe4bdebbb07e2' '943e67bcb139d37b9b62cec0004ace88')
'00873c77c5c080e3a23f7c0853adbfeb'
'f21bddcbe8c4e1dedaf31e2959b284d9')
build() { build() {
cd "${srcdir}/" gcc -Wno-error=implicit-function-declaration brcm_patchram_plus.c -o brcm_patchram_plus
gcc -c -Wno-implicit-function-declaration brcm_patchram_plus.c -o brcm_patchram_plus
} }
package() { package() {
cd "${srcdir}/" install -D -m0644 "${srcdir}/bcm4329_nvram.txt" "${pkgdir}/usr/lib/firmware/brcm/brcmfmac4329-sdio.txt"
mkdir -p ${pkgdir}/usr/lib/firmware/brcm install -D -m0644 "${srcdir}/bcm4330_nvram.txt" "${pkgdir}/usr/lib/firmware/brcm/brcmfmac4330-sdio.txt"
mkdir -p ${pkgdir}/usr/bin install -D -m0644 "${srcdir}/bcm4329.hcd" "${pkgdir}/usr/lib/firmware/brcm/bcm4329.hcd"
mkdir -p ${pkgdir}/etc/conf.d install -D -m0644 "${srcdir}/bcm4330.hcd" "${pkgdir}/usr/lib/firmware/brcm/bcm4330.hcd"
mkdir -p ${pkgdir}/usr/lib/systemd/scripts install -D -m0755 "${srcdir}/brcm_patchram_plus" "${pkgdir}/usr/bin/brcm_patchram_plus"
install -D -m0644 bcm4329_nvram.txt "${pkgdir}/usr/lib/firmware/brcm/brcmfmac4329-sdio.txt" install -D -m0644 "${srcdir}/80-brcm43xx-firmware.rules" "${pkgdir}/usr/lib/udev/rules.d/80-brcm43xx-firmware.rules"
install -D -m0644 bcm4330_nvram.txt "${pkgdir}/usr/lib/firmware/brcm/brcmfmac4330-sdio.txt" install -D -m0644 "${srcdir}/brcm43xx-firmware@.service" "${pkgdir}/usr/lib/systemd/system/brcm43xx-firmware@.service"
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 -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"
} }

View file

@ -1,4 +0,0 @@
MAC_ADDR=
HCD=
TTY=
OPTIONS=

View file

@ -1,70 +0,0 @@
#!/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 --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

View file

@ -1,19 +0,0 @@
[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

View file

@ -0,0 +1,8 @@
[Unit]
Description=Broadcom sdio firmware update for %I
ConditionPathExists=/dev/ttymxc2
[Service]
Type=simple
RemainAfterExit=yes
ExecStart=/usr/bin/brcm_patchram_plus --patchram /lib/firmware/brcm/%I.hcd --baudrate 3000000 --use_baudrate_for_download /dev/ttymxc2 --enable_hci --no2bytes --tosleep=50000

View file

@ -1,13 +0,0 @@
[Unit]
Description=Broadcom 43xx bluetooth HCI
Requires=brcm43xx-firmware.service
After=brcm43xx-firmware.service
Before=bluetooth.service
ConditionPathExists=/dev/brcm43xx
[Service]
Type=simple
ExecStart=/usr/bin/btattach -B /dev/brcm43xx -P bcm -S 3000000
[Install]
WantedBy=bluetooth.target