Files
ps5-linux-mwifiex/install.sh
Hasanuddin Abu Bakar 10b51c3dc0 mwifiex: rebase PS5 IW620 patch for linux 7.1.y (#5)
* mwifiex: rebase PS5 IW620 patch for linux 7.1

- Rebase ps5-iw620.patch onto nxp-imx/mwifiex lf-6.18.20_2.0.0, which carries the cfg80211 API updates needed by Linux 7.1.

- Restore PS5 IW620 Wi-Fi module builds on the linux-7.1.y kernel by avoiding the net_device versus wireless_dev API mismatch.

- Target the PS5 IW620 PCIe path and disable unrelated SDIO/USB targets so the build does not pull unresolved sdio_* symbols.

- Export the PCI module alias so the PS5 IW620 module can autoload when the device is present.

- Keep the PS5 connected-state scan workaround, which fake-completes scans while associated to reduce firmware/driver instability.

- Preserve the legacy scan option behavior used by the PS5 load parameters.

- Update README fresh-build instructions to use the new NXP base ref.

* mwifiex: avoid IW620 scan and regulatory firmware quirks

The PS5 IW620 firmware accepts the core STA path but rejects the channel-attribute regulatory download with CHAN_REGION_CFG status 0x3. That shows up at boot as sub_id=0x200046 action=1 [FW_CMDRESP], even though the interface can still scan and associate.

Skip the channel attribute download for the PCIEIW620/PCIE9097 card type used by PS5 so the driver does not send the firmware command that fails on this platform.

Also treat a scan response with exactly zero optional TLV bytes as valid. NXP used a strict greater-than check, so normal scan responses without trailing TLVs were logged as scan_resp_size: Incorrect size of TLV buff size even when AP parsing completed successfully.

Keep the existing PS5 behavior that forces legacy scan mode and fake-completes connected-state scans for stability.

* Fix mwifiex installer ref

---------

Co-authored-by: Anderson <22428720+buzzer-re@users.noreply.github.com>
2026-06-21 22:29:47 +02:00

160 lines
3.8 KiB
Bash
Executable File

#!/bin/sh
set -eu
REPO_URL=https://github.com/nxp-imx/mwifiex.git
REF=lf-6.18.20_2.0.0
KERNEL_RELEASE=$(uname -r)
KERNELDIR=/lib/modules/$KERNEL_RELEASE/build
script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd)
BUILD_DIR=$script_dir/build
DRIVER_DIR=$BUILD_DIR/mwifiex
PATCH_FILE=$script_dir/ps5-iw620.patch
MODULE_DIR=/lib/modules/$KERNEL_RELEASE/extra/ps5-iw620
MODPROBE_CONF=/etc/modprobe.d/ps5-iw620.conf
FW_NAME=nxp/pcieuartiw620_combo_v1.bin
FW_PATH=/lib/firmware/$FW_NAME
MOAL_OPTIONS="fw_name=$FW_NAME pcie_int_mode=1 drv_mode=1 cfg80211_wext=4 sta_name=mlan ext_scan=1 auto_fw_reload=0 wifi_reset_config=0 sched_scan=0 ps_mode=2 auto_ds=2 amsdu_disable=1"
usage() {
cat <<EOF
Usage: $0 [uninstall]
Run without arguments to build, install, and load the driver.
Run with uninstall to remove the installed modules and modprobe config.
EOF
}
say() {
printf '%s\n' "$*"
}
die() {
printf 'ERROR: %s\n' "$*" >&2
exit 1
}
need_root() {
[ "$(id -u)" -eq 0 ] || die "run install/uninstall as root"
}
git_driver() {
git -c safe.directory="$DRIVER_DIR" -C "$DRIVER_DIR" "$@"
}
prepare_source() {
[ -f "$PATCH_FILE" ] || die "patch file not found: $PATCH_FILE"
[ -d "$KERNELDIR" ] || die "kernel build directory not found: $KERNELDIR"
mkdir -p "$BUILD_DIR"
if [ ! -d "$DRIVER_DIR/.git" ]; then
[ ! -e "$DRIVER_DIR" ] || die "$DRIVER_DIR exists but is not a git checkout"
say "Cloning driver source into $DRIVER_DIR"
git clone "$REPO_URL" "$DRIVER_DIR"
else
say "Using existing driver source at $DRIVER_DIR"
fi
say "Updating driver source"
if ! git_driver fetch --tags origin; then
git_driver rev-parse --verify "$REF^{commit}" >/dev/null 2>&1 ||
die "failed to fetch driver source and $REF is not available locally"
say "Fetch failed; using local $REF"
fi
say "Checking out $REF"
git_driver checkout "$REF"
if git_driver apply --check "$PATCH_FILE" >/dev/null 2>&1; then
say "Applying PS5 IW620 patch"
git_driver apply "$PATCH_FILE"
elif git_driver apply -R --check "$PATCH_FILE" >/dev/null 2>&1; then
say "PS5 IW620 patch is already applied"
else
die "patch does not apply cleanly in $DRIVER_DIR"
fi
}
build_driver() {
prepare_source
say "Building modules for $KERNEL_RELEASE"
make -C "$DRIVER_DIR" CONFIG_OBJTOOL= KERNELDIR="$KERNELDIR" ARCH=x86 -j"$(nproc)"
[ -f "$DRIVER_DIR/mlan.ko" ] || die "missing built module: $DRIVER_DIR/mlan.ko"
[ -f "$DRIVER_DIR/moal.ko" ] || die "missing built module: $DRIVER_DIR/moal.ko"
}
copy_boot_lib_payload() {
fw_src=/boot/efi/lib/$FW_NAME
if [ ! -f "$fw_src" ]; then
say "Firmware not found at $fw_src; skipping firmware copy"
return
fi
say "Installing firmware to $FW_PATH"
install -d "$(dirname "$FW_PATH")"
install -m 0644 "$fw_src" "$FW_PATH"
}
write_modprobe_config() {
say "Writing modprobe config to $MODPROBE_CONF"
install -d "$(dirname "$MODPROBE_CONF")"
cat >"$MODPROBE_CONF" <<EOF
# PS5 IW620 mwifiex
softdep moal pre: cfg80211 mlan
options moal $MOAL_OPTIONS
EOF
}
install_driver() {
need_root
build_driver
copy_boot_lib_payload
say "Installing modules to $MODULE_DIR"
install -d "$MODULE_DIR"
install -m 0644 "$DRIVER_DIR/mlan.ko" "$MODULE_DIR/mlan.ko"
install -m 0644 "$DRIVER_DIR/moal.ko" "$MODULE_DIR/moal.ko"
write_modprobe_config
say "Running depmod for $KERNEL_RELEASE"
depmod "$KERNEL_RELEASE"
say "Loading installed driver"
if modprobe moal; then
say "Driver loaded"
else
say "Install finished, but modprobe moal failed. Check dmesg for details."
fi
}
uninstall_driver() {
need_root
say "Removing installed modules"
rm -f "$MODULE_DIR/mlan.ko" "$MODULE_DIR/moal.ko"
rmdir "$MODULE_DIR" 2>/dev/null || true
say "Removing $MODPROBE_CONF"
rm -f "$MODPROBE_CONF"
say "Running depmod for $KERNEL_RELEASE"
depmod "$KERNEL_RELEASE"
}
cmd=${1:-}
case "$cmd" in
"") install_driver ;;
uninstall) uninstall_driver ;;
-h|--help|help) usage ;;
*) usage >&2; exit 2 ;;
esac