Skip to content

About

Hybrid - combined st-link/daplink probe open source firmware

Topics

Resources

Stars

53 stars

Watchers

3 watching

Forks

Repository files navigation

hybridlink

Warning

hybridlink is work in progress and has not been tested enough yet. It does not ship on production Jolt Connect or Streamline Connect probes yet (it will soon). Converting a probe now, over USB or SWD, is entirely at your own risk: a failed or interrupted install can leave a probe that needs an SWD reflash, and going back to DAPLink always needs SWD.

Open-source multi-mode debug probe firmware, written from scratch on top of TinyUSB. One firmware, several probe personalities selected at run time:

  • ST-Link mode: ST-Link/V2-1 compatible, recognised by STM32CubeIDE, STM32CubeProgrammer, OpenOCD and the stlink tools
  • CMSIS-DAP mode: DAPLink compatible CMSIS-DAP v2, for targets ST's tools do not cover, such as the RP2350
  • WCH-Link mode: WCH-Link compatible, for WCH's CH32V RISC-V chips over their two-wire RVSWD interface; works with MounRiver Studio, WCH's OpenOCD, wlink and probe-rs

In every mode:

  • USB to UART (virtual COM port) at up to 2 Mbit/s: the full 200 kB/s from the target, byte exact, also while a debugger is busy reading or writing memory over SWD or RVSWD (see VCP notes)

See Probe modes. hybridlink is to become the default firmware of the Jolt Connect and the Streamline Connect, whose hardware matches the ST-Link found on early Nucleo boards (STM32F103CB, 8 MHz crystal). Everything outside port/ and boards/ is portable, so other probe MCUs can follow.

No ST code is used: no HAL, no CMSIS device headers, no ST libraries. The STM32F1 port is written at register level from the reference manual. Likewise no WCH code and no Arm CMSIS-DAP reference code: the WCH-Link and CMSIS-DAP protocols are written from observation and from the published specifications.

The firmware has two parts:

Part Address Purpose
bootloader 0x08000000, 15 KiB updater: standard USB DFU and ST's update protocol
configuration page 0x08003C00, 1 KiB written by ST's updater, used by ST firmware only
application 0x08004000, up to end of flash the probe (ST-Link, CMSIS-DAP or WCH-Link mode): SWD / RVSWD, virtual COM port, SWO

What the host sees

  • USB 0483:3752 "hybridlink ST-Link compatible" (manufacturer "STM32World"; ST tools go by VID/PID, not by these strings), the ST-Link/V2-1 layout without mass storage:
    • IF0 vendor debug interface: EP1 OUT/IN (64), EP2 IN trace (32)
    • IF1/IF2 CDC ACM virtual COM port (IAD): EP4 notify, EP5 data
  • Firmware version V2J49M36 by default (configurable, see below), serial = the 96-bit UID as 24 hex digits, just like a genuine V2-1.
  • Recognised as an ST-Link by STM32CubeIDE (ST-LINK_gdbserver), STM32CubeProgrammer, OpenOCD and the stlink tools.

The bootloader enumerates like the genuine ST-Link bootloader, 0483:3748, with two interfaces:

  • interface 0: ST's update protocol, so ST-LinkUpgrade (also used by STM32CubeIDE and STM32CubeProgrammer) can install ST firmware
  • interface 1: standard USB DFU 1.1, for hybridlink images with dfu-util

USB power

Both the Jolt Connect and the Streamline Connect bring 5 V and 3.3 V out on the target connector, and their supply easily handles 1 A, so a target board can be powered from the probe.

What a USB device may draw is set by what it asks for: each configuration descriptor carries bMaxPower, and USB 2.0 allows at most 500 mA. A genuine ST-Link/V2-1 asks for 100 mA (bootloader and firmware alike), so a target that draws more than that is over the probe's budget, and hosts or hubs that enforce power budgets (bus-powered hubs, some laptops and single-board computers) may cut the port or refuse the configuration.

hybridlink asks for the USB 2.0 maximum, 500 mA, in both modes and in the bootloader (USB_MAX_POWER_MA in common/usb_ids.h). The probe itself draws only a few tens of milliamps, so most of that is available to the target. Beyond 500 mA it depends on the port: many ports (chargers, USB 3 and USB-C ports) supply more without asking, but the probe does not negotiate it.

Probe modes

