OpenWRT and Tracking Down Firmeware Drivers and KMOD Stuff

wiki.TerraBase.info
Revision as of 00:40, 27 August 2024 by Root (talk | contribs) (Created page with "Wanna track down Firmware / Driver and / or KMOD Module for some obscure USB Wireless Device? Search forums? Result: Hair ripping out pain reading through all the drivel. Just no. Rely on the actual Chip or Chipset that is in the device, either by visually looking at the microscopic printing on the Chip or by the description of the seller or by plugging it into Windows computer and using something like USB Tree View or AIDA to figure it out. Sure, that often works....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Wanna track down Firmware / Driver and / or KMOD Module for some obscure USB Wireless Device? Search forums? Result: Hair ripping out pain reading through all the drivel. Just no. Rely on the actual Chip or Chipset that is in the device, either by visually looking at the microscopic printing on the Chip or by the description of the seller or by plugging it into Windows computer and using something like USB Tree View or AIDA to figure it out. Sure, that often works. But...

Here's a live example for a very inexpensive USB Device with DUAL

  • lspci -nn
  • lsusb

Bus 007 Device 002: ID 0bda:c811 Realtek 802.11ac NIC

Vendor ID: 0bda:c811

grep -i "0bda.*c811" /lib/modules/$(uname -r)/modules.alias

alias usb:v0BDApC811d*dc*dsc*dp*icFFiscFFipFFin* rtl8821CU

lsmod

filename:       /lib/modules/6.1.25/rtl8821CU.ko
import_ns:      VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver
version:        v5.4.1_28754.20180921_COEX20180712-3232
author:         Realtek Semiconductor Corp.
description:    Realtek Wireless Lan Driver
license:        GPL
srcversion:     FCEA94BFD2918CC097B1D1E
alias:          usb:v2001p331Dd*dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v0BDAp2006d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp8811d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDApC811d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDApC82Bd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDApC82Ad*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDApC820d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDApC821d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDApB820d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDApB82Bd*dc*dsc*dp*icFFiscFFipFFin*
depends:        cfg80211
name:           rtl8821CU
vermagic:       6.1.25 SMP mod_unload modversions aarch64
parm:           rtw_wireless_mode:int
parm:           rtw_ips_mode:The default IPS mode (int)
parm:           rtw_lps_level:The default LPS level (int)
parm:           rtw_max_bss_cnt:int
parm:           rtw_usb_rxagg_mode:int
parm:           rtw_dynamic_agg_enable:int
parm:           rtw_drv_log_level:set log level when insert driver module, default log level is _DRV_INFO_ = 4 (uint)
parm:           rtw_tx_bw_mode:The max tx bw for 2.4G and 5G. format is the same as rtw_bw_mode (uint)
parm:           rtw_rx_ampdu_sz_limit_1ss:RX AMPDU size limit for 1SS link of each BW, 0xFF: no limitation (array of uint)
parm:           rtw_rx_ampdu_sz_limit_2ss:RX AMPDU size limit for 2SS link of each BW, 0xFF: no limitation (array of uint)
parm:           rtw_rx_ampdu_sz_limit_3ss:RX AMPDU size limit for 3SS link of each BW, 0xFF: no limitation (array of uint)
parm:           rtw_rx_ampdu_sz_limit_4ss:RX AMPDU size limit for 4SS link of each BW, 0xFF: no limitation (array of uint)
parm:           rtw_vht_enable:int
parm:           rtw_vht_rx_mcs_map:VHT RX MCS map (uint)
parm:           rtw_rf_config:int
parm:           rtw_country_code:The default country code (in alpha2) (charp)
parm:           rtw_channel_plan:The default chplan ID when rtw_alpha2 is not specified or valid (int)
parm:           rtw_excl_chs:exclusive channel array (array of uint)
parm:           rtw_btcoex_enable:BT co-existence on/off, 0:off, 1:on, 2:by efuse (int)
parm:           rtw_ant_num:Antenna number setting, 0:by efuse (int)
parm:           rtw_qos_opt_enable:int
parm:           ifname:The default name to allocate for first interface (charp)
parm:           if2name:The default name to allocate for second interface (charp)
parm:           rtw_pwrtrim_enable:int
parm:           rtw_initmac:charp
parm:           rtw_special_rf_path:int
parm:           rtw_chip_version:int
parm:           rtw_rfintfs:int
parm:           rtw_lbkmode:int
parm:           rtw_network_mode:int
parm:           rtw_channel:int
parm:           rtw_mp_mode:int
parm:           rtw_wmm_enable:int
parm:           rtw_vrtl_carrier_sense:int
parm:           rtw_vcs_type:int
parm:           rtw_busy_thresh:int
parm:           rtw_ht_enable:int
parm:           rtw_bw_mode:int
parm:           rtw_ampdu_enable:int
parm:           rtw_rx_stbc:int
parm:           rtw_rx_ampdu_amsdu:int
parm:           rtw_tx_ampdu_amsdu:int
parm:           rtw_lowrate_two_xmit:int
parm:           rtw_power_mgnt:int
parm:           rtw_smart_ps:int
parm:           rtw_low_power:int
parm:           rtw_wifi_spec:int
parm:           rtw_full_ch_in_p2p_handshake:int
parm:           rtw_antdiv_cfg:int
parm:           rtw_antdiv_type:int
parm:           rtw_drv_ant_band_switch:int
parm:           rtw_single_ant_path:int
parm:           rtw_switch_usb_mode:int
parm:           rtw_enusbss:int
parm:           rtw_hwpdn_mode:int
parm:           rtw_hwpwrp_detect:int
parm:           rtw_hw_wps_pbc:int
parm:           rtw_check_hw_status:int
parm:           rtw_max_roaming_times:The max roaming times to try (uint)
parm:           rtw_mc2u_disable:int
parm:           rtw_notch_filter:0:Disable, 1:Enable, 2:Enable only for P2P (uint)
parm:           rtw_hiq_filter:0:allow all, 1:allow special, 2:deny all (uint)
parm:           rtw_adaptivity_en:0:disable, 1:enable (uint)
parm:           rtw_adaptivity_mode:0:normal, 1:carrier sense (uint)
parm:           rtw_adaptivity_th_l2h_ini:th_l2h_ini for Adaptivity (int)
parm:           rtw_adaptivity_th_edcca_hl_diff:th_edcca_hl_diff for Adaptivity (int)
parm:           rtw_amplifier_type_2g:BIT3:2G ext-PA, BIT4:2G ext-LNA (uint)
parm:           rtw_amplifier_type_5g:BIT6:5G ext-PA, BIT7:5G ext-LNA (uint)
parm:           rtw_RFE_type:default init value:64 (uint)
parm:           rtw_powertracking_type:default init value:64 (uint)
parm:           rtw_GLNA_type:default init value:0 (uint)
parm:           rtw_TxBBSwing_2G:default init value:0xFF (uint)
parm:           rtw_TxBBSwing_5G:default init value:0xFF (uint)
parm:           rtw_OffEfuseMask:default open Efuse Mask value:0 (uint)
parm:           rtw_FileMaskEfuse:default drv Mask Efuse value:0 (uint)
parm:           rtw_rxgain_offset_2g:default RF Gain 2G Offset value:0 (uint)
parm:           rtw_rxgain_offset_5gl:default RF Gain 5GL Offset value:0 (uint)
parm:           rtw_rxgain_offset_5gh:uint
parm:           rtw_rxgain_offset_5gm:default RF Gain 5GM Offset value:0 (uint)
parm:           rtw_pll_ref_clk_sel:force pll_ref_clk_sel, 0xF:use autoload value (uint)
parm:           rtw_tx_pwr_by_rate:0:Disable, 1:Enable, 2: Depend on efuse (int)
parm:           rtw_target_tx_pwr_2g_a:2.4G target tx power (unit:dBm) of RF path A for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_target_tx_pwr_2g_b:2.4G target tx power (unit:dBm) of RF path B for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_target_tx_pwr_2g_c:2.4G target tx power (unit:dBm) of RF path C for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_target_tx_pwr_2g_d:2.4G target tx power (unit:dBm) of RF path D for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_target_tx_pwr_5g_a:5G target tx power (unit:dBm) of RF path A for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_target_tx_pwr_5g_b:5G target tx power (unit:dBm) of RF path B for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_target_tx_pwr_5g_c:5G target tx power (unit:dBm) of RF path C for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_target_tx_pwr_5g_d:5G target tx power (unit:dBm) of RF path D for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_tsf_update_pause_factor:num of bcn intervals to stay TSF update pause status (int)
parm:           rtw_tsf_update_restore_factor:num of bcn intervals to stay TSF update restore status (int)
parm:           rtw_phy_file_path:The path of phy parameter (charp)
parm:           rtw_load_phy_file:PHY File Bit Map (int)
parm:           rtw_decrypt_phy_file:Enable Decrypt PHY File (int)
parm:           rtw_en_napi:int
parm:           rtw_en_gro:int
parm:           rtw_iqk_fw_offload:int
parm:           rtw_ch_switch_offload:int

The following command: iw phy phy1 info (use iw dev if multiple adapters are connected to determine which device to display information for) ...will display the below information;

Wiphy phy1
        wiphy index: 1
        max # scan SSIDs: 9
        max scan IEs length: 2304 bytes
        max # sched scan SSIDs: 0
        max # match sets: 0
        Retry short limit: 7
        Retry long limit: 4
        Coverage class: 0 (up to 0m)
        Available Antennas: TX 0 RX 0
        Supported interface modes:
                 * IBSS
                 * managed
                 * AP
                 * monitor
                 * P2P-client
                 * P2P-GO
        Band 1:
                Frequencies:
                        * 2412 MHz [1] (20.0 dBm)
                        * 2417 MHz [2] (20.0 dBm)
                        * 2422 MHz [3] (20.0 dBm)
                        * 2427 MHz [4] (20.0 dBm)
                        * 2432 MHz [5] (20.0 dBm)
                        * 2437 MHz [6] (20.0 dBm)
                        * 2442 MHz [7] (20.0 dBm)
                        * 2447 MHz [8] (20.0 dBm)
                        * 2452 MHz [9] (20.0 dBm)
                        * 2457 MHz [10] (20.0 dBm)
                        * 2462 MHz [11] (20.0 dBm)
                        * 2467 MHz [12] (20.0 dBm) (no IR)
                        * 2472 MHz [13] (20.0 dBm) (no IR)
                        * 2484 MHz [14] (disabled)
        Band 2:
                Frequencies:
                        * 5180 MHz [36] (23.0 dBm)
                        * 5200 MHz [40] (23.0 dBm)
                        * 5220 MHz [44] (23.0 dBm)
                        * 5240 MHz [48] (23.0 dBm)
                        * 5260 MHz [52] (23.0 dBm) (no IR, radar detection)
                        * 5280 MHz [56] (23.0 dBm) (no IR, radar detection)
                        * 5300 MHz [60] (23.0 dBm) (no IR, radar detection)
                        * 5320 MHz [64] (23.0 dBm) (no IR, radar detection)
                        * 5500 MHz [100] (30.0 dBm) (no IR, radar detection)
                        * 5520 MHz [104] (30.0 dBm) (no IR, radar detection)
                        * 5540 MHz [108] (30.0 dBm) (no IR, radar detection)
                        * 5560 MHz [112] (30.0 dBm) (no IR, radar detection)
                        * 5580 MHz [116] (30.0 dBm) (no IR, radar detection)
                        * 5600 MHz [120] (30.0 dBm) (no IR, radar detection)
                        * 5620 MHz [124] (30.0 dBm) (no IR, radar detection)
                        * 5640 MHz [128] (30.0 dBm) (no IR, radar detection)
                        * 5660 MHz [132] (30.0 dBm) (no IR, radar detection)
                        * 5680 MHz [136] (30.0 dBm) (no IR, radar detection)
                        * 5700 MHz [140] (30.0 dBm) (no IR, radar detection)
                        * 5720 MHz [144] (disabled)
                        * 5745 MHz [149] (30.0 dBm)
                        * 5765 MHz [153] (30.0 dBm)
                        * 5785 MHz [157] (30.0 dBm)
                        * 5805 MHz [161] (30.0 dBm)
                        * 5825 MHz [165] (30.0 dBm)
                        * 5845 MHz [169] (disabled)
                        * 5865 MHz [173] (disabled)
                        * 5885 MHz [177] (disabled)
        interface combinations are not supported
        max # scan plans: 1
        max scan plan interval: -1
        max scan plan iterations: 0
        Supported extended features:

...ChatGPT Notes;

On Linux and OpenWRT, most of the driver and device mapping information is indeed compiled into binary files, such as kernel modules and system binaries. However, there are still some plain text files on the device that you can inspect to gather information about supported devices and drivers. Here are the key locations and files you might find useful:

### 1. **`/lib/modules/$(uname -r)/modules.alias`**

   - This is a plain text file generated by the kernel build process that maps device IDs to the modules that support them. It’s one of the most useful files for determining which driver supports a particular device.

   

   Example command to search for your device:

   ```sh

   grep "7922" /lib/modules/$(uname -r)/modules.alias

   ```

### 2. **`/lib/modules/$(uname -r)/modules.dep`**

   - This file lists dependencies between kernel modules. While it doesn't directly show device IDs, it can be useful for understanding the relationships between different modules.

   To search for a particular module:

   ```sh

   grep "mt7921e" /lib/modules/$(uname -r)/modules.dep

   ```

### 3. **`/lib/modules/$(uname -r)/modules.builtin`**

   - This file lists all the modules that are built into the kernel. If a driver is built into the kernel rather than as a loadable module, it would be listed here.

   Example command to check for a built-in module:

   ```sh

   grep "mt7921e" /lib/modules/$(uname -r)/modules.builtin

   ```

### 4. **`/sys/class/net/<interface>/device/modalias`**

   - This is a small text file that contains the alias for the device, which is used to match it with the appropriate module.

   Example command:

   ```sh

   cat /sys/class/net/wlan0/device/modalias

   ```

   This will output a string that you can then search for in `modules.alias` or `modinfo`.

### 5. **`/proc/bus/pci/devices`**

   - This file contains information about PCI devices detected by the system, including vendor and device IDs, though it doesn’t directly map them to drivers.

   To inspect it:

   ```sh

   cat /proc/bus/pci/devices

   ```

### 6. **`/usr/share/misc/pci.ids`**

   - As mentioned earlier, this file is a database of known PCI IDs. It’s a plain text file and can confirm that a device is recognized, though it won’t tell you which driver supports it.

   To search for your device:

   ```sh

   grep "7922" /usr/share/misc/pci.ids

   ```

### 7. **Device Tree Files (`/proc/device-tree` or `/sys/firmware/devicetree/base`)**

   - These files (if applicable on your device) describe the hardware layout to the kernel, including information about devices and their compatible drivers. They are often used on ARM-based systems like the RK3568.

   

   To explore these:

   ```sh

   ls /proc/device-tree/

   ```

These files can provide a lot of useful information, even though much of the driver-device mapping is handled within compiled binaries. If you’re looking for a text file that explicitly lists every supported device, similar to a Windows `.ini` file, the closest equivalent is the `modules.alias` file on the device.


OR


In Linux, the equivalent of Windows' .ini files for driver support information is typically found in a combination of kernel source code, module source files, and device ID mappings that the driver uses to determine hardware compatibility.

### Methods to Find Supported Devices in Linux:

1. **Kernel Source Code and Module Files**:

   - The kernel source code for a particular driver often contains a list of supported devices by PCI IDs (like the 7922 you mentioned).

   - If you have the source code for the driver, you can search for the PCI ID in the driver files.

   For example, you might search in the driver directory (assuming you have access to the source code):

   ```sh

   grep -r "0x7922" /path/to/kernel/source/drivers/net/wireless/mediatek/mt7921/

   ```

   This command searches for the string 0x7922 in the driver files, indicating that the driver supports the device.

2. **PCI ID Database (`/usr/share/misc/pci.ids`)**:

   - This file contains a list of known PCI IDs and their associated vendors and devices. It's useful to confirm that the device is recognized but doesn't show which drivers support it.

   

   You can search for the device ID in the pci.ids file:

   ```sh

   grep "7922" /usr/share/misc/pci.ids

   ```

   However, this only tells you about the device itself, not the driver support.

3. **Module Information (`modinfo`)**:

   - The `modinfo` command shows detailed information about a kernel module, including the list of supported device IDs (if available).

   

   For example:

   ```sh

   modinfo mt7921e | grep -i "alias"

   ```

   This command will show all the PCI aliases (device IDs) that the `mt7921e` module supports. If `7922` appears, it confirms that the driver supports your device.

4. **Device ID Lists in `/lib/modules/$(uname -r)/modules.alias`**:

   - The `modules.alias` file contains mappings of device IDs to the modules that support them. This file is generated automatically when modules are built.

   You can search this file to see if your device is supported by any module:

   ```sh

   grep "7922" /lib/modules/$(uname -r)/modules.alias

   ```

   This will show you which module(s) claim to support the `7922` device ID.

### Example Workflow:

To find out which driver supports the `7922` device:

1. **Search `modules.alias`**:

   ```sh

   grep "7922" /lib/modules/$(uname -r)/modules.alias

   ```

   Output might look something like:

   ```

   alias pci:v000014C3d00007922sv*sd*bc*sc*i* mt7921e

   ```

   This line means that the `mt7921e` module supports the PCI device with vendor ID `0x14C3` and device ID `0x7922`.

2. **Use `modinfo` to Verify**:

   ```sh

   modinfo mt7921e | grep "7922"

   ```

   This should confirm that the driver includes support for the device.

By following these steps, you can verify whether a driver supports a particular device in Linux, similar to how you would examine a `.ini` file in Windows.