Skip to main content
Control debugger operations for embedded development including flashing, GDB server management, memory access, and RTT logging.

Syntax

Global Options

Commands

Command Reference

gdbserver

Start JLinkGDBServer for remote debugging. This is the primary command to establish a debug connection.
Options:
  • --box TEXT - Lagerbox name or IP
  • --force / --no-force - Force new connection (default: reuse existing)
  • --halt / --no-halt - Halt device when connecting (default: no-halt)
  • --speed KHZ - SWD/JTAG speed in kHz (e.g., 100, 4000) or “adaptive”
  • --quiet - Suppress informational messages
  • --json - Output results in JSON format
  • --rtt - Automatically stream RTT logs after starting GDB server
  • --rtt-reset - Reset device then stream RTT (captures boot sequence)
  • --reset - Reset device after starting GDB server
  • --gdb-port PORT - Override the auto-allocated GDB server port. By default the box picks a port based on the probe’s slot (2331 for the first probe, 2334 for the second, etc.); pass this only if you need a specific port, and avoid it on multi-probe boxes.
  • --rtt-search-addr HEX - RAM start address for the RTT control block search (hex, e.g., 0x20020000)
  • --rtt-search-size HEX - Size of the RAM region to search for the RTT control block (hex, e.g., 0x4000)
  • --rtt-chunk-size HEX - Read chunk size for the RTT search (hex, e.g., 0x1000)
Examples:
Connecting with GDB:

disconnect

Stop JLinkGDBServer and free debug resources.
Options:
  • --box TEXT - Lagerbox name or IP
  • --keep-server - Keep JLinkGDBServer running for external connections
Examples:

flash

Flash firmware to target. Supports Intel HEX, ELF, and binary file formats.
Options:
  • --box TEXT - Lagerbox name or IP
  • --hex FILE - Path to Intel HEX file
  • --elf FILE - Path to ELF executable
  • --bin ADDRESS FILE - Path to binary file with load address
  • --verbose - Show detailed J-Link output
  • --force-reconnect - Force clean reconnect before flash
  • --no-erase - Skip the erase step (by default flash erases before programming for a clean state)
  • --halt / --no-halt - Halt device after flashing (default: no-halt)
flash erases before programming by default, so no flag is needed for a clean state (this is what RTT initialization wants). Pass --no-erase only when you intentionally want to preserve existing flash contents. The older --erase flag is now a no-op kept for backward compatibility.
Examples:

reset

Reset the target device.
Options:
  • --box TEXT - Lagerbox name or IP
  • --halt / --no-halt - Halt after reset (default: no-halt)
  • --force-reconnect - Force clean reconnect before reset
Examples:

erase

Erase all flash memory on target. This is a destructive operation.
Options:
  • --box TEXT - Lagerbox name or IP
  • --speed KHZ - SWD/JTAG speed in kHz (default: 4000)
  • --yes - Skip confirmation prompt
  • --quiet - Suppress warning messages
  • --json - Output results in JSON format
  • --halt / --no-halt - Halt after erase (default: no-halt)
Examples:

memrd

Read memory from the target device.
Arguments:
  • START_ADDR - Starting memory address (e.g., 0x20000000)
  • LENGTH - Number of bytes to read
Options:
  • --box TEXT - Lagerbox name or IP
  • --json - Output results in JSON format
  • --halt / --no-halt - Halt device during read (default: no-halt). --no-halt overrides the auto-halt for DA1469x QSPI XIP
  • --no-reset - DA1469x only. Skip the reset+halt the box performs before the read. A running DA1469x has SWD disabled, so without the reset the read fails — use this only on a blank/awake part to avoid rebooting it
Examples:
Output:

status

Show debug net status and configuration information.
Options:
  • --box TEXT - Lagerbox name or IP
Examples:
Output:

health

Check debug service health and resource usage.
Options:
  • --box TEXT - Lagerbox name or IP
  • --verbose - Show detailed health information
Examples:
Output (verbose):

Listing Debug Nets

When invoked with only --box and no subcommand, lists all debug nets on the Lager Box:
Output:

RTT (Real-Time Transfer) Logging

RTT provides low-latency logging over the debug probe. Use the --rtt or --rtt-reset flags with gdbserver:

Decoding defmt logs

Most Rust (and much C) firmware logs via defmt, a compressed binary format. Raw RTT bytes from defmt firmware are not human-readable — they must be decoded by defmt-print using the exact ELF that is flashed on the target.
Two things to watch:
  • Redirect stderr. The RTT payload is written to stdout; status messages (JLinkGDBServer started!, etc.) go to stderr. Pipe stdout only — append 2>/dev/null (or 2>debug.log) so status lines never corrupt defmt-print’s input.
  • The stream never ends. --rtt runs until the process is killed. In scripts or non-interactive sessions, wrap it in timeout <seconds> to capture a fixed window; when the lager process is killed the pipe closes and defmt-print exits on EOF.
Install defmt-print with cargo install defmt-print on the machine where you run the pipe (the same machine that holds the .elf).

Typical Workflows

Development Cycle

RTT Debugging

Memory Inspection

Clean Up

JLinkScript Support

JLinkScript files allow you to customize J-Link debug probe behavior for specific hardware configurations. They can handle custom reset sequences, clock initialization, pin configurations, and other device-specific operations that the standard J-Link connection flow does not cover.

Configuring JLinkScript

There are three ways to attach a J-Link script to a debug net: 1. During net creation:
2. On an existing net:
3. Per-project in .lager config:

Script Priority

When both a net-level script (stored on the box via set-script) and a project-level script (in .lager config) exist, the project-level script takes priority. This allows you to override the box-stored script for specific projects.

Managing Scripts

Once attached, the script is used automatically for all debug operations (connect, flash, erase, reset) without any additional flags.

Supported Debug Probes

Supported Device Families

Lager supports 70+ ARM Cortex-M device families with automatic architecture detection. The device type is specified as the channel when creating a debug net (e.g., STM32F407VG, nRF52840).

Cortex-M0/M0+ (ARMv6-M)

Cortex-M3 (ARMv7-M)

Cortex-M4/M7 (ARMv7E-M)

Cortex-M23 (ARMv8-M Base)

Cortex-M33/M55 (ARMv8-M Main)

Devices not in the table above default to Cortex-M4 (ARMv7E-M) architecture. If your device is not detected correctly, specify the full device part number (e.g., STM32F407VG rather than just STM32F4) when creating the debug net.

Notes

  • Debug nets are created with lager nets add <name> debug <device_type> <address>
  • The system auto-connects when needed for commands like flash and reset
  • flash erases before programming by default, giving a clean state for RTT initialization (use --no-erase to opt out)
  • RTT streaming requires the device to have RTT support in firmware
  • Memory reads are more reliable with --halt to pause the CPU
  • Use lager debug health --verbose to diagnose connection issues
  • JLinkScript files are base64-encoded for storage and decoded automatically on the box

See Also