numerous updates- MU-MIMO works

This commit is contained in:
morrownr 2023-01-27 10:16:08 -06:00
parent d0f2241ec5
commit 9597e68f44
12 changed files with 332 additions and 241 deletions

View File

@ -10,13 +10,13 @@
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_power_mgnt=1 rtw_switch_usb_mode=0
options 88x2bu rtw_drv_log_level=1 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
#
# Note: The above `options` line is a good default for managed mode. Below is
# an example for AP mode. Modify as required after reading the documentation:
#options 88x2bu rtw_drv_log_level=1 rtw_led_ctrl=1 rtw_vht_enable=2 rtw_power_mgnt=1 rtw_beamform_cap=1 rtw_dfs_region_domain=1
#options 88x2bu rtw_drv_log_level=1 rtw_led_ctrl=1 rtw_vht_enable=2 rtw_power_mgnt=1 rtw_beamform_cap=1 rtw_switch_usb_mode=1 rtw_dfs_region_domain=1
#
# After editing is complete, save this file (if using nano: Ctrl + x, y, Enter)
# and reboot to activate the changes.
@ -40,7 +40,7 @@ options 88x2bu rtw_drv_log_level=1 rtw_led_ctrl=1 rtw_vht_enable=1 rtw_power_mgn
#
# sudo ./save-log.sh
#
# Note: The name of the log file will be ```rtw.log```.
# Note: The name of the log file will be `rtw.log`.
#
# -----
#

View File

@ -1,6 +1,7 @@
config RTL8822BU
tristate "Realtek 8822B USB WiFi"
depends on USB
select WIRELESS_EXT
help
Help message of RTL8822BU

View File

