1
0
mirror of https://github.com/bluekitchen/btstack.git synced 2025-03-25 16:43:28 +00:00

libusb: add known realtek usb controllers, configure chipset support

This commit is contained in:
Matthias Ringwald 2022-04-14 18:06:29 +02:00
parent 4a4e2291e1
commit df9a25ac84
4 changed files with 64 additions and 9 deletions

@ -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)

@ -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

@ -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!

@ -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<usb_path_len;i++){
if (i) printf("-");
printf("%02x", usb_path[i]);
}
printf("\n");
// set Product ID for Realtek Controllers
btstack_chipset_realtek_set_product_id(product_id);
break;
case BTSTACK_EVENT_STATE:
switch (btstack_event_state_get_state(packet)){
@ -259,6 +268,16 @@ int main(int argc, const char * argv[]){
// register callback for CTRL-c
btstack_signal_register_callback(SIGINT, &trigger_shutdown);
// register known Realtek USB Controllers
uint16_t realtek_num_controllers = btstack_chipset_realtek_get_num_usb_controllers();
uint16_t i;
for (i=0;i<realtek_num_controllers;i++){
uint16_t vendor_id;
uint16_t product_id;
btstack_chipset_realtek_get_vendor_product_id(i, &vendor_id, &product_id);
hci_transport_usb_add_device(vendor_id, product_id);
}
// setup app
btstack_main(argc, argv);