Skip to content

Commit

Permalink
Run firmware script with sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpenedblade committed Feb 17, 2024
1 parent bed552f commit 9a2832b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions docs/guides/wifi-bluetooth.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ You have two options here. You can follow either of the two, its purely based on
sudo umount /dev/nvme0n1p1
sudo mkdir -p /tmp/apple-wifi-efi
sudo mount /dev/nvme0n1p1 /tmp/apple-wifi-efi
bash /tmp/apple-wifi-efi/firmware.sh
sudo /tmp/apple-wifi-efi/firmware.sh
```

#### For those who don’t know how to run a script
Expand All @@ -55,7 +55,7 @@ If you don’t know how to run a script, follow these instructions.
2. Open the terminal and run :-

``` bash
bash ~/Downloads/firmware.sh
sudo ~/Downloads/firmware.sh
```

3. Then boot into Linux and place the same script in the **Downloads** folder over there or simply run the commands the script asked you to run in Linux when you executed it in macOS.
Expand Down
38 changes: 19 additions & 19 deletions docs/tools/firmware.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ case "$os" in
identifier=$(system_profiler SPHardwareDataType | grep "Model Identifier" | cut -d ":" -f 2 | xargs)
echo "Mounting the EFI partition"
EFILABEL=$(diskutil info disk0s1 | grep "Volume Name" | cut -d ":" -f 2 | xargs)
sudo diskutil mount disk0s1
diskutil mount disk0s1
echo "Getting Wi-Fi and Bluetooth firmware"
if [[ ${1-default} = -v ]]
then
Expand All @@ -47,9 +47,9 @@ case "$os" in
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 "/Volumes/${EFILABEL}/"
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\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"
echo -e "Run the following commands or run this script itself in Linux now to set up Wi-Fi:\n\n mkdir -p /tmp/apple-wifi-efi\n mount /dev/nvme0n1p1 /tmp/apple-wifi-efi\n /tmp/apple-wifi-efi/firmware.sh\n"
;;
(Linux)
echo "Detected Linux"
Expand All @@ -59,15 +59,15 @@ case "$os" in
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
mount -v /dev/nvme0n1p1 $mountpoint
tar --warning=no-unknown-keyword -xvC $workdir -f $mountpoint/firmware.tar.gz
python3 $0 $workdir $workdir/firmware-renamed.tar
sudo tar -xvC /lib/firmware -f $workdir/firmware-renamed.tar
tar -xvC /lib/firmware -f $workdir/firmware-renamed.tar
else
sudo mount /dev/nvme0n1p1 $mountpoint
sudo tar --warning=no-unknown-keyword -xC $workdir -f $mountpoint/firmware.tar.gz
mount /dev/nvme0n1p1 $mountpoint
tar --warning=no-unknown-keyword -xC $workdir -f $mountpoint/firmware.tar.gz
python3 $0 $workdir $workdir/firmware-renamed.tar &> /dev/null
sudo tar -xC /lib/firmware -f $workdir/firmware-renamed.tar
tar -xC /lib/firmware -f $workdir/firmware-renamed.tar
fi
echo "Installing extra firmware"
for file in "$mountpoint/brcmfmac4364b2-pcie.txt" \
Expand All @@ -77,9 +77,9 @@ case "$os" in
then
if [[ ${1-default} = -v ]]
then
sudo cp -v $file /lib/firmware/brcm
cp -v $file /lib/firmware/brcm
else
sudo cp $file /lib/firmware/brcm
cp $file /lib/firmware/brcm
fi
fi
done
Expand All @@ -96,19 +96,19 @@ case "$os" in
do
if [ -f "$file" ]
then
sudo rm $file
rm $file
fi
done
fi

sudo umount $mountpoint
sudo rm -r $workdir/*
sudo rmdir $mountpoint
umount $mountpoint
rm -r $workdir/*
rmdir $mountpoint
echo "Reloading Wi-Fi drivers"
sudo modprobe -r brcmfmac
sudo modprobe brcmfmac
sudo modprobe -r hci_bcm4377
sudo modprobe hci_bcm4377
modprobe -r brcmfmac
modprobe brcmfmac
modprobe -r hci_bcm4377
modprobe hci_bcm4377
echo "Done!"
;;
(*)
Expand Down

0 comments on commit 9a2832b

Please sign in to comment.