Last active
January 9, 2021 21:45
-
-
Save jinnko/4b9af7dacb6e9841a63a76a78b14f4a8 to your computer and use it in GitHub Desktop.
Automate patching Killer Wireless firmware on Ubuntu for Dell XPS 9370
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
# | |
# See the following AskUbuntu question for why this is a thing | |
# https://askubuntu.com/questions/1024281/dell-xps-13-9370-bluetooth-issues/1148484#1148484 | |
# | |
# As the overwritten files are owned by the linux-firmware package you may want to add this | |
# script to an @reboot cron of the root user. | |
# | |
# This script uses the Windows driver package as the src of the firmware bin files. This can | |
# be acquired from https://www.dell.com/support/home/uk/en/ukbsdt1/drivers/driversdetails?driverId=1JVK3 | |
set -euo pipefail | |
SRC_PATH="/lib/firmware/__00_manual_override" | |
# This is a ZSH associative array, so the file on the left is patched by the file on the right | |
typeset -A PATCHES | |
PATCHES=( | |
rampatch_usb_00000302.bin AthrBT_0x00000302.dfu | |
nvm_usb_00000302.bin ramps_0x00000302_48.dfu | |
) | |
[ -d "$SRC_PATH" ] || mkdir "$SRC_PATH" | |
for DEST SRC in ${(kv)PATCHES}; do | |
# Get the MD5 and fully qualified path of the original files from the linux-firmware manifest | |
MD5=$(awk '/'"$DEST"'/ { print $1 }' /var/lib/dpkg/info/linux-firmware.md5sums) | |
FQP=$(awk '/'"$DEST"'/ { print $2 }' /var/lib/dpkg/info/linux-firmware.md5sums) | |
# Hash the currently used firmware file | |
HASH=$(md5sum -b "/$FQP" | awk '{print $1}') | |
# If the hashes don't match, then backup the current one and replace it with the one | |
# found in the unpacked path of the downloaded Windows driver. | |
if [ $MD5 = $HASH ]; then | |
cp "/$FQP" "/$FQP.$(date -Im).orig" | |
find $SRC_PATH/Killer-Wireless*(on[-1]) -path '*x64*' \ | |
-name "$SRC" \ | |
-print \ | |
-exec cp '{}' "/$FQP" \; | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment