diff --git a/88x2bu.conf b/88x2bu.conf index 590898e..8c5a39d 100644 --- a/88x2bu.conf +++ b/88x2bu.conf @@ -10,7 +10,7 @@ blacklist rtw88_8822bu # # Edit the following line to change, add or delete options: -options 88x2bu rtw_drv_log_level=1 rtw_led_ctrl=1 rtw_vht_enable=1 rtw_switch_usb_mode=0 +options 88x2bu rtw_drv_log_level=0 rtw_led_ctrl=1 rtw_vht_enable=1 rtw_switch_usb_mode=0 # # Note: To activate USB3 mode, change rtw_switch_usb_mode above to rtw_switch_usb_mode=1 # @@ -27,21 +27,14 @@ options 88x2bu rtw_drv_log_level=1 rtw_led_ctrl=1 rtw_vht_enable=1 rtw_switch_us # # Log options ( rtw_drv_log_level ) # -# 0 = NONE -# 1 = ALWAYS (default) +# 0 = NONE (default) +# 1 = ALWAYS # 2 = ERROR # 3 = WARNING # 4 = INFO # 5 = DEBUG # 6 = MAX # -# Note: You can save a log file that only includes RTW log entries by running -# the following in a terminal: -# -# sudo ./save-log.sh -# -# Note: The name of the log file will be `rtw.log`. -# # ----- # # LED options ( rtw_led_ctrl ) diff --git a/FAQ.md b/FAQ.md index 8297e9f..5f968a0 100644 --- a/FAQ.md +++ b/FAQ.md @@ -196,13 +196,32 @@ dtoverlay=disable-wifi ----- -Question: After `sudo apt upgrade`, my 32 Bit Raspberry Pi OS runs on a 64 bit -kernel and now I can't compile an out-of-kernel Realtek driver. +Question: When running `sudo sh install-driver.sh` on my RasPi 4B or +400, I see the following: -Answer: See: +``` +Your kernel header files aren't properly installed. +Please consult your distro documentation or user support forums. +Once the header files are properly installed, please run... +``` + +Answer: The Pi 4/400 firmware now prefers the 64-bit kernel if one +exists so even if you installed the 32 bit version of the RasPiOS, +you may now have the 64 bit kernel active. + +The fix: + +add the following to /boot/config.txt and reboot: + +arm_64bit=0 + +Reference: https://forums.raspberrypi.com/viewtopic.php?p=2091532&hilit=Tp+link#p2091532 +Note to RasPiOS devs: We really really wish you would consider the +consequences of the changes you make. Thank you. + ----- Question: Were compromises made to make this work on EL8 (RHEL, CentOS, diff --git a/Kconfig b/Kconfig index 8b48040..3526cac 100644 --- a/Kconfig +++ b/Kconfig @@ -1,7 +1,6 @@ config RTL8822BU tristate "Realtek 8822B USB WiFi" depends on USB - select WIRELESS_EXT help Help message of RTL8822BU diff --git a/README.md b/README.md index 35c7d3f..cb13264 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ - v5.13.1 (Realtek) (20210702) plus updates from the Linux community -Note: Please read "supported-device-IDs" for information about how to -confirm that this is the correct driver for your adapter. +Note: Please read the file "supported-device-IDs" for information about +how to confirm that this is the correct driver for your adapter. ### Supported Features @@ -29,7 +29,7 @@ confirm that this is the correct driver for your adapter. - AP mode DFS channel support - Supported interface modes * Managed - * Monitor (see FAQ) (see [Monitor_Mode](https://github.com/morrownr/Monitor_Mode)) + * Monitor (see [Monitor_Mode](https://github.com/morrownr/Monitor_Mode)) * AP (see FAQ) (see [Bridged Wireless Access Point](https://github.com/morrownr/USB-WiFi/blob/main/home/AP_Mode/Bridged_Wireless_Access_Point.md)) * P2P-client * P2P-GO @@ -42,7 +42,7 @@ confirm that this is the correct driver for your adapter. ### Not supported -- hcxdumptool +- hcxdumptool (see hcxdumptool documentation) ### A FAQ is available in this repo with the name `FAQ.md` @@ -57,19 +57,25 @@ confirm that this is the correct driver for your adapter. - armv6l, armv7l (arm) - aarch64 (arm64) +Note: Additional CPU architectures may work but I currently only have +the hardware to test the above. + ### Compatible Kernels - Kernels: 4.19 - 5.11 (Realtek) - Kernels: 5.12 - 6.5 (community support) +Note: Kernels earlier than 4.19 may work but are not tested or +supported. + ### Tested Compilers -- gcc 10, 11 and 12 +- gcc 10, 11, 12 and 13 ### Tested Linux Distributions -Note: The information in this section depends largely on user reports which can -be provided via PR or message in Issues. +Note: The information in this section depends largely on user reports +which can be provided via PR or message in Issues. - [Arch Linux](https://www.archlinux.org) (kernels 5.4 and 5.11) @@ -79,19 +85,19 @@ be provided via PR or message in Issues. - [Fedora](https://getfedora.org) Fedora 38 (6.2.13-300) -- [Kali Linux](https://www.kali.org/) (kernel 5.10) +- [Kali Linux](https://www.kali.org/) (kernel 6.3) -- [Manjaro](https://manjaro.org) (kernel 5.13) +- [Manjaro](https://manjaro.org) (kernel 5.15) - [openSUSE](https://www.opensuse.org/) Tumbleweed (rolling) (kernel 5.15) -- [Raspberry Pi OS](https://www.raspberrypi.org) (2023-02-21) (ARM 32 bit and 64 bit) (kernel 5.15) +- [Raspberry Pi OS](https://www.raspberrypi.org) (2023-05-03)(ARM 32 bit and 64 bit) (kernel 6.1.38) - [Raspberry Pi Desktop](https://www.raspberrypi.org) (2022-07-01) (x86 32 bit) (kernel 5.10) - [SkiffOS](https://github.com/skiffos/skiffos/) for Odroid XU4 (ARM 32 bit) (kernel 6.0.7) -- [Ubuntu](https://www.ubuntu.com) 22.04 (kernel 5.15), 22.10 (kernel 5.19), 23.04 (kernel 6.2) +- [Ubuntu](https://www.ubuntu.com) 22.04 (kernel 5.15) and 22.10 (kernel 5.19) (kernel 6.2) - [Void Linux](https://voidlinux.org/) (kernel 5.18) @@ -112,6 +118,14 @@ support knowledgable Android developers if they want to merge and keep current the required support (most likely just instructions about how to compile and maybe a modification or two to the Makefile). +Current Android maintainer: none + +Note: OpenWRT is not supported. OpenWRT provides drivers for USB WiFi +adapters. OpenWRT provided drivers include support for the MT7921au +(AXE3000), MT7612u (AC1200), MT7610u (AC600) chipsets. It is a challenge +to use Realtek based adapters that use out-of-kernel drivers with +OpenWRT so it is strongly advised to use the already supported chipsets. + ### Compatible Devices * [ALFA AWUS036ACU](https://store.rokland.com/collections/wi-fi-usb-adapters/products/alfa-awus036acu-802-11ac-ac1200-dual-band-wifi-usb-dongle-rp-sma-antennas) @@ -131,56 +145,69 @@ compile and maybe a modification or two to the Makefile). - Numerous additional adapters that are based on the supported chipsets Note: If you are looking for information about what adapter to buy, -click [here](https://github.com/morrownr/USB-WiFi) and look for Main Menu -item 2 which will show information about and links to recommended adapters. +click [here](https://github.com/morrownr/USB-WiFi) and look for Main +Menu item 2 which will show information about and links to recommended +adapters. -Note: If you decide to buy an adapter that is supported by this driver, I -recommend you search for an adapter that is `single-state and single-function`. -Multi-function adapters, wifi and bluetooth, can be problematic. The rtl8822bu -chipset is multi-fuction. The rtl8812bu chipset is single-function. For advice -about single-state and multi-state adapters. click -[here](https://github.com/morrownr/USB-WiFi) and look for Main Menu item 1. +Note: If you decide to buy an adapter that is supported by this driver, +I recommend you search for an adapter that is `single-state and +single-function`. Multi-function adapters, wifi and bluetooth, can be +problematic. The rtl8852bu chipset is multi-fuction. The rtl8832bu +chipset is single-function. For advice about single-state and +multi-state adapters. click [here](https://github.com/morrownr/USB-WiFi) +and look for Main Menu item 1. ### Installation Information -Note: As of Linux kernel 6.2, an in-kernel driver for the chipsets supported by -this driver has been included in the Linux kernel. The installation and removal -scripts for the driver in this repo automatically deactivate the in-kernel -driver on installation and reactivate the in-kernel driver on removal. No -special action needs to be taken by users. +Warning: It is recommended that you follow the installation instructions +in the Installation Steps section. Avoid installation by downloading the +zip file if at all possible. Support can only be provided, on a best +effort basis, if the Installation Steps in the next section are followed. Warning: Installing multiple out-of-kernel drivers for the same hardware -usually does not end well. The install-driver.sh script has the capability -to detect and remove many conflicting drivers but not all. If this driver -does not work well after installation and you have previously installed a -driver that you did not remove, it is suggested that you run the following -command in an effort to determine if you need to take action to manually -remove conflicting drivers: +usually does not end well. The install-driver.sh script has the +capability to detect and remove most conflicting drivers but not all. If +this driver does not work well after installation and you have +previously installed a driver that you did not remove, it is suggested +that you run the following command in an effort to determine if you need +to take action to manually remove conflicting drivers: ``` sudo dkms status ``` -Warning: If you decide to do a distro upgrade, which will likely install a -new version of kernel such as 5.15 to 6.1, you need to upgrade this driver -with the newest available code before performing the disto upgrade. Use -the following commands in the driver directory: +Warning: If you decide to do a distro upgrade, which will likely install +a new version of kernel such as 5.15 to 6.1, you need to update this +driver with the newest available code and then run the removal script +before performing the disto upgrade. Use the following commands in the +driver directory: ``` git pull ``` +Note: Do not reboot before running the below command so that the driver +stays active until after your distro upgrade is complete. + ``` -sudo ./install-driver.sh +sudo sh remove-driver.sh ``` -Temporary internet access is required for installation. There are numerous ways -to enable temporary internet access depending on your hardware and situation. -[One method is to use tethering from a phone.](https://www.makeuseof.com/tag/how-to-tether-your-smartphone-in-linux). +Note: The following command will reinstall the updated driver after you +are finished with the distro upgrade and reboot. + +``` +sudo sh install-driver.sh +``` + +Internet access is required for initial installation. There are +numerous ways to enable temporary internet access depending on your +hardware and situation. [One method is to use tethering from a phone.](https://www.makeuseof.com/tag/how-to-tether-your-smartphone-in-linux). Another method is to keep a [WiFi adapter that uses an in-kernel driver](https://github.com/morrownr/USB-WiFi/blob/main/home/USB_WiFi_Adapters_that_are_supported_with_Linux_in-kernel_drivers.md) in your toolkit. -You will need to use the terminal interface. The quick way to open a terminal: -Ctrl+Alt+T (hold down on the Ctrl and Alt keys then press the T key). +You will need to use the terminal interface. The quick way to open a +terminal: Ctrl+Alt+T (hold down on the Ctrl and Alt keys then press the +T key). An alternative terminal is to use SSH (Secure Shell) from the same or from another computer, in which case you will be in a suitable terminal after logging @@ -204,19 +231,22 @@ Secure Boot: see FAQ. ### Installation Steps -Note: The installation instructions are for the novice user. Experienced users are -welcome to alter the installation to meet their needs. Support will be provided, -on a best effort basis, based on the steps below. +Note: The installation instructions are for the novice user. Experienced +users are welcome to alter the installation to meet their needs. Support +will be provided, on a best effort basis, based on the steps below. Another +way to word this paragraph is that if you do not follow the below steps for +installation, you are your own tech support. #### Step 1: Open a terminal (e.g. Ctrl+Alt+T) #### Step 2: Update and upgrade system packages (select the option for the distro you are using) Note: If your Linux distro does not fall into one of options listed -below, you will need to research how to `update` and `upgrade` your system -packages. +below, you will need to research how to `update` and `upgrade` your +system packages. -- Option for Debian based distributions such as Ubuntu, Kali, Armbian and Raspberry Pi OS +- Option for Debian based distributions such as Ubuntu, Kali, Armbian +and Raspberry Pi OS ``` sudo apt update && sudo apt upgrade @@ -296,7 +326,8 @@ sudo apt install -y build-essential dkms git iw - Option for Fedora -Note: Fedora users should also install `openssl` if secure boot is active. +Note: Fedora users should also install `openssl` if secure boot is +active. ``` sudo dnf -y install git dkms kernel-devel @@ -369,10 +400,44 @@ cd ~/src/88x2bu-20210702 #### Step 8: Run the installation script (`install-driver.sh`) -Note: It is recommended that you terminate running apps so as to provide the -maximum amount of RAM to the compilation process. +Important: The compilation may fail if the major version of gcc that is +in use is not the same as the major version of the gcc that was used to +compile the kernel that is in use: -Note: For automated builds (non-interactive), use `NoPrompt` as an option. +Example of bad situation: + +gcc 12.1 (used to compile the kernel) +gcc 10.3 (version of gcc in use) + +Example of good situation: + +gcc 12.2 (used to compile the kernel) +gcc 12.1 (version of gcc in use) + +To determine the values: + +``` +cat /proc/version +``` + +``` +gcc --version +``` + +If you find your system in a bad situation, it is recommended that you +install a version of gcc that matches the major version of gcc that was +used to compile your kernel. Here is an example for Ubuntu: + +``` +sudo apt install gcc-12 +``` + +Note: If your system is a low memory system, it is recommended that you +terminate running apps so as to provide the maximum amount of RAM to the +compilation process. + +Note: For automated builds (non-interactive), use `NoPrompt` as an +option. ``` sudo ./install-driver.sh @@ -397,16 +462,16 @@ sudo mokutil --import /var/lib/dkms/mok.pub ### Manual Installation Instructions -Note: The above installation steps automate the installation process, -however, if you want to or need to do a basic command line installation, -use the following: +Note: The installation script, install-driver.sh, automates the +installation process, however, if you want to or need to do a basic +command line installation, use the following: ``` make clean ``` ``` -make +make -j$(nproc) ``` If secure boot is off: @@ -428,8 +493,8 @@ enter commands. sudo make sign-install ``` -You will be promted for a password, please remember the password as it -will be used in some of the following steps. +Note: You will be promted for a password, please remember the password +as it will be used in some of the following steps. ``` sudo reboot @@ -437,7 +502,7 @@ sudo reboot The MOK managerment screen will appear during boot: -`Shim UEFI Key Management" +`Shim UEFI Key Management` `Press any key...` @@ -449,18 +514,28 @@ Select "Yes" When promted, enter the password you entered earlier. -If you enter the wrong password, your computer will not be bootable. In -this case, use the BOOT menu from your BIOS to boot then as follows: +Warning: If you enter the wrong password, your computer will not be +bootable. In this case, use the BOOT menu from your BIOS to boot then as +follows: ``` sudo mokutil --reset ``` -Restart your computer and use the BOOT menu from BIOS to boot. In the MOK -managerment screen, select `reset MOK list`. Then Reboot and retry from -the step `sudo make sign-install`. +Restart your computer. Use the BOOT menu from BIOS to boot. In the MOK +managerment screen, select `reset MOK list`, then reboot and retry from +the above step `sudo make sign-install`. -To remove the driver if installed by the manual installation instructions: +Note: If you use the Manual Installation Instructions, you will need to +repeat the installation process each time a new kernel is installed in +your distro. + +----- + +### Manual Removal Instructions + +To remove the driver if installed by the Manual Installation +Instructions: ``` sudo make uninstall @@ -478,14 +553,17 @@ installed in your distro. ### Driver Options (`edit-options.sh`) +Note: In Linux, driver options are called module parameters. + A file called `88x2bu.conf` will be installed in `/etc/modprobe.d` by -default if you use the `install-driver.sh` script. +default if you use the installation script, `install-driver.sh`. If you +are following the Manual Installation Instructions, you can use the +`edit-options.sh` script to install and/or edit the file. -Note: The installation script will prompt you to edit the options. +Note: The installation script, `install-driver.sh`. will prompt you to +edit the options. -Location: `/etc/modprobe.d/88x2bu.conf` - -This file will be read and applied to the driver on each system boot. +`88x2bu.conf` will be read and applied to the driver on each system boot. To edit the driver options file, run the `edit-options.sh` script @@ -493,18 +571,21 @@ To edit the driver options file, run the `edit-options.sh` script sudo ./edit-options.sh ``` -Note: Documentation for Driver Options is included in the file `88x2bu.conf`. +Note: Documentation for Driver Options is included in the file + `88x2bu.conf`. ----- ### Upgrading the Driver -Note: Linux development is continuous therefore work on this driver is continuous. +Note: Linux development is continuous therefore work on this driver is +continuous. Note: Upgrading the driver is advised in the following situations: - if a new or updated version of the driver needs to be installed -- if a distro version upgrade is going to be installed (i.e. going from kernel 5.10 to kernel 5.15) +- if a distro version upgrade is going to be installed (i.e. going from +kernel 5.10 to kernel 5.15) #### Step 1: Move to the driver directory @@ -552,7 +633,8 @@ cd ~/src/88x2bu-20210702 #### Step 3: Run the removal script -Note: For automated builds (non-interactive), use `NoPrompt` as an option. +Note: For automated builds (non-interactive), use `NoPrompt` as an +option. ``` sudo ./remove-driver.sh @@ -562,23 +644,44 @@ sudo ./remove-driver.sh ### Recommended WiFi Router/ Access Point Settings -Note: These are general recommendations, some of which may not apply to your specific situation. +Note: These are general recommendations, some of which may not apply to +your specific situation. -- Security: Set WPA2-AES or WPA2/WPA3 mixed or WPA3. Do not set WPA2 mixed mode or WPA or TKIP. +- Security: Set WPA2-AES or WPA2/WPA3 mixed or WPA3. Do not set WPA2 +mixed mode or WPA or TKIP. -- Channel width for 2.4 GHz: Set 20 MHz fixed width. Do not use 40 MHz or 20/40 automatic. +- Channel width for 2.4 GHz: Set 20 MHz fixed width. Do not use 40 MHz +or 20/40 automatic. -- Channels for 2.4 GHz: Set channel 1 or 6 or 11 depending on the congestion at your location. Do not set automatic channel selection. As time passes, if you notice poor performance, recheck congestion and set channel appropriately. The environment around you can and does change over time. +- Channels for 2.4 GHz: Set channel 1 or 6 or 11 depending on the +congestion at your location. Do not set automatic channel selection. As +time passes, if you notice poor performance, recheck congestion and set +channel appropriately. The environment around you can and does change +over time. -- Mode for 2.4 GHz: For best performance, set "N only" if you no longer use B or G capable devices. +- Mode for 2.4 GHz: For best performance, set "N only" if you no longer +use B or G capable devices. -- Network names: Do not set the 2.4 GHz Network and the 5 GHz Network to the same name. Note: Unfortunately many routers come with both networks set to the same name. You need to be able to control which network that is in use so changing the name of one of the networks is recommended. Since many IoT devices use the 2.4 GHz network, it may be better to change the name of the 5 GHz network. +- Network names: Do not set the 2.4 GHz Network and the 5 GHz Network +to the same name. Note: Unfortunately many routers come with both +networks set to the same name. You need to be able to control which +network that is in use so changing the name of one of the networks is +recommended. Since many IoT devices use the 2.4 GHz network, it may be +better to change the name of the 5 GHz network. -- Channels for 5 GHz: Not all devices are capable of using DFS channels (I'm looking at you Roku.) It may be necessary to set a fixed channel in the range of 36 to 48 or 149 to 165 in order for all of your devices to work on 5 GHz. (For US, other countries may vary.) +- Channels for 5 GHz: Not all devices are capable of using DFS channels +(I'm looking at you Roku.) It may be necessary to set a fixed channel in +the range of 36 to 48 or 149 to 165 in order for all of your devices to +work on 5 GHz. (For US, other countries may vary.) -- Best location for the WiFi router/access point: Near center of apartment or house, at least a couple of feet away from walls, in an elevated location. You may have to test to see what the best location is in your environment. +- Best location for the WiFi router/access point: Near center of +apartment or house, at least a couple of feet away from walls, in an +elevated location. You may have to test to see what the best location is +in your environment. -- Check congestion: There are apps available for smart phones that allow you to get an idea of the congestion levels on WiFi channels. The apps generally go by the name of `WiFi Analyzer` or something similar. +- Check congestion: There are apps available for smart phones that allow +you to get an idea of the congestion levels on WiFi channels. The apps +generally go by the name of `WiFi Analyzer` or something similar. After making and saving changes, reboot the router. @@ -586,19 +689,33 @@ After making and saving changes, reboot the router. ### Recommendations regarding USB -- Moving your USB WiFi adapter to a different USB port has been known to fix a variety of problems. +- Moving your USB WiFi adapter to a different USB port has been known to +fix a variety of problems. -- If connecting your USB WiFi adapter to a desktop computer, use the USB ports on the rear of the computer. Why? The ports on the rear are directly connected to the motherboard which will reduce problems with interference and disconnection. +- If connecting your USB WiFi adapter to a desktop computer, use the USB +ports on the rear of the computer. Why? The ports on the rear are +directly connected to the motherboard which will reduce problems with +interference and disconnection. -- If your USB WiFi adapter is USB 3 capable and you want it to operate in USB3 mode, plug it into a USB 3 port. +- If your USB WiFi adapter is USB 3 capable and you want it to operate +in USB3 mode, plug it into a USB 3 port. -- Avoid USB 3.1 Gen 2 ports if possible as almost all currently available adapters have been tested with USB 3.1 Gen 1 (aka USB 3) and not with USB 3.1 Gen 2. +- Avoid USB 3.1 Gen 2 ports if possible as almost all currently +available adapters have been tested with USB 3.1 Gen 1 (aka USB 3) and +not with USB 3.1 Gen 2. -- If you use an extension cable and your adapter is USB 3 capable, the cable needs to be USB 3 capable (if not, you will be limited to USB 2 speeds). +- If you use an extension cable and your adapter is USB 3 capable, the +cable needs to be USB 3 capable (if not, you will be limited to USB 2 +speeds). -- Extention cables can be problematic. A way to check if the extension cable is the problem is to plug the adapter temporarily into a USB port on the computer. +- Extention cables can be problematic. A way to check if the extension +cable is the problem is to plug the adapter temporarily into a USB port +on the computer. -- Some USB WiFi adapters require considerable electrical current and push the capabilities of the power available via USB port. One example is adapters that use the Realtek 8814au chipset. Using a powered multiport USB extension can be a good idea in cases like this. +- Some USB WiFi adapters require considerable electrical current and +push the capabilities of the power available via USB port. One example +is adapters that use the Realtek 8814au chipset. Using a powered +multiport USB extension can be a good idea in cases like this. ----- diff --git a/dkms-make.sh b/dkms-make.sh index cecac5c..09e73f7 100755 --- a/dkms-make.sh +++ b/dkms-make.sh @@ -9,10 +9,7 @@ SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }') # sproc needs to be set here if dkms build is not initiated by install-driver.sh sproc=$(nproc) -# calculate number of cores to be used in order to avoid Out of Memory -# condition in low-RAM systems by limiting core usage. -# this section of code is also in the file install-driver.sh and that -# code should stay the same as this code. +# avoid Out of Memory condition in low-RAM systems by limiting core usage if [ "$sproc" -gt 1 ]; then if [ "$SMEM" -lt 1400000 ]; then sproc=2 diff --git a/docs/dkms/Ubuntu Manpage_ dkms.pdf b/docs/dkms/Ubuntu Manpage_ dkms.pdf new file mode 100644 index 0000000..2734897 Binary files /dev/null and b/docs/dkms/Ubuntu Manpage_ dkms.pdf differ diff --git a/edit-options.sh b/edit-options.sh index e7acd6b..12a6e37 100755 --- a/edit-options.sh +++ b/edit-options.sh @@ -24,7 +24,7 @@ # GNU General Public License for more details. SCRIPT_NAME="edit-options.sh" -# SCRIPT_VERSION="20230126" +# SCRIPT_VERSION="20230710" OPTIONS_FILE="88x2bu.conf" # check to ensure sudo was used to start the script diff --git a/install-driver.sh b/install-driver.sh index 8d33010..3cc51b9 100755 --- a/install-driver.sh +++ b/install-driver.sh @@ -28,19 +28,33 @@ # GNU General Public License for more details. SCRIPT_NAME="install-driver.sh" -SCRIPT_VERSION="20230628" -MODULE_NAME="88x2bu" +SCRIPT_VERSION="20230830" + +DRV_NAME="rtl88x2bu" DRV_VERSION="5.13.1" +MODULE_NAME="88x2bu" -KARCH="$(uname -m)" -KVER="$(uname -r)" -MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/" +#KARCH="$(uname -m)" +if [ -z "${KARCH+1}" ]; then + KARCH="$(uname -m)" +fi + +#KVER="$(uname -r)" +if [ -z "${KVER+1}" ]; then + KVER="$(uname -r)" +fi + +#GARCH="$(uname -m | sed -e "s/i.86/i386/; s/ppc/powerpc/; s/armv.l/arm/; s/aarch64/arm64/; s/riscv.*/riscv/;")" +if [ -z "${GARCH+1}" ]; then + GARCH="$(uname -m | sed -e "s/i.86/i386/; s/ppc/powerpc/; s/armv.l/arm/; s/aarch64/arm64/; s/riscv.*/riscv/;")" +fi -DRV_NAME="rtl${MODULE_NAME}" DRV_DIR="$(pwd)" + +MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/" OPTIONS_FILE="${MODULE_NAME}.conf" -# check to ensure sudo was used to start the script +# check to ensure sudo or su - was used to start the script if [ "$(id -u)" -ne 0 ]; then echo "You must run this script with superuser (root) privileges." echo "Try: \"sudo ./${SCRIPT_NAME}\"" @@ -65,11 +79,6 @@ do shift done -# ensure /usr/sbin is in the PATH so iw can be found -if ! echo "$PATH" | grep -qw sbin; then - export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -fi - # check to ensure gcc is installed if ! command -v gcc >/dev/null 2>&1; then echo "A required package is not installed." @@ -102,21 +111,26 @@ if [ ! -d "/lib/modules/$(uname -r)/build" ]; then exit 1 fi +# ensure /usr/sbin is in the PATH so iw can be found +#if ! echo "$PATH" | grep -qw sbin; then +# export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +#fi + # check to ensure iw is installed -if ! command -v iw >/dev/null 2>&1; then - echo "A required package is not installed." - echo "Please install the following package: iw" - echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\"" - exit 1 -fi +#if ! command -v iw >/dev/null 2>&1; then +# echo "A required package is not installed." +# echo "Please install the following package: iw" +# echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\"" +# exit 1 +#fi # check to ensure rfkill is installed -if ! command -v rfkill >/dev/null 2>&1; then - echo "A required package is not installed." - echo "Please install the following package: rfkill" - echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\"" - exit 1 -fi +#if ! command -v rfkill >/dev/null 2>&1; then +# echo "A required package is not installed." +# echo "Please install the following package: rfkill" +# echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\"" +# exit 1 +#fi DEFAULT_EDITOR="$(cat default-editor.txt)" # try to find the user's default text editor through the EDITORS_SEARCH array @@ -138,13 +152,12 @@ echo ": ${SCRIPT_NAME} v${SCRIPT_VERSION}" # information that helps with bug reports -# display architecture -echo ": ${KARCH} (architecture)" +# display kernel architecture +echo ": ${KARCH} (kernel architecture)" + +# display architecture to send to gcc +echo ": ${GARCH} (architecture to send to gcc)" -# calculate number of cores to be used in order to avoid Out of Memory -# condition in low-RAM systems by limiting core usage. -# this section of code is also in the file dkms-make.sh and that -# code should stay the same as this code. SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }') sproc=$(nproc) # avoid Out of Memory condition in low-RAM systems by limiting core usage @@ -168,6 +181,10 @@ echo ": ${SMEM} (total system memory)" # display kernel version echo ": ${KVER} (kernel version)" +# display version of gcc used to compile the kernel +gcc_ver_used_to_compile_the_kernel=$(cat /proc/version | sed 's/^.*gcc/gcc/' | sed 's/\s.*$//') +echo ": ""${gcc_ver_used_to_compile_the_kernel} (version of gcc used to compile the kernel)" + # display gcc version gcc_ver=$(gcc --version | grep -i gcc) echo ": ""${gcc_ver}" @@ -192,17 +209,29 @@ if command -v mokutil >/dev/null 2>&1; then else echo ": mokutil not installed" fi +# need to fix the following +#: --------------------------- +#: install-driver.sh v20230718 +#: x86_64 (system architecture) +#: x86_64 (gcc architecture) +#: 4/4 (in-use/total processing units) +#: 16283584 (total system memory) +#: 5.19.0-50-generic (kernel version) +#: gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 +#: dkms-2.8.7 +#This system doesn't support Secure Boot +#This system doesn't support Secure Boot +#This system doesn't support Secure Boot +#: --------------------------- echo ": ---------------------------" echo -echo "Checking for previously installed drivers." +echo "Checking for previously installed drivers..." # check for and remove non-dkms installations # standard naming if [ -f "${MODDESTDIR}${MODULE_NAME}.ko" ]; then - echo ": ---------------------------" - echo echo "Removing a non-dkms installation: ${MODDESTDIR}${MODULE_NAME}.ko" rm -f "${MODDESTDIR}"${MODULE_NAME}.ko /sbin/depmod -a "${KVER}" @@ -217,8 +246,6 @@ fi # check for and remove non-dkms installations # with rtl added to module name (PClinuxOS) if [ -f "${MODDESTDIR}rtl${MODULE_NAME}.ko" ]; then - echo ": ---------------------------" - echo echo "Removing a non-dkms installation: ${MODDESTDIR}rtl${MODULE_NAME}.ko" rm -f "${MODDESTDIR}"rtl${MODULE_NAME}.ko /sbin/depmod -a "${KVER}" @@ -235,8 +262,6 @@ fi # Example: /usr/lib/modules/5.15.80-rockchip64/kernel/drivers/net/wireless/rtl8821cu/8821cu.ko.xz # Dear Armbiam, this is a really bad idea. if [ -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz" ]; then - echo ": ---------------------------" - echo echo "Removing a non-dkms installation: /usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz" rm -f /usr/lib/modules/"${KVER}"/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz /sbin/depmod -a "${KVER}" @@ -248,24 +273,40 @@ if [ -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODU echo "Removal complete." fi -# check for and remove dkms installations +# check for and remove all dkms installations with DRV_NAME +# +# dkms status [module/module-version] [-k kernel/arch] +# +# $ dkms status +# +# nvidia/535.86.05, 6.2.0-27-generic, x86_64: installed +# nvidia/535.86.05, 6.5.0-060500rc5-generic, x86_64: installed +# rtl8852bu/1.19.3, 6.2.0-27-generic, x86_64: installed +# rtl8852bu/1.19.3, 6.5.0-060500rc5-generic, x86_64: installed +# rtl8852bu/1.15.2, 6.5.0-060500rc5-generic, x86_64: installed +# +# dkms remove [module/module-version] [-k kernel/arch] [--all] +# +# $ dkms remove "${modname}/${modver}" -c "/usr/src/${modname}-${modver}/dkms.conf" --all +# if command -v dkms >/dev/null 2>&1; then - if dkms status | grep -i ${DRV_NAME}; then - echo ": ---------------------------" - echo -# need to add code here to delete any DRV_VERSION - echo "Removing a dkms installation." - dkms remove -m ${DRV_NAME} -v ${DRV_VERSION} --all - echo "Removing ${OPTIONS_FILE} from /etc/modprobe.d" + dkms status | while IFS="/, " read -r modname modver kerver _dummy; do + case "$modname" in *${MODULE_NAME}) + echo "--> ${modname} ${modver} ${kerver}" + dkms remove -m "${modname}" -v "${modver}" -k "${kerver}" -c "/usr/src/${modname}-${modver}/dkms.conf" + esac + done + if [ -f /etc/modprobe.d/${OPTIONS_FILE} ]; then rm -f /etc/modprobe.d/${OPTIONS_FILE} - echo "Removing source files from /usr/src/${DRV_NAME}-${DRV_VERSION}" + fi + if [ -f /usr/src/${DRV_NAME}-${DRV_VERSION} ]; then rm -rf /usr/src/${DRV_NAME}-${DRV_VERSION} - echo "Removal complete." fi fi -# sets module parameters (driver options) and blacklisted modules +echo "Finished checking for and removing previously installed drivers." echo ": ---------------------------" + echo echo "Starting installation." echo "Installing ${OPTIONS_FILE} to /etc/modprobe.d" @@ -323,8 +364,10 @@ else # the dkms add command requires source in /usr/src/${DRV_NAME}-${DRV_VERSION} echo "Copying source files to /usr/src/${DRV_NAME}-${DRV_VERSION}" cp -rf "${DRV_DIR}" /usr/src/${DRV_NAME}-${DRV_VERSION} +# echo "${DRV_DIR}" +# echo "/usr/src/${DRV_NAME}-${DRV_VERSION}" - dkms add -m ${DRV_NAME} -v ${DRV_VERSION} + dkms add -m ${DRV_NAME} -v ${DRV_VERSION} -k "${KVER}/${KARCH}" -c "/usr/src/${DRV_NAME}-${DRV_VERSION}/dkms.conf" RESULT=$? # RESULT will be 3 if the DKMS tree already contains the same module/version @@ -346,12 +389,13 @@ else else echo "The driver was added to dkms successfully." echo ": ---------------------------" + echo fi if command -v /usr/bin/time >/dev/null 2>&1; then - /usr/bin/time -f "Compile time: %U seconds" dkms build -m ${DRV_NAME} -v ${DRV_VERSION} + /usr/bin/time -f "Compile time: %U seconds" dkms build -m ${DRV_NAME} -v ${DRV_VERSION} -k "${KVER}/${KARCH}" -c "/usr/src/${DRV_NAME}-${DRV_VERSION}/dkms.conf" else - dkms build -m ${DRV_NAME} -v ${DRV_VERSION} + dkms build -m ${DRV_NAME} -v ${DRV_VERSION} -k "${KVER}/${KARCH}" -c "/usr/src/${DRV_NAME}-${DRV_VERSION}/dkms.conf" fi RESULT=$? @@ -367,7 +411,7 @@ else echo ": ---------------------------" fi - dkms install -m ${DRV_NAME} -v ${DRV_VERSION} + dkms install -m ${DRV_NAME} -v ${DRV_VERSION} -k "${KVER}/${KARCH}" -c "/usr/src/${DRV_NAME}-${DRV_VERSION}/dkms.conf" RESULT=$? if [ "$RESULT" != "0" ]; then @@ -385,13 +429,18 @@ else fi # provide driver upgrade information -echo "Info: Upgrade this driver with the following commands as needed:" +echo "Info: Update this driver with the following commands as needed:" +echo echo "$ git pull" echo "$ sudo sh install-driver.sh" -echo "Note: Upgrades to this driver should be performed before distro upgrades." -echo "Note: Upgrades can be performed as often as you like." -echo "Note: Work on this driver is continuous." -echo ": ---------------------------" +echo +echo "Note: Updates to this driver SHOULD be performed before distro" +echo " upgrades such as Ubuntu 23.10 to 24.04." +echo "Note: Updates can be performed as often as you like. It is" +echo " recommended to update at least every 2 months." +echo "Note: Work on this driver, like the Linux kernel, is continuous." +echo +echo "Enjoy!" echo # unblock wifi diff --git a/remove-driver.sh b/remove-driver.sh index 275ee7d..50697a5 100755 --- a/remove-driver.sh +++ b/remove-driver.sh @@ -28,18 +28,26 @@ # GNU General Public License for more details. SCRIPT_NAME="remove-driver.sh" -SCRIPT_VERSION="20230226" -MODULE_NAME="88x2bu" +SCRIPT_VERSION="20230830" + +DRV_NAME="rtl88x2bu" DRV_VERSION="5.13.1" +MODULE_NAME="88x2bu" + +#KARCH="$(uname -m)" +if [ -z "${KARCH+1}" ]; then + KARCH="$(uname -m)" +fi + +#KVER="$(uname -r)" +if [ -z "${KVER+1}" ]; then + KVER="$(uname -r)" +fi -KARCH="$(uname -m)" -KVER="$(uname -r)" MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/" - -DRV_NAME="rtl${MODULE_NAME}" OPTIONS_FILE="${MODULE_NAME}.conf" -# check to ensure sudo was used to start the script +# check to ensure sudo or su - was used to start the script if [ "$(id -u)" -ne 0 ]; then echo "You must run this script with superuser (root) privileges." echo "Try: \"sudo ./${SCRIPT_NAME}\"" @@ -49,7 +57,8 @@ fi # support for the NoPrompt option allows non-interactive use of this script NO_PROMPT=0 # get the script options -while [ $# -gt 0 ]; do +while [ $# -gt 0 ] +do case $1 in NoPrompt) NO_PROMPT=1 ;; @@ -70,8 +79,8 @@ echo ": ${SCRIPT_NAME} v${SCRIPT_VERSION}" # information that helps with bug reports -# display architecture -echo ": ${KARCH} (architecture)" +# display kernel architecture +echo ": ${KARCH} (kernel architecture)" # display kernel version echo ": ${KVER} (kernel version)" @@ -105,17 +114,25 @@ if [ -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODU /sbin/depmod -a "${KVER}" fi -# determine if dkms is installed and run the appropriate routines +# check for and remove all dkms installations with DRV_NAME +# +# dkms status [module/module-version] [-k kernel/arch] +# +# $ dkms status +# if command -v dkms >/dev/null 2>&1; then - echo "Removing a dkms installation." - # 2>/dev/null suppresses the output of dkms - dkms remove -m ${DRV_NAME} -v ${DRV_VERSION} --all 2>/dev/null + dkms status | while IFS="/, " read -r modname modver kerver _dummy; do + case "$modname" in *${MODULE_NAME}) + echo "--> ${modname} ${modver} ${kerver}" + dkms remove -m "${modname}" -v "${modver}" -k "${kerver}" -c "/usr/src/${modname}-${modver}/dkms.conf" + esac + done RESULT=$? - #echo "Result=${RESULT}" +# echo "Result=${RESULT}" - # RESULT will be 3 if there are no instances of module to remove - # however we still need to remove various files or the install script - # may complain. +# RESULT will be 3 if there are no instances of module to remove +# however we still need to remove various files or the install script +# may complain. if [ "$RESULT" = "0" ] || [ "$RESULT" = "3" ]; then if [ "$RESULT" = "0" ]; then echo "${DRV_NAME}/${DRV_VERSION} has been removed" diff --git a/save-log.sh b/save-log.sh deleted file mode 100755 index d328796..0000000 --- a/save-log.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -# Purpose: Save a log file with RTW lines only. -# -# To make this file executable: -# -# $ chmod +x save-log.sh -# -# To execute this file: -# -# $ sudo ./save-log.sh -# -# or -# -# $ sudo sh save-log.sh - -SCRIPT_NAME="save-log.sh" - -if [ "$(id -u)" -ne 0 ]; then - echo "You must run this script with superuser (root) privileges." - echo "Try: \"sudo ./${SCRIPT_NAME}\"" - exit 1 -fi - -# deletes existing log -rm -f -- rtw.log - -dmesg | cut -d"]" -f2- | grep -i RTW >> rtw.log -RESULT=$? - -if [ "$RESULT" != "0" ]; then - echo "An error occurred while running: ${SCRIPT_NAME}" - echo "Did you set a log level > 0 ?" - exit 1 -else -# dmesg | cut -d"]" -f2- | grep -i USB >> rtw.log - echo "rtw.log saved successfully." -fi