Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Commit db5247c

Browse files
perigosodragonmux
authored andcommitted
hosted/jlink_protocol: add PID info
This information was extracted from the Jlink software suite for linux udev rules
1 parent df4dfd4 commit db5247c

3 files changed

Lines changed: 157 additions & 8 deletions

File tree

src/platforms/hosted/jlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ bool jlink_init(void)
573573
return false;
574574
info.usb_link = link;
575575
link->context = info.libusb_ctx;
576-
int result = libusb_open(info.libusb_dev, &link->device_handle);
576+
const int result = libusb_open(info.libusb_dev, &link->device_handle);
577577
if (result != LIBUSB_SUCCESS) {
578578
DEBUG_ERROR("libusb_open() failed (%d): %s\n", result, libusb_error_name(result));
579579
return false;

src/platforms/hosted/jlink_protocol.h

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,162 @@
331331
/* J-Link USB protocol constants */
332332
#define JLINK_USB_TIMEOUT 5000U /* 5 seconds */
333333

334+
/*
335+
* J-Link USB Product-Id assignment
336+
*
337+
* Old format
338+
* ┌───────────┬───────────────────┬──────────────┬──────────────────┐
339+
* │ Bit │ 15:8 │ 7:4 │ 3:0 │
340+
* ├───────────┼───────────────────┼──────────────┼──────────────────┤
341+
* │ Interface │ 0x01 - Old format │ 0 - Reserved │ Class interfaces │
342+
* └───────────┴───────────────────┴──────────────┴──────────────────┘
343+
*
344+
* Class interfaces:
345+
* 1: J-Link (default)
346+
* 2: J-Link w/ USBAddr = 1 (obsolete)
347+
* 3: J-Link w/ USBAddr = 2 (obsolete)
348+
* 4: J-Link w/ USBAddr = 3 (obsolete)
349+
* 5: J-Link | CDC
350+
* 6: CDC
351+
* 7: J-Link | RNDIS
352+
* 8: J-Link | MSD
353+
*
354+
* Known values:
355+
* 0x0101: J-Link | Flasher STM8 | Flasher ARM | Flasher 5 PRO
356+
* 0x0102: J-Link USBAddr = 1
357+
* 0x0103: J-Link USBAddr = 2
358+
* 0x0104: J-Link USBAddr = 3
359+
* 0x0105: J-Link | CDC
360+
* 0x0106: CDC
361+
* 0x0107: J-Link | RNDIS
362+
* 0x0108: J-Link | MSD
363+
*
364+
* New format
365+
* ┌───────────┬───────────────────┬──────────────┬──────┬────────────┬────────────┬─────┬─────┬───────┬─────┐
366+
* │ Bit │ 15:8 │ 7 │ 6 │ 5 │ 4 │ 3 │ 2 │ 1 │ 0 │
367+
* ├───────────┼───────────────────┼──────────────┼──────┼────────────┼────────────┼─────┼─────┼───────┼─────┤
368+
* │ Interface │ 0x10 - New format │ 0 - Reserved │ CDC2 │ WINUSB_DRV │ SEGGER_DRV │ HID │ CDC │ RNDIS │ MSD │
369+
* └───────────┴───────────────────┴──────────────┴──────┴────────────┴────────────┴─────┴─────┴───────┴─────┘
370+
*
371+
* 1: Denotes the interface is present
372+
* 0: Denotes the interface is not present
373+
*
374+
* CDC/CDC2: Communication Device Class interfaces
375+
* Note: It seems they added more CDC interfaces later on, and to handle them they added a new bit
376+
* but dislocated from the original bit, this makes up a 2 bit value for the number of CDC interfaces
377+
*
378+
* SEGGER_DRV: BULK via SEGGER host driver interface
379+
* WINUSB_DRV: BULK via WinUSB driver interface (Needs enabling in J-Link config area)
380+
* Note: SEGGER_DRV and WINUSB_DRV are mutually exclusive
381+
*
382+
* Known values:
383+
* 0x1001: MSD
384+
* 0x1002: RNDIS
385+
* 0x1003: RNDIS | MSD
386+
* 0x1004: CDC
387+
* 0x1005: CDC | MSD
388+
* 0x1006: RNDIS | CDC
389+
* 0x1007: RNDIS | CDC | MSD
390+
* 0x1008: HID
391+
* 0x1009: MSD | HID
392+
* 0x100a: RNDIS | HID
393+
* 0x100b: RNDIS | MSD | HID
394+
* 0x100c: CDC | HID
395+
* 0x100d: CDC | MSD | HID
396+
* 0x100e: RNDIS | CDC | HID
397+
* 0x100f: RNDIS | CDC | MSD | HID
398+
* 0x1010: SEGGER_DRV
399+
* 0x1011: SEGGER_DRV | MSD
400+
* 0x1012: SEGGER_DRV | RNDIS
401+
* 0x1013: SEGGER_DRV | RNDIS | MSD
402+
* 0x1014: SEGGER_DRV | CDC
403+
* 0x1015: SEGGER_DRV | CDC | MSD
404+
* 0x1016: SEGGER_DRV | CDC | RNDIS
405+
* 0x1017: SEGGER_DRV | CDC | RNDIS | MSD
406+
* 0x1018: SEGGER_DRV | HID
407+
* 0x1019: SEGGER_DRV | HID | MSD
408+
* 0x101a: SEGGER_DRV | HID | RNDIS
409+
* 0x101b: SEGGER_DRV | HID | RNDIS | MSD
410+
* 0x101c: SEGGER_DRV | HID | CDC
411+
* 0x101d: SEGGER_DRV | HID | CDC | MSD
412+
* 0x101e: SEGGER_DRV | HID | CDC | RNDIS
413+
* 0x101f: SEGGER_DRV | HID | CDC | RNDIS | MSD
414+
* 0x1020: WINUSB_DRV
415+
* 0x1021: WINUSB_DRV | MSD
416+
* 0x1022: WINUSB_DRV | RNDIS
417+
* 0x1023: WINUSB_DRV | RNDIS | MSD
418+
* 0x1024: WINUSB_DRV | CDC
419+
* 0x1025: WINUSB_DRV | CDC | MSD
420+
* 0x1026: WINUSB_DRV | CDC | RNDIS
421+
* 0x1027: WINUSB_DRV | CDC | RNDIS | MSD
422+
* 0x1028: WINUSB_DRV | HID
423+
* 0x1029: WINUSB_DRV | HID | MSD
424+
* 0x102a: WINUSB_DRV | HID | RNDIS
425+
* 0x102b: WINUSB_DRV | HID | RNDIS | MSD
426+
* 0x102c: WINUSB_DRV | HID | CDC
427+
* 0x102d: WINUSB_DRV | HID | CDC | MSD
428+
* 0x102e: WINUSB_DRV | HID | CDC | RNDIS
429+
* 0x102f: WINUSB_DRV | HID | CDC | RNDIS | MSD
430+
* 0x103x: SEGGER_DRV | WINUSB_DRV is not valid
431+
* 0x1050: SEGGER_DRV | 2x CDC
432+
* 0x1051: SEGGER_DRV | 2x CDC | MSD
433+
* 0x1052: SEGGER_DRV | 2x CDC | RNDIS
434+
* 0x1053: SEGGER_DRV | 2x CDC | RNDIS | MSD
435+
* 0x1054: SEGGER_DRV | 3x CDC
436+
* 0x1055: SEGGER_DRV | 3x CDC | MSD
437+
* 0x1056: SEGGER_DRV | 3x CDC | RNDIS
438+
* 0x1057: SEGGER_DRV | 3x CDC | RNDIS | MSD
439+
* 0x1058: SEGGER_DRV | HID | 2x CDC
440+
* 0x1059: SEGGER_DRV | HID | 2x CDC | MSD
441+
* 0x105a: SEGGER_DRV | HID | 2x CDC | RNDIS
442+
* 0x105b: SEGGER_DRV | HID | 2x CDC | RNDIS | MSD
443+
* 0x105c: SEGGER_DRV | HID | 3x CDC
444+
* 0x105d: SEGGER_DRV | HID | 3x CDC | MSD
445+
* 0x105e: SEGGER_DRV | HID | 3x CDC | RNDIS
446+
* 0x105f: SEGGER_DRV | HID | 3x CDC | RNDIS | MSD
447+
* 0x1060: WINUSB_DRV | 2x CDC
448+
* 0x1061: WINUSB_DRV | 2x CDC | MSD
449+
* 0x1062: WINUSB_DRV | 2x CDC | RNDIS
450+
* 0x1063: WINUSB_DRV | 2x CDC | RNDIS | MSD
451+
* 0x1064: WINUSB_DRV | 3x CDC
452+
* 0x1065: WINUSB_DRV | 3x CDC | MSD
453+
* 0x1066: WINUSB_DRV | 3x CDC | RNDIS
454+
* 0x1067: WINUSB_DRV | 3x CDC | RNDIS | MSD
455+
* 0x1068: WINUSB_DRV | HID | 2x CDC
456+
* 0x1069: WINUSB_DRV | HID | 2x CDC | MSD
457+
* 0x106a: WINUSB_DRV | HID | 2x CDC | RNDIS
458+
* 0x106b: WINUSB_DRV | HID | 2x CDC | RNDIS | MSD
459+
* 0x106c: WINUSB_DRV | HID | 3x CDC
460+
* 0x106d: WINUSB_DRV | HID | 3x CDC | MSD
461+
* 0x106e: WINUSB_DRV | HID | 3x CDC | RNDIS
462+
* 0x106f: WINUSB_DRV | HID | 3x CDC | RNDIS | MSD
463+
*/
464+
#define JLINK_USB_PID_FORMAT_OFFSET 8U
465+
#define JLINK_USB_PID_FORMAT_MASK (0xffU << JLINK_USB_PID_FORMAT_OFFSET)
466+
#define JLINK_USB_PID_FORMAT_OLD 0x01U
467+
#define JLINK_USB_PID_FORMAT_NEW 0x10U
468+
469+
#define JLINK_USB_PID_OLD_MASK 0x0fU
470+
#define JLINK_USB_PID_OLD_JLINK 0x01U /* J-Link */
471+
#define JLINK_USB_PID_OLD_JLINK_ADDR1 0x02U /* J-Link USBAddr = 1 */
472+
#define JLINK_USB_PID_OLD_JLINK_ADDR2 0x03U /* J-Link USBAddr = 2 */
473+
#define JLINK_USB_PID_OLD_JLINK_ADDR3 0x04U /* J-Link USBAddr = 3 */
474+
#define JLINK_USB_PID_OLD_JLINK_CDC 0x05U /* J-Link | CDC */
475+
#define JLINK_USB_PID_OLD_CDC 0x06U /* CDC */
476+
#define JLINK_USB_PID_OLD_JLINK_RNDIS 0x07U /* J-Link | RNDIS */
477+
#define JLINK_USB_PID_OLD_JLINK_MSD 0x08U /* J-Link | MSD */
478+
479+
#define JLINK_USB_PID_MASK 0x7fU
480+
#define JLINK_USB_PID_MSD (1U << 0U) /* MSD */
481+
#define JLINK_USB_PID_RNDIS (1U << 1U) /* RNDIS */
482+
#define JLINK_USB_PID_HID (1U << 3U) /* HID */
483+
#define JLINK_USB_PID_DRV_SEGGER (1U << 4U) /* J-Link (BULK via SEGGER host driver) */
484+
#define JLINK_USB_PID_DRV_WINUSB (1U << 5U) /* J-Link (BULK via WinUSB driver. Needs enabling in J-Link config area) */
485+
#define JLINK_USB_PID_CDC_OFFSET 2U
486+
#define JLINK_USB_PID_CDC2_OFFSET 6U
487+
#define JLINK_USB_PID_CDC (1U << JLINK_USB_PID_CDC_OFFSET) /* CDC */
488+
#define JLINK_USB_PID_CDC2 (1U << JLINK_USB_PID_CDC2_OFFSET) /* CDC2 */
489+
334490
typedef enum jlink_swd_dir {
335491
JLINK_SWD_OUT,
336492
JLINK_SWD_IN,

src/platforms/hosted/platform.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,6 @@ void platform_buffer_flush(void);
7777
#define VENDOR_ID_ORBCODE 0x1209U
7878
#define PRODUCT_ID_ORBTRACE 0x3443U
7979

80-
/*
81-
* All known Segger J-Link Product IDs for future reference:
82-
* 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0107, 0x0108,
83-
* 0x1010, 0x1011, 0x1012, 0x1013, 0x1014, 0x1015, 0x1016,
84-
* 0x1017, 0x1018, 0x1020, 0x1024, 0x1051, 0x1055, 0x1061
85-
*/
86-
8780
typedef enum bmp_type_e {
8881
BMP_TYPE_NONE = 0,
8982
BMP_TYPE_BMP,

0 commit comments

Comments
 (0)