mode USB for
ST-Link (default) 0483:3752, ST-Link/V2-1 STM32CubeIDE, STM32CubeProgrammer, OpenOCD, stlink
CMSIS-DAP 0D28:0204, "hybridlink CMSIS-DAP" OpenOCD, pyOCD, probe-rs, Pico SDK tools
WCH-Link 1A86:8010, "WCH-Link" MounRiver Studio, WCH OpenOCD, wlink, probe-rs (CH32V RISC-V targets)
hybridlink set-type dap --serial <serial>
hybridlink set-type wch --serial <serial>
hybridlink set-type st --serial <serial>

(stlink, daplink and wchlink work as well.)

The mode is stored in the configuration page and the probe restarts in it. All modes keep the virtual COM port, the serial number, the bootloader and hybridlink update.

CMSIS-DAP mode implements CMSIS-DAP v2 (bulk endpoints, WinUSB through Microsoft OS 2.0 descriptors, so no driver on Windows) for SWD: info, connect, transfer and transfer block with posted reads and value matching, SWJ pins / clock / sequence, SWD sequence (dormant wake-up, multidrop TARGETSEL), SWO UART through DAP_SWO_Data, and execute/queue commands. JTAG is not supported (the Jolt Connect only routes SWD); there is no HID (CMSIS-DAP v1) interface, the F103 USB packet memory does not fit it next to the VCP. The command processor is written from the published protocol (app/dap.c), not taken from Arm's reference code.

0D28:0204 is the DAPLink identity, kept so existing udev rules and tool setups apply; tools find CMSIS-DAP probes by the product string, so any VID/PID works (DAP_USB_VID / DAP_USB_PID at build time).

WCH-Link mode

WCH-Link mode makes the probe look like a WCH-Link (firmware 2.12, the CH549 based "WCH-Link-CH549") and debug WCH's CH32V RISC-V chips over RVSWD, WCH's two-wire debug interface, on the probe's SWCLK and SWDIO pins. Wiring to a CH32V board: SWCLK to the target's SWCLK/CLK (PA14 on a CH32V307), SWDIO to SWDIO/DIO (PA13), GND, and the VCP to a target UART.

  • Host tools: MounRiver Studio (download and debugging), WCH's OpenOCD (program, GDB), wlink (flash, erase, reset, read protection, memory, registers) and probe-rs (it finds the probe by the product string "WCH-Link").
  • The probe answers the WCH-Link command set itself: version, attach, speed, debug module (DMI) access, reset, chip information, read protection, memory read, flash erase and programming. The flash routine that host tools upload for the probe to run is not used: the probe programs the flash itself through the debug module (fast 256-byte page erase and program), so no WCH binary is ever run or stored. A failed or mismatching page stops the acknowledgements, so the host reports an error.
  • Tested on a CH32V307 (CH32V30x family). The CH32V20x and V10x use the same RVSWD and flash controller but are not tested yet; the one-wire SDI of the CH32V003 is not supported.
  • VCP: the command endpoints are 16 bytes instead of 64, so the serial port keeps 64-byte endpoints; 2 Mbit/s full duplex runs at about 180 kB/s.

The protocol notes, as observed on a genuine WCH-Link, are in docs/wch.md.

Downloads

No toolchain needed: each release has

  • hybridlink-<version>.tar.gz / .zip: the hybridlink tool (bin/) and all firmware images (share/hybridlink/). Unpack it and run bin/hybridlink install (on Windows python bin\hybridlink install). It needs Python 3 with pyusb and cryptography, and dfu-util.
  • hybridlink-daplink.bin: for probes running DAPLink, drag and drop onto the DAPLINK drive (see Installing).
  • hybridlink-full.bin: bootloader and application, for flashing over SWD.

Releases are built by .github/workflows/release.yml when a tag v<version> matching HYBRIDLINK_VERSION in common/usb_ids.h is pushed; make dist builds the same archives locally.

Building

Needs arm-none-eabi-gcc and a C library (picolibc is used by default; override LIBC_SPECS, LIBC_INC and PORT_LIBDIR for another one).

git submodule update --init lib/tinyusb
make

Outputs in build/:

  • bootloader.bin – flash at 0x08000000 (does not touch the configuration page)
  • app.bin – flash at 0x08004000, or download through DFU
  • hybridlink-full.bin – both together, for the first installation over SWD
  • installer.bin – bootloader installer, used by hybridlink install
  • hybridlink-daplink.bin – the full image as a DAPLink bootloader update (drag and drop onto the DAPLINK drive)

