Using J-Link with Embedder

From SEGGER Knowledge Base
Jump to navigation Jump to search

Embedder is an AI-powered development platform designed specifically for embedded software. It can analyze hardware documentation and source code, modify firmware, program a target device, collect runtime information, and assist with debugging on real hardware.

J-Link provides the connection between Embedder and the target system. Embedder can automatically detect connected J-Link debug probes and use them for programming, GDB-based debugging, and collecting runtime output through SEGGER Real-Time Transfer (RTT).

Integration status: J-Link integration available; joint reference setup and validation in progress.

Overview

Component Description
Development tool Embedder
Integration type J-Link GDB backend and SEGGER RTT
User interface Visual Studio Code extension or Embedder CLI
Supported debug interfaces SWD and JTAG
Required SEGGER software J-Link Software and Documentation Pack
Validation status Joint SEGGER/Embedder validation in progress

Supported workflows

The following workflows are available when using Embedder with J-Link:

Workflow J-Link interface Description
Detect the debug probe J-Link software Embedder automatically detects connected J-Link debug probes.
Connect to the target J-Link Connect to supported target devices using SWD or JTAG.
Program the target J-Link flash programming Download the generated firmware to the target device.
Control target execution J-Link GDB Server Reset, halt, start, and step through the target application.
Set breakpoints J-Link GDB Server Set code breakpoints and inspect the target when a breakpoint is reached.
Inspect memory and registers J-Link GDB Server Read CPU registers, variables, and target memory.
Analyze faults J-Link GDB Server Inspect the processor state and relevant fault registers.
Attach to a running target J-Link GDB Server Inspect a running system without performing an initial reset.
Collect runtime output SEGGER RTT Read log messages and test results without requiring an additional UART connection.
Automated test and debug workflow J-Link GDB Server and SEGGER RTT Program the firmware, collect runtime information, analyze the result, and apply corrections.

How the integration works

For debugging, Embedder uses GDB together with J-Link as the debug backend:

  1. Embedder builds the embedded application and locates the ELF file.
  2. Embedder starts or connects to the GDB environment.
  3. The J-Link GDB Server translates the GDB commands into target-specific debug operations.
  4. The J-Link debug probe communicates with the target over SWD or JTAG.
  5. Debug information is returned to Embedder for analysis.

SEGGER RTT can additionally be used to transfer log messages, test results, and other runtime information from the target to Embedder.

Prerequisites

Before getting started, make sure the following components are available:

  • A supported J-Link debug probe
  • A supported target device and development board
  • A USB or network connection to the J-Link debug probe
  • The latest J-Link Software and Documentation Pack
  • Visual Studio Code with the Embedder extension or the Embedder CLI
  • An embedded project that generates an ELF file containing debug information
  • A physical SWD or JTAG connection between J-Link and the target
  • Target power supplied by the development board or an external power supply

SEGGER RTT must be included and initialized by the target application if RTT output is required.

Tested setup

The following reference configuration was used to validate this integration:

Component Version or configuration
Embedder 0.3.187
Embedder VS Code extension 0.3.187
J-Link Software and Documentation Pack V9.76
J-Link model J-Link PLUS
Development board Cortex-M Trace Reference Board
https://www.segger.com/products/debug-probes/j-trace/accessories/trace-reference-boards/overview/
Target device STM32F407VE
Debug interface SWD
Host operating system Windows
Compiler and version Arm GNU Toolchain 13.2.rel1 — arm-none-eabi-gcc 13.2.1 (20231009)
Example project File:Embedder Example.zip

Getting started

1. Install the J-Link software

Download and install the latest version of the J-Link Software and Documentation Pack:

The package contains the J-Link USB drivers, J-Link Commander, J-Link GDB Server, and the required target device support.

2. Connect J-Link and the target

Connect the J-Link debug probe to the host computer and to the target system.

Make sure that:

  • The target is powered.
  • The SWD or JTAG signals are connected correctly.
  • The target reference voltage can be detected by J-Link.
  • No other application is currently using the J-Link connection.

Optionally, use J-Link Commander to verify that the target can be detected and connected before configuring Embedder.

3. Install Embedder

Embedder initialization

Install the Embedder extension from the Visual Studio Code Marketplace.

Alternatively, install and start the Embedder CLI according to the Embedder installation instructions.

After installation:

  1. Open the embedded project.
  2. Open the Embedder panel.
  3. Select or create an Embedder project.
  4. Select the target platform and required peripherals.
  5. Run /init to generate the project configuration.

4. Configure J-Link as the debug interface

Add the following information to the project's EMBEDDER.md file:

Debug Interface = jlink
Target MCU = <J-Link device name>

Replace <J-Link device name> with the exact device name supported by the J-Link Software and Documentation Pack.

