Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions install/hardware/fix-bcm43xx.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Install Wi-Fi drivers for Broadcom chips found in some MacBooks, as well as other systems:
# - BCM4360 (2013–2015 MacBooks)
# - BCM4331 (2012, early 2013 MacBooks)
# - BCM43224 (2012 MacBook Air 5,2)

pci_info=$(lspci -nn)

if (echo "$pci_info" | grep -q "14e4:43a0" || echo "$pci_info" | grep -q "14e4:4331"); then
echo "BCM4360 / BCM4331 detected"
if (echo "$pci_info" | grep -q "14e4:43a0" || echo "$pci_info" | grep -q "14e4:4331" || echo "$pci_info" | grep -q "14e4:4353"); then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Existing installs miss the fix. This detection and blacklist run during installation or an explicit hardware-setup rerun, but no migration applies them to existing systems. Updating an affected MacBook Air therefore leaves its driver conflict unresolved unless the user reruns hardware setup. Add an upgrade migration so existing installations receive the fix.

echo "BCM4360 / BCM4331 / BCM43224 detected"
omarchy-pkg-add broadcom-wl-dkms
fi
103 changes: 103 additions & 0 deletions test/shell.d/bcm43xx-wifi-fix-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

fix_script="$ROOT/install/hardware/fix-bcm43xx.sh"

# === Static analysis ===

grep -q '14e4:43a0' "$fix_script" || \
fail "fix-bcm43xx.sh still detects BCM4360 (14e4:43a0)"
pass "fix-bcm43xx.sh still detects BCM4360 (14e4:43a0)"

grep -q '14e4:4331' "$fix_script" || \
fail "fix-bcm43xx.sh still detects BCM4331 (14e4:4331)"
pass "fix-bcm43xx.sh still detects BCM4331 (14e4:4331)"
Comment on lines +11 to +17

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Existing chips lack behavior tests. These checks only confirm that the BCM4360 and BCM4331 IDs appear somewhere in the script. They would still pass if detection stopped handling either chip but its ID remained in a comment. Run both IDs through the stubbed lspci path so the tests catch regressions in the shared detection branch.


grep -q '14e4:4353' "$fix_script" || \
fail "fix-bcm43xx.sh detects BCM43224 (14e4:4353) in MacBook Air 5,2"
pass "fix-bcm43xx.sh detects BCM43224 (14e4:4353) in MacBook Air 5,2"

# === Test 1: BCM43224 detection ===

test_tmp=$(mktemp -d)
trap 'rm -rf "$test_tmp"' EXIT

stub_bin="$test_tmp/bin"
calls="$test_tmp/calls.log"
mkdir -p "$stub_bin"
: >"$calls"

cat >"$stub_bin/lspci" <<'SH'
#!/bin/bash

echo '02:00.0 Network controller [0280]: Broadcom Inc. and subsidiaries BCM43224 802.11a/b/g/n [14e4:4353] (rev 01)'
SH

cat >"$stub_bin/omarchy-pkg-add" <<'SH'
#!/bin/bash

printf 'omarchy-pkg-add\t%s\n' "$*" >>"$TEST_LOG"
SH

chmod +x "$stub_bin"/*

# Redirect /etc/modprobe.d to sandbox so the test runs without root
script="$test_tmp/fix-bcm43xx.sh"
sed -e "s|/etc/modprobe.d|$test_tmp/etc/modprobe.d|g" \
"$fix_script" >"$script"

PATH="$stub_bin:$PATH" \
TEST_LOG="$calls" \
OMARCHY_INSTALL="$ROOT/install" \
bash -euo pipefail "$script" >/dev/null

# Verify package install was called (tab-separated)
grep -qx $'omarchy-pkg-add\tbroadcom-wl-dkms' "$calls" || \
fail "BCM43224 triggers broadcom-wl-dkms installation, relying on the base install's kernel headers"
pass "BCM43224 triggers broadcom-wl-dkms installation, relying on the base install's kernel headers"

# broadcom-wl-dkms ships its own blacklist, which goes away with the package
[[ ! -d "$test_tmp/etc/modprobe.d" ]] || fail "BCM43224 leaves blacklisting to broadcom-wl-dkms"
pass "BCM43224 leaves blacklisting to broadcom-wl-dkms"

# === Test 2: Non-Broadcom hardware is skipped ===

test_tmp2=$(mktemp -d)
trap 'rm -rf "$test_tmp" "$test_tmp2"' EXIT

stub_bin2="$test_tmp2/bin"
calls2="$test_tmp2/calls.log"
mkdir -p "$stub_bin2"
: >"$calls2"

cat >"$stub_bin2/lspci" <<'SH'
#!/bin/bash

echo '02:00.0 Network controller [0280]: Intel Corporation Wi-Fi 6 AX201 [8086:06f0] (rev 01)'
SH

cat >"$stub_bin2/omarchy-pkg-add" <<'SH'
#!/bin/bash

printf 'omarchy-pkg-add\t%s\n' "$*" >>"$TEST_LOG"
SH

chmod +x "$stub_bin2"/*

script2="$test_tmp2/fix-bcm43xx.sh"
sed -e "s|/etc/modprobe.d|$test_tmp2/etc/modprobe.d|g" \
"$fix_script" >"$script2"

PATH="$stub_bin2:$PATH" \
TEST_LOG="$calls2" \
OMARCHY_INSTALL="$ROOT/install" \
bash -euo pipefail "$script2" >/dev/null

[[ ! -s $calls2 ]] || fail "non-Broadcom hardware skips driver installation"
pass "non-Broadcom hardware skips driver installation"

[[ ! -d "$test_tmp2/etc/modprobe.d" ]] || fail "non-Broadcom hardware skips blacklist creation"
pass "non-Broadcom hardware skips blacklist creation"