The host tool tools/hybridlink (Python 3 with pyusb; cryptography for talking to ST's bootloader; dfu-util) runs from the source tree as it is, or is installed with the images it uses:

sudo make install

That puts hybridlink in /usr/local/bin and the images in /usr/local/share/hybridlink; make install PREFIX=~/.local installs for the current user only, make uninstall removes it again. The tool takes its images from ../build next to itself, otherwise from ../share/hybridlink, so hybridlink install and hybridlink update need no file names. The examples below use the installed name; from the source tree run tools/hybridlink instead.

Installing

First time, over SWD with any other probe:

st-flash --reset write build/hybridlink-full.bin 0x08000000

Or over USB only, on a probe that still has ST's bootloader (ST-Link/V2-1 firmware, as shipped) or an older hybridlink bootloader:

hybridlink install

This puts the probe into its bootloader, uploads installer.bin through the bootloader's ST update protocol (the same encrypted transfer ST's updater uses), and lets it run. The installer is an ordinary application at 0x08004000 that carries the hybridlink bootloader. It:

  • does nothing if the bootloader is already the one it carries;
  • refuses if the bootloader area is protected: write protection in the option bytes, or read protection (many ST-Links leave the factory with it on), which on ST's STM32F103 also makes the first 4 KiB unwritable. With read protection set it checks those pages with a write that changes no bit (a halfword programmed with the value it already has) and goes ahead only if all of them accept it, for an F103 clone that does not enforce the rule. When it refuses it erases the "application valid" marker in the last flash word, so ST's bootloader stays in update mode, and the tool installs app.bin under ST's bootloader instead (see below);
  • otherwise writes the bootloader page by page, the vector table page last, and restarts into the new bootloader's DFU mode.

