diff --git a/demo/main.cpp b/demo/main.cpp index 5f2843b..74dfe3e 100644 --- a/demo/main.cpp +++ b/demo/main.cpp @@ -8,7 +8,15 @@ #include "WiFiDriver.h" #define USB_VENDOR_ID 0x0bda -#define USB_PRODUCT_ID 0x8812 + +/* Known USB product IDs for RTL8812AU (2T2R) and RTL8811AU (1T1R, 1x1 cut of + * the same Jaguar silicon). Both are driven by this library. */ +static constexpr uint16_t kRealtekProductIds[] = { + 0x8812, /* RTL8812AU (also seen on some 8811AU boards) */ + 0x0811, /* RTL8811AU */ + 0xa811, /* RTL8811AU */ + 0xb811, /* RTL8811AU/8821AU variants */ +}; static void packetProcessor(const Packet &packet) {} @@ -25,11 +33,17 @@ int main() { libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_DEBUG); - libusb_device_handle *dev_handle = - libusb_open_device_with_vid_pid(ctx, USB_VENDOR_ID, USB_PRODUCT_ID); + libusb_device_handle *dev_handle = nullptr; + for (uint16_t pid : kRealtekProductIds) { + dev_handle = libusb_open_device_with_vid_pid(ctx, USB_VENDOR_ID, pid); + if (dev_handle != NULL) { + logger->info("Opened Realtek device {:04x}:{:04x}", USB_VENDOR_ID, pid); + break; + } + } if (dev_handle == NULL) { - logger->error("Cannot find device {:04x}:{:04x}", USB_VENDOR_ID, - USB_PRODUCT_ID); + logger->error("Cannot find any supported Realtek device under VID {:04x}", + USB_VENDOR_ID); libusb_exit(ctx); return 1; } diff --git a/src/EepromManager.cpp b/src/EepromManager.cpp index ada3863..e3551ae 100644 --- a/src/EepromManager.cpp +++ b/src/EepromManager.cpp @@ -47,11 +47,15 @@ void EepromManager::read_chip_version_8812a(RtlUsbAdapter device) { .ICType = CHIP_8812, .ChipType = (value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP, .VendorType = (value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC, - .RFType = RF_TYPE_2T2R, /* RF_2T2R; */ + /* SYS_CFG bit 27 (RF_TYPE_ID): set on 1T1R cuts (RTL8811AU), + * clear on 2T2R cuts (RTL8812AU). */ + .RFType = (value32 & RF_TYPE_ID) ? RF_TYPE_1T1R : RF_TYPE_2T2R, }; + /* Manual override: force 1T1R even when SYS_CFG reports 2T2R + * (useful if EFUSE/strap is mis-burnt on a 1T1R board). */ if (registry_priv::special_rf_path == 1) { - version_id.RFType = RF_TYPE_1T1R; /* RF_1T1R; */ + version_id.RFType = RF_TYPE_1T1R; } version_id.CUTVersion = (HAL_CUT_VERSION_E)(((value32 & CHIP_VER_RTL_MASK) >>