diff --git a/port/libusb/CMakeLists.txt b/port/libusb/CMakeLists.txt index e35d6ee9c..708252fb1 100644 --- a/port/libusb/CMakeLists.txt +++ b/port/libusb/CMakeLists.txt @@ -64,6 +64,7 @@ include_directories(../../3rd-party/rijndael) include_directories(../../3rd-party/yxml) include_directories(../../3rd-party/tinydir) include_directories(../../src) +include_directories(../../chipset/realtek) include_directories(../../chipset/zephyr) include_directories(../../platform/posix) include_directories(../../platform/embedded) @@ -84,6 +85,7 @@ file(GLOB SOURCES_RIJNDAEL "../../3rd-party/rijndael/rijndael.c") file(GLOB SOURCES_POSIX "../../platform/posix/*.c") file(GLOB SOURCES_LIBUSB "../../port/libusb/*.c" "../../platform/libusb/*.c") file(GLOB SOURCES_ZEPHYR "../../chipset/zephyr/*.c") +file(GLOB SOURCES_REALTEK "../../chipset/realtek/*.c") set(LWIP_CORE_SRC ../../3rd-party/lwip/core/src/core/def.c @@ -150,6 +152,7 @@ set(SOURCES ${SOURCES_CLASSIC} ${SOURCES_UECC} ${SOURCES_HXCMOD} + ${SOURCES_REALTEK} ${SOURCES_ZEPHYR} ) list(SORT SOURCES) diff --git a/port/libusb/Makefile b/port/libusb/Makefile index 96b9a0094..85b060fa8 100644 --- a/port/libusb/Makefile +++ b/port/libusb/Makefile @@ -21,6 +21,7 @@ CFLAGS += -I${BTSTACK_ROOT}/platform/posix \ -I${BTSTACK_ROOT}/platform/embedded \ -I${BTSTACK_ROOT}/3rd-party/tinydir \ -I${BTSTACK_ROOT}/3rd-party/rijndael \ + -I${BTSTACK_ROOT}/chipset/realtek \ -I${BTSTACK_ROOT}/chipset/zephyr VPATH += ${BTSTACK_ROOT}/3rd-party/rijndael @@ -28,6 +29,7 @@ VPATH += ${BTSTACK_ROOT}/platform/embedded VPATH += ${BTSTACK_ROOT}/platform/posix VPATH += ${BTSTACK_ROOT}/platform/libusb VPATH += ${BTSTACK_ROOT}/chipset/csr +VPATH += ${BTSTACK_ROOT}/chipset/realtek VPATH += ${BTSTACK_ROOT}/chipset/zephyr # use pkg-config diff --git a/port/libusb/README.md b/port/libusb/README.md index 967c9fb06..cd9329ba5 100644 --- a/port/libusb/README.md +++ b/port/libusb/README.md @@ -29,6 +29,9 @@ To add an udev rule, please create `/etc/udev/rules.d/btstack.rules` and add thi # Match all devices from CSR SUBSYSTEM=="usb", ATTRS{idVendor}=="0a12", MODE="0666" + # Match all devices from Realtek + SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", MODE="0666" + # Match Cypress Semiconductor / Broadcom BCM20702A, e.g. DeLOCK Bluetooth 4.0 dongle SUBSYSTEM=="usb", ATTRS{idVendor}=="0a5c", ATTRS{idProduct}=="21e8", MODE="0666" @@ -57,6 +60,15 @@ Note: if you get this error, and you didn't start another instance and you didn't assign the USB Controller to a virtual machine, macOS uses the plugged-in Bluetooth Controller. Please configure NVRAM as explained and try again after a reboot. +### Broadcom/Cypress/Infineon Controllers +During startup BTstack queries the Controlle for the Local Name, which is set to the Controller type (e.g. 'BCM20702A). +The chipset support uses this information to look for a local PatchRAM file of that name and uploads it. + +### Realtek Controllers +During startup, the libusb HCI transport implementations reports the USB Vendor/Product ID, which is then forwarded to the Realtek chipset support. +The chipset support contains a mapping between USB Product ID and ( Patch, Configuration ) files. If found, these are +uploaded. + ## Running the examples @@ -67,23 +79,42 @@ On start, BTstack will try to find a suitable Bluetooth module. It will also pri $ ./le_counter Packet Log: /tmp/hci_dump.pklg BTstack counter 0001 - USB Path: 06 - BTstack up and running on 00:1A:7D:DA:71:13. + Packet Log: /tmp/hci_dump_6.pklg + USB device 0x0a12/0x0001, path: 06 + Local version information: + - HCI Version 0x0006 + - HCI Revision 0x22bb + - LMP Version 0x0006 + - LMP Subversion 0x22bb + - Manufacturer 0x000a + BTstack up and running on 00:1A:7D:DA:71:01. If you want to run multiple examples at the same time, it helps to fix the path to the used Bluetooth module by passing -u usb-path to the executable. -Example running le_streamer and le_streamer_client in two processes, using Bluetooth dongles at USB path 6 and 4: +Example running le_streamer and le_streamer_client in two processes, using CSR Bluetooth dongles at USB path 6 and 4: ./le_streamer -u 6 Specified USB Path: 06 Packet Log: /tmp/hci_dump_6.pklg - USB Path: 06 - BTstack up and running on 00:1A:7D:DA:71:13. + USB device 0x0a12/0x0001, path: 06 + Local version information: + - HCI Version 0x0006 + - HCI Revision 0x22bb + - LMP Version 0x0006 + - LMP Subversion 0x22bb + - Manufacturer 0x000a + BTstack up and running on 00:1A:7D:DA:71:01. To start the streaming, please run the le_streamer_client example on other device, or use some GATT Explorer, e.g. LightBlue, BLExplr. $ ./le_streamer_client -u 4 Specified USB Path: 04 Packet Log: /tmp/hci_dump_4.pklg - USB Path: 04 - BTstack up and running on 00:1A:7D:DA:71:13. + USB device 0x0a12/0x0001, path: 04 + Local version information: + - HCI Version 0x0006 + - HCI Revision 0x22bb + - LMP Version 0x0006 + - LMP Subversion 0x22bb + - Manufacturer 0x000a + BTstack up and running on 00:1A:7D:DA:71:02. Start scanning! diff --git a/port/libusb/main.c b/port/libusb/main.c index 0f607de5d..66ab58928 100644 --- a/port/libusb/main.c +++ b/port/libusb/main.c @@ -54,6 +54,7 @@ #include "ble/le_device_db_tlv.h" #include "bluetooth_company_id.h" #include "btstack_audio.h" +#include "btstack_chipset_realtek.h" #include "btstack_chipset_zephyr.h" #include "btstack_debug.h" #include "btstack_event.h" @@ -110,6 +111,11 @@ static void local_version_information_handler(uint8_t * packet){ // sm required to setup static random Bluetooth address sm_init(); break; + case BLUETOOTH_COMPANY_ID_REALTEK_SEMICONDUCTOR_CORPORATION: + printf("- Realtek controller - provide firmware and config\n"); + btstack_chipset_realtek_set_lmp_subversion(lmp_subversion); + hci_set_chipset(btstack_chipset_realtek_instance()); + break; default: break; } @@ -121,6 +127,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack uint8_t i; uint8_t usb_path_len; const uint8_t * usb_path; + uint16_t product_id; if (packet_type != HCI_EVENT_PACKET) return; @@ -129,14 +136,16 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack usb_path_len = hci_event_transport_usb_info_get_path_len(packet); usb_path = hci_event_transport_usb_info_get_path(packet); // print device path + product_id = hci_event_transport_usb_info_get_product_id(packet); printf("USB device 0x%04x/0x%04x, path: ", - hci_event_transport_usb_info_get_vendor_id(packet), - hci_event_transport_usb_info_get_product_id(packet)); + hci_event_transport_usb_info_get_vendor_id(packet), product_id); for (i=0;i