-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3103 from holta/rpi-wifi-firmware2
Raspberry Pi WiFi hotspot firmware reliability fix, incl new/better choices for 3B+ & 4 (WIP, this is PR #3101 rebased)
- Loading branch information
Showing
14 changed files
with
256 additions
and
115 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,56 @@ | ||
#!/bin/bash | ||
|
||
WARN=0 | ||
DATE=$(date +%F-%T) | ||
|
||
# 2021-08-18: bash scripts using default_vars.yml &/or local_vars.yml | ||
# https://github.com/iiab/iiab-factory/blob/master/iiab | ||
# https://github.com/iiab/iiab/blob/master/roles/firmware/templates/iiab-check-firmware#L13 | ||
# https://github.com/iiab/iiab/blob/master/roles/firmware/templates/iiab-check-firmware#L10-14 | ||
# https://github.com/iiab/iiab/blob/master/roles/network/templates/gateway/iiab-gen-iptables#L48-L52 | ||
# https://github.com/iiab/maps/blob/master/osm-source/pages/viewer/scripts/iiab-install-map-region#L25-L34 | ||
# https://github.com/iiab/iiab/blob/master/roles/openvpn/templates/iiab-support READS AND WRITES, INCL NON-BOOLEAN | ||
|
||
if grep -q '^wifi_hotspot_capacity_rpi_fix:\s\+[fF]alse\b' /etc/iiab/local_vars.yml ; then | ||
echo "'wifi_hotspot_capacity_rpi_fix: False' found in /etc/iiab/local_vars.yml" | ||
echo "...so WiFi firmware will NOT be checked or replaced." | ||
|
||
exit 0 | ||
fi | ||
|
||
echo -e "'wifi_hotspot_capacity_rpi_fix: True' presumed..." | ||
echo -e "...in /etc/iiab/local_vars.yml (or /opt/iiab/iiab/vars/default_vars.yml ?)\n" | ||
|
||
if ! $(diff -q /lib/firmware/brcm/brcmfmac43455-sdio.bin.iiab /lib/firmware/brcm/brcmfmac43455-sdio.bin); then | ||
mv /lib/firmware/brcm/brcmfmac43455-sdio.bin /lib/firmware/brcm/brcmfmac43455-sdio.bin.$DATE | ||
cp /lib/firmware/brcm/brcmfmac43455-sdio.bin.iiab /lib/firmware/brcm/brcmfmac43455-sdio.bin | ||
echo "Replacing /lib/firmware/brcm/brcmfmac43455-sdio.bin" | ||
WARN=1 | ||
fi | ||
|
||
if ! $(diff -q /lib/firmware/brcm/brcmfmac43455-sdio.clm_blob.iiab /lib/firmware/brcm/brcmfmac43455-sdio.clm_blob); then | ||
mv /lib/firmware/brcm/brcmfmac43455-sdio.clm_blob /lib/firmware/brcm/brcmfmac43455-sdio.clm_blob.$DATE | ||
cp /lib/firmware/brcm/brcmfmac43455-sdio.clm_blob.iiab /lib/firmware/brcm/brcmfmac43455-sdio.clm_blob | ||
echo "Replacing /lib/firmware/brcm/brcmfmac43455-sdio.clm_blob" | ||
WARN=1 | ||
fi | ||
iiab_var_value() { | ||
v1=$(grep "^$1:\s" /opt/iiab/iiab/vars/default_vars.yml | tail -1 | sed "s/^$1:\s\+//; s/#.*//; s/\s*$//; s/^\(['\"]\)\(.*\)\1$/\2/") | ||
v2=$(grep "^$1:\s" /etc/iiab/local_vars.yml | tail -1 | sed "s/^$1:\s\+//; s/#.*//; s/\s*$//; s/^\(['\"]\)\(.*\)\1$/\2/") | ||
[ "$v2" != "" ] && echo $v2 || echo $v1 # [ "$v2" ] ALSO WORKS | ||
} | ||
|
||
link_fw() { | ||
if [[ $(readlink /lib/firmware/brcm/$1) != $1.iiab ]] ; then | ||
echo | ||
mv /lib/firmware/brcm/$1 /lib/firmware/brcm/$1.$(date +%F-%T) | ||
ln -s $1.iiab /lib/firmware/brcm/$1 | ||
echo -e "\e[1mSymlinked /lib/firmware/brcm/$1 -> $1.iiab\e[0m" | ||
touch /tmp/.fw_modified | ||
fi | ||
} | ||
|
||
if ! $(diff -q /lib/firmware/brcm/brcmfmac43430-sdio.bin.iiab /lib/firmware/brcm/brcmfmac43430-sdio.bin); then | ||
mv /lib/firmware/brcm/brcmfmac43430-sdio.bin /lib/firmware/brcm/brcmfmac43430-sdio.bin.$DATE | ||
cp /lib/firmware/brcm/brcmfmac43430-sdio.bin.iiab /lib/firmware/brcm/brcmfmac43430-sdio.bin | ||
cp /lib/firmware/brcm/brcmfmac43430-sdio.clm_blob.iiab /lib/firmware/brcm/brcmfmac43430-sdio.clm_blob | ||
echo "Replacing /lib/firmware/brcm/brcmfmac43430-sdio.bin" | ||
WARN=1 | ||
if [[ $(iiab_var_value rpi3bplus_rpi4_wifi_firmware) != "os" ]] ; then | ||
link_fw brcmfmac43455-sdio.bin | ||
link_fw brcmfmac43455-sdio.clm_blob | ||
fi | ||
|
||
if ! $(diff -q /lib/firmware/brcm/brcmfmac43430-sdio.clm_blob.iiab /lib/firmware/brcm/brcmfmac43430-sdio.clm_blob); then | ||
mv /lib/firmware/brcm/brcmfmac43430-sdio.clm_blob /lib/firmware/brcm/brcmfmac43430-sdio.clm_blob.$DATE | ||
cp /lib/firmware/brcm/brcmfmac43430-sdio.clm_blob.iiab /lib/firmware/brcm/brcmfmac43430-sdio.clm_blob | ||
echo "Replacing /lib/firmware/brcm/brcmfmac43430-sdio.clm_blob" | ||
WARN=1 | ||
if [[ $(iiab_var_value rpizerow_rpi3_wifi_firmware) != "os" ]] ; then | ||
link_fw brcmfmac43430-sdio.bin | ||
link_fw brcmfmac43430-sdio.clm_blob | ||
fi | ||
|
||
if [ "$WARN" = "1" ]; then | ||
echo -e "\n \e[41;1mWiFi Firmware has been replaced, per iiab/iiab#823.\e[0m" | ||
echo -e " \e[41;1mReboot is required to activate.\e[0m\n" | ||
touch /.fw_replaced | ||
#echo "rebooting..." | ||
#reboot | ||
if [ -f /tmp/.fw_modified ]; then | ||
bash /etc/profile.d/iiab-firmware-warn.sh | ||
else | ||
echo -e " WiFi Firmware check \e[42;1mPASSED\e[0m, per iiab/iiab#823." # Or \e[92m for green on black | ||
echo -e " (Assuming you've rebooted since it was replaced!)\n" | ||
if [ -f /.fw_replaced ]; then | ||
rm /.fw_replaced | ||
fi | ||
echo -e "\n\e[1mWiFi Firmware links in /lib/firmware/brcm appear \e[92mCORRECT\e[0m\e[1m, per iiab/iiab#2853.\e[0m" | ||
echo | ||
echo -e "\e[100;1m(No reboot appears necessary!)\e[0m" | ||
echo | ||
echo -e "NOTE: If you change rpi3bplus_rpi4_wifi_firmware or rpizerow_rpi3_wifi_firmware" | ||
echo -e "settings in /etc/iiab/local_vars.yml, please then run:" | ||
echo | ||
echo -e " cd /opt/iiab/iiab" | ||
echo -e " sudo iiab-hotspot-off # Sometimes nec, eg to restore 'wifi_up_down: True'" | ||
echo -e " sudo ./iiab-network # Or, 'sudo ./runrole firmware' is SOMETIMES enough" | ||
echo -e " sudo iiab-hotspot-on # Sometimes nec, eg to restore 'wifi_up_down: True'" | ||
echo -e " sudo poweroff\n" | ||
#echo | ||
#echo -e "Disconnect your power cord before rebooting, for better WiFi firmware results.\n" | ||
fi | ||
|
||
# exit 0 | ||
# \e[1m = bright white \e[100;1m = bright white, on gray \n\e[41;1m = bright white, on red | ||
# \e[42;1m = bright white, on bright green \e[92m = green on black |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
#!/bin/bash | ||
|
||
if [ -f /.fw_replaced ]; then | ||
echo -e "\n \e[41;1mWiFi Firmware has been replaced, per iiab/iiab#823.\e[0m" | ||
if grep -q '^wifi_hotspot_capacity_rpi_fix:\s\+[fF]alse\b' /etc/iiab/local_vars.yml ; then | ||
echo -e " \e[100;1mIf you want these warnings to stop, run:\e[0m" | ||
echo | ||
echo -e " \e[100;1msudo rm /.fw_replaced\e[0m\n" | ||
else | ||
echo -e " \e[41;1mReboot is required to activate.\e[0m\n" | ||
fi | ||
if [ -f /tmp/.fw_modified ]; then | ||
echo -e "\n\e[41;1mWiFi Firmware link(s) modified, per iiab/iiab#2853: PLEASE REBOOT!\e[0m" | ||
echo | ||
echo -e "If you want this warning to stop, run: sudo rm /tmp/.fw_modified\n" | ||
fi | ||
|
||
# \e[1m = bright white \e[100;1m = bright white, on gray \n\e[41;1m = bright white, on red |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.