Skip to content

Commit

Permalink
Rename firmware files on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpenedblade committed Feb 15, 2024
1 parent a771e87 commit d9cf05a
Showing 1 changed file with 20 additions and 32 deletions.
52 changes: 20 additions & 32 deletions docs/tools/firmware.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ case "$os" in
EFILABEL=$(diskutil info disk0s1 | grep "Volume Name" | cut -d ":" -f 2 | xargs)
sudo diskutil mount disk0s1
echo "Getting Wi-Fi and Bluetooth firmware"
cd /usr/share/firmware
if [[ ${1-default} = -v ]]
then
tar czvf "/Volumes/${EFILABEL}/firmware.tar.gz" *
python3 $0 /usr/share/firmware "/Volumes/${EFILABEL}/firmware.tar"
gzip --best "/Volumes/${EFILABEL}/firmware.tar"
else
tar czf "/Volumes/${EFILABEL}/firmware.tar.gz" *
python3 $0 /usr/share/firmware "/Volumes/${EFILABEL}/firmware.tar" &> /dev/null
gzip --best "/Volumes/${EFILABEL}/firmware.tar"
fi
if [[ (${identifier} = iMac19,1) || (${identifier} = iMac19,2) || (${identifier} = iMacPro1,1) ]]
then
Expand All @@ -43,58 +44,45 @@ case "$os" in
cp /usr/share/firmware/wifi/C-4364__s-B2/${txcapblob} "/Volumes/${EFILABEL}/brcmfmac4364b2-pcie.txcap_blob"
fi
fi
echo "Copying this script to EFI"
cd - >/dev/null
cp "$0" "/Volumes/${EFILABEL}/firmware.sh"|| (echo -e "\nFailed to copy script.\nPlease copy the script manually to the EFI partition using Finder\nMake sure the name of the script is firmware.sh in the EFI partition\n" && echo && read -p "Press enter after you have copied" && echo)
echo "Copying this script to the ESP"
cp "$0" "/Volumes/${EFILABEL}/firmware.sh"|| (echo -e "\nFailed to copy script.\nPlease copy the script manually to the EFI partition using Finder\n" && echo && read -p "Press enter after you have copied" && echo)
echo "Unmounting the EFI partition"
sudo diskutil unmount disk0s1
sudo diskutil unmount "/Volumes/${EFILABEL}/"
echo
echo -e "Run the following commands or run this script itself in Linux now to set up Wi-Fi :-\n\nsudo umount /dev/nvme0n1p1\nsudo mkdir -p /tmp/apple-wifi-efi\nsudo mount /dev/nvme0n1p1 /tmp/apple-wifi-efi\nbash /tmp/apple-wifi-efi/firmware.sh\n"
echo -e "Run the following commands or run this script itself in Linux now to set up Wi-Fi:\n\n sudo mkdir -p /tmp/apple-wifi-efi\n sudo mount /dev/nvme0n1p1 /tmp/apple-wifi-efi\n /tmp/apple-wifi-efi/firmware.sh\n"
;;
(Linux)
echo "Detected Linux"
mountpoint=$(mktemp -d)
workdir=$(mktemp -d)
echo "Getting Wi-Fi and Bluetooth firmware"
echo "Installing Wi-Fi and Bluetooth firmware"
if [[ ${1-default} = -v ]]
then
sudo mount -v /dev/nvme0n1p1 $mountpoint
sudo tar --warning=no-unknown-keyword -xvC $workdir -f $mountpoint/firmware.tar.gz
sudo cp -v $0 $workdir/firmware.sh
sudo tar --warning=no-unknown-keyword -xvC /lib/firmware -f $mountpoint/firmware.tar.gz
else
sudo mount /dev/nvme0n1p1 $mountpoint
sudo tar --warning=no-unknown-keyword -xC $workdir -f $mountpoint/firmware.tar.gz 2&>
sudo cp $0 $workdir/firmware.sh
sudo tar --warning=no-unknown-keyword -xC /lib/firmware -f $mountpoint/firmware.tar.gz
fi
sudo umount $mountpoint; sudo rmdir $mountpoint
echo "Processing and installing firmware"
if [[ ${1-default} = -v ]]
then
sudo python3 $workdir/firmware.sh $workdir
sudo tar -xvC /usr/lib/firmware -f $workdir/firmware-processed.tar
else
sudo python3 $workdir/firmware.sh $workdir >/dev/null
sudo tar -xC /usr/lib/firmware -f $workdir/firmware-processed.tar
fi
for file in "$workdir/brcmfmac4364b2-pcie.txt" \
"$workdir/brcmfmac4364b2-pcie.txcap_blob"
echo "Installing extra firmware"
for file in "$mountpoint/brcmfmac4364b2-pcie.txt" \
"$mountpoint/brcmfmac4364b2-pcie.txcap_blob"
do
if [ -f "$file" ]
then
if [[ ${1-default} = -v ]]
then
sudo cp -v $file /usr/lib/firmware/brcm
sudo cp -v $file /lib/firmware/brcm
else
sudo cp $file /usr/lib/firmware/brcm
sudo cp $file /lib/firmware/brcm
fi
fi
done
echo "Releoading Wi-Fi drivers"
sudo umount $mountpoint; sudo rmdir $mountpoint
echo "Reloading Wi-Fi drivers"
sudo modprobe -r brcmfmac
sudo modprobe brcmfmac
sudo modprobe -r hci_bcm4377
sudo modprobe hci_bcm4377
sudo rm -r $workdir
echo "Done!"
;;
(*)
Expand All @@ -110,7 +98,7 @@ from collections import namedtuple, defaultdict
#from .core import FWFile
log = logging.getLogger("asahi_firmware.bluetooth")
log = logging.getLogger("t2linux_firmware_installer")
BluetoothChip = namedtuple(
"BluetoothChip", ("chip", "stepping", "board_type", "vendor")
Expand Down Expand Up @@ -424,7 +412,7 @@ class FWPackage(object):
pkg = FWPackage(sys.argv[1]+"/firmware-processed.tar")
pkg = FWPackage(sys.argv[2])
col = WiFiFWCollection(sys.argv[1]+"/wifi")
pkg.add_files(sorted(col.files()))
col = BluetoothFWCollection(sys.argv[1]+"/bluetooth")
Expand Down

0 comments on commit d9cf05a

Please sign in to comment.