mirror of
https://github.com/ps5-linux/ps5-linux-mwifiex.git
synced 2026-07-16 01:40:37 +00:00
Copy firmware from usb boot partition
This commit is contained in:
18
README.md
18
README.md
@@ -9,25 +9,15 @@ Run from this package root:
|
||||
```sh
|
||||
sudo ./install.sh
|
||||
```
|
||||
If no boot `lib/` payload exists, the installer logs that and continues; this
|
||||
keeps kernel module upgrades independent from firmware delivery.
|
||||
|
||||
Load the installed driver with:
|
||||
To remove the installed driver files:
|
||||
|
||||
```sh
|
||||
sudo modprobe moal
|
||||
sudo ./install.sh uninstall
|
||||
```
|
||||
|
||||
If the firmware is not already installed at
|
||||
`/lib/firmware/nxp/pcieuartiw620_combo_v1.bin`, pass it to the installer:
|
||||
|
||||
```sh
|
||||
sudo FIRMWARE_SRC=/path/to/pcieuartiw620_combo_v1.bin ./install.sh
|
||||
```
|
||||
|
||||
The firmware should be installed automatically by the Linux loader:
|
||||
https://github.com/ps5-linux/ps5-linux-loader
|
||||
|
||||
If it is not, please open an issue.
|
||||
|
||||
## Fresh Build
|
||||
|
||||
Run from this package root:
|
||||
|
||||
158
install.sh
158
install.sh
@@ -1,49 +1,29 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
REPO_URL=${REPO_URL:-https://github.com/nxp-imx/mwifiex.git}
|
||||
REF=${REF:-lf-6.18.2_1.0.0}
|
||||
KERNEL_RELEASE=${KERNEL_RELEASE:-$(uname -r)}
|
||||
KERNELDIR=${KERNELDIR:-/lib/modules/$KERNEL_RELEASE/build}
|
||||
REPO_URL=https://github.com/nxp-imx/mwifiex.git
|
||||
REF=lf-6.18.2_1.0.0
|
||||
|
||||
KERNEL_RELEASE=$(uname -r)
|
||||
KERNELDIR=/lib/modules/$KERNEL_RELEASE/build
|
||||
|
||||
script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd)
|
||||
BUILD_DIR=${BUILD_DIR:-$script_dir/build}
|
||||
DRIVER_DIR=${DRIVER_DIR:-$BUILD_DIR/mwifiex}
|
||||
PATCH_FILE=${PATCH_FILE:-$script_dir/ps5-iw620.patch}
|
||||
INSTALL_MOD_DIR=${INSTALL_MOD_DIR:-extra/ps5-iw620}
|
||||
MODULE_DIR=${MODULE_DIR:-/lib/modules/$KERNEL_RELEASE/$INSTALL_MOD_DIR}
|
||||
MODPROBE_CONF=${MODPROBE_CONF:-/etc/modprobe.d/ps5-iw620.conf}
|
||||
BUILD_DIR=$script_dir/build
|
||||
DRIVER_DIR=$BUILD_DIR/mwifiex
|
||||
PATCH_FILE=$script_dir/ps5-iw620.patch
|
||||
|
||||
FW_NAME=${FW_NAME:-nxp/pcieuartiw620_combo_v1.bin}
|
||||
FIRMWARE_SRC=${FIRMWARE_SRC:-}
|
||||
FIRMWARE_DIR=${FIRMWARE_DIR:-/lib/firmware}
|
||||
MODULE_DIR=/lib/modules/$KERNEL_RELEASE/extra/ps5-iw620
|
||||
MODPROBE_CONF=/etc/modprobe.d/ps5-iw620.conf
|
||||
FW_NAME=nxp/pcieuartiw620_combo_v1.bin
|
||||
|
||||
ARCH=${ARCH:-}
|
||||
JOBS=${JOBS:-}
|
||||
|
||||
MOAL_OPTIONS=${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}
|
||||
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 [install|build|uninstall|clean]
|
||||
Usage: $0 [uninstall]
|
||||
|
||||
Commands:
|
||||
install Build and install the driver modules (default)
|
||||
build Build the driver without installing it
|
||||
uninstall Remove installed modules and modprobe config
|
||||
clean Remove the local build directory
|
||||
|
||||
Environment:
|
||||
KERNEL_RELEASE Kernel release to build for (default: $(uname -r))
|
||||
KERNELDIR Kernel build directory (default: $KERNELDIR)
|
||||
DRIVER_DIR Driver source checkout (default: $DRIVER_DIR)
|
||||
MODULE_DIR Module install path (default: $MODULE_DIR)
|
||||
MODPROBE_CONF Modprobe config path (default: $MODPROBE_CONF)
|
||||
FW_NAME Firmware name passed to moal (default: $FW_NAME)
|
||||
FIRMWARE_SRC Optional local firmware file to copy into /lib/firmware
|
||||
FIRMWARE_DIR Firmware install root (default: $FIRMWARE_DIR)
|
||||
ARCH Kernel build ARCH override
|
||||
JOBS Parallel make jobs
|
||||
Run without arguments to build, install, and load the driver.
|
||||
Run with uninstall to remove the installed modules and modprobe config.
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -56,66 +36,42 @@ die() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
need_cmd() {
|
||||
command -v "$1" >/dev/null 2>&1 || die "missing command: $1"
|
||||
}
|
||||
|
||||
need_root() {
|
||||
[ "$(id -u)" -eq 0 ] || die "run install/uninstall as root"
|
||||
}
|
||||
|
||||
build_arch() {
|
||||
if [ -n "$ARCH" ]; then
|
||||
printf '%s\n' "$ARCH"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$(uname -m)" in
|
||||
x86_64|i386|i486|i586|i686) printf 'x86\n' ;;
|
||||
aarch64|arm64) printf 'arm64\n' ;;
|
||||
arm*) printf 'arm\n' ;;
|
||||
riscv64) printf 'riscv\n' ;;
|
||||
ppc64*) printf 'powerpc\n' ;;
|
||||
*) uname -m ;;
|
||||
esac
|
||||
}
|
||||
|
||||
make_jobs() {
|
||||
if [ -n "$JOBS" ]; then
|
||||
printf '%s\n' "$JOBS"
|
||||
elif command -v nproc >/dev/null 2>&1; then
|
||||
nproc
|
||||
else
|
||||
getconf _NPROCESSORS_ONLN 2>/dev/null || printf '1\n'
|
||||
fi
|
||||
git_driver() {
|
||||
git -c safe.directory="$DRIVER_DIR" -C "$DRIVER_DIR" "$@"
|
||||
}
|
||||
|
||||
prepare_source() {
|
||||
need_cmd git
|
||||
need_cmd make
|
||||
[ -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: $DRIVER_DIR"
|
||||
[ ! -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 "Fetching driver refs"
|
||||
git -C "$DRIVER_DIR" fetch --tags origin
|
||||
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 -C "$DRIVER_DIR" checkout "$REF"
|
||||
git_driver checkout "$REF"
|
||||
|
||||
if git -C "$DRIVER_DIR" apply --check "$PATCH_FILE" >/dev/null 2>&1; then
|
||||
if git_driver apply --check "$PATCH_FILE" >/dev/null 2>&1; then
|
||||
say "Applying PS5 IW620 patch"
|
||||
git -C "$DRIVER_DIR" apply "$PATCH_FILE"
|
||||
elif git -C "$DRIVER_DIR" apply -R --check "$PATCH_FILE" >/dev/null 2>&1; then
|
||||
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"
|
||||
@@ -124,28 +80,24 @@ prepare_source() {
|
||||
|
||||
build_driver() {
|
||||
prepare_source
|
||||
arch=$(build_arch)
|
||||
jobs=$(make_jobs)
|
||||
|
||||
say "Building modules for $KERNEL_RELEASE (ARCH=$arch)"
|
||||
make -C "$DRIVER_DIR" CONFIG_OBJTOOL= KERNELDIR="$KERNELDIR" ARCH="$arch" -j "$jobs"
|
||||
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"
|
||||
}
|
||||
|
||||
install_firmware() {
|
||||
target=$FIRMWARE_DIR/$FW_NAME
|
||||
copy_boot_lib_payload() {
|
||||
for dir in /boot/lib /boot/efi/lib /efi/lib; do
|
||||
if [ -d "$dir" ]; then
|
||||
say "Copying boot lib payload from $dir to /lib"
|
||||
cp -a "$dir/." /lib/
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$FIRMWARE_SRC" ]; then
|
||||
[ -f "$FIRMWARE_SRC" ] || die "firmware file not found: $FIRMWARE_SRC"
|
||||
say "Installing firmware to $target"
|
||||
install -d "$(dirname "$target")"
|
||||
install -m 0644 "$FIRMWARE_SRC" "$target"
|
||||
elif [ ! -f "$target" ]; then
|
||||
say "WARNING: firmware not found at $target"
|
||||
say " If needed, rerun with FIRMWARE_SRC=/path/to/$(basename "$FW_NAME")"
|
||||
fi
|
||||
say "No boot lib payload found; skipping firmware copy"
|
||||
}
|
||||
|
||||
write_modprobe_config() {
|
||||
@@ -160,9 +112,8 @@ EOF
|
||||
|
||||
install_driver() {
|
||||
need_root
|
||||
need_cmd install
|
||||
need_cmd depmod
|
||||
build_driver
|
||||
copy_boot_lib_payload
|
||||
|
||||
say "Installing modules to $MODULE_DIR"
|
||||
install -d "$MODULE_DIR"
|
||||
@@ -170,19 +121,22 @@ install_driver() {
|
||||
install -m 0644 "$DRIVER_DIR/moal.ko" "$MODULE_DIR/moal.ko"
|
||||
|
||||
write_modprobe_config
|
||||
install_firmware
|
||||
|
||||
say "Running depmod for $KERNEL_RELEASE"
|
||||
depmod "$KERNEL_RELEASE"
|
||||
|
||||
say "Done. Load with: modprobe moal"
|
||||
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
|
||||
need_cmd depmod
|
||||
|
||||
say "Removing modules from $MODULE_DIR"
|
||||
say "Removing installed modules"
|
||||
rm -f "$MODULE_DIR/mlan.ko" "$MODULE_DIR/moal.ko"
|
||||
rmdir "$MODULE_DIR" 2>/dev/null || true
|
||||
|
||||
@@ -193,25 +147,11 @@ uninstall_driver() {
|
||||
depmod "$KERNEL_RELEASE"
|
||||
}
|
||||
|
||||
clean_build() {
|
||||
case "$BUILD_DIR" in
|
||||
"$script_dir"/build)
|
||||
say "Removing $BUILD_DIR"
|
||||
rm -rf "$BUILD_DIR"
|
||||
;;
|
||||
*)
|
||||
die "refusing to remove custom BUILD_DIR: $BUILD_DIR"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
cmd=${1:-install}
|
||||
cmd=${1:-}
|
||||
|
||||
case "$cmd" in
|
||||
install) install_driver ;;
|
||||
build) build_driver ;;
|
||||
"") install_driver ;;
|
||||
uninstall) uninstall_driver ;;
|
||||
clean) clean_build ;;
|
||||
-h|--help|help) usage ;;
|
||||
*) usage >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user