@ -1,6 +1,6 @@
/******************************************************************************
*
* Copyright(c) 2007 - 2022 Realtek Corporation.
* Copyright(c) 2007 - 2023 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as

View File

@ -2513,7 +2513,7 @@ install:
/sbin/depmod -a ${KVER}
uninstall:
rm -f $(MODDESTDIR)/$(MODULE_NAME).ko
rm -f $(MODDESTDIR)$(MODULE_NAME).ko
/sbin/depmod -a ${KVER}
backup_rtlwifi:

115
README.md
View File

@ -18,6 +18,10 @@ confirm that this is the correct driver for your adapter.
* Supports WPA/WPA2 TLS client
- Power saving modes
- Miracast
- WiFi-Direct
- MU-MIMO
- Mesh
- Wake on WLAN
- Wireshark compatible
- Aircrack-ng compatible
- Packet injection
@ -44,7 +48,7 @@ confirm that this is the correct driver for your adapter.
- x86, i686
- x86-64, amd64
- armv7l, armv6l (arm)
- armv6l, armv7l (arm)
- aarch64 (arm64)
### Compatible Kernels
@ -54,7 +58,7 @@ confirm that this is the correct driver for your adapter.
### Tested Compilers
- gcc 9, 10, 11 and 12
- gcc 10, 11 and 12
### Tested Linux Distributions
@ -67,7 +71,7 @@ be provided via PR or message in Issues.
- Debian 11 (kernels 5.10 and 5.15)
- Fedora (kernel 5.11) and Fedora 37 (kernel 6.0)
- Fedora 37 (kernel 6.0)
- Kali Linux (kernel 5.10)
@ -122,10 +126,6 @@ a modification or two to the Makefile).
### Compatible Devices
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.
* [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)
* ASUS AC1300 USB-AC55 B1
* ASUS AC53 Nano
@ -141,6 +141,17 @@ item 2 which will show information about and links to recommended adapters.
* TRENDnet TEW-808UBM
* Numerous additional products 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.
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.
### Installation Information
Note: As of Linux kernel 6.2, an in-kernel driver for the chipsets supported by
@ -155,7 +166,7 @@ or if you have previously installed another driver for chipsets supported by
this driver, you MUST remove anything that the previous attempt
installed BEFORE attempting to install this driver. This driver can be
removed with the script called `./remove-driver.sh`. Information is
available in the section called `Removal of the Driver.` You can get a
available in the section called `Removal of the Driver`. You can get a
good idea as to whether you need to remove a previously installed
driver by running the following command:
@ -164,14 +175,20 @@ sudo dkms status
```
Warning: If you decide to upgrade to a new version of kernel such as
5.15 to 5.19, you need to remove the driver you have installed and
install the newest available before installing the new kernel. Use the
5.15 to 5.19, you need to upgrade the driver you have installed with
the newest available before installing the new kernel. Use the
following commands in the driver directory:
```
$ sudo ./remove-driver.sh
$ git pull
$ sudo ./install-driver.sh
sudo ./remove-driver.sh
```
```
git pull
```
```
sudo ./install-driver.sh
```
Temporary internet access is required for installation. There are numerous ways
@ -272,7 +289,7 @@ system to work with. The installation can then be continued with Step 3.
sudo reboot
```
#### Step 3: Install the required packages (select the option for the OS you are using)
#### Step 3: Install the required 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 properly setup up the development
@ -375,14 +392,23 @@ git clone https://github.com/morrownr/88x2bu-20210702.git
cd ~/src/88x2bu-20210702
```
#### Step 8: Run the installation script ( install-driver.sh )
#### Step 8: Run the installation script (`install-driver.sh`)
Note: For automated builds (non-interactive), use _NoPrompt_ as an option.
Note: 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
```
or
```
sudo sh install-driver.sh
```
Note: If you elect to skip the reboot at the end of the installation
script, the driver may not load immediately and the driver options will
not be applied. Rebooting is strongly recommended.
@ -390,28 +416,49 @@ not be applied. Rebooting is strongly recommended.
Note: Fedora users that have secure boot turned on should run the following to
enroll the key:
$ sudo mokutil --import /var/lib/dkms/mok.pub
```
sudo mokutil --import /var/lib/dkms/mok.pub
```
Manual build instructions: The above script automates the installation
process, however, if you want to or need to do a command line
installation, use the following:
Manual build and installation instructions: The above installation steps
automate the installation process, however, if you want to or need to do a
command line installation, use the following:
```
make clean
```
```
make
```
```
sudo make install
```
```
sudo reboot
```
Note: If you use the manual build instructions, you will need to repeat
To remove the driver if installed by the manual installation instructions:
```
sudo make uninstall
```
```
sudo reboot
```
Note: If you use the manual installation instructions, you will need to repeat
the process each time a new kernel is installed in your distro.
-----
### Driver Options ( edit-options.sh )
### Driver Options (`edit-options.sh`)
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 `install-driver.sh` script.
Note: The installation script will prompt you to edit the options.
@ -463,7 +510,7 @@ sudo ./install-driver.sh
```
-----
### Removal of the Driver ( remove-driver.sh )
### Removal of the Driver (`remove-driver.sh`)
Note: Removing the driver is advised in the following situations:
@ -484,7 +531,7 @@ 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
@ -510,7 +557,7 @@ Note: These are general recommendations, some of which may not apply to your spe
- 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.
@ -536,7 +583,7 @@ After making and saving changes, reboot the router.
### How to disable onboard WiFi on Raspberry Pi 3B, 3B+, 3A+, 4B and Zero W
Add the following line to /boot/config.txt
Add the following line to `/boot/config.txt`
```
dtoverlay=disable-wifi
@ -546,21 +593,23 @@ dtoverlay=disable-wifi
### How to forget a saved WiFi network on a Raspberry Pi
#### Step 1: Edit wpa_supplicant.conf
#### Step 1: Edit `wpa_supplicant.conf`
```
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
sudo ${EDITOR} /etc/wpa_supplicant/wpa_supplicant.conf
```
#### Step 2: Delete the relevant WiFi network block (including the 'network=' and opening/closing braces.
Note: Replace ${EDITOR} with the name of the text editor you wish to use.
#### Step 3: Press ctrl-x followed by 'y' and enter to save the file.
#### Step 2: Delete the relevant WiFi network block (including the '`network=`' and opening/closing braces).
#### Step 3: Press ctrl-x followed by '`y`' and enter to save the file.
#### Step 4: Reboot
-----
### FAQ:
### FAQ
Question: Is WPA3 supported?
@ -672,7 +721,7 @@ reports of success or failure are needed. If you have yet to buy an
adapter to use with monitor mode, there are adapters available that are
known to work very well with monitor mode. My recommendation for those
looking to buy an adapter for monitor mode is to buy adapters based on
the following chipsets: mt7921au, mt7612u, mt7610u, rtl8812au and
the following chipsets: mt7921au, mt7612u, mt7610u, rtl8812au, rtl8821cu and
rtl8811au. My specific recommendations for adapters in order of
preference are:

1
default-editor.txt Normal file
View File

@ -0,0 +1 @@
nano

17
dkms-make.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh
# SMEM needs to be set here if dkms build is not initiated by install-driver.sh
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)
# 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
fi
fi
kernelver=${kernelver:-$(uname -r)}
make "-j$sproc" "KVER=$kernelver" "KSRC=/lib/modules/$kernelver/build"

View File

@ -1,7 +1,7 @@
PACKAGE_NAME="rtl88x2bu"
PACKAGE_VERSION="5.13.1"
MAKE[0]="'make' -j$(nproc) KVER=${kernelver} KSRC=/lib/modules/${kernelver}/build"
CLEAN="'make' clean"
BUILT_MODULE_NAME[0]="88x2bu"
DEST_MODULE_LOCATION[0]="/kernel/drivers/net/wireless"
AUTOINSTALL="yes"
MAKE="./dkms-make.sh"
CLEAN="'make' clean"
DEST_MODULE_LOCATION[0]="/updates/dkms"
AUTOINSTALL="YES"

View File

@ -1,10 +1,9 @@
#!/bin/bash
#
OPTIONS_FILE="88x2bu.conf"
SCRIPT_NAME="edit-options.sh"
#
#!/bin/sh
# Purpose: Make it easier to edit the driver options file.
#
# Flexible editor support.
#
# To make this file executable:
#
# $ chmod +x edit-options.sh
@ -13,20 +12,45 @@ SCRIPT_NAME="edit-options.sh"
#
# $ sudo ./edit-options.sh
#
if [[ $EUID -ne 0 ]]
then
# Copyright(c) 2023 Nick Morrow
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
SCRIPT_NAME="edit-options.sh"
# SCRIPT_VERSION="20230126"
OPTIONS_FILE="88x2bu.conf"
# check to ensure sudo 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}\""
exit 1
fi
nano /etc/modprobe.d/${OPTIONS_FILE}
read -p "Do you want to apply the new options by rebooting now? [y/N] " -n 1 -r
echo # move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
reboot
DEFAULT_EDITOR="$(cat default-editor.txt)"
# try to find the user's default text editor through the EDITORS_SEARCH array
for TEXT_EDITOR in "${VISUAL}" "${EDITOR}" "${DEFAULT_EDITOR}" vi; do
command -v "${TEXT_EDITOR}" >/dev/null 2>&1 && break
done
# failure message if no editor was found
if ! command -v "${TEXT_EDITOR}" >/dev/null 2>&1; then
echo "No text editor was found (default: ${DEFAULT_EDITOR})."
echo "Please install ${DEFAULT_EDITOR} or edit the file 'default-editor.txt' to specify your editor."
echo "Once complete, please run \"sudo ./${SCRIPT_NAME}\""
exit 1
fi
exit 0
${TEXT_EDITOR} /etc/modprobe.d/${OPTIONS_FILE}
printf "Do you want to apply the new options by rebooting now? (recommended) [y/N] "
read -r REPLY
case "$REPLY" in
[yY]*) reboot ;;
esac

View File

@ -1,9 +1,17 @@
#!/bin/bash
#!/bin/sh
# Purpose: Install Realtek out-of-kernel USB WiFi adapter drivers.
#
# Supports dkms and non-dkms installations.
#
# To make this file executable:
#
# $ chmod +x edit-options.sh
#
# To execute this file:
#
# $ sudo ./edit-options.sh
#
# Copyright(c) 2023 Nick Morrow
#
# This program is free software; you can redistribute it and/or modify
@ -16,88 +24,27 @@
# GNU General Public License for more details.
SCRIPT_NAME="install-driver.sh"
SCRIPT_VERSION="20230109"
SCRIPT_VERSION="20230126"
MODULE_NAME="88x2bu"
DRV_VERSION="5.13.1"
KVER="$(uname -r)"
KARCH="$(uname -m)"
#KSRC="/lib/modules/${KVER}/build"
MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/"
DRV_NAME="rtl${MODULE_NAME}"
DRV_DIR="$(pwd)"
OPTIONS_FILE="${MODULE_NAME}.conf"
# check to ensure sudo was used
if [[ $EUID -ne 0 ]]
then
# check to ensure sudo 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}\""
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 gcc is installed
if ! command -v gcc >/dev/null 2>&1
then
echo "A required package is not installed."
echo "Please install the following package: gcc"
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
exit 1
fi
# check to ensure make is installed
if ! command -v make >/dev/null 2>&1
then
echo "A required package is not installed."
echo "Please install the following package: make"
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
exit 1
fi
# check to see if header files are installed
if [ ! -d "/lib/modules/$(uname -r)/build" ]; then
echo "Your kernel header files aren't properly installed."
echo "Please consult your distro documentation."
echo "Once the header files are installed, please run \"sudo ./${SCRIPT_NAME}\""
exit 1
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
# 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
# check to ensure nano is installed
if ! command -v nano >/dev/null 2>&1
then
echo "A required package is not installed."
echo "Please install the following package: nano"
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
exit 1
fi
# support for the NoPrompt option allows non-interactive use of this script
NO_PROMPT=0
# get the script options
while [ $# -gt 0 ]
do
@ -114,41 +61,113 @@ 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."
echo "Please install the following package: gcc"
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
exit 1
fi
# check to ensure make is installed
if ! command -v make >/dev/null 2>&1; then
echo "A required package is not installed."
echo "Please install the following package: make"
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
exit 1
fi
# check to see if the correct header files are installed
if [ ! -d "/lib/modules/$(uname -r)/build" ]; then
echo "Your kernel header files aren't properly installed."
echo "Please consult your distro documentation or user support forums."
echo "Once the header files are properly installed, please run \"sudo ./${SCRIPT_NAME}\""
exit 1
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
# 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
DEFAULT_EDITOR="$(cat default-editor.txt)"
# try to find the user's default text editor through the EDITORS_SEARCH array
for TEXT_EDITOR in "${VISUAL}" "${EDITOR}" "${DEFAULT_EDITOR}" vi; do
command -v "${TEXT_EDITOR}" >/dev/null 2>&1 && break
done
# fail if no editor was found
if ! command -v "${TEXT_EDITOR}" >/dev/null 2>&1; then
echo "No text editor found (default: ${DEFAULT_EDITOR})."
echo "Please install ${DEFAULT_EDITOR} or edit the file 'default-editor.txt' to specify your editor."
echo "Once complete, please run \"sudo ./${SCRIPT_NAME}\""
exit 1
fi
echo ": ---------------------------"
# displays script name and version
echo ": ${SCRIPT_NAME} v${SCRIPT_VERSION}"
# information that helps with bug reports
# display architecture
echo ": ${KARCH}"
echo ": ${KARCH} (architecture)"
# display total memory in system
#grep MemTotal /proc/meminfo
SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }')
sproc=$(nproc)
# 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
fi
fi
# display number of in-use processing units / total processing units
echo ": ${sproc}/$(nproc) (in-use/total processing units)"
# display total system memory
echo ": ${SMEM} (total system memory)"
# display kernel version
echo ": ${KVER}"
echo ": ${KVER} (kernel version)"
# display gcc version
gcc_ver=$(gcc --version | grep -i gcc)
echo ": "${gcc_ver}
echo ": ""${gcc_ver}"
# display dkms version if installed
if command -v dkms >/dev/null 2>&1
then
if command -v dkms >/dev/null 2>&1; then
dkms_ver=$(dkms --version)
echo ": "${dkms_ver}
echo ": ""${dkms_ver}"
fi
# display secure mode status if mokutil is installed
if command -v mokutil >/dev/null 2>&1
then
if command -v mokutil >/dev/null 2>&1; then
sb_state=$(mokutil --sb-state)
echo ": "${sb_state}
echo ": ""${sb_state}"
fi
# needs work
# display ISO 3166-1 alpha-2 Country Code
#a2_country_code=$(iw reg get | grep -i country)
#echo "Country: "${a2_country_code}
#echo ": Location: ""${a2_country_code}"
#if [[ $a2_country_code == *"00"* ]];
#then
# echo "The Country Code may not be properly set."
@ -156,13 +175,14 @@ fi
# echo "Please read and follow the directions in the file after installation."
#fi
echo ": ---------------------------"
# check for and remove non-dkms installations
# standard naming
if [[ -f "${MODDESTDIR}${MODULE_NAME}.ko" ]]
then
if [ -f "${MODDESTDIR}${MODULE_NAME}.ko" ]; then
echo "Removing a non-dkms installation: ${MODDESTDIR}${MODULE_NAME}.ko"
rm -f ${MODDESTDIR}${MODULE_NAME}.ko
/sbin/depmod -a ${KVER}
rm -f "${MODDESTDIR}"${MODULE_NAME}.ko
/sbin/depmod -a "${KVER}"
echo "Removing ${OPTIONS_FILE} from /etc/modprobe.d"
rm -f /etc/modprobe.d/${OPTIONS_FILE}
echo "Removing source files from /usr/src/${DRV_NAME}-${DRV_VERSION}"
@ -172,11 +192,10 @@ fi
# check for and remove non-dkms installations
# with rtl added to module name (PClinuxOS)
if [[ -f "${MODDESTDIR}rtl${MODULE_NAME}.ko" ]]
then
if [ -f "${MODDESTDIR}rtl${MODULE_NAME}.ko" ]; then
echo "Removing a non-dkms installation: ${MODDESTDIR}rtl${MODULE_NAME}.ko"
rm -f ${MODDESTDIR}rtl${MODULE_NAME}.ko
/sbin/depmod -a ${KVER}
rm -f "${MODDESTDIR}"rtl${MODULE_NAME}.ko
/sbin/depmod -a "${KVER}"
echo "Removing ${OPTIONS_FILE} from /etc/modprobe.d"
rm -f /etc/modprobe.d/${OPTIONS_FILE}
echo "Removing source files from /usr/src/${DRV_NAME}-${DRV_VERSION}"
@ -188,11 +207,10 @@ fi
# with compressed module in a unique non-standard location (Armbian)
# 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
if [ -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz" ]; then
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}
rm -f /usr/lib/modules/"${KVER}"/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz
/sbin/depmod -a "${KVER}"
echo "Removing ${OPTIONS_FILE} from /etc/modprobe.d"
rm -f /etc/modprobe.d/${OPTIONS_FILE}
echo "Removing source files from /usr/src/${DRV_NAME}-${DRV_VERSION}"
@ -201,10 +219,8 @@ then
fi
# check for and remove dkms installations
if command -v dkms >/dev/null 2>&1
then
if dkms status | grep -i ${DRV_NAME}
then
if command -v dkms >/dev/null 2>&1; then
if dkms status | grep -i ${DRV_NAME}; then
echo "Removing a dkms installation: ${DRV_NAME}"
dkms remove -m ${DRV_NAME} -v ${DRV_VERSION} --all
echo "Removing ${OPTIONS_FILE} from /etc/modprobe.d"
@ -219,17 +235,15 @@ echo "Installing ${OPTIONS_FILE} to /etc/modprobe.d"
cp -f ${OPTIONS_FILE} /etc/modprobe.d
# determine if dkms is installed and run the appropriate routines
if ! command -v dkms >/dev/null 2>&1
then
if ! command -v dkms >/dev/null 2>&1; then
echo "The non-dkms installation routines are in use."
make clean >/dev/null 2>&1
make -j$(nproc)
make -j"$(nproc)"
RESULT=$?
if [[ "$RESULT" != "0" ]]
then
if [ "$RESULT" != "0" ]; then
echo "An error occurred: ${RESULT}"
echo "Please report this error."
echo "Please copy all screen output and paste it into the problem report."
@ -245,8 +259,7 @@ then
make install
RESULT=$?
if [[ "$RESULT" = "0" ]]
then
if [ "$RESULT" = "0" ]; then
make clean >/dev/null 2>&1
echo "The driver was installed successfully."
else
@ -269,10 +282,8 @@ else
# RESULT will be 3 if the DKMS tree already contains the same module/version
# combo. You cannot add the same module/version combo more than once.
if [[ "$RESULT" != "0" ]]
then
if [[ "$RESULT" = "3" ]]
then
if [ "$RESULT" != "0" ]; then
if [ "$RESULT" = "3" ]; then
echo "This driver may already be installed."
echo "Run the following and then reattempt installation."
echo "$ sudo ./remove-driver.sh"
@ -289,16 +300,14 @@ else
echo "The driver was added to dkms successfully."
fi
if command -v /usr/bin/time >/dev/null 2>&1
then
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}
else
dkms build -m ${DRV_NAME} -v ${DRV_VERSION}
fi
RESULT=$?
if [[ "$RESULT" != "0" ]]
then
if [ "$RESULT" != "0" ]; then
echo "An error occurred. dkms build error: ${RESULT}"
echo "Please report this error."
echo "Please copy all screen output and paste it into the problem report."
@ -312,8 +321,7 @@ else
dkms install -m ${DRV_NAME} -v ${DRV_VERSION}
RESULT=$?
if [[ "$RESULT" != "0" ]]
then
if [ "$RESULT" != "0" ]; then
echo "An error occurred. dkms install error: ${RESULT}"
echo "Please report this error."
echo "Please copy all screen output and paste it into the problem report."
@ -326,29 +334,23 @@ else
fi
# unblock wifi
if command -v rfkill >/dev/null 2>&1
then
if command -v rfkill >/dev/null 2>&1; then
rfkill unblock wlan
else
echo "Unable to run $ rfkill unblock wlan"
fi
# if NoPrompt is not used, ask user some questions
if [ $NO_PROMPT -ne 1 ]
then
read -p "Do you want to edit the driver options file now? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
nano /etc/modprobe.d/${OPTIONS_FILE}
fi
if [ $NO_PROMPT -ne 1 ]; then
printf "Do you want to edit the driver options file now? [y/N] "
read -r REPLY
case "$REPLY" in
[yY]*) ${TEXT_EDITOR} /etc/modprobe.d/${OPTIONS_FILE} ;;
esac
read -p "Do you want to reboot now? (recommended) [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
reboot
fi
printf "Do you want to apply the new options by rebooting now? (recommended) [y/N] "
read -r REPLY
case "$REPLY" in
[yY]*) reboot ;;
esac
fi
exit 0

View File

@ -1,9 +1,17 @@
#!/bin/bash
#!/bin/sh
# Purpose: Remove Realtek out-of-kernel USB WiFi adapter drivers.
#
# Supports dkms and non-dkms removals.
#
# To make this file executable:
#
# $ chmod +x edit-options.sh
#
# To execute this file:
#
# $ sudo ./edit-options.sh
#
# Copyright(c) 2023 Nick Morrow
#
# This program is free software; you can redistribute it and/or modify
@ -16,22 +24,19 @@
# GNU General Public License for more details.
SCRIPT_NAME="remove-driver.sh"
SCRIPT_VERSION="20230109"
SCRIPT_VERSION="20230126"
MODULE_NAME="88x2bu"
DRV_VERSION="5.13.1"
KVER="$(uname -r)"
KARCH="$(uname -m)"
#KSRC="/lib/modules/${KVER}/build"
MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/"
DRV_NAME="rtl${MODULE_NAME}"
DRV_DIR="$(pwd)"
OPTIONS_FILE="${MODULE_NAME}.conf"
# check to ensure sudo was used
if [[ $EUID -ne 0 ]]
then
# check to ensure sudo 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}\""
exit 1
@ -39,10 +44,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 ;;
@ -56,49 +59,49 @@ do
shift
done
echo ": ---------------------------"
# displays script name and version
echo ": ${SCRIPT_NAME} v${SCRIPT_VERSION}"
# information that helps with bug reports
# display architecture
echo ": ${KARCH} (ARCH)"
# display kernel version
echo ": ${KVER}"
echo ": ---------------------------"
# check for and remove non-dkms installations
# standard naming
if [[ -f "${MODDESTDIR}${MODULE_NAME}.ko" ]]
then
if [ -f "${MODDESTDIR}${MODULE_NAME}.ko" ]; then
echo "Removing a non-dkms installation: ${MODDESTDIR}${MODULE_NAME}.ko"
rm -f ${MODDESTDIR}${MODULE_NAME}.ko
/sbin/depmod -a ${KVER}
rm -f "${MODDESTDIR}"${MODULE_NAME}.ko
/sbin/depmod -a "${KVER}"
fi
# check for and remove non-dkms installations
# with rtl added to module name (PClinuxOS)
if [[ -f "${MODDESTDIR}rtl${MODULE_NAME}.ko" ]]
then
if [ -f "${MODDESTDIR}rtl${MODULE_NAME}.ko" ]; then
echo "Removing a non-dkms installation: ${MODDESTDIR}rtl${MODULE_NAME}.ko"
rm -f ${MODDESTDIR}rtl${MODULE_NAME}.ko
/sbin/depmod -a ${KVER}
rm -f "${MODDESTDIR}"rtl${MODULE_NAME}.ko
/sbin/depmod -a "${KVER}"
fi
# check for and remove non-dkms installations
# with compressed module in a unique non-standard location (Armbian)
# 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
if [ -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz" ]; then
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}
rm -f /usr/lib/modules/"${KVER}"/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz
/sbin/depmod -a "${KVER}"
fi
# information that helps with bug reports
# display kernel version
echo ": ${KVER}"
# display architecture
echo ": ${KARCH}"
# determine if dkms is installed and run the appropriate routines
if command -v dkms >/dev/null 2>&1
then
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
@ -108,10 +111,8 @@ then
# 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
if [ "$RESULT" = "0" ] || [ "$RESULT" = "3" ]; then
if [ "$RESULT" = "0" ]; then
echo "${DRV_NAME}/${DRV_VERSION} has been removed"
fi
else
@ -130,14 +131,11 @@ echo "The driver was removed successfully."
echo "You may now delete the driver directory if desired."
# if NoPrompt is not used, ask user some questions
if [ $NO_PROMPT -ne 1 ]
then
read -p "Do you want to reboot now? (recommended) [y/N] " -n 1 -r
if [ $NO_PROMPT -ne 1 ]; then
printf "Do you want to apply the new options by rebooting now? (recommended) [y/N] "
read -r REPLY
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
reboot
fi
case "$REPLY" in
[yY]*) reboot ;;
esac
fi
exit 0

View File

@ -1,7 +1,5 @@
#!/bin/bash
#
SCRIPT_NAME="save-log.sh"
#
#!/bin/sh
# Purpose: Save a log file with RTW lines only.
#
# To make this file executable:
@ -11,24 +9,25 @@ SCRIPT_NAME="save-log.sh"
# To execute this file:
#
# $ sudo ./edit-options.sh
#
if [[ $EUID -ne 0 ]]; then
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
# deletes existing log
rm -f -- rtw.log
dmesg | cut -d"]" -f2- | grep "RTW" >> rtw.log
RESULT=$?
if [[ "$RESULT" != "0" ]]; then
if [ "$RESULT" != "0" ]; then
echo "An error occurred while running: ${SCRIPT_NAME}"
echo "Did you set a log level > 0 ?"
exit 1
else
echo "rtw.log saved successfully."
exit 0
fi