update to scripts and docs

pull/120/head
morrownr 2023-09-25 10:04:26 -05:00
parent de36dfeff8
commit 8e300c0885
7 changed files with 360 additions and 162 deletions

View File

@ -1,7 +1,6 @@
config RTL8821CU config RTL8821CU
tristate "Realtek 8821C USB WiFi" tristate "Realtek 8821C USB WiFi"
depends on USB depends on USB
select WIRELESS_EXT
help help
Help message of RTL8821CU Help message of RTL8821CU

265
README.md
View File

@ -4,8 +4,8 @@
- v5.12.0.4 (Realtek) (20210916) plus updates from the Linux community - v5.12.0.4 (Realtek) (20210916) plus updates from the Linux community
Note: Please read "supported-device-IDs" for information about how to Note: Please read the file "supported-device-IDs" for information about
confirm that this is the correct driver for your adapter. how to confirm that this is the correct driver for your adapter.
### Supported Features ### Supported Features
@ -67,6 +67,9 @@ the hardware to test the above.
- Kernels: 4.19 - 5.11 (Realtek) - Kernels: 4.19 - 5.11 (Realtek)
- Kernels: 5.12 - 6.6 (community support) - Kernels: 5.12 - 6.6 (community support)
Note: Kernels earlier than 4.19 may work but are not tested or
supported.
### Tested Compilers ### Tested Compilers
- gcc 10, 11, 12 and 13 - gcc 10, 11, 12 and 13
@ -128,56 +131,68 @@ OpenWRT so it is strongly advised to use the already supported chipsets.
- Numerous adapters that are based on the supported chipsets - Numerous adapters that are based on the supported chipsets
Note: If you are looking for information about what adapter to buy, 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 click [here](https://github.com/morrownr/USB-WiFi) and look for Main
item 2 which will show information about and links to recommended adapters. 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 Note: If you decide to buy an adapter that is supported by this driver,
recommend you search for an adapter that is `single-state and single-function`. I recommend you search for an adapter that is `single-state and
Multi-function adapters, wifi and bluetooth, can be problematic. The rtl8821cu single-function`. Multi-function adapters, wifi and bluetooth, can be
chipset is multi-fuction. The rtl8811cu chipset is single-function. For advice problematic. For advice about single-state and multi-state adapters,
about single-state and multi-state adapters. click click [here](https://github.com/morrownr/USB-WiFi) and look for Main
[here](https://github.com/morrownr/USB-WiFi) and look for Main Menu item 1. Menu item 1.
### Installation Information ### Installation Information
Note: As of Linux kernel 6.2, an in-kernel driver for the chipsets supported by Warning: It is recommended that you follow the installation instructions
this driver has been included in the Linux kernel. The installation and removal in the Installation Steps section. Avoid installation by downloading the
scripts for the driver in this repo automatically deactivate the in-kernel zip file if at all possible. Support can only be provided, on a best
driver on installation and reactivate the in-kernel driver on removal. No effort basis, if the Installation Steps in the next section are followed.
special action needs to be taken by users.
Warning: Installing multiple out-of-kernel drivers for the same hardware Warning: Installing multiple out-of-kernel drivers for the same hardware
usually does not end well. The install-driver.sh script has the capability usually does not end well. The install-driver.sh script has the
to detect and remove many conflicting drivers but not all. If this driver capability to detect and remove most conflicting drivers but not all. If
does not work well after installation and you have previously installed a this driver does not work well after installation and you have
driver that you did not remove, it is suggested that you run the following previously installed a driver that you did not remove, it is suggested
command in an effort to determine if you need to take action to manually that you run the following command in an effort to determine if you need
remove conflicting drivers: to take action to manually remove conflicting drivers:
``` ```
sudo dkms status sudo dkms status
``` ```
Warning: If you decide to do a distro upgrade, which will likely install a Warning: If you decide to do a distro upgrade, which will likely install
new version of kernel such as 5.15 to 6.1, you need to upgrade this driver a new version of kernel such as 5.15 to 6.1, you need to update this
with the newest available code before performing the disto upgrade. Use driver with the newest available code and then run the removal script
the following commands in the driver directory: before performing the disto upgrade. Use the following commands in the
driver directory:
``` ```
git pull 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 Note: The following command will reinstall the updated driver after you
to enable temporary internet access depending on your hardware and situation. are finished with the distro upgrade and reboot.
[One method is to use tethering from a phone.](https://www.makeuseof.com/tag/how-to-tether-your-smartphone-in-linux).
```
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. 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: You will need to use the terminal interface. The quick way to open a
Ctrl+Alt+T (hold down on the Ctrl and Alt keys then press the T key). 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 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 another computer, in which case you will be in a suitable terminal after logging
@ -201,19 +216,22 @@ Secure Boot: see FAQ.
### Installation Steps ### Installation Steps
Note: The installation instructions are for the novice user. Experienced users are Note: The installation instructions are for the novice user. Experienced
welcome to alter the installation to meet their needs. Support will be provided, users are welcome to alter the installation to meet their needs. Support
on a best effort basis, based on the steps below. 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 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) #### 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 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 below, you will need to research how to `update` and `upgrade` your
packages. 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 sudo apt update && sudo apt upgrade
@ -364,10 +382,44 @@ cd ~/src/8821cu-20210916
#### Step 8: Run the installation script (`install-driver.sh`) #### Step 8: Run the installation script (`install-driver.sh`)
Note: It is recommended that you terminate running apps so as to provide the Important: The compilation may fail if the major version of gcc that is
maximum amount of RAM to the compilation process. 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 sudo ./install-driver.sh
@ -392,16 +444,16 @@ sudo mokutil --import /var/lib/dkms/mok.pub
### Manual Installation Instructions ### Manual Installation Instructions
Note: The above installation steps automate the installation process, Note: The installation script, install-driver.sh, automates the
however, if you want to or need to do a basic command line installation, installation process, however, if you want to or need to do a basic
use the following: command line installation, use the following:
``` ```
make clean make clean
``` ```
``` ```
make make -j$(nproc)
``` ```
If secure boot is off: If secure boot is off:
@ -423,8 +475,8 @@ enter commands.
sudo make sign-install sudo make sign-install
``` ```
You will be promted for a password, please remember the password as it Note: You will be promted for a password, please remember the password
will be used in some of the following steps. as it will be used in some of the following steps.
``` ```
sudo reboot sudo reboot
@ -432,7 +484,7 @@ sudo reboot
The MOK managerment screen will appear during boot: The MOK managerment screen will appear during boot:
`Shim UEFI Key Management" `Shim UEFI Key Management`
`Press any key...` `Press any key...`
@ -444,18 +496,28 @@ Select "Yes"
When promted, enter the password you entered earlier. When promted, enter the password you entered earlier.
If you enter the wrong password, your computer will not be bootable. In Warning: If you enter the wrong password, your computer will not be
this case, use the BOOT menu from your BIOS to boot then as follows: bootable. In this case, use the BOOT menu from your BIOS to boot then as
follows:
``` ```
sudo mokutil --reset sudo mokutil --reset
``` ```
Restart your computer and use the BOOT menu from BIOS to boot. In the MOK 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 managerment screen, select `reset MOK list`, then reboot and retry from
the step `sudo make sign-install`. 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 sudo make uninstall
@ -465,21 +527,25 @@ sudo make uninstall
sudo reboot sudo reboot
``` ```
Note: If you use the manual installation instructions, you will need to Note: If you use the manual installation instructions, or if dkms is not
repeat the process each time a new kernel is installed in your distro. installed, 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 `8821cu.conf` will be installed in `/etc/modprobe.d` by Note: In Linux, driver options are called module parameters.
default if you use the `install-driver.sh` script.
Note: The installation script will prompt you to edit the options. A file called `88x2bu.conf` will be installed in `/etc/modprobe.d` by
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.
Location: `/etc/modprobe.d/8821cu.conf` Note: The installation script, `install-driver.sh`. will prompt you to
edit the options.
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 To edit the driver options file, run the `edit-options.sh` script
@ -487,18 +553,21 @@ To edit the driver options file, run the `edit-options.sh` script
sudo ./edit-options.sh sudo ./edit-options.sh
``` ```
Note: Documentation for Driver Options is included in the file `8821cu.conf`. Note: Documentation for Driver Options is included in the file
`8821cu.conf`.
----- -----
### Upgrading the Driver ### 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: 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 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 #### Step 1: Move to the driver directory
@ -546,7 +615,8 @@ cd ~/src/8821cu-20210916
#### Step 3: Run the removal script #### 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 sudo ./remove-driver.sh
@ -556,23 +626,44 @@ sudo ./remove-driver.sh
### Recommended WiFi Router/ Access Point Settings ### 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. After making and saving changes, reboot the router.
@ -580,19 +671,33 @@ After making and saving changes, reboot the router.
### Recommendations regarding USB ### 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.
----- -----

View File

@ -1,5 +1,8 @@
#!/bin/sh #!/bin/sh
# Warning: Do not run this script in a terminal. It is designed to be
# run from another script.
# SMEM needs to be set here if dkms build is not initiated by install-driver.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 }') SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }')
@ -11,6 +14,9 @@ if [ "$sproc" -gt 1 ]; then
if [ "$SMEM" -lt 1400000 ]; then if [ "$SMEM" -lt 1400000 ]; then
sproc=2 sproc=2
fi fi
if [ "$SMEM" -lt 700000 ]; then
sproc=1
fi
fi fi
kernelver=${kernelver:-$(uname -r)} kernelver=${kernelver:-$(uname -r)}

View File

@ -4,4 +4,4 @@ BUILT_MODULE_NAME[0]="8821cu"
MAKE="./dkms-make.sh" MAKE="./dkms-make.sh"
CLEAN="'make' clean" CLEAN="'make' clean"
DEST_MODULE_LOCATION[0]="/updates/dkms" DEST_MODULE_LOCATION[0]="/updates/dkms"
AUTOINSTALL="YES" AUTOINSTALL="yes"

View File

@ -24,7 +24,7 @@
# GNU General Public License for more details. # GNU General Public License for more details.
SCRIPT_NAME="edit-options.sh" SCRIPT_NAME="edit-options.sh"
# SCRIPT_VERSION="20230126" # SCRIPT_VERSION="20230710"
OPTIONS_FILE="8821cu.conf" OPTIONS_FILE="8821cu.conf"
# check to ensure sudo was used to start the script # check to ensure sudo was used to start the script
@ -47,10 +47,16 @@ if ! command -v "${TEXT_EDITOR}" >/dev/null 2>&1; then
exit 1 exit 1
fi fi
${TEXT_EDITOR} /etc/modprobe.d/${OPTIONS_FILE} if [ -f "/etc/modprobe.d/${OPTIONS_FILE}" ]; then
${TEXT_EDITOR} /etc/modprobe.d/${OPTIONS_FILE}
else
cp -f ${OPTIONS_FILE} /etc/modprobe.d
${TEXT_EDITOR} /etc/modprobe.d/${OPTIONS_FILE}
fi
printf "Do you want to apply the new options by rebooting now? (recommended) [y/N] " printf "Do you want to apply the new options by rebooting now? (recommended) [Y/n] "
read -r REPLY read -r yn
case "$REPLY" in case "$yn" in
[yY]*) reboot ;; [nN]) ;;
*) reboot ;;
esac esac

View File

@ -28,19 +28,34 @@
# GNU General Public License for more details. # GNU General Public License for more details.
SCRIPT_NAME="install-driver.sh" SCRIPT_NAME="install-driver.sh"
SCRIPT_VERSION="20230227" SCRIPT_VERSION="20230830"
MODULE_NAME="8821cu"
DRV_NAME="rtl8821cu"
DRV_VERSION="5.12.0.4" DRV_VERSION="5.12.0.4"
MODULE_NAME="8821cu"
KARCH="$(uname -m)"
KVER="$(uname -r)"
MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/"
DRV_NAME="rtl${MODULE_NAME}" #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_DIR="$(pwd)" DRV_DIR="$(pwd)"
MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/"
OPTIONS_FILE="${MODULE_NAME}.conf" 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 if [ "$(id -u)" -ne 0 ]; then
echo "You must run this script with superuser (root) privileges." echo "You must run this script with superuser (root) privileges."
echo "Try: \"sudo ./${SCRIPT_NAME}\"" echo "Try: \"sudo ./${SCRIPT_NAME}\""
@ -65,11 +80,6 @@ do
shift shift
done 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 # check to ensure gcc is installed
if ! command -v gcc >/dev/null 2>&1; then if ! command -v gcc >/dev/null 2>&1; then
echo "A required package is not installed." echo "A required package is not installed."
@ -102,21 +112,26 @@ if [ ! -d "/lib/modules/$(uname -r)/build" ]; then
exit 1 exit 1
fi 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 # check to ensure iw is installed
if ! command -v iw >/dev/null 2>&1; then #if ! command -v iw >/dev/null 2>&1; then
echo "A required package is not installed." # echo "A required package is not installed."
echo "Please install the following package: iw" # echo "Please install the following package: iw"
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\"" # echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
exit 1 # exit 1
fi #fi
# check to ensure rfkill is installed # check to ensure rfkill is installed
if ! command -v rfkill >/dev/null 2>&1; then #if ! command -v rfkill >/dev/null 2>&1; then
echo "A required package is not installed." # echo "A required package is not installed."
echo "Please install the following package: rfkill" # echo "Please install the following package: rfkill"
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\"" # echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
exit 1 # exit 1
fi #fi
DEFAULT_EDITOR="$(cat default-editor.txt)" DEFAULT_EDITOR="$(cat default-editor.txt)"
# try to find the user's default text editor through the EDITORS_SEARCH array # try to find the user's default text editor through the EDITORS_SEARCH array
@ -138,8 +153,11 @@ echo ": ${SCRIPT_NAME} v${SCRIPT_VERSION}"
# information that helps with bug reports # information that helps with bug reports
# display architecture # display kernel architecture
echo ": ${KARCH} (architecture)" echo ": ${KARCH} (kernel architecture)"
# display architecture to send to gcc
echo ": ${GARCH} (architecture to send to gcc)"
SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }') SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }')
sproc=$(nproc) sproc=$(nproc)
@ -149,6 +167,10 @@ if [ "$sproc" -gt 1 ]; then
then then
sproc=2 sproc=2
fi fi
if [ "$SMEM" -lt 700000 ]
then
sproc=1
fi
fi fi
# display number of in-use processing units / total processing units # display number of in-use processing units / total processing units
@ -160,6 +182,10 @@ echo ": ${SMEM} (total system memory)"
# display kernel version # display kernel version
echo ": ${KVER} (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 # display gcc version
gcc_ver=$(gcc --version | grep -i gcc) gcc_ver=$(gcc --version | grep -i gcc)
echo ": ""${gcc_ver}" echo ": ""${gcc_ver}"
@ -170,24 +196,43 @@ if command -v dkms >/dev/null 2>&1; then
echo ": ""${dkms_ver}" echo ": ""${dkms_ver}"
fi fi
# display secure mode status if SecureBoot is enabled and if mokutil is installed # display secure mode status
if command -v mokutil >/dev/null 2>&1; then if command -v mokutil >/dev/null 2>&1; then
if mokutil --sb-state | grep -i enabled >/dev/null 2>&1; then if mokutil --sb-state | grep -i enabled >/dev/null 2>&1; then
echo ": SecureBoot enabled - read FAQ about SecureBoot" echo ": SecureBoot enabled"
fi fi
if mokutil --sb-state | grep -i disabled >/dev/null 2>&1; then
echo ": SecureBoot disabled"
fi
if mokutil --sb-state | grep -i EFI >/dev/null 2>&1; then
echo ": EFI variables are not supported on this system"
fi
else
echo ": mokutil not installed"
fi 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 echo
echo "Checking for previously installed drivers." echo "Checking for previously installed drivers..."
# check for and remove non-dkms installations # check for and remove non-dkms installations
# standard naming # standard naming
if [ -f "${MODDESTDIR}${MODULE_NAME}.ko" ]; then if [ -f "${MODDESTDIR}${MODULE_NAME}.ko" ]; then
echo ": ---------------------------"
echo
echo "Removing a non-dkms installation: ${MODDESTDIR}${MODULE_NAME}.ko" echo "Removing a non-dkms installation: ${MODDESTDIR}${MODULE_NAME}.ko"
rm -f "${MODDESTDIR}"${MODULE_NAME}.ko rm -f "${MODDESTDIR}"${MODULE_NAME}.ko
/sbin/depmod -a "${KVER}" /sbin/depmod -a "${KVER}"
@ -202,8 +247,6 @@ fi
# check for and remove non-dkms installations # check for and remove non-dkms installations
# with rtl added to module name (PClinuxOS) # with rtl added to module name (PClinuxOS)
if [ -f "${MODDESTDIR}rtl${MODULE_NAME}.ko" ]; then if [ -f "${MODDESTDIR}rtl${MODULE_NAME}.ko" ]; then
echo ": ---------------------------"
echo
echo "Removing a non-dkms installation: ${MODDESTDIR}rtl${MODULE_NAME}.ko" echo "Removing a non-dkms installation: ${MODDESTDIR}rtl${MODULE_NAME}.ko"
rm -f "${MODDESTDIR}"rtl${MODULE_NAME}.ko rm -f "${MODDESTDIR}"rtl${MODULE_NAME}.ko
/sbin/depmod -a "${KVER}" /sbin/depmod -a "${KVER}"
@ -220,8 +263,6 @@ fi
# Example: /usr/lib/modules/5.15.80-rockchip64/kernel/drivers/net/wireless/rtl8821cu/8821cu.ko.xz # Example: /usr/lib/modules/5.15.80-rockchip64/kernel/drivers/net/wireless/rtl8821cu/8821cu.ko.xz
# Dear Armbiam, this is a really bad idea. # 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 ": ---------------------------"
echo
echo "Removing a non-dkms installation: /usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz" 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 rm -f /usr/lib/modules/"${KVER}"/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz
/sbin/depmod -a "${KVER}" /sbin/depmod -a "${KVER}"
@ -233,24 +274,40 @@ if [ -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODU
echo "Removal complete." echo "Removal complete."
fi 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 command -v dkms >/dev/null 2>&1; then
if dkms status | grep -i ${DRV_NAME}; then dkms status | while IFS="/, " read -r modname modver kerver _dummy; do
echo ": ---------------------------" case "$modname" in *${MODULE_NAME})
echo echo "--> ${modname} ${modver} ${kerver}"
# need to add code here to delete any DRV_VERSION dkms remove -m "${modname}" -v "${modver}" -k "${kerver}" -c "/usr/src/${modname}-${modver}/dkms.conf"
echo "Removing a dkms installation." esac
dkms remove -m ${DRV_NAME} -v ${DRV_VERSION} --all done
echo "Removing ${OPTIONS_FILE} from /etc/modprobe.d" if [ -f /etc/modprobe.d/${OPTIONS_FILE} ]; then
rm -f /etc/modprobe.d/${OPTIONS_FILE} 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} rm -rf /usr/src/${DRV_NAME}-${DRV_VERSION}
echo "Removal complete."
fi fi
fi fi
# sets module parameters (driver options) and blacklisted modules echo "Finished checking for and removing previously installed drivers."
echo ": ---------------------------" echo ": ---------------------------"
echo echo
echo "Starting installation." echo "Starting installation."
echo "Installing ${OPTIONS_FILE} to /etc/modprobe.d" echo "Installing ${OPTIONS_FILE} to /etc/modprobe.d"
@ -308,8 +365,10 @@ else
# the dkms add command requires source in /usr/src/${DRV_NAME}-${DRV_VERSION} # the dkms add command requires source in /usr/src/${DRV_NAME}-${DRV_VERSION}
echo "Copying source files to /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} 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=$?
# RESULT will be 3 if the DKMS tree already contains the same module/version # RESULT will be 3 if the DKMS tree already contains the same module/version
@ -331,12 +390,13 @@ else
else else
echo "The driver was added to dkms successfully." echo "The driver was added to dkms successfully."
echo ": ---------------------------" echo ": ---------------------------"
echo
fi 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} /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 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 fi
RESULT=$? RESULT=$?
@ -352,7 +412,7 @@ else
echo ": ---------------------------" echo ": ---------------------------"
fi 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=$? RESULT=$?
if [ "$RESULT" != "0" ]; then if [ "$RESULT" != "0" ]; then
@ -370,13 +430,18 @@ else
fi fi
# provide driver upgrade information # 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 "$ git pull"
echo "$ sudo sh install-driver.sh" echo "$ sudo sh install-driver.sh"
echo "Note: Upgrades to this driver should be performed before distro upgrades." echo
echo "Note: Upgrades can be performed as often as you like." echo "Note: Updates to this driver SHOULD be performed before distro"
echo "Note: Work on this driver is continuous." echo " upgrades such as Ubuntu 23.10 to 24.04."
echo ": ---------------------------" 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 echo
# unblock wifi # unblock wifi

