J-Link MCP
v0.8.0Debug embedded firmware on real hardware: J-Link probes, Cortex-M faults, RTT logs, GDB.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
list_devices
Scan for connected PROBES — the debuggers plugged into this machine, not target chips. Despite the name it does not list target devices; use search_devices for those. Shows probe serial numbers and whether one is reachable.
check_setup
Check that everything needed to debug is in place: the probe software, a connected probe, a target device name, and the optional files that make output readable. Run this first when anything fails, or when starting on a machine for the first time.
set_svd_path
Point the server at a CMSIS-SVD file for the target at runtime, so peripheral reads come back with named fields and decoded values instead of raw hex. Mirrors set_device — you do not have to restart with SVD_PATH set.
| Parameter | Type | Description |
|---|---|---|
path * | string | Path to a .svd or .svd.gz file for this exact part |
set_rtt_address
Tell the server where the firmware's RTT control block is (its _SEGGER_RTT symbol), at runtime. Without it RTT cannot be recovered after a reset or flash, and a stopped stream is indistinguishable from a quiet device. Mirrors set_device.
| Parameter | Type | Description |
|---|---|---|
address * | string | Hex address of _SEGGER_RTT, e.g. '0x20002050' |
search_devices
Search the device names this J-Link installation accepts, by part number, manufacturer, or core. Use this before set_device instead of guessing a part number — the name must match exactly, and a wrong one fails in a way that looks like broken hardware.
| Parameter | Type | Description |
|---|---|---|
query * | string | Substring of a part number, manufacturer, or core. E.g. 'stm32f407', 'nrf528', 'nordic', 'cortex-m33' |
limit | number | Maximum results (default 40) |
set_device
Set the target device name at runtime. Required before any debugging commands will work. The name must match J-Link's exactly — use search_devices to find it rather than guessing a part number. Examples: 'nRF52840_XXAA', 'nRF5340_xxAA_APP', 'STM32F407VG', 'STM32L476RG'.
| Parameter | Type | Description |
|---|---|---|
device * | string | Target device name (e.g., 'nRF52840_XXAA', 'STM32F407VG') |
set_serial_number
Set the debug probe serial number at runtime. Required when multiple probes are connected to select which one to communicate with. Run list_devices to see connected serial numbers.
| Parameter | Type | Description |
|---|---|---|
serialNumber * | string | Probe serial number from list_devices (e.g. '776287991'), or empty string to clear |
start_debug_session
One-call setup: starts GDB server via SEGGER J-Link, connects RTT (if supported), waits for initial output. This is the recommended first tool to call. If no device is configured, use list_devices and set_device first.
snapshot
Capture complete device state: CPU registers (compact), fault status, recent RTT output, and stack dump.
| Parameter | Type | Description |
|---|---|---|
rttLines | number | RTT lines to include (default 30) |
diagnose_crash
Auto-read and decode ARM Cortex-M fault registers (CFSR, HFSR, MMFAR, BFAR), exception stack frame, and recent errors.
device_info
Halt the target and read its registers via SEGGER J-Link. Returns the probe name and a compact register summary. Leaves the target HALTED — call resume when you are done.
halt
Halt the target CPU
resume
Resume the target CPU
reset
Reset the target device. Halting leaves the core stopped at the reset vector, which is where you want it before flashing, or to watch startup run.
| Parameter | Type | Description |
|---|---|---|
halt | boolean | Halt at the reset vector after reset (default: false) |
strategy | number | J-Link reset type. Omit to let J-Link pick the right one for the device, which is what SEGGER recommends and is almost always correct. 0 = normal; 1 = core only, via VECTRESET, leaving peripherals run… |
step
Step one CPU instruction
read_memory
Read memory from the target. Returns clean hex dump.
| Parameter | Type | Description |
|---|---|---|
address * | string | Hex address (e.g., '0x20000000') |
length * | number | Bytes to read (max 4096) |
write_memory
Write a 32-bit value to memory
| Parameter | Type | Description |
|---|---|---|
address * | string | Hex address |
value * | string | Hex value (e.g., '0xDEADBEEF') |
read_registers
Read all CPU registers (compact format, FP only if non-zero).
read_register
Read a specific CPU register by name
| Parameter | Type | Description |
|---|---|---|
register * | string | Register name (e.g., 'PC', 'SP', 'R0') |
flash
Flash firmware to the target device
| Parameter | Type | Description |
|---|---|---|
filePath * | string | Path to firmware file (.hex, .bin, .elf) |
baseAddress | string | Base address for .bin files (hex) |
erase
Erase target flash memory
list_peripherals
List the target's peripherals and base addresses, from its CMSIS-SVD description. Requires an SVD file to be configured.
| Parameter | Type | Description |
|---|---|---|
filter | string | Case-insensitive substring, e.g. 'uart' or 'timer' |
read_peripheral
Read every register of a peripheral from the target and decode each one's bit fields by name. This is read_memory plus the meaning of what was read.
| Parameter | Type | Description |
|---|---|---|
peripheral * | string | Peripheral name, e.g. 'FICR', 'UARTE0' |
registers | array | Only these registers (default: all readable ones) |
decode_register
Decode a value into named bit fields using the target's SVD. Reads from the device unless a value is supplied — useful for interpreting a number you already have.
| Parameter | Type | Description |
|---|---|---|
peripheral * | string | Peripheral name, e.g. 'UARTE0' |
register * | string | Register name, e.g. 'ENABLE' or 'INFO.PART' |
value | string | Hex value to decode instead of reading the device |
set_breakpoint
Set a hardware breakpoint
| Parameter | Type | Description |
|---|---|---|
address * | string | Hex address |
clear_breakpoints
Clear all breakpoints, including any left armed in the debug hardware by an earlier session
gdb_server_start
Start SEGGER J-Link GDB server
gdb_server_stop
Stop SEGGER J-Link GDB server and disconnect RTT
gdb_server_status
Get GDB server, RTT, and telnet proxy status
gdb_connect
Connect a GDB client to the running GDB server. Enables source-level debugging: backtraces, variable inspection, conditional breakpoints, stepping by source line. Optionally load an ELF file for symbol info.
| Parameter | Type | Description |
|---|---|---|
elfFile | string | Path to .elf file with debug symbols (enables source-level debugging) |
host | string | GDB server host (default: localhost) |
port | number | GDB server port (default: 2331) |
gdb_command
Send any GDB command and get the response. For execution commands (continue, step, next, finish, until), blocks until the target stops or times out. If the target doesn't stop, use gdb_wait to poll. Examples: 'bt' (backtrace), 'info threads', 'print myVar', 'break main', 'continue', 'next', 'step', 'finish', 'info registers', 'x/10xw 0x20000000'
| Parameter | Type | Description |
|---|---|---|
command * | string | GDB command to execute |
timeout | number | Timeout in ms for run commands (default 15000) |
gdb_wait
Poll for target stop after a continue/step that timed out. Returns the stop reason (breakpoint hit, signal, finished stepping, etc.) when the target halts.
| Parameter | Type | Description |
|---|---|---|
timeout | number | How long to wait in ms (default 30000) |
gdb_load
Load an ELF file into GDB. By default loads symbols only (for source-level debugging: backtraces with file:line, variable names). Set flash=true to also program it onto the target.
| Parameter | Type | Description |
|---|---|---|
elfFile * | string | Path to .elf file with debug symbols |
flash | boolean | Also flash the ELF to the target (default: false, symbols only) |
gdb_backtrace
Get a stack backtrace. With debug symbols loaded, shows function names, file paths, and line numbers.
| Parameter | Type | Description |
|---|---|---|
full | boolean | Include local variables in each frame (default false) |
gdb_disconnect
Disconnect the GDB client (does not stop the GDB server)
rtt_connect
Connect to RTT
rtt_disconnect
Disconnect from RTT
rtt_read
Read RTT log lines (clean, parsed Zephyr format). Non-destructive — reading does not consume the buffer. Returns the NEWEST lines by default; oldest:true returns the start of the buffer. Note the buffer spans reflashes: its oldest lines may be from firmware you have since replaced. rtt_clear drops them.
| Parameter | Type | Description |
|---|---|---|
count | number | How many lines (default 50) |
oldest | boolean | Return the OLDEST lines instead of the newest — use this to see boot output |
rtt_search
Search/filter RTT logs by level, module, or regex
| Parameter | Type | Description |
|---|---|---|
count | number | Max results (default 50) |
level | string | Log level: 'err', 'wrn', 'inf', 'dbg' |
module | string | Module name (partial match) |
pattern | string | Regex or text pattern |
rtt_send
Send data to device via RTT down-channel
| Parameter | Type | Description |
|---|---|---|
data * | string | Data to send |
rtt_status
Read SEGGER's RTT control block on the target: is it initialised, how much has the firmware written, and how much has the probe collected. Use this when RTT is silent — it separates a quiet device from a probe that stopped collecting, which look identical from rtt_read.
| Parameter | Type | Description |
|---|---|---|
address | string | Address of the control block (your _SEGGER_RTT symbol), e.g. '0x20002050'. Defaults to JLINK_RTT_ADDR if that is set. |
rtt_clear
Clear RTT buffer
telnet_proxy_start
Start a TCP relay that re-serves the RTT stream on another port, so an external decoder (Trice, Pigweed, or your own) can consume it alongside this server. It relays bytes; it does not decode them.
telnet_proxy_stop
Stop telnet proxy
telnet_proxy_status
Get telnet proxy status
telnet_proxy_read
Read raw data from telnet proxy buffer
| Parameter | Type | Description |
|---|---|---|
lines | number | Lines (default 100) |
probe_command
Execute raw SEGGER J-Link commands
| Parameter | Type | Description |
|---|---|---|
commands * | array | Commands to execute |
get_config
Get current probe and server configuration