diff --git a/src/platforms/hosted/bmp_libusb.c b/src/platforms/hosted/bmp_libusb.c index ec4c7f8d221..07af85b7422 100644 --- a/src/platforms/hosted/bmp_libusb.c +++ b/src/platforms/hosted/bmp_libusb.c @@ -65,7 +65,7 @@ typedef struct debugger_device { } debugger_device_s; /* Create the list of debuggers BMDA works with */ -debugger_device_s debugger_devices[] = { +static const debugger_device_s debugger_devices[] = { {VENDOR_ID_BMP, PRODUCT_ID_BMP, BMP_TYPE_BMP, bmp_read_product_version, "Black Magic Probe"}, {VENDOR_ID_STLINK, PRODUCT_ID_STLINKV2, BMP_TYPE_STLINK_V2, stlinkv2_read_serial, "ST-Link v2"}, {VENDOR_ID_STLINK, PRODUCT_ID_STLINKV21, BMP_TYPE_STLINK_V2, NULL, "ST-Link v2.1"}, @@ -73,25 +73,27 @@ debugger_device_s debugger_devices[] = { {VENDOR_ID_STLINK, PRODUCT_ID_STLINKV3_NO_MSD, BMP_TYPE_STLINK_V2, NULL, "ST-Link v2.1 No MSD"}, {VENDOR_ID_STLINK, PRODUCT_ID_STLINKV3, BMP_TYPE_STLINK_V2, NULL, "ST-Link v3"}, {VENDOR_ID_STLINK, PRODUCT_ID_STLINKV3E, BMP_TYPE_STLINK_V2, NULL, "ST-Link v3E"}, - {VENDOR_ID_SEGGER, PRODUCT_ID_UNKNOWN, BMP_TYPE_JLINK, NULL, "Segger JLink"}, + {VENDOR_ID_SEGGER, PRODUCT_ID_ANY, BMP_TYPE_JLINK, NULL, "Segger JLink"}, {VENDOR_ID_FTDI, PRODUCT_ID_FTDI_FT2232, BMP_TYPE_FTDI, NULL, "FTDI FT2232"}, {VENDOR_ID_FTDI, PRODUCT_ID_FTDI_FT4232, BMP_TYPE_FTDI, NULL, "FTDI FT4232"}, {VENDOR_ID_FTDI, PRODUCT_ID_FTDI_FT232, BMP_TYPE_FTDI, NULL, "FTDI FT232"}, {0, 0, BMP_TYPE_NONE, NULL, ""}, }; -bmp_type_t get_type_from_vid_pid(const uint16_t probe_vid, const uint16_t probe_pid) +const debugger_device_s *get_debugger_device_from_vid_pid(const uint16_t probe_vid, const uint16_t probe_pid) { - bmp_type_t probe_type = BMP_TYPE_NONE; - /* Segger probe PIDs are unknown, if we have a Segger probe force the type to JLink */ - if (probe_vid == VENDOR_ID_SEGGER) - return BMP_TYPE_JLINK; - - for (size_t index = 0; debugger_devices[index].type != BMP_TYPE_NONE; index++) { - if (debugger_devices[index].vendor == probe_vid && debugger_devices[index].product == probe_pid) - return debugger_devices[index].type; + /* Iterate over the list excluding the last entry (BMP_TYPE_NONE) */ + for (size_t index = 0; index < ARRAY_LENGTH(debugger_devices) - 1U; index++) { + /* Check for a vendor id match */ + if (debugger_devices[index].vendor != probe_vid) + continue; + + /* If the map product id is "any", then we accept all products ids, otherwise check for a match */ + if (debugger_devices[index].product == PRODUCT_ID_ANY || probe_pid == debugger_devices[index].product) + return &debugger_devices[index]; } - return probe_type; + /* Return the last entry in the list (BMP_TYPE_NONE) */ + return &debugger_devices[ARRAY_LENGTH(debugger_devices) - 1U]; } void bmp_ident(bmp_info_s *info) @@ -116,7 +118,7 @@ void libusb_exit_function(bmp_info_s *info) static char *get_device_descriptor_string(libusb_device_handle *handle, uint16_t string_index) { - char read_string[128] = {0}; + char read_string[128U] = {0}; if (string_index != 0) { const int result = libusb_get_string_descriptor_ascii(handle, string_index, (uint8_t *)read_string, sizeof(read_string)); @@ -148,8 +150,8 @@ void bmp_read_product_version(libusb_device_descriptor_s *device_descriptor, lib while (start_of_version[0] == ' ' && start_of_version != *product) --start_of_version; - start_of_version[1] = '\0'; - start_of_version += 2; + start_of_version[1U] = '\0'; + start_of_version += 2U; while (start_of_version[0] == ' ') ++start_of_version; *version = strdup(start_of_version); @@ -167,7 +169,7 @@ void stlinkv2_read_serial(libusb_device_descriptor_s *device_descriptor, libusb_ (void)manufacturer; (void)version; /* libusb_get_string_descriptor requires a byte buffer, but returns char16_t's */ - char16_t raw_serial[64] = {0}; + char16_t raw_serial[64U] = {0}; const int raw_length = libusb_get_string_descriptor( handle, device_descriptor->iSerialNumber, 0x0409U, (uint8_t *)raw_serial, sizeof(raw_serial)); if (raw_length < LIBUSB_SUCCESS) @@ -177,11 +179,11 @@ void stlinkv2_read_serial(libusb_device_descriptor_s *device_descriptor, libusb_ * Re-encode the resulting chunk of data as hex, skipping the first char16_t which * contains the header of the string descriptor */ - char encoded_serial[128] = {0}; + char encoded_serial[128U] = {0}; for (size_t offset = 0; offset < (size_t)raw_length - 2U; offset += 2U) { uint8_t digit = raw_serial[1 + (offset / 2U)]; encoded_serial[offset + 0] = hex_digit(digit >> 4U); - encoded_serial[offset + 1] = hex_digit(digit & 0x0fU); + encoded_serial[offset + 1U] = hex_digit(digit & 0x0fU); } *serial = strdup(encoded_serial); } @@ -289,7 +291,7 @@ void orbtrace_read_version(libusb_device *device, libusb_device_handle *handle, const size_t version_len = strlen(version); if (begins_with(version, version_len, "Version")) { /* Chop off the "Version: " prefix */ - memmove(version, version + 9, version_len - 8); + memmove(version, version + 9U, version_len - 8); break; } } @@ -300,7 +302,7 @@ void orbtrace_read_version(libusb_device *device, libusb_device_handle *handle, static void process_cmsis_interface(const libusb_device_descriptor_s *const device_descriptor, libusb_device *const device, libusb_device_handle *const handle, probe_info_s **probe_list) { - char read_string[128]; + char read_string[128U]; char *version; if (device_descriptor->idVendor == VENDOR_ID_ORBCODE && device_descriptor->idProduct == PRODUCT_ID_ORBTRACE) { orbtrace_read_version(device, handle, read_string, sizeof(read_string)); @@ -394,7 +396,7 @@ static void check_cmsis_interface_type(libusb_device *const device, bmp_info_s * /* If we've found an interface without a description string, ignore it */ if (descriptor->iInterface == 0) continue; - char interface_string[128]; + char interface_string[128U]; /* Read out the string */ if (libusb_get_string_descriptor_ascii( handle, descriptor->iInterface, (unsigned char *)interface_string, sizeof(interface_string)) < 0) @@ -425,51 +427,45 @@ static void check_cmsis_interface_type(libusb_device *const device, bmp_info_s * static bool process_vid_pid_table_probe( libusb_device_descriptor_s *device_descriptor, libusb_device *device, probe_info_s **probe_list) { - bool probe_added = false; - for (size_t index = 0; debugger_devices[index].type != BMP_TYPE_NONE; ++index) { - /* Check for a match, skip the entry if we don't get one */ - if (device_descriptor->idVendor != debugger_devices[index].vendor || - (device_descriptor->idProduct != debugger_devices[index].product && - debugger_devices[index].product != PRODUCT_ID_UNKNOWN)) - continue; + /* Check for a match */ + const debugger_device_s *const debugger_device = + get_debugger_device_from_vid_pid(device_descriptor->idVendor, device_descriptor->idProduct); + if (debugger_device->type == BMP_TYPE_NONE) + return false; - libusb_device_handle *handle = NULL; - /* Try to open the device */ - if (libusb_open(device, &handle) != LIBUSB_SUCCESS) - break; - - const bmp_type_t probe_type = get_type_from_vid_pid(device_descriptor->idVendor, device_descriptor->idProduct); - char *product = NULL; - char *manufacturer = NULL; - char *serial = NULL; - char *version = NULL; - /* - * If the probe has a custom string reader available, use it first. - * - * This will read and process any strings that need special work, e.g., extracting - * a version string from a product string (BMP native) - */ - if (debugger_devices[index].function != NULL) - debugger_devices[index].function( - device_descriptor, device, handle, &product, &manufacturer, &serial, &version); - - /* Now read any strings that have not been set by a custom reader function */ - if (product == NULL) - product = get_device_descriptor_string(handle, device_descriptor->iProduct); - if (manufacturer == NULL) - manufacturer = get_device_descriptor_string(handle, device_descriptor->iManufacturer); - if (serial == NULL) - serial = get_device_descriptor_string(handle, device_descriptor->iSerialNumber); - - if (version == NULL) - version = strdup("---"); - - *probe_list = probe_info_add_by_id(*probe_list, probe_type, device, device_descriptor->idVendor, - device_descriptor->idProduct, manufacturer, product, serial, version); - probe_added = true; - libusb_close(handle); - } - return probe_added; + libusb_device_handle *handle = NULL; + /* Try to open the device */ + if (libusb_open(device, &handle) != LIBUSB_SUCCESS) + return false; + + char *product = NULL; + char *manufacturer = NULL; + char *serial = NULL; + char *version = NULL; + /* + * If the probe has a custom string reader available, use it first. + * + * This will read and process any strings that need special work, e.g., extracting + * a version string from a product string (BMP native) + */ + if (debugger_device->function != NULL) + debugger_device->function(device_descriptor, device, handle, &product, &manufacturer, &serial, &version); + + /* Now read any strings that have not been set by a custom reader function */ + if (product == NULL) + product = get_device_descriptor_string(handle, device_descriptor->iProduct); + if (manufacturer == NULL) + manufacturer = get_device_descriptor_string(handle, device_descriptor->iManufacturer); + if (serial == NULL) + serial = get_device_descriptor_string(handle, device_descriptor->iSerialNumber); + + if (version == NULL) + version = strdup("---"); + + *probe_list = probe_info_add_by_id(*probe_list, debugger_device->type, device, device_descriptor->idVendor, + device_descriptor->idProduct, manufacturer, product, serial, version); + libusb_close(handle); + return true; } static const probe_info_s *scan_for_devices(bmp_info_s *info) diff --git a/src/platforms/hosted/jlink.c b/src/platforms/hosted/jlink.c index a606ac1bd63..b2359d51923 100644 --- a/src/platforms/hosted/jlink.c +++ b/src/platforms/hosted/jlink.c @@ -573,7 +573,7 @@ bool jlink_init(void) return false; info.usb_link = link; link->context = info.libusb_ctx; - int result = libusb_open(info.libusb_dev, &link->device_handle); + const int result = libusb_open(info.libusb_dev, &link->device_handle); if (result != LIBUSB_SUCCESS) { DEBUG_ERROR("libusb_open() failed (%d): %s\n", result, libusb_error_name(result)); return false; diff --git a/src/platforms/hosted/jlink_protocol.h b/src/platforms/hosted/jlink_protocol.h index 6da5fca9556..258d6aafdf6 100644 --- a/src/platforms/hosted/jlink_protocol.h +++ b/src/platforms/hosted/jlink_protocol.h @@ -40,7 +40,8 @@ * The mapping between the J-Link USB Protocol reference manual commands and the new Black Magic Debug commands is listed at the start of each command group below. */ -/* System information commands +/* + * System information commands * * ┌────────────────────────────────────────────────┬──────────────────────────────────┐ * │ BMDA J-Link command │ RM08001 J-Link USB Protocol RM │ @@ -58,7 +59,8 @@ #define JLINK_CMD_INFO_GET_PROBE_EXTENDED_CAPABILITIES 0xedU /* Get probe extended capabilities */ #define JLINK_CMD_INFO_GET_MAX_MEM_BLOCK 0xd4U /* Get the maximum memory blocksize */ -/* Interface commands +/* + * Interface commands * * ┌────────────────────────────────────────┬────────────────────────────────┐ * │ BMDA J-Link command │ RM08001 J-Link USB Protocol RM │ @@ -74,7 +76,8 @@ #define JLINK_CMD_INTERFACE_SET_SELECTED 0xc7U /* Select the probe interface */ #define JLINK_CMD_INTERFACE_GET 0xc7U /* Get current selected interface or available interfaces */ -/* Target power commands +/* + * Target power commands * * ┌───────────────────────────────┬────────────────────────────────┐ * │ BMDA J-Link command │ RM08001 J-Link USB Protocol RM │ @@ -86,7 +89,8 @@ #define JLINK_CMD_POWER_SET_KICKSTART 0x08U /* Set KickStart power state on pin 19 (J-Link 20 pin connector) */ #define JLINK_CMD_POWER_GET_STATE 0xc1U /* Get Kickstart power state and overcurrent timers */ -/* Low level hardware commands +/* + * Low level hardware commands * * ┌──────────────────────────────┬────────────────────────────────┐ * │ BMDA J-Link command │ RM08001 J-Link USB Protocol RM │ @@ -116,7 +120,8 @@ #define JLINK_CMD_SIGNAL_CLEAR_TDI 0xcbU /* Clear TDI pin */ #define JLINK_CMD_SIGNAL_SET_TDI 0xccU /* Set TDI pin */ -/* Low level IO commands +/* + * Low level IO commands * * ┌────────────────────────────────────┬────────────────────────────────────┐ * │ BMDA J-Link command │ RM08001 J-Link USB Protocol RM │ @@ -138,7 +143,8 @@ #define JLINK_CMD_IO_TRANSACTION_OBSOLETE1 0xcdU /* Obsolete: Send data on TDI and TMS and return TDO */ #define JLINK_CMD_IO_TRANSACTION_OBSOLETE2 0xceU /* Obsolete: Send data on TDI and TMS and return TDO */ -/* High level target commands +/* + * High level target commands * * ┌─────────────────────────────────────────────┬────────────────────────────────────────────┐ * │ BMDA J-Link command │ RM08001 J-Link USB Protocol RM │ @@ -166,7 +172,8 @@ #define JLINK_CMD_TARGET_MEASURE_RTCK_REACTION_TIME 0xf6U /* Measure RTCK reaction time of the target device */ #define JLINK_CMD_TARGET_GET_CONNECTION_STATE 0xc2U /* Get target connection timer counters */ -/* Configuration commands +/* + * Configuration commands * * ┌────────────────────────┬────────────────────────────────┐ * │ BMDA J-Link command │ RM08001 J-Link USB Protocol RM │ @@ -201,7 +208,8 @@ #define JLINK_HARDWARE_VERSION_TYPE_JLINKPRO 3U #define JLINK_HARDWARE_VERSION_TYPE_LPCLINK2 18U -/* J-Link capabilities - JLINK_CMD_INFO_GET_PROBE_CAPABILITIES +/* + * J-Link capabilities - JLINK_CMD_INFO_GET_PROBE_CAPABILITIES * * ┌─────┬──────────────────────────────────────────┬────────────────────────────┐ * │ Bit │ BMDA J-Link capability │ §5.3.4 EMU_CMD_GET_CAPS │ @@ -331,6 +339,162 @@ /* J-Link USB protocol constants */ #define JLINK_USB_TIMEOUT 5000U /* 5 seconds */ +/* + * J-Link USB Product-Id assignment + * + * Old format + * ┌───────────┬───────────────────┬──────────────┬──────────────────┐ + * │ Bit │ 15:8 │ 7:4 │ 3:0 │ + * ├───────────┼───────────────────┼──────────────┼──────────────────┤ + * │ Interface │ 0x01 - Old format │ 0 - Reserved │ Class interfaces │ + * └───────────┴───────────────────┴──────────────┴──────────────────┘ + * + * Class interfaces: + * 1: J-Link (default) + * 2: J-Link w/ USBAddr = 1 (obsolete) + * 3: J-Link w/ USBAddr = 2 (obsolete) + * 4: J-Link w/ USBAddr = 3 (obsolete) + * 5: J-Link | CDC + * 6: CDC + * 7: J-Link | RNDIS + * 8: J-Link | MSD + * + * Known values: + * 0x0101: J-Link | Flasher STM8 | Flasher ARM | Flasher 5 PRO + * 0x0102: J-Link USBAddr = 1 + * 0x0103: J-Link USBAddr = 2 + * 0x0104: J-Link USBAddr = 3 + * 0x0105: J-Link | CDC + * 0x0106: CDC + * 0x0107: J-Link | RNDIS + * 0x0108: J-Link | MSD + * + * New format + * ┌───────────┬───────────────────┬──────────────┬──────┬────────────┬────────────┬─────┬─────┬───────┬─────┐ + * │ Bit │ 15:8 │ 7 │ 6 │ 5 │ 4 │ 3 │ 2 │ 1 │ 0 │ + * ├───────────┼───────────────────┼──────────────┼──────┼────────────┼────────────┼─────┼─────┼───────┼─────┤ + * │ Interface │ 0x10 - New format │ 0 - Reserved │ CDC2 │ WINUSB_DRV │ SEGGER_DRV │ HID │ CDC │ RNDIS │ MSD │ + * └───────────┴───────────────────┴──────────────┴──────┴────────────┴────────────┴─────┴─────┴───────┴─────┘ + * + * 1: Denotes the interface is present + * 0: Denotes the interface is not present + * + * CDC/CDC2: Communication Device Class interfaces + * Note: It seems they added more CDC interfaces later on, and to handle them they added a new bit + * but dislocated from the original bit, this makes up a 2 bit value for the number of CDC interfaces + * + * SEGGER_DRV: BULK via SEGGER host driver interface + * WINUSB_DRV: BULK via WinUSB driver interface (Needs enabling in J-Link config area) + * Note: SEGGER_DRV and WINUSB_DRV are mutually exclusive + * + * Known values: + * 0x1001: MSD + * 0x1002: RNDIS + * 0x1003: RNDIS | MSD + * 0x1004: CDC + * 0x1005: CDC | MSD + * 0x1006: RNDIS | CDC + * 0x1007: RNDIS | CDC | MSD + * 0x1008: HID + * 0x1009: MSD | HID + * 0x100a: RNDIS | HID + * 0x100b: RNDIS | MSD | HID + * 0x100c: CDC | HID + * 0x100d: CDC | MSD | HID + * 0x100e: RNDIS | CDC | HID + * 0x100f: RNDIS | CDC | MSD | HID + * 0x1010: SEGGER_DRV + * 0x1011: SEGGER_DRV | MSD + * 0x1012: SEGGER_DRV | RNDIS + * 0x1013: SEGGER_DRV | RNDIS | MSD + * 0x1014: SEGGER_DRV | CDC + * 0x1015: SEGGER_DRV | CDC | MSD + * 0x1016: SEGGER_DRV | CDC | RNDIS + * 0x1017: SEGGER_DRV | CDC | RNDIS | MSD + * 0x1018: SEGGER_DRV | HID + * 0x1019: SEGGER_DRV | HID | MSD + * 0x101a: SEGGER_DRV | HID | RNDIS + * 0x101b: SEGGER_DRV | HID | RNDIS | MSD + * 0x101c: SEGGER_DRV | HID | CDC + * 0x101d: SEGGER_DRV | HID | CDC | MSD + * 0x101e: SEGGER_DRV | HID | CDC | RNDIS + * 0x101f: SEGGER_DRV | HID | CDC | RNDIS | MSD + * 0x1020: WINUSB_DRV + * 0x1021: WINUSB_DRV | MSD + * 0x1022: WINUSB_DRV | RNDIS + * 0x1023: WINUSB_DRV | RNDIS | MSD + * 0x1024: WINUSB_DRV | CDC + * 0x1025: WINUSB_DRV | CDC | MSD + * 0x1026: WINUSB_DRV | CDC | RNDIS + * 0x1027: WINUSB_DRV | CDC | RNDIS | MSD + * 0x1028: WINUSB_DRV | HID + * 0x1029: WINUSB_DRV | HID | MSD + * 0x102a: WINUSB_DRV | HID | RNDIS + * 0x102b: WINUSB_DRV | HID | RNDIS | MSD + * 0x102c: WINUSB_DRV | HID | CDC + * 0x102d: WINUSB_DRV | HID | CDC | MSD + * 0x102e: WINUSB_DRV | HID | CDC | RNDIS + * 0x102f: WINUSB_DRV | HID | CDC | RNDIS | MSD + * 0x103x: SEGGER_DRV | WINUSB_DRV is not valid + * 0x1050: SEGGER_DRV | 2x CDC + * 0x1051: SEGGER_DRV | 2x CDC | MSD + * 0x1052: SEGGER_DRV | 2x CDC | RNDIS + * 0x1053: SEGGER_DRV | 2x CDC | RNDIS | MSD + * 0x1054: SEGGER_DRV | 3x CDC + * 0x1055: SEGGER_DRV | 3x CDC | MSD + * 0x1056: SEGGER_DRV | 3x CDC | RNDIS + * 0x1057: SEGGER_DRV | 3x CDC | RNDIS | MSD + * 0x1058: SEGGER_DRV | HID | 2x CDC + * 0x1059: SEGGER_DRV | HID | 2x CDC | MSD + * 0x105a: SEGGER_DRV | HID | 2x CDC | RNDIS + * 0x105b: SEGGER_DRV | HID | 2x CDC | RNDIS | MSD + * 0x105c: SEGGER_DRV | HID | 3x CDC + * 0x105d: SEGGER_DRV | HID | 3x CDC | MSD + * 0x105e: SEGGER_DRV | HID | 3x CDC | RNDIS + * 0x105f: SEGGER_DRV | HID | 3x CDC | RNDIS | MSD + * 0x1060: WINUSB_DRV | 2x CDC + * 0x1061: WINUSB_DRV | 2x CDC | MSD + * 0x1062: WINUSB_DRV | 2x CDC | RNDIS + * 0x1063: WINUSB_DRV | 2x CDC | RNDIS | MSD + * 0x1064: WINUSB_DRV | 3x CDC + * 0x1065: WINUSB_DRV | 3x CDC | MSD + * 0x1066: WINUSB_DRV | 3x CDC | RNDIS + * 0x1067: WINUSB_DRV | 3x CDC | RNDIS | MSD + * 0x1068: WINUSB_DRV | HID | 2x CDC + * 0x1069: WINUSB_DRV | HID | 2x CDC | MSD + * 0x106a: WINUSB_DRV | HID | 2x CDC | RNDIS + * 0x106b: WINUSB_DRV | HID | 2x CDC | RNDIS | MSD + * 0x106c: WINUSB_DRV | HID | 3x CDC + * 0x106d: WINUSB_DRV | HID | 3x CDC | MSD + * 0x106e: WINUSB_DRV | HID | 3x CDC | RNDIS + * 0x106f: WINUSB_DRV | HID | 3x CDC | RNDIS | MSD + */ +#define JLINK_USB_PID_FORMAT_OFFSET 8U +#define JLINK_USB_PID_FORMAT_MASK (0xffU << JLINK_USB_PID_FORMAT_OFFSET) +#define JLINK_USB_PID_FORMAT_OLD 0x01U +#define JLINK_USB_PID_FORMAT_NEW 0x10U + +#define JLINK_USB_PID_OLD_MASK 0x0fU +#define JLINK_USB_PID_OLD_JLINK 0x01U /* J-Link */ +#define JLINK_USB_PID_OLD_JLINK_ADDR1 0x02U /* J-Link USBAddr = 1 */ +#define JLINK_USB_PID_OLD_JLINK_ADDR2 0x03U /* J-Link USBAddr = 2 */ +#define JLINK_USB_PID_OLD_JLINK_ADDR3 0x04U /* J-Link USBAddr = 3 */ +#define JLINK_USB_PID_OLD_JLINK_CDC 0x05U /* J-Link | CDC */ +#define JLINK_USB_PID_OLD_CDC 0x06U /* CDC */ +#define JLINK_USB_PID_OLD_JLINK_RNDIS 0x07U /* J-Link | RNDIS */ +#define JLINK_USB_PID_OLD_JLINK_MSD 0x08U /* J-Link | MSD */ + +#define JLINK_USB_PID_MASK 0x7fU +#define JLINK_USB_PID_MSD (1U << 0U) /* MSD */ +#define JLINK_USB_PID_RNDIS (1U << 1U) /* RNDIS */ +#define JLINK_USB_PID_HID (1U << 3U) /* HID */ +#define JLINK_USB_PID_DRV_SEGGER (1U << 4U) /* J-Link (BULK via SEGGER host driver) */ +#define JLINK_USB_PID_DRV_WINUSB (1U << 5U) /* J-Link (BULK via WinUSB driver. Needs enabling in J-Link config area) */ +#define JLINK_USB_PID_CDC_OFFSET 2U +#define JLINK_USB_PID_CDC2_OFFSET 6U +#define JLINK_USB_PID_CDC (1U << JLINK_USB_PID_CDC_OFFSET) /* CDC */ +#define JLINK_USB_PID_CDC2 (1U << JLINK_USB_PID_CDC2_OFFSET) /* CDC2 */ + typedef enum jlink_swd_dir { JLINK_SWD_OUT, JLINK_SWD_IN, diff --git a/src/platforms/hosted/platform.h b/src/platforms/hosted/platform.h index 4cf19fa2a03..d3fea0d963e 100644 --- a/src/platforms/hosted/platform.h +++ b/src/platforms/hosted/platform.h @@ -49,6 +49,8 @@ void platform_buffer_flush(void); } while (0) #define PLATFORM_HAS_POWER_SWITCH +#define PRODUCT_ID_ANY 0xffffU + #define VENDOR_ID_BMP 0x1d50U #define PRODUCT_ID_BMP_BL 0x6017U #define PRODUCT_ID_BMP 0x6018U @@ -65,8 +67,7 @@ void platform_buffer_flush(void); #define PRODUCT_ID_STLINKV3 0x374fU #define PRODUCT_ID_STLINKV3E 0x374eU -#define VENDOR_ID_SEGGER 0x1366U -#define PRODUCT_ID_UNKNOWN 0xffffU +#define VENDOR_ID_SEGGER 0x1366U #define VENDOR_ID_FTDI 0x0403U #define PRODUCT_ID_FTDI_FT2232 0x6010U @@ -76,13 +77,6 @@ void platform_buffer_flush(void); #define VENDOR_ID_ORBCODE 0x1209U #define PRODUCT_ID_ORBTRACE 0x3443U -/* - * All known Segger J-Link Product IDs for future reference: - * 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0107, 0x0108, - * 0x1010, 0x1011, 0x1012, 0x1013, 0x1014, 0x1015, 0x1016, - * 0x1017, 0x1018, 0x1020, 0x1024, 0x1051, 0x1055, 0x1061 - */ - typedef enum bmp_type_e { BMP_TYPE_NONE = 0, BMP_TYPE_BMP,