Hosted: Handle devices w/o serial number, e.g. GigaDevices GD-Link ARM/CMSIS-DAP

This commit is contained in:
Uwe Bonnes 2020-12-09 17:33:47 +01:00
parent 0f1fe9e438
commit 4c5ce0b16a
2 changed files with 16 additions and 10 deletions

View File

@ -98,12 +98,19 @@ int find_debuggers(BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
char serial[64];
char manufacturer[128];
char product[128];
bmp_type_t type = BMP_TYPE_NONE;
bmp_type_t type;
bool access_problems = false;
char *active_cable = NULL;
bool ftdi_unknown = false;
rescan:
type = BMP_TYPE_NONE;
found_debuggers = 0;
serial[0] = 0;
manufacturer[0] = 0;
product[0] = 0;
access_problems = false;
active_cable = NULL;
ftdi_unknown = false;
for (int i = 0; devs[i]; i++) {
libusb_device *dev = devs[i];
int res = libusb_get_device_descriptor(dev, &desc);
@ -130,12 +137,8 @@ int find_debuggers(BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
res = libusb_get_string_descriptor_ascii(
handle, desc.iSerialNumber, (uint8_t*)serial,
sizeof(serial));
if (res <= 0) {
/* This can fail for many devices. Continue silent!*/
libusb_close(handle);
continue;
}
if (cl_opts->opt_serial && !strstr(serial, cl_opts->opt_serial)) {
if (cl_opts->opt_serial && ((res <= 0) ||
!strstr(serial, cl_opts->opt_serial))) {
libusb_close(handle);
continue;
}
@ -154,6 +157,9 @@ int find_debuggers(BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
libusb_close(handle);
continue;
}
} else {
libusb_close(handle);
continue;
}
libusb_close(handle);
if (cl_opts->opt_ident_string) {

View File

@ -56,18 +56,18 @@ int dap_init(bmp_info_t *info)
if (hid_init())
return -1;
int size = strlen(info->serial);
wchar_t serial[size + 1], *wc = serial;
wchar_t serial[64] = {0}, *wc = serial;
for (int i = 0; i < size; i++)
*wc++ = info->serial[i];
*wc = 0;
/* Blacklist devices that do not wirk with 513 byte report length
/* Blacklist devices that do not work with 513 byte report length
* FIXME: Find a solution to decipher from the device.
*/
if ((info->vid == 0x1fc9) && (info->pid == 0x0132)) {
DEBUG_WARN("Blacklist\n");
report_size = 64 + 1;
}
handle = hid_open(info->vid, info->pid, serial);
handle = hid_open(info->vid, info->pid, (serial[0]) ? serial : NULL);
if (!handle)
return -1;
dap_disconnect();