The tool then installs app.bin with dfu-util (--app picks another image). The configuration page is left alone, so the probe mode and the reported version survive; a version older than J46 (ST's updater leaves the version it installed there, e.g. J32 on early probes) is reset to the default, which ST's current tools accept, and so is one written by ST-Link/V2 firmware (its last field is the SWIM version, which under the V2-1 identity reads as a mass storage version and makes OpenOCD refuse the probe). Unplugging before the application is installed is harmless: the installer finds its bootloader in place and returns to DFU. Losing power during the bootloader write itself (well under a second) leaves a probe that needs an SWD reflash.

Uploading through ST's bootloader needs the Python cryptography package.

A probe whose bootloader is protected keeps ST's bootloader: read protection makes the first 4 KiB of flash unwritable, and lifting it erases the whole chip, which without SWD access would leave a dead probe. The hybridlink application runs under ST's bootloader just as it does under its own. update then writes through ST's update protocol instead of dfu-util, and set-type tells ST's bootloader to start the application again (it stays in update mode after a software reset). STLinkUpgrade can put ST's firmware back at any time.

On a probe running DAPLink (STM32F103 hardware, HIC ID 97969908, as on a Jolt Connect or Streamline Connect), hybridlink install uses DAPLink's own bootloader update instead. It copies build/hybridlink-daplink.bin to the DAPLINK drive, checks that DAPLink accepted it, and restarts the probe. The same works by hand without any tools: drag hybridlink-daplink.bin onto the DAPLINK drive, wait for the drive to come back (no FAIL.TXT), and reconnect the probe.

hybridlink-daplink.bin (made by tools/mkdaplink.py) is the full image (bootloader, blank configuration page, application) padded to DAPLink's 48 KiB bootloader region, with DAPLink's info block in reserved vector table slots at 0x20 and a CRC-32 in the last word. DAPLink writes it in a power-fail safe way: the first sector keeps pointing at the DAPLink interface until everything else is written and the CRC is checked. DAPLink must be running its interface firmware (the DAPLINK drive, not MAINTENANCE) with "Automation allowed: 1" in DETAILS.TXT. Going back to DAPLink afterwards needs SWD, as DAPLink's bootloader is replaced.

Updating the application later, over USB only:

hybridlink update

This writes app.bin (or the image given after update): it sends the bootloader command (F9 01) to the running probe, waits for the DFU device and runs dfu-util. Done by hand:

hybridlink dfu
dfu-util -d 0483:3748 -a 0 -D build/app.bin -R

The usual ST-Link udev rules (as shipped with STM32CubeIDE / stlink) already cover 0483:3748, so no extra rule is needed.

update replaces only the application; the bootloader changes only with install. To see which versions are on a probe:

hybridlink version
serial      066CFF3632504E3043053243
bootloader  hybridlink 0.8.1
application hybridlink 0.8.1

It works in every mode and also while the probe is in its bootloader. From 0.8.1 on each image carries its version in a reserved vector table slot (0x34); older images show as "older than 0.8.1", ST's firmware as such.

hybridlink-full.bin covers 0x08000000-0x08003FFF including the configuration page; flash bootloader.bin and app.bin separately to keep a configuration page written by ST's updater.

Installing ST firmware (STM32CubeIDE / ST-LinkUpgrade)

The bootloader implements ST's update protocol, so ST's own upgrade tool works on a hybridlink probe, from the hybridlink application as well as from ST's firmware:

java -jar STLinkUpgrade.jar -sn <serial> -update

(or the GUI from STM32CubeIDE). It installs the firmware only when the reported version is older than the one it ships; -force_prog installs it anyway. On a probe whose configuration page is still blank (hybridlink installed over SWD) the bootloader reports the values ST's updater records for an ST-Link/V2-1 with "STM32 Debug+VCP" firmware, so the probe is recognised without a type option. This installs ST's proprietary, encrypted firmware in place of the hybridlink application. ST's firmware finds the bootloader through the header at 0x08000100, so going back is the normal update path:

hybridlink update

The protocol: commands F3 <request> on the bulk endpoints tunnel a DfuSe-like state machine (download, get status, ...). Block 0 carries "set address" (0x21) and "erase page" (0x41) commands, data blocks are AES-128 encrypted with a per-device key that is derived from the chip's unique ID with ST's master key, and checksummed over the plain text. See bootloader/st_proto.c. Build with ST_COMPAT=0 to leave this out.

Reported version and STM32CubeIDE updates

ST-LINK_gdbserver (used by STM32CubeIDE) reads the firmware version (F1) when it starts. Below a minimum it refuses to run ("ST-LINK firmware upgrade required"); below the version it knows as current, newer releases only warn ("ST-LINK firmware update available"). Measured with V2-1 firmware versions:

gdbserver from refuses below warns below
7.10.0 STM32CubeCLT 1.18 J45 –
(2.2.400 plugin) STM32CubeIDE 2.1.x J46 –
7.14.0 STM32CubeIDE 2.2.0 – J46
7.14.0 STM32CubeIDE 2.3.0 – –

STM32CubeIDE 2.3.0's gdbserver accepts J48, but the IDE wants the version its ST-LinkUpgrade ships, V2J49M36 (the updater calls a probe reporting it up to date), so that is the default since 0.8.0.

Reporting a higher version than ST ships changes nothing else: gdbserver and STM32CubeProgrammer send the same commands at J48 and at J63.

So the reported version is a setting, not part of the build. It is the last halfword of the configuration page (0x08003FFE, big endian), the same place ST's updater records the version it installed; while it is blank (0xFFFF) the compiled-in default (V2J49M36 since 0.8.0, V2J48M35 before) is reported. The bootloader reports the same word to ST-LinkUpgrade. Changing it needs no ST firmware and no rebuild:

hybridlink set-version V2J49M36 --serial <serial>
hybridlink set-version auto --serial <serial>
hybridlink set-version default --serial <serial>

auto runs every ST-LINK_gdbserver it finds (STM32CubeIDE plugin folders and STM32CubeCLT under ~, ~/st, /opt/st, ...; or --gdbserver PATH) against the probe and raises the J number until none refuses it or asks for an update. It never lowers the version. Run it after installing a new STM32CubeIDE. info shows where the reported version comes from.

The tool uses vendor control requests of the application (see common/settings.h); the rest of the configuration page is kept when the version is rewritten.

Bootloader behaviour

  • Starts the application unless the application asked to stay in DFU mode (RAM mailbox at the top of RAM, see common/layout.h) or the application vector table is not valid.
  • During an update (DFU or ST protocol) the first application page is kept in RAM and written last, so an interrupted update never leaves a half-written image that looks valid. The bootloader then simply stays in update mode.
  • DFU upload (dfu-util -U) reads the application back, for hybridlink images only (marked with HLNK in the first reserved vector table slot): other firmware installed through the ST protocol, such as ST's own, is not readable over USB. make DFU_UPLOAD_ANY=1 builds a bootloader that reads back any application.
  • Leaves for the application on DFU detach or the bus reset after dfu-util -R.

Source layout

common/            portable: HAL interface, flash layout, USB IDs, serial number
boards/<board>/    pin assignment (board.h)
port/<mcu>/        MCU support: startup, linker scripts, HAL, SWD pin I/O,
                   a minimal device header for TinyUSB
bootloader/        DFU bootloader (TinyUSB DFU class)
port/<mcu>/installer.c
                   bootloader installer (an application carrying bootloader.bin)
app/               probe application
  stlink.c         ST-Link command interpreter (transport independent)
  stlink_usb.c     TinyUSB class driver for the ST-Link debug interface
  dap.c            CMSIS-DAP command processor (transport independent)
  dap_usb.c        TinyUSB class driver for the CMSIS-DAP v2 interface
  wch.c            WCH-Link command set (transport independent)
  wch_flash.c      CH32V flash programming through the debug module
  wch_usb.c        TinyUSB class driver for the WCH-Link interface
  rvswd.c          WCH RVSWD packet layer (bit-banged through swd_io.h)
  rvdm.c           RISC-V debug module helpers (halt, reset, memory access)
  settings.c       mode / version settings, vendor control requests
  swd.c            SWD / ADIv5 / MEM-AP engine (bit-banged through swd_io.h)
  vcp.c            CDC <-> UART bridge
tools/             host helpers

SWD clock

The SWD clock is bit-banged; requested clocks (ST-Link divisor table, DAP_SWJ_Clock, OpenOCD adapter speed) are mapped to the nearest clock that is not faster, from measurements on the 72 MHz F103: full speed is about 3.7 MHz reading / 2.8 MHz writing, below that within about 10 % of the request down to 5 kHz. A port measures its own timing with the SWD_CALIBRATE build (CFLAGS=-DSWD_CALIBRATE make): it records CPU cycles per bit for a range of delays in swd_cal[] at start-up, to be read over the probe's own SWD port; the mapping lives in the port's swd_io.h.

Status LED

The Jolt / Streamline Connect has a red and a blue LED on one pin (PA9 high: red, low: blue, tri-stated: off), so it can show one colour, the other or nothing. hybridlink uses them like the COM LED of ST's ST-Link/V2-1 (LD1 on Nucleo boards, ST's UM1724), in every mode (ST-Link, CMSIS-DAP and WCH-Link), with blue where ST shows green and red where ST shows orange:

