mirror of
https://github.com/morrownr/8821cu-20210916.git
synced 2024-12-22 06:15:50 +00:00
update to scripts and docs
This commit is contained in:
parent
de36dfeff8
commit
8e300c0885
1
Kconfig
1
Kconfig
@ -1,7 +1,6 @@
|
||||
config RTL8821CU
|
||||
tristate "Realtek 8821C USB WiFi"
|
||||
depends on USB
|
||||
select WIRELESS_EXT
|
||||
help
|
||||
Help message of RTL8821CU
|
||||
|
||||
|
265
README.md
265
README.md
@ -4,8 +4,8 @@
|
||||
|
||||
- v5.12.0.4 (Realtek) (20210916) 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
|
||||
|
||||
@ -67,6 +67,9 @@ the hardware to test the above.
|
||||
- Kernels: 4.19 - 5.11 (Realtek)
|
||||
- Kernels: 5.12 - 6.6 (community support)
|
||||
|
||||
Note: Kernels earlier than 4.19 may work but are not tested or
|
||||
supported.
|
||||
|
||||
### Tested Compilers
|
||||
|
||||
- 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
|
||||
|
||||
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 rtl8821cu
|
||||
chipset is multi-fuction. The rtl8811cu 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. 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
|
||||
@ -201,19 +216,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
|
||||
@ -364,10 +382,44 @@ cd ~/src/8821cu-20210916
|
||||
|
||||
#### 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
|
||||
@ -392,16 +444,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:
|
||||
@ -423,8 +475,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
|
||||
@ -432,7 +484,7 @@ sudo reboot
|
||||
|
||||
The MOK managerment screen will appear during boot:
|
||||
|
||||
`Shim UEFI Key Management"
|
||||
`Shim UEFI Key Management`
|
||||
|
||||
`Press any key...`
|
||||
|
||||
@ -444,18 +496,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
|
||||
@ -465,21 +527,25 @@ 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.
|
||||
Note: If you use the manual installation instructions, or if dkms is not
|
||||
installed, you will need to repeat the process each time a new kernel is
|
||||
installed in your distro.
|
||||
|
||||
-----
|
||||
|
||||
### Driver Options (`edit-options.sh`)
|
||||
|
||||
A file called `8821cu.conf` will be installed in `/etc/modprobe.d` by
|
||||
default if you use the `install-driver.sh` script.
|
||||
Note: In Linux, driver options are called module parameters.
|
||||
|
||||
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
|
||||
|
||||
@ -487,18 +553,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 `8821cu.conf`.
|
||||
Note: Documentation for Driver Options is included in the file
|
||||
`8821cu.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
|
||||
|
||||
@ -546,7 +615,8 @@ cd ~/src/8821cu-20210916
|
||||
|
||||
#### 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
|
||||
@ -556,23 +626,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.
|
||||
|
||||
@ -580,19 +671,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.
|
||||
|
||||
-----
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
#!/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=$(LANG=C free | awk '/Mem:/ { print $2 }')
|
||||
|
||||
@ -11,6 +14,9 @@ if [ "$sproc" -gt 1 ]; then
|
||||
if [ "$SMEM" -lt 1400000 ]; then
|
||||
sproc=2
|
||||
fi
|
||||
if [ "$SMEM" -lt 700000 ]; then
|
||||
sproc=1
|
||||
fi
|
||||
fi
|
||||
|
||||
kernelver=${kernelver:-$(uname -r)}
|
||||
|
@ -4,4 +4,4 @@ BUILT_MODULE_NAME[0]="8821cu"
|
||||
MAKE="./dkms-make.sh"
|
||||
CLEAN="'make' clean"
|
||||
DEST_MODULE_LOCATION[0]="/updates/dkms"
|
||||
AUTOINSTALL="YES"
|
||||
AUTOINSTALL="yes"
|
||||
|
@ -24,7 +24,7 @@
|
||||
# GNU General Public License for more details.
|
||||
|
||||
SCRIPT_NAME="edit-options.sh"
|
||||
# SCRIPT_VERSION="20230126"
|
||||
# SCRIPT_VERSION="20230710"
|
||||
OPTIONS_FILE="8821cu.conf"
|
||||
|
||||
# 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
|
||||
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] "
|
||||
read -r REPLY
|
||||
case "$REPLY" in
|
||||
[yY]*) reboot ;;
|
||||
printf "Do you want to apply the new options by rebooting now? (recommended) [Y/n] "
|
||||
read -r yn
|
||||
case "$yn" in
|
||||
[nN]) ;;
|
||||
*) reboot ;;
|
||||
esac
|
||||
|
@ -28,19 +28,34 @@
|
||||
# GNU General Public License for more details.
|
||||
|
||||
SCRIPT_NAME="install-driver.sh"
|
||||
SCRIPT_VERSION="20230227"
|
||||
MODULE_NAME="8821cu"
|
||||
SCRIPT_VERSION="20230830"
|
||||
|
||||
DRV_NAME="rtl8821cu"
|
||||
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)"
|
||||
|
||||
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 +80,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 +112,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,8 +153,11 @@ 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)"
|
||||
|
||||
SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }')
|
||||
sproc=$(nproc)
|
||||
@ -149,6 +167,10 @@ if [ "$sproc" -gt 1 ]; then
|
||||
then
|
||||
sproc=2
|
||||
fi
|
||||
if [ "$SMEM" -lt 700000 ]
|
||||
then
|
||||
sproc=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# display number of in-use processing units / total processing units
|
||||
@ -160,6 +182,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}"
|
||||
@ -170,24 +196,43 @@ if command -v dkms >/dev/null 2>&1; then
|
||||
echo ": ""${dkms_ver}"
|
||||
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 mokutil --sb-state | grep -i enabled >/dev/null 2>&1; then
|
||||
echo ": SecureBoot enabled - read FAQ about SecureBoot"
|
||||
echo ": SecureBoot enabled"
|
||||
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
|
||||
|
||||
# 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}"
|
||||
@ -202,8 +247,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}"
|
||||
@ -220,8 +263,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}"
|
||||
@ -233,24 +274,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"
|
||||
@ -308,8 +365,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
|
||||
@ -331,12 +390,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=$?
|
||||
|
||||
@ -352,7 +412,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
|
||||
@ -370,13 +430,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
|
||||
|
@ -28,18 +28,26 @@
|
||||
# GNU General Public License for more details.
|
||||
|
||||
SCRIPT_NAME="remove-driver.sh"
|
||||
SCRIPT_VERSION="20230226"
|
||||
MODULE_NAME="8821cu"
|
||||
SCRIPT_VERSION="20230830"
|
||||
|
||||
DRV_NAME="rtl8821cu"
|
||||
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/"
|
||||
|
||||
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"
|
||||
|
Loading…
Reference in New Issue
Block a user