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
JLinkInterface
Represents and instance of a J-Link Debugger
Methods:
Name | Description |
---|---|
__init__ |
Create a new J-Link instance. Note that this constructor does not attempt to communicate to the J-Link; that is done |
load_file |
Load a file onto the target device via the J-Link. Note that this function does not support .bin files as they |
reset_and_go |
Perform a reset of the target device. |
run_commands |
Run a series of J-Link Commands as you would find in a script file. |
__init__(device, interface='SWD', speed=4000)
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
|
load_file(filename, logfile=None)
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) |
reset_and_go(logfile=None)
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_commands(commands, logfile=None)
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) |