> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# J-Link debugging

> Connect a SEGGER J-Link, program a debug build or attach with matching symbols, and inspect the target.

Use a SEGGER J-Link to program a debug build, or attach to running firmware, and then inspect it in Debug mode. Your installed SEGGER software decides which targets are supported. A board appearing in Inlay's catalog doesn't establish J-Link compatibility, so verify the exact MCU and probe combination.

## Prepare the host and board

1. Install the SEGGER J-Link Software for your host. It includes J-Link GDB Server.
2. Connect the probe to the board's debug connector with the correct signal wiring, ground, and target voltage reference. Power the board.
3. Build an ELF with debug symbols. To attach to an existing run, use the ELF that matches the firmware on the board.
4. Find the exact SEGGER device name (see [Record the device](#record-the-device)) and whether the board uses **SWD** or **JTAG**.
5. Close other applications that hold the probe.

Inlay downloads its own GDB client on Windows x64, macOS, and Linux x64 or Arm64. On Linux it needs glibc 2.28 or later. You only install the SEGGER software.

Inlay finds J-Link GDB Server on `PATH` or in SEGGER's default folders:

| Host | Default folders |
| - | - |
| macOS | `/Applications/SEGGER/JLink` |
| Linux | `/opt/SEGGER/JLink`, `/usr/bin` |
| Windows | `JLink` or a versioned `JLink_…` folder under `C:\Program Files\SEGGER` or `C:\Program Files (x86)\SEGGER`, or the folder recorded by the SEGGER installer |

In Debug mode, if a J-Link probe is connected but the software isn't found, Inlay shows **J-Link Software Required**. Install the software, then choose **I've installed it, retry detection**. **Continue without J-Link** carries on without J-Link debugging.

### Record the device

The device name must match an entry in your installed SEGGER device list. A board name or a nearby MCU name isn't a substitute. In VS Code, select an RTT port in the Inlay Monitor: its **Device** picker lists the names from your installed J-Link software, and you can filter it with **Search device…**.

In [INLAY.md](/docs/core-concepts/inlay-md.md), set the debug interface and record the exact device name so every chat uses the same target:

```text theme={"theme":"css-variables"}
Target MCU = STM32F407VG
Debug Interface = jlink
```

Ask Inlay to check J-Link readiness and list the detected probes before connecting.

## Start a debug run

Switch to Debug mode with `/debug`, then give Inlay the artifact, device name, and interface:

```text theme={"theme":"css-variables"}
Use the connected J-Link and the exact SEGGER device name recorded in
INLAY.md. Program build/app.elf over SWD, run to main, then show the
current frame and registers. Report the selected device before starting.
```

Replace `build/app.elf` and the interface with your project's values. Inlay asks you to approve before it connects, unless your [approval settings](/docs/core-concepts/approvals.md) already allow it. A normal connection programs the ELF and tries to stop at `main`. If `main` isn't reached within about 5 seconds, Inlay halts the target where it is, so check the reported stop location.

You can then ask for breakpoints, stepping, stack frames, variables, registers, or memory. See [GDB debugging](/docs/debug-mode/gdb.md).

## Attach to existing firmware

The normal connection programs the ELF. Ask for **attach-only** to load symbols without programming or running to `main`. Ask for **no halt** as well if the target should keep running.

```text theme={"theme":"css-variables"}
Attach through J-Link using build/app.elf for symbols only. Do not program
or run to main. Check whether this target setup permits no-reset, no-halt
attachment before connecting; preserve the current fault state.
```

Turning off run-to-main alone still programs the target. Asking for no halt on a programming connection makes Inlay reset and halt the target after loading the ELF. Follow the [attachment precautions](/docs/debug-mode/gdb.md#attach-to-a-running-target), because probe startup can still affect execution.

## Script a J-Link connection

For a repeatable check, save a [hardware script](/docs/debug-mode/hardware-scripts.md) under `.inlay/hardware/`:

```python theme={"theme":"css-variables"}
gdb.jlink_connect(
    device="STM32F407VG",
    elf="build/app.elf",
    interface="SWD",
    run_to_main=True,
)
print(gdb.stack())
print(gdb.read_registers())
```

Replace the device and artifact with your own, then ask Inlay to run it. This example programs the target. The debugger connection closes when the script ends.

After connecting, the script can use the shared GDB helpers, such as `gdb.stack()` and `gdb.read_registers()`. See [Script helpers](/docs/debug-mode/gdb.md#script-helpers).

| Option | Default | Effect |
| - | - | - |
| `device` | Required | Exact SEGGER device name |
| `elf` | Required | Firmware ELF with symbols |
| `interface` | `"SWD"` | `"SWD"` or `"JTAG"` |
| `run_to_main` | `True` | Run to `main` after programming |
| `attach` | `False` | Load symbols only, without programming |
| `no_halt` | `False` | Don't request a halt when connecting |
| `enable_rtt` | `True` | Start RTT alongside the debugger |

## RTT and probe sharing

Use [RTT](/docs/debug-mode/rtt.md) for firmware output through J-Link. A J-Link debug connection starts RTT by default, but the firmware must provide RTT channels.

Starting a J-Link debug session takes over the probe:

* An RTT session that uses the probe is released.
* Any J-Link GDB Server already running on this computer is closed, including one started by another tool.

When you're finished, tell Inlay whether to leave the firmware running or halted, then disconnect. Stop competing sessions before starting another probe operation.

## Troubleshoot

* **J-Link Software Required, or `JLinkGDBServer not found`:** install the full SEGGER package. If you installed it outside the default folders, add its folder to `PATH` and restart VS Code or the terminal running Inlay.
* **Unknown device:** check the exact SEGGER name and whether your installed package supports it.
* **Target voltage too low:** the board isn't powered or the voltage reference isn't connected.
* **Connection times out:** the probe responds but the target doesn't. Check target power and SWD or JTAG wiring.
* **Cannot connect:** check target power, voltage reference, wiring, the SWD or JTAG choice, and competing probe users.
* **Wrong source or missing variables:** use matching symbols and check optimization settings.
* **Run-to-main fails:** verify the entry path and the `main` symbol, then inspect the actual stop reason before continuing.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.