Applicable Scenarios
- A usable firmware artifact already exists in the workspace, and the target board is connected to a SEGGER J-Link probe.
- You need to use J-Link Commander for flashing and verification, rather than OpenOCD.
- You need to use J-Link RTT (Real-Time Transfer) for high-speed log capture.
- You need to scan the workspace for
.jlinkconfiguration files or J-Link settings in.vscode/launch.json.
Required Inputs
- The firmware artifact path, or the
artifact_pathcontainingProject Profile。 --deviceparameter specifies the target chip model (e.g.,STM32F407VG), which J-Link Commander requires to be specified.- Optional interface type (SWD or JTAG, default SWD) and flashing speed.
- If the artifact is a BIN, the
--base-addressflashing base address is also required.
Automatic Detection
- Upon startup, the script automatically reuses the last successful profile in the project root directory
.em_skill.jsonas the default parameters (explicit parameters take precedence; no need to manually pass--resume);--resumeis only used to assert that the cache must exist; exits non-zero if there is no cache. When there is no cache or the user explicitly requests re-detection, the script automatically falls back to a normal scan. - Select the firmware artifact by
ELF > HEX > BIN. - The script automatically locates JLinkExe, searching in the order of configuration files, PATH, and common installation paths.
--scan-configsScan the workspace for.jlinkfiles and the J-Link configuration in.vscode/launch.json.- It will not guess the device name; when
--deviceis missing, it blocks and returnsambiguous-context。
Execution Steps
- First read references/usage.mdto confirm whether this is environment detection, configuration scanning, or performing a flash.
- If you are unsure about the J-Link environment status, first run the built-in script scripts/jlink_flasher.py 's
--detectmode to confirm. - If you are unsure about the device model or interface configuration, use
--scan-configsto scan the workspace for clues. - Use
--artifact+--deviceto perform the flash, optionally--interfaceand--speed。 - For BIN files, you must also provide
--base-address。 - When RTT logs are needed, use
--rttto start RTT capture. - Read the flashing result report output by the script, focusing on the verification status and failure classification.
Failure Triage
- When
JLinkExeis unavailable, returnenvironment-missing。 - When the artifact cannot be safely resolved, or
BINlacks a flashing base address, returnartifact-missing。 - When J-Link cannot discover the probe or target, return
connection-failure。 - When the configuration file is invalid or the device name is not recognized by J-Link, return
project-config-error。 - When flashing starts but verification or reset fails, return
target-response-abnormal。 - When
--deviceis missing and cannot be inferred from the workspace, returnambiguous-context。
Platform Notes
- JLinkExe is
JLinkExeon Linux/macOS, andJLink.exe。 - SEGGER default installation paths: Linux
/opt/SEGGER/JLink/,WindowsC:\Program Files\SEGGER\JLink\。 - The built-in script uses the Python standard library and subprocess to call JLinkExe, and is cross-platform compatible.
- RTT functionality is unique to J-Link, does not occupy a UART, and is suitable for scenarios without a serial port.
Output Conventions
- Output the JLinkExe command, device name, interface type, artifact path, and verification result.
- In
Project Profilekeep or updateartifact_path、artifact_kind、jlink_device、jlink_interface。 - After successful flashing, it is recommended to
serial-monitorordebug-jlink。
Handoff relationships
- When the next step is to check runtime logs, hand off the successful flashing result to
serial-monitor。 - When the user needs GDB debugging, hand off the result to
debug-jlink。 - When RTT logs are needed instead of serial, you can directly use this skill's
--rttmode.