LED Meaning
slow red blink USB not configured yet
fast red blink enumerated, no debug software has talked to the probe yet
red debug software has talked to the probe, but no target answered (yet)
red/blue blink target communication in progress
blue the last target communication succeeded
off USB suspended

The SWD and RVSWD layers record every transfer; the LED itself is updated from the 1 ms tick interrupt, so it keeps blinking during long commands. The pin level that lights red is LED_RED_LEVEL in boards/<board>/board.h.

Porting

Everything outside port/ and boards/ only uses common/hal.h, swd_io.h and TinyUSB. A new MCU needs a port/<mcu>/ directory with port.mk, hal.c, swd_io.h, startup code and linker scripts; a new board needs a boards/<board>/board.h. Select them with make PORT=... BOARD=....

Jolt Connect pin map

Pin Function
PB13 (+PA5) SWCLK (RVSWD CLK in WCH-Link mode)
PB14 SWDIO driver (tri-stated while reading; RVSWD DIO)
PB12 SWDIO sense
PB0 target NRST (open drain)
PA2 / PA3 VCP TX / RX (USART2)
PA10 SWO (USART1 RX)
PA0 target voltage (1:2 divider)
PA9 status LEDs: high red, low blue, tri-state off (see Status LED)
PA15 USB D+ pull-up control

Hybridlink on Blue Pill

Untested speculation. Nobody has run hybridlink on a Blue Pill yet. This section is reasoning from the schematics and the firmware; reports are welcome.

The firmware runs unchanged on a plain STM32F103C8/CB "Blue Pill" (8 MHz crystal; the 47 KB full image also fits a 64 KB C8), but the board lacks a few parts of the Jolt Connect, and one of them is essential (see below).

