drivers/jlink: Print serial numbers when multiple devices are connected

When multiple jlink programmers are connected and no specific serial
or USB location is specified, print out the detected serial numbers.

Signed-off-by: Marcus Nilsson <brainbomb@gmail.com>
Change-Id: I280da2b85363f7054c5f466637120427cadcf7d1
Reviewed-on: https://review.openocd.org/c/openocd/+/8356
Reviewed-by: Mark Zhuang <mark.zhuang@spacemit.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
This commit is contained in:
Marcus Nilsson 2024-08-07 11:24:04 +02:00 committed by Antonio Borneo
parent f0bad430df
commit 0efedd7bd7
1 changed files with 14 additions and 0 deletions

View File

@ -564,6 +564,20 @@ static int jlink_open_device(uint32_t ifaces, bool *found_device)
if (!use_serial_number && !use_usb_address && !use_usb_location && num_devices > 1) { if (!use_serial_number && !use_usb_address && !use_usb_location && num_devices > 1) {
LOG_ERROR("Multiple devices found, specify the desired device"); LOG_ERROR("Multiple devices found, specify the desired device");
LOG_INFO("Found devices:");
for (size_t i = 0; devs[i]; i++) {
uint32_t serial;
ret = jaylink_device_get_serial_number(devs[i], &serial);
if (ret == JAYLINK_ERR_NOT_AVAILABLE) {
continue;
} else if (ret != JAYLINK_OK) {
LOG_WARNING("jaylink_device_get_serial_number() failed: %s",
jaylink_strerror(ret));
continue;
}
LOG_INFO("Device %zu serial: %" PRIu32, i, serial);
}
jaylink_free_devices(devs, true); jaylink_free_devices(devs, true);
jaylink_exit(jayctx); jaylink_exit(jayctx);
return ERROR_JTAG_INIT_FAILED; return ERROR_JTAG_INIT_FAILED;