View File

@ -28,18 +28,26 @@
# GNU General Public License for more details. # GNU General Public License for more details.
SCRIPT_NAME="remove-driver.sh" SCRIPT_NAME="remove-driver.sh"
SCRIPT_VERSION="20230226" SCRIPT_VERSION="20230830"
MODULE_NAME="8821cu"
DRV_NAME="rtl8821cu"
DRV_VERSION="5.12.0.4" DRV_VERSION="5.12.0.4"
MODULE_NAME="8821cu"
#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/" MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/"
DRV_NAME="rtl${MODULE_NAME}"
OPTIONS_FILE="${MODULE_NAME}.conf" 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 if [ "$(id -u)" -ne 0 ]; then
echo "You must run this script with superuser (root) privileges." echo "You must run this script with superuser (root) privileges."
echo "Try: \"sudo ./${SCRIPT_NAME}\"" echo "Try: \"sudo ./${SCRIPT_NAME}\""
@ -49,7 +57,8 @@ fi
# support for the NoPrompt option allows non-interactive use of this script # support for the NoPrompt option allows non-interactive use of this script
NO_PROMPT=0 NO_PROMPT=0
# get the script options # get the script options
while [ $# -gt 0 ]; do while [ $# -gt 0 ]
do
case $1 in case $1 in
NoPrompt) NoPrompt)
NO_PROMPT=1 ;; NO_PROMPT=1 ;;
@ -70,8 +79,8 @@ echo ": ${SCRIPT_NAME} v${SCRIPT_VERSION}"
# information that helps with bug reports # information that helps with bug reports
# display architecture # display kernel architecture
echo ": ${KARCH} (architecture)" echo ": ${KARCH} (kernel architecture)"
# display kernel version # display kernel version
echo ": ${KVER} (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}" /sbin/depmod -a "${KVER}"
fi 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 if command -v dkms >/dev/null 2>&1; then
echo "Removing a dkms installation." dkms status | while IFS="/, " read -r modname modver kerver _dummy; do
# 2>/dev/null suppresses the output of dkms case "$modname" in *${MODULE_NAME})
dkms remove -m ${DRV_NAME} -v ${DRV_VERSION} --all 2>/dev/null echo "--> ${modname} ${modver} ${kerver}"
dkms remove -m "${modname}" -v "${modver}" -k "${kerver}" -c "/usr/src/${modname}-${modver}/dkms.conf"
esac
done
RESULT=$? RESULT=$?
#echo "Result=${RESULT}" # echo "Result=${RESULT}"
# RESULT will be 3 if there are no instances of module to remove # 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 # however we still need to remove various files or the install script
# may complain. # may complain.
if [ "$RESULT" = "0" ] || [ "$RESULT" = "3" ]; then if [ "$RESULT" = "0" ] || [ "$RESULT" = "3" ]; then
if [ "$RESULT" = "0" ]; then if [ "$RESULT" = "0" ]; then
echo "${DRV_NAME}/${DRV_VERSION} has been removed" echo "${DRV_NAME}/${DRV_VERSION} has been removed"