Example:

Debug Interface = jlink
Target MCU = nRF52840_xxAA

If no debug interface is specified, Embedder may automatically select a detected debug probe. Explicitly configuring jlink is recommended for reproducible setups.

5. Build the application

Build the project and make sure that an ELF file with debug information is generated.

For the best debugging experience, use a debug build with limited compiler optimization. High optimization levels may prevent GDB from displaying local variables accurately.

6. Start debug mode

Enter Embedder's hardware-aware debug mode:

/debug

When entering debug mode, Embedder checks for connected hardware and available debug interfaces.

7. Start a J-Link debug workflow

Debugging with Embedder

The target can now be inspected using natural-language prompts.

For example:

Use J-Link to connect to the target and halt at main.
Set a breakpoint at uart_init, run the application, and show me the
register values when the breakpoint is reached.
The device is no longer responding. Attach without resetting it and
show me where the application is currently executing.
The device is hard-faulting during startup. Inspect the fault registers
and identify the instruction that caused the fault.

Embedder displays the operations it intends to perform before executing them. Review all target-modifying operations before approving them.

Using SEGGER RTT

SEGGER RTT provides high-speed bidirectional communication between the target and Embedder through the J-Link debug connection.

RTT can be used for:

  • Application log messages
  • Test status and test results
  • Diagnostic information
  • Runtime measurements
  • Interactive target communication
  • Automated verification workflows

To use RTT:

  1. Add SEGGER RTT to the target application.
  2. Initialize RTT during application startup.
  3. Connect the J-Link debug probe.
  4. Open the Embedder console.
  5. Select RTT as the connection type.
  6. Select the target device and debug interface.
  7. Start the target application.

Example prompt:

Program the current firmware, start the target, and monitor the RTT
output for errors.

A more complete automated workflow could use:

Build and program the application using J-Link. Monitor the RTT output
for 30 seconds. If the self-test reports an error, analyze the relevant
code and propose a fix.

Example debugging workflow

The following example demonstrates an iterative AI-assisted debugging workflow:

  1. Ask Embedder to analyze the existing firmware.
  2. Ask Embedder to implement or modify a peripheral driver.
  3. Review and approve the proposed source-code changes.
  4. Build the application.
  5. Program the target using J-Link.
  6. Start the application.
  7. Collect runtime output using SEGGER RTT.
  8. Ask Embedder to analyze unexpected behavior.
  9. Inspect the target state through the J-Link GDB Server if required.
  10. Apply the proposed correction.
  11. Rebuild, reprogram, and repeat the test.

This creates a closed-loop workflow in which the AI-generated code is verified on the actual target hardware.

Troubleshooting

Problem Possible cause Solution
J-Link is not detected J-Link software is missing, outdated, or the probe is already in use Install the latest J-Link Software and Documentation Pack, reconnect the probe, and close other applications using J-Link.
Target connection fails Incorrect target device, interface, wiring, or target power Verify the J-Link device name, SWD/JTAG selection, target power, and physical connection.
Embedder selects a different debug probe The debug interface is not explicitly configured Add Debug Interface = jlink to EMBEDDER.md.
Incorrect target device is selected The target device was detected incorrectly Add the exact J-Link device name as Target MCU in EMBEDDER.md.
No ELF file is found The project has not been built or the output path is unknown Build the project and verify that an ELF file containing debug information is generated.
Variables are shown as optimized out The application was built with a high optimization level Use -Og or -O0 for the relevant source files.
No RTT output is available RTT is not initialized or the RTT control block cannot be located Verify the target-side RTT configuration and make sure the application reaches the RTT initialization code.
The target is reset unexpectedly The requested workflow includes a reset or programming operation Explicitly request an attach without reset when the current target state must be preserved.

Support responsibilities

For problems related to the J-Link debug probe, target connectivity, device support, J-Link GDB Server, or SEGGER RTT, contact SEGGER Support.

For problems related to the Embedder extension, Embedder account, AI behavior, project configuration, or generated source code, contact Embedder Support.

When reporting a problem, provide:

  • J-Link serial number and model
  • J-Link Software and Documentation Pack version
  • Embedder version
  • Host operating system
  • Target device and board
  • Debug interface
  • Relevant log output
  • A description of the operation that failed

Limitations

  • Available functionality may depend on the target architecture and device.
  • The target application must provide an ELF file with suitable debug information for source-level debugging.
  • RTT requires target-side integration of SEGGER RTT.
  • AI-generated changes and target operations should be reviewed before execution.
  • Trace functionality and advanced J-Link features may require separate integration.
  • Support for a J-Link device does not automatically imply that the complete Embedder workflow has been validated for that device.

Related links