Since 64 KB of flash is enough, it will probably also run on STM32F103 clones such as the GD32F103 or HK32F103, which turn up on many Blue Pills; again untested. The SWD clock is calibrated in CPU cycles on a genuine STM32F103, so on a clone with different flash wait states the actual SWD frequencies may differ somewhat.

What the Blue Pill lacks:

  • SWDIO uses two pins. PB14 drives SWDIO and PB12 reads it back (as on ST's ST-Link/V2-1). On a bare Blue Pill PB12 is not connected to anything, so every acknowledge reads as garbage and no target is detected. Connect PB14 to PB12 through a 100 Ω resistor (R8 on the Jolt Connect) and take the target's SWDIO from the PB12 side. A plain wire would also do, since PB14 is tri-stated while reading; the resistor limits the current if host and target ever drive at the same time.
  • SWCLK is PB13 (the Jolt Connect has 100 Ω, R11, in series). PA5 is kept as an input and can stay unconnected.
  • NRST is PB0 (open drain), SWO PA10, VCP TX PA2 / RX PA3.
  • Target voltage is read on PA0 through a 1:2 divider (100k/100k). Without it the reported voltage is meaningless; the firmware only reports it and never refuses to connect, but some host tools warn about a 0 V target.
  • Status LED: PA9 drives two LEDs (high red, low blue). The Blue Pill's own LED on PC13 is not used.
  • USB re-enumeration: the Blue Pill's D+ pull-up is fixed, so PA15 does nothing. The firmware also drives D+ (PA12) low for 20 ms before starting USB, which should be enough for the host to see a re-enumeration after a mode change or DFU. Many Blue Pills have a 10 kΩ pull-up (R10) where USB wants 1.5 kΩ; if the host does not enumerate the board reliably, fix that first.

A blank Blue Pill has no USB bootloader, so the first install is build/hybridlink-full.bin at 0x08000000, either with another SWD probe (st-flash write build/hybridlink-full.bin 0x08000000) or through ST's serial bootloader on USART1 (BOOT0 high, PA9/PA10, e.g. stm32flash). Afterwards hybridlink update works over USB as usual.

Hybridlink on cheap ST-Link/V2 clones

The ST-Link/V2 "USB stick" clones sold for a dollar or two (USB 0483:3748, STM32F103C8 or a compatible chip, ST's ST-Link/V2 firmware) take hybridlink over USB only, like a genuine probe. Tested on one with ST's V2J39S7 and, after STLinkUpgrade, V2J49S7: install from stock, update, set-type in both directions, set-version; st-flash (read, write + verify) and OpenOCD in ST-Link and CMSIS-DAP mode against an STM32F411.

Things to know:

  • Only SWD and NRST are wired. The clones have no VCP and no SWO pins, and the target voltage input reads a fixed value. SWD uses the same pins as the ST-Link/V2-1 (PB13 clock, PB14 drive, PB12 sense), so the standard build works unchanged.
  • ST's bootloader stays. The clones come with ST's V2 bootloader and read protection, which on the F103 makes the first 4 KiB unwritable for any code, including the installer (checked on the tested clone with a write that changes no bit: write protection error on every testable page). Lifting read protection erases the whole chip and needs SWD access to the clone's MCU. install therefore puts the hybridlink application under ST's bootloader; STLinkUpgrade can put ST's firmware back at any time.
  • Install right after plugging in. ST's V2 firmware has no command to switch to its bootloader (STLinkUpgrade asks for a replug as well), so install asks you to unplug the probe, plug it in again and run it straight away. Close STM32CubeIDE first: it opens ST-Links as they appear and starts their firmware.
  • ST's V2 bootloader does not start the application by itself. After power-up it waits in update mode until a host sends "exit DFU" (F3 07). ST's tools, st-flash and OpenOCD send it, after which hybridlink re-enumerates as 0483:3752, so the first tool run after plugging in may fail and the second works. The hybridlink tool starts the application itself when it needs it.
  • Serial number. ST's V2 firmware and bootloader send the 12 UID bytes raw; hybridlink reports them as hex, each 32-bit word byte-reversed, as the V2-1 does. The hybridlink tool maps one to the other, so --serial takes the hex form throughout.

Protocol coverage

Implemented: F1 version, F5 mode, F7 target voltage, F3 07 DFU exit, F9 00/01 bootloader query/enter and the debug command set (F2): enter/exit SWD, IDCODEs, status, halt/run/step, system reset, NRST control, core register read/write (single and all, incl. FP), debug register read/write, 8/16/32-bit memory read/write with and without address increment (any length, streamed in chunks), last R/W status (both forms), SWD clock, DAP register read/write, AP init/close, queued 32-bit AP accesses (RW_MISC_OUT/IN, used by OpenOCD's stlink-dap driver), SWO trace start/stop/count and the board/capability queries (56, 57, 58) that current ST tools send.

Not implemented: JTAG (the Jolt Connect only routes SWD), SWIM and the USB mass storage drag-and-drop function.

Status

Tested on a Jolt Connect against an STM32F407:

  • STM32CubeProgrammer: probe listed as V2J48, connect, read (~136 KB/s), program + verify
  • ST-LINK_gdbserver (STM32CubeIDE): connect, reset, step, hardware breakpoint; SWV at 2 MHz (ITM data console and statistical profiling together, PC sampling with timestamps): 1.7 MB of trace decoded without a lost byte
  • OpenOCD 0.12: reset/halt, step, 8/16/32-bit memory access, registers, breakpoints, 128 KiB RAM download in 0.9 s at 4 MHz (byte exact from 4 MHz down to 100 kHz); also with the stlink-dap (dap-direct) driver: step, hardware breakpoint, 64 KiB RAM write, verify and read back; on an STM32H723 (several access ports) as well since 0.6.0
  • stlink (st-info / st-flash): probe, read 512 KiB, write + verify
  • bootloader: app -> DFU switch, dfu-util download/upload, return to app
  • ST-LinkUpgrade 3.17.11: installs ST's V2J48M35 on a blank probe and from the hybridlink application; ST's firmware runs on the hybridlink bootloader (mass storage, VCP, debugging work) and switches back to the bootloader for hybridlink updates
  • hybridlink install over USB only: stock ST firmware V2J48M35 on ST's bootloader -> hybridlink bootloader + application; repeated on a converted probe in ST-Link and in CMSIS-DAP mode (mode kept); from DAPLink 0259 on a Streamline Connect (RP2354 blade examined over CMSIS-DAP afterwards); on a read-protected rev G DIY probe with stock V2J48M35: the installer refuses, the application is installed under ST's bootloader, then update and set-type in both directions; on a rev D DIY probe (STM32F103C8, 64 KiB) with ST's V2J32M1 "STM32+Audio" firmware (USB 0483:374a): full conversion, old version reset; CubeIDE's ST-Link update installs ST's firmware on the hybridlink bootloader; on a cheap ST-Link/V2 clone (read protected, ST's V2J39S7 and V2J49S7): the application under ST's bootloader, update, set-type, set-version, STLinkUpgrade back to ST's firmware and install again
  • VCP: line coding, host -> target transmit, target -> host receive (16 KiB burst at 921600 baud, byte exact, while SWD is busy); STM32F407 at 2 Mbit/s with OpenOCD reading memory back to back over SWD: 5 minutes of target -> host at the full 200 kB/s (60 MB) and 5 minutes of full-duplex echo of random data, both byte exact
  • SWO: 2 Mbaud UART/NRZ trace, sustained full rate (100 KB, ~200 KB/s) and paced streams byte exact with a polling host, also with 256-byte host reads as OpenOCD does; OpenOCD capture of 8 x 100000 ITM characters at full rate byte exact; since 0.7.3 also 200 kB/s while OpenOCD reads memory back to back at 1.8 and 4 MHz SWD (most runs byte exact, an occasional loss when OpenOCD goes about 20 ms without polling trace)

CMSIS-DAP mode, against an RP2354 (RP2350, Raspberry Pi OpenOCD 0.12.0+dev):

  • both Cortex-M33 cores examined at 4 MHz; program + verify of an 80 KB image in 4.0 s (DAPLink's CMSIS-DAP v1 build on the same hardware: 8.2 s)
  • 256 KiB flash read and RAM write at about 125 KB/s, byte exact
  • GDB: reset halt, hardware breakpoint, step, hardware watchpoint
  • pyOCD 0.45 (target rp2350): connect, memory access
  • VCP: target UART output at 115200; at 2 Mbit/s with OpenOCD reading memory back to back over SWD: 5 minutes of target -> host at the full 200 kB/s (60 MB) and 5 minutes of full-duplex echo of random data, both byte exact (the same with an STM32F407)
  • Pico SDK flashing from VS Code, also after a cold start of the RP2350 (dormant debug port woken by OpenOCD through DAP_SWJ_Sequence)

CMSIS-DAP mode, against an STM32F407 (OpenOCD 0.12):

  • program + verify of 512 KiB flash in 16.5 s
  • GDB: reset halt, step, hardware breakpoint; pyOCD (generic cortex_m)
  • SWO: 2 Mbaud UART trace through DAP_SWO_Data, byte exact at full rate

WCH-Link mode, against a CH32V307 (CH32V307V-R1 board, its own WCH-Link disconnected):

  • wlink 0.1.3: status, registers, flash of 20 KB in about 3 s, erase, reset, read protection on and off
  • probe-rs 0.32: list, info, download, reset, memory read
  • WCH OpenOCD (from MounRiver Studio): program ... verify reset; GDB with hardware breakpoints, stepping, memory read and write
  • MounRiver Studio 3.0.0: download and debugging; the USB traffic matches the genuine WCH-Link's command for command
  • every flash test writes two different images in turn and reads each back
  • VCP at 2 Mbit/s: target -> host at the full 200 kB/s; 5 minutes of it while a debugger halts the core, reads memory over RVSWD and resumes it about 10 times a second, byte exact; 8 minutes of full-duplex echo of random data (74.5 MB), byte exact

VCP notes

Target data is received by USART2 with circular DMA into a 2 KiB buffer and goes to the host in transfers of up to 512 bytes. Debug commands are executed in pieces (ST-Link memory transfers 256 bytes at a time), so the serial port keeps flowing at 2 Mbit/s while a debugger is busy. If the host stops reading (the port open but nobody reading it), the oldest data is dropped. To see the counters:

hybridlink vcp-status

It shows the bytes received from the target, delivered and dropped, the UART error flags and the longest time the probe left the receiver unserviced since the last call.

Not tested yet: multidrop TARGETSEL (the RP2350 configuration does not use it; an RP2040 would), Windows.

SWO notes

SWO is received as UART/NRZ by USART1 with circular DMA into a 5 KiB buffer, up to 4.5 Mbaud (2 Mbaud is what STM32CubeIDE uses by default). Hosts read it in two ways, and both are handled:

  • polled (ST-LINK_gdbserver, OpenOCD): GET_TRACE_NB, then a read of exactly that many bytes. Once a host polls, the probe sends exactly the bytes the last count promised, as 32-byte packets and a short last one. An early short packet would end the host's read too soon and a larger one would overflow it, which STM32CubeIDE reports as "SWV info, Failed to read data!!!" (fixed in 0.5.1).
  • streamed (no GET_TRACE_NB): full packets as soon as the host takes the previous one, a short packet after 5 ms of silence.

Trace goes to the host in transfers of up to 512 bytes, whose 32-byte packets the USB interrupt sends back to back (since 0.7.3; before, one packet per main-loop pass lost trace under SWD load and slowed OpenOCD's memory reads). The 5 KiB buffer (4 KiB before 0.7.4) covers about 25 ms at 2 Mbaud: a host that goes longer without asking for trace loses some. OpenOCD does not poll while it runs a command; back-to-back 1 KiB read_memory calls over its TCL port at 1.8 MHz SWD take about 19 ms each. hybridlink swo-status also shows how much of the stack has never been used since reset, the margin left for larger buffers.

If the host falls more than the buffer behind, the oldest data is dropped. OpenOCD 0.12 does not poll trace while it is blocked (wait_halt, sleep), so a long full-rate burst captured that way gets truncated; that is a host-side limit.

To see what the probe's receiver is doing, run this while a trace session is open:

hybridlink swo-status

It shows the bytes received, delivered and dropped, and the UART and DMA state. Overflow packets in STM32CubeIDE's SWV views come from the target's ITM, not from the probe: the target produces more than the SWO clock carries. PC sampling with a timestamp on every packet is the usual cause; a higher timestamp prescaler, a coarser sampling resolution or a faster SWO clock helps.

About

Hybrid - combined st-link/daplink probe open source firmware

Topics

Resources

Stars

53 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages