From 2d4dc48bcb1c158ea6eea79a834d9e2641940ca6 Mon Sep 17 00:00:00 2001 From: morrownr Date: Mon, 9 Jan 2023 12:27:31 -0600 Subject: [PATCH] various updates --- 88x2bu.conf | 41 ++++++------ Makefile | 2 +- README.md | 59 +++++++---------- hal/led/hal_usb_led.c | 16 +++++ hal/rtl8822b/usb/rtl8822bu_led.c | 24 ++----- include/autoconf.h | 2 +- include/drv_types.h | 2 +- install-driver.sh | 105 +++++++++++++++++++------------ os_dep/linux/os_intfs.c | 10 +-- remove-driver.sh | 8 +-- 10 files changed, 145 insertions(+), 124 deletions(-) diff --git a/88x2bu.conf b/88x2bu.conf index 0c16269..1d367f2 100644 --- a/88x2bu.conf +++ b/88x2bu.conf @@ -13,6 +13,10 @@ options 88x2bu rtw_drv_log_level=1 rtw_led_ctrl=1 rtw_vht_enable=1 rtw_switch_us # # 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_dfs_region_domain=1 +# # After editing is complete, save this file (if using nano: Ctrl + x, y, Enter) # and reboot to activate the changes. # @@ -22,8 +26,8 @@ options 88x2bu rtw_drv_log_level=1 rtw_led_ctrl=1 rtw_vht_enable=1 rtw_switch_us # # Log options ( rtw_drv_log_level ) # -# 0 = NONE (default) -# 1 = ALWAYS +# 0 = NONE +# 1 = ALWAYS (default) # 2 = ERROR # 3 = WARNING # 4 = INFO @@ -68,6 +72,14 @@ options 88x2bu rtw_drv_log_level=1 rtw_led_ctrl=1 rtw_vht_enable=1 rtw_switch_us # # ----- # +# USB options: ( rtw_switch_usb_mode ) +# +# 0 = No switch (default) +# 1 = Switch from usb 2.0 to usb 3.0 +# 2 = Switch from usb 3.0 to usb 2.0 +# +# ----- +# # DFS Options ( rtw_dfs_region_domain ) # # 0 = NONE (default) @@ -86,13 +98,6 @@ options 88x2bu rtw_drv_log_level=1 rtw_led_ctrl=1 rtw_vht_enable=1 rtw_switch_us # # ----- # -# Select P2P interface in concurrent mode ( rtw_sel_p2p_iface ) -# -# 0 = Sets interface 0 to be p2p interface -# 1 = Sets interface 1 to be p2p interface (default) -# -# ----- -# # Wireless Mode options ( rtw_wireless_mode ) # # 1 = 2.4GHz 802.11b @@ -109,18 +114,18 @@ options 88x2bu rtw_drv_log_level=1 rtw_led_ctrl=1 rtw_vht_enable=1 rtw_switch_us # # ----- # -# USB options ( rtw_switch_usb_mode ) +# Country Code options ( rtw_country_code ) # -# 0 = No switch (default) -# 1 = Switch from usb 2.0 to usb 3.0 -# 2 = Switch from usb 3.0 to usb 2.0 +# Note: Allows the Country Code to be set in cases where it is unable to +# be obtained otherwise. # -# Note: This driver may need to stay in USB2 mode for AP mode operations -# on some platforms in order to avoid dropping offline. This issue has been -# observed on the Raspberry Pi 4B with both the 32 and 64 bit versions of the -# Raspberry Pi OS. This problem appears to be specific to the Raspberry Pi 4B -# and adapters based on the rtl8812bu chipset. +# URL: http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 # +# Example for the US: rtw_country_code=US +# Example for Panama: rtw_country_code=PA +# Example for Norway: rtw_country_code=NO +# Example for Kuwait: rtw_country_code=KW +# Example for Taiwan: rtw_country_code=TW # # ----- # diff --git a/Makefile b/Makefile index 1af157a..33cedcd 100644 --- a/Makefile +++ b/Makefile @@ -124,7 +124,7 @@ endif CONFIG_RTW_DEBUG = y # default log level is _DRV_INFO_ = 4, # please refer to "How_to_set_driver_debug_log_level.doc" to set the available level. -CONFIG_RTW_LOG_LEVEL = 0 +CONFIG_RTW_LOG_LEVEL = 1 # enable /proc/net/rtlxxxx/ debug interfaces CONFIG_PROC_DEBUG = y diff --git a/README.md b/README.md index 426819d..64a2bb8 100644 --- a/README.md +++ b/README.md @@ -11,18 +11,18 @@ confirm that this is the correct driver for your adapter. - IEEE 802.11 b/g/n/ac WiFi compliant - 802.1x, WEP, WPA TKIP and WPA2 AES/Mixed mode for PSK and TLS (Radius) -- WPA3 (see FAQ) +- WPA3-SAE (Personal) (see FAQ) - IEEE 802.11b/g/n/ac Client mode * Supports wireless security for WEP, WPA TKIP and WPA2 AES PSK * Supports site survey scan and manual connect * Supports WPA/WPA2 TLS client - Power saving modes +- Miracast - Wireshark compatible - Aircrack-ng compatible - Packet injection - hostapd compatible - AP mode DFS channel support -- Miracast - Supported interface modes * Managed * Monitor (see FAQ) @@ -38,6 +38,8 @@ confirm that this is the correct driver for your adapter. ### A FAQ is available at the end of this document. +### Additional documentation is in the file `88x2bu.conf`. + ### Compatible CPU Architectures - x86, i686 @@ -81,7 +83,7 @@ be provided via PR or message in Issues. - SkiffOS for Odroid XU4 (ARM 32 bit) (kernel 6.0.7) -- Ubuntu 22.04 (kernel 5.15) and 22.10 (kernel 5.19) (kernel 6.2 rc1) +- Ubuntu 22.04 (kernel 5.15) and 22.10 (kernel 5.19) (kernel 6.2) - Void Linux (kernel 5.18) @@ -141,9 +143,15 @@ item 2 which will show information about and links to recommended adapters. ### Installation Information -Warning: Installing multiple drivers for the same hardware usually does -not end well. If a previous attempt to install this driver failed or if -you have previously installed another driver for chipsets supported by +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: Installing multiple out-of-kernel drivers for the same hardware +usually does not end well. If a previous attempt to install this driver failed +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 @@ -169,7 +177,7 @@ $ sudo ./install-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). -Another method is to keep a [WiFi adapter that uses an in-kernel driver](https://github.com/morrownr/USB-WiFi) 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: Ctrl+Alt+T (hold down on the Ctrl and Alt keys then press the T key). @@ -184,7 +192,7 @@ can be executed as the `root` user. (If the command `sudo echo Yes` returns "Yes", with or without having to enter your password, you do have sufficient access rights.) -DKMS is used for the installation if available. DKMS is a system utility +DKMS is used for the installation, if available. DKMS is a system utility which will automatically recompile and reinstall this driver when a new kernel is installed. DKMS is provided by and maintained by Dell. @@ -212,24 +220,6 @@ install this driver and, after a reboot, the driver is not working, you can go into the BIOS and temporarily turn secure boot off to see if secure boot is the problem. -Please ensure the ISO 3166-1 alpha-2 Country Code is set in your Linux distro. -If it is not set, you will likely have problems accessing some channels, especially -5 Ghz and 6 GHz channels. To set your Country Code: - -``` -sudo iw reg set US -``` - -If you are not in the US, please use the country code for your country. See: - -ISO 3166-1 alpha-2 codes: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 - -To check if your country code is properly set: - -``` -iw reg get -``` - ### Installation Steps Note: The installation instructions are for the novice user. Experienced users are @@ -238,7 +228,7 @@ on a best effort basis, based on the steps below. #### Step 1: Open a terminal (e.g. Ctrl+Alt+T) -#### Step 2: Update and upgrade system packages (select the option for the OS 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 below, you will need to research how to update and upgrade your system @@ -574,17 +564,16 @@ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf Question: Is WPA3 supported? -Answer: WPA3-SAE support is in this driver according to Realtek and it -works well on some Linux distros but not all. Generally the reason for -WPA3 not working on Linux distros is that the distro has an old version -of wpa_supplicant or Network Manager. Your options are to upgrade to a -more modern distro (most distros released after mid 2022) or compile and -install new versions of the wpa_supplicant and Network Manager utilities. +Answer: WPA3-SAE is supported. It works well on most modern Linux distros but +not all. Generally the reason for WPA3 not working on Linux distros is that the +distro has an old version of wpa_supplicant or Network Manager. Your options +are to upgrade to a more modern distro (distros released after mid 2022) or +compile and install new versions of wpa_supplicant and/or Network Manager. ----- -Question: I bought two rtl8812bu based adapters and am planning to use -both in the same computer. How do I set that up? +Question: I bought two usb wifi adapters based on this chipset and am planning +to use both in the same computer. How do I set that up? Answer: Realtek drivers do not support more than one adapter with the same chipset in the same computer. You can have multiple Realtek based diff --git a/hal/led/hal_usb_led.c b/hal/led/hal_usb_led.c index a16baeb..032de9b 100644 --- a/hal/led/hal_usb_led.c +++ b/hal/led/hal_usb_led.c @@ -1745,6 +1745,22 @@ void BlinkHandler(PLED_USB pLed) return; } + #ifdef CONFIG_SW_LED + // 1 is normal blinking + if (padapter->registrypriv.led_ctrl != 1) { + if (padapter->registrypriv.led_ctrl == 0) + { + // Set LED to off + pLed->BlinkingLedState = RTW_LED_OFF; + } else { + // Set LED to solid for 2 or greater + pLed->BlinkingLedState = RTW_LED_ON; + } + // Skip various switch cases where SwLedBlink*() is called below + pLed->CurrLedState = LED_UNKNOWN; + } + #endif + switch (ledpriv->LedStrategy) { #if CONFIG_RTW_SW_LED_TRX_DA_CLASSIFY case SW_LED_MODE_UC_TRX_ONLY: diff --git a/hal/rtl8822b/usb/rtl8822bu_led.c b/hal/rtl8822b/usb/rtl8822bu_led.c index ec32f9e..b21cc38 100644 --- a/hal/rtl8822b/usb/rtl8822bu_led.c +++ b/hal/rtl8822b/usb/rtl8822bu_led.c @@ -57,19 +57,11 @@ static void swledon(PADAPTER padapter, PLED_USB led) case LED_PIN_LED1: case LED_PIN_LED2: default: - if (padapter->registrypriv.led_ctrl == 0) { - rtw_halmac_led_switch(adapter_to_dvobj(padapter), 0); - } else { - rtw_halmac_led_switch(adapter_to_dvobj(padapter), 1); - } + rtw_halmac_led_switch(adapter_to_dvobj(padapter), 1); break; } - if (padapter->registrypriv.led_ctrl == 0) { - led->bLedOn = _FALSE; - } else { - led->bLedOn = _TRUE; - } + led->bLedOn = _TRUE; } @@ -91,19 +83,11 @@ static void swledoff(PADAPTER padapter, PLED_USB led) case LED_PIN_LED1: case LED_PIN_LED2: default: - if (padapter->registrypriv.led_ctrl <= 1) { - rtw_halmac_led_switch(adapter_to_dvobj(padapter), 0); - } else { - rtw_halmac_led_switch(adapter_to_dvobj(padapter), 1); - } + rtw_halmac_led_switch(adapter_to_dvobj(padapter), 0); break; } - if (padapter->registrypriv.led_ctrl <= 1) { - led->bLedOn = _FALSE; - } else { - led->bLedOn = _TRUE; - } + led->bLedOn = _FALSE; } /* diff --git a/include/autoconf.h b/include/autoconf.h index 299fc8e..c1aa58f 100644 --- a/include/autoconf.h +++ b/include/autoconf.h @@ -178,7 +178,7 @@ #define CONFIG_RTW_LED #ifdef CONFIG_RTW_LED - #define CONFIG_RTW_SW_LED +// #define CONFIG_RTW_SW_LED #ifdef CONFIG_RTW_SW_LED /* #define CONFIG_RTW_LED_HANDLED_BY_CMD_THREAD */ #endif diff --git a/include/drv_types.h b/include/drv_types.h index ffa4f94..d9dbaed 100644 --- a/include/drv_types.h +++ b/include/drv_types.h @@ -242,7 +242,7 @@ struct registry_priv { #ifdef CONFIG_TX_EARLY_MODE u8 early_mode; #endif -#ifdef CONFIG_RTW_SW_LED +#ifdef CONFIG_SW_LED u8 led_ctrl; #endif #ifdef CONFIG_NARROWBAND_SUPPORTING diff --git a/install-driver.sh b/install-driver.sh index 952d325..e046253 100755 --- a/install-driver.sh +++ b/install-driver.sh @@ -4,7 +4,7 @@ # # Supports dkms and non-dkms installations. -# Copyright(c) 2022 Nick Morrow +# 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 @@ -16,7 +16,7 @@ # GNU General Public License for more details. SCRIPT_NAME="install-driver.sh" -SCRIPT_VERSION="20221228" +SCRIPT_VERSION="20230109" MODULE_NAME="88x2bu" DRV_VERSION="5.13.1" @@ -115,7 +115,46 @@ do done # displays script name and version -echo "Script: ${SCRIPT_NAME} version ${SCRIPT_VERSION}" +echo "Script: ${SCRIPT_NAME} v${SCRIPT_VERSION}" + +# information that helps with bug reports + +# display architecture +echo "Arch:${KARCH}" + +# display total memory in system +grep MemTotal /proc/meminfo + +# display kernel version +echo "Kernel: ${KVER}" + +# display gcc version +gcc_ver=$(gcc --version | grep -i gcc) +echo "gcc: "${gcc_ver} + +# display dkms version +# run if dkms is installed +if command -v dkms >/dev/null 2>&1 +then + dkms --version +fi + +# display secure mode status +# run if mokutil is installed +if command -v mokutil >/dev/null 2>&1 +then + mokutil --sb-state +fi + +# display ISO 3166-1 alpha-2 Country Code +#a2_country_code=$(iw reg get | grep -i country) +#echo "Country: "${a2_country_code} +#if [[ $a2_country_code == *"00"* ]]; +#then +# echo "The Country Code may not be properly set." +# echo "File alpha-2_Country_Codes is located in the driver directory." +# echo "Please read and follow the directions in the file after installation." +#fi # check for and remove non-dkms installations # standard naming @@ -124,6 +163,11 @@ then echo "Removing a non-dkms installation: ${MODDESTDIR}${MODULE_NAME}.ko" 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}" + rm -rf /usr/src/${DRV_NAME}-${DRV_VERSION} + make clean >/dev/null 2>&1 fi # check for and remove non-dkms installations @@ -133,6 +177,11 @@ then echo "Removing a non-dkms installation: ${MODDESTDIR}rtl${MODULE_NAME}.ko" 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}" + rm -rf /usr/src/${DRV_NAME}-${DRV_VERSION} + make clean >/dev/null 2>&1 fi # check for and remove non-dkms installations @@ -144,49 +193,27 @@ 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} + 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}" + rm -rf /usr/src/${DRV_NAME}-${DRV_VERSION} + make clean >/dev/null 2>&1 fi -# check for existing dkms installations of any version of this driver +# check for and remove dkms installations if command -v dkms >/dev/null 2>&1 then - if dkms status | grep -i ${DRV_NAME}; then - echo "The above driver needs to be removed before the installation can be successfull." - echo "Example: $ sudo dkms remove ${DRV_NAME}/X.X.X.X --all" - echo "Please replace X.X.X.X by the driver version number shown above." - echo "Once the driver is removed, please run \"sudo ./${SCRIPT_NAME}\"" - exit 1 + 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" + rm -f /etc/modprobe.d/${OPTIONS_FILE} + echo "Removing source files from /usr/src/${DRV_NAME}-${DRV_VERSION}" + rm -rf /usr/src/${DRV_NAME}-${DRV_VERSION} fi fi -# information that helps with bug reports - -# display kernel version -echo "Kernel: ${KVER}" - -# display architecture -echo "Arch: ${KARCH}" - -# display gcc version -gcc_ver=$(gcc --version | grep -i gcc) -echo "gcc: "${gcc_ver} - -# display ISO 3166-1 alpha-2 Country Code -a2_country_code=$(iw reg get | grep -i country) -echo "Country: "${a2_country_code} -if [[ $a2_country_code == *"00"* ]]; -then - echo "The Country Code may not be properly set." - echo "File alpha-2_Country_Codes is located in the driver directory." - echo "Please read and follow the directions in the file after installation." -fi - -# display secure mode status -# run if mokutil is installed -if command -v mokutil >/dev/null 2>&1 -then - mokutil --sb-state -fi - # sets module parameters (driver options) and blacklisted modules echo "Installing ${OPTIONS_FILE} to /etc/modprobe.d" cp -f ${OPTIONS_FILE} /etc/modprobe.d diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index e2b4249..05854ef 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -142,8 +142,8 @@ int rtw_check_fw_ps = 1; int rtw_early_mode = 1; #endif -#ifdef CONFIG_RTW_SW_LED -int rtw_led_ctrl = 1; /* default led blink */ +#ifdef CONFIG_SW_LED +int rtw_led_ctrl = 1; // default to normal blinking #endif int rtw_usb_rxagg_mode = 2;/* RX_AGG_DMA=1, RX_AGG_USB=2 */ @@ -617,9 +617,9 @@ module_param(rtw_pci_aspm_enable, int, 0644); module_param(rtw_early_mode, int, 0644); #endif -#ifdef CONFIG_RTW_SW_LED +#ifdef CONFIG_SW_LED module_param(rtw_led_ctrl, int, 0644); -MODULE_PARM_DESC(rtw_led_ctrl,"led control, 0:led off, 1:led blink, 2:led on"); +MODULE_PARM_DESC(rtw_led_ctrl,"Led Control: 0=Always off, 1=Normal blink, 2=Always on"); #endif #ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE @@ -1318,7 +1318,7 @@ uint loadparam(_adapter *padapter) #ifdef CONFIG_TX_EARLY_MODE registry_par->early_mode = (u8)rtw_early_mode; #endif -#ifdef CONFIG_RTW_SW_LED +#ifdef CONFIG_SW_LED registry_par->led_ctrl = (u8)rtw_led_ctrl; #endif registry_par->trx_path_bmp = (u8)rtw_trx_path_bmp; diff --git a/remove-driver.sh b/remove-driver.sh index eca53f5..6ebaf78 100755 --- a/remove-driver.sh +++ b/remove-driver.sh @@ -4,7 +4,7 @@ # # Supports dkms and non-dkms removals. -# Copyright(c) 2022 Nick Morrow +# 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 @@ -16,7 +16,7 @@ # GNU General Public License for more details. SCRIPT_NAME="remove-driver.sh" -SCRIPT_VERSION="20221228" +SCRIPT_VERSION="20230109" MODULE_NAME="88x2bu" DRV_VERSION="5.13.1" @@ -57,7 +57,7 @@ do done # displays script name and version -echo "Script: ${SCRIPT_NAME} version ${SCRIPT_VERSION}" +echo "Script: ${SCRIPT_NAME} v${SCRIPT_VERSION}" # check for and remove non-dkms installations # standard naming @@ -94,7 +94,7 @@ fi echo "Kernel: ${KVER}" # display architecture -echo "Arch: ${KARCH}" +echo "Arch : ${KARCH}" # determine if dkms is installed and run the appropriate routines if command -v dkms >/dev/null 2>&1