Skip to content

J-Link Interface

The J-Link Interface is used to connect to a physical J-Link probe and is used mainly for flashing firmware.

Provide an interface to the J-Link Command program through a Python interface

Represents and instance of a J-Link Debugger

Create a new J-Link instance. Note that this constructor does not attempt to communicate to the J-Link; that is done on subsequent function calls.

Parameters:

Name Type Description Default
device str

Name of the device target processor

required
interface str

Interface via which to connect to the target (defaults to SWD)

'SWD'
speed int

Connection speed (default 4000 KHz)

4000

Internal function to build a connection args string based on the initial values from the constructor

Parameters:

Name Type Description Default
command_file str

Path to command file

required

Returns:

Type Description
str

Full argument string that can be passed to the J-Link commander

Execute a set of full arguments, optionally log to a file, and return the status of the execution.

Load a file onto the target device via the J-Link. Note that this function does not support .bin files as they require an offset address.

Parameters:

Name Type Description Default
filename str

Path of the file to be loaded

required
logfile str

Optional path to a file that JLink Commander will write logs to

None

Returns:

Type Description
bool

Status of operation (True on success, False otherwise)

Perform a reset of the target device.

Parameters:

Name Type Description Default
logfile str

Optional path to a file that JLink Commander will write logs to

None

Returns:

Type Description
bool

Status of operation (True on success, False otherwise)

Run a series of J-Link Commands as you would find in a script file. Example commands are loadfile, reset, go, etc. Each element in the array is a command and its arguments, for example: commands = ['reset', 'loadfile /build/fw.hex', 'exit']

Commands can be found at https://wiki.segger.com/J-Link_Commander.

Parameters:

Name Type Description Default
commands list[str]

List of commands to execute

required
logfile str

Optional path to a file that JLink Commander will write logs to

None

Returns:

Type Description
bool

Status of operation (True on success, False otherwise)