Skip to content

Transport and Adapter

The Transport subsystem provides access to the debug transport layer — the physical protocol used to communicate between the debug adapter and the target. OpenOCD supports several transports including JTAG, SWD, and SWIM, used with adapter hardware like CMSIS-DAP, ST-Link, and J-Link probes.

Access it through the session:

session.transport

select() returns the name of the currently active transport as a string.

import asyncio
from openocd import Session
async def main():
async with await Session.connect() as session:
transport = await session.transport.select()
print(f"Active transport: {transport}")
# Typical output: "swd" or "jtag"
asyncio.run(main())

Common return values:

ValueProtocol
"jtag"IEEE 1149.1 JTAG
"swd"ARM Serial Wire Debug
"swim"STM8 Single Wire Interface Module

list() returns all transports supported by the current adapter configuration.

async with await Session.connect() as session:
available = await session.transport.list()
print(f"Available transports: {', '.join(available)}")

A CMSIS-DAP adapter typically supports both ["jtag", "swd"], while an ST-Link V2 may report ["hla_swd"].

adapter_info() returns a description of the connected debug adapter. It tries the adapter name command first (OpenOCD 0.12+) and falls back to adapter info for older versions.

async with await Session.connect() as session:
info = await session.transport.adapter_info()
print(f"Adapter: {info}")
# Example: "cmsis-dap" or "st-link"

adapter_speed(khz=None) gets or sets the debug adapter clock frequency in kHz. When called without arguments it returns the current speed. When called with a value it sets the speed and returns the new value.

async with await Session.connect() as session:
# Query current speed
current = await session.transport.adapter_speed()
print(f"Current speed: {current} kHz")
# Set to 4 MHz
new_speed = await session.transport.adapter_speed(4000)
print(f"Speed set to: {new_speed} kHz")
AdapterTypical TransportsNotes
CMSIS-DAPJTAG, SWDOpen standard, wide device support
ST-LinkSWD (HLA)ST Microelectronics probes
J-LinkJTAG, SWDSEGGER probes, high performance
FTDIJTAG, SWDFT2232-based adapters
Raspberry Pi GPIOJTAG, SWDDirect bitbang via GPIO pins

Transport and adapter operations raise OpenOCDError on failure.

from openocd import OpenOCDError
try:
speed = await session.transport.adapter_speed(99999)
except OpenOCDError as e:
print(f"Speed setting failed: {e}")
MethodReturn TypeDescription
select()strGet the active transport name
list()list[str]List available transports
adapter_info()strGet adapter description string
adapter_speed(khz=None)intGet or set adapter speed in kHz