Crate jaylink

Source
Expand description

A crate for talking to J-Link debug probes connected via USB.

This crate allows access to the vendor-specific USB interface used to control JTAG / SWD operations and other functionality. It does not provide access to the virtual COM port functionality (which is a regular CDC device, so no special support is needed).

Inspired by libjaylink (though this library is not a port).

§Pinout

J-Link uses a pinout based on the standard 20-pin ARM JTAG connector, extended for SWD compatibility and with pins for UART.

JTAG pinout:

           ┌───────────┐
    VTref  │ *  1  2 * │ NC
    nTRST  │ *  3  4 * │ GND
      TDI  │ *  5  6 * │ GND
      TMS  │ *  7  8 * │ GND
      TCK ┌┘ *  9 10 * │ GND
     RTCK └┐ * 11 12 * │ GND
      TDO  │ * 13 14 * │ GND
    RESET  │ * 15 16 * │ GND
    DBGRQ  │ * 17 18 * │ GND
5V-Supply  │ * 19 20 * │ GND
           └───────────┘

SWD (+ UART) pinout:

           ┌───────────┐
    VTref  │ *  1  2 * │ NC
        -  │ *  3  4 * │ GND
J-Link TX  │ *  5  6 * │ GND
    SWDIO  │ *  7  8 * │ GND
    SWCLK ┌┘ *  9 10 * │ GND
        - └┐ * 11 12 * │ GND
      SWO  │ * 13 14 * │ GND
    RESET  │ * 15 16 * │ GND
J-Link RX  │ * 17 18 * │ GND
5V-Supply  │ * 19 20 * │ GND
           └───────────┘

PIC32 ICSP pinout (untested):

           ┌───────────┐
    VTref  │ *  1  2 * │ NC
        -  │ *  3  4 * │ GND
        -  │ *  5  6 * │ GND
     PGED  │ *  7  8 * │ GND
     PGEC ┌┘ *  9 10 * │ GND
        - └┐ * 11 12 * │ GND
        -  │ * 13 14 * │ GND
    RESET  │ * 15 16 * │ GND
        -  │ * 17 18 * │ GND
5V-Supply  │ * 19 20 * │ GND
           └───────────┘

§Reference

Segger has released a PDF documenting the USB protocol: “Reference manual for J-Link USB Protocol” (Document RM08001-R2).

The archive.org version is the most up-to-date one.

Structs§

BitIter
An iterator over a received bit stream.
Capabilities
A set of capabilities advertised by a probe.
Error
The error type used by this library.
HardwareVersion
A hardware version returned by JayLink::read_hardware_version.
InterfaceIter
Iterator over supported Interfaces.
Interfaces
A set of supported target interfaces.
JayLink
A handle to a J-Link USB device.
SpeedConfig
Target communication speed setting.
SpeedInfo
J-Link communication speed info.
SwoData
SWO data that was read via JayLink::swo_read.
SwoSpeedInfo
Supported SWO capture speed info.
SwoStream
A SWO data stream that implements std::io::Read.
UsbDeviceInfo
Generic info about a USB device.

Enums§

Capability
List of capabilities that may be advertised by a probe.
ErrorKind
List of specific errors that may occur when using this library.
HardwareType
The hardware/product type of the device.
Interface
List of target interfaces.
SwoMode
The supported SWO data encoding modes.

Functions§

scan_usb
Scans for J-Link USB devices.

Type Aliases§

Result
A result type with the error hardwired to Error.