Import
Methods
The Net-based API provides methods for embedded debugging operations.| Method | Description |
|---|---|
connect(speed, transport) | Connect to target device |
disconnect() | Disconnect from target |
reset(halt) | Reset the device |
flash(firmware_path) | Flash firmware to device |
erase() | Perform full chip erase |
read_memory(address, length) | Read memory from device |
status() | Get connection status |
rtt(channel) | Create RTT session for bidirectional communication |
Method Reference
Net.get(name, type=NetType.Debug)
Get a debug net by name.
| Parameter | Type | Description |
|---|---|---|
name | str | Name of the debug net |
type | NetType | Must be NetType.Debug |
channel field (e.g., ‘NRF52840_XXAA’, ‘R7FA0E107’).
connect(speed=None, transport=None)
Connect to the target device.
| Parameter | Type | Default | Description |
|---|---|---|---|
speed | str | '4000' | Interface speed in kHz (e.g., ‘4000’) or ‘adaptive’ |
transport | str | 'SWD' | Transport protocol (‘SWD’ or ‘JTAG’) |
dict - Status dictionary with connection information
disconnect()
Disconnect from the target device.
dict - Status dictionary
reset(halt=False)
Reset the device.
| Parameter | Type | Default | Description |
|---|---|---|---|
halt | bool | False | Halt CPU after reset |
str - Combined output from reset operation
flash(firmware_path)
Flash firmware to the device.
| Parameter | Type | Description |
|---|---|---|
firmware_path | str | Path to firmware file (.hex, .bin, or .elf) |
str - Combined output from flash operation
Note: For .bin files, flash address defaults to 0x00000000.
erase()
Perform full chip erase. This erases ALL flash memory including protection settings.
str - Combined output from erase operation
read_memory(address, length)
Read memory from the target device.
| Parameter | Type | Description |
|---|---|---|
address | int | Starting memory address |
length | int | Number of bytes to read |
bytes - Memory data
status()
Get the current connection status.
dict - Status dictionary with connection information
rtt(channel=0)
Create an RTT (Real-Time Transfer) session for bidirectional communication with the target device.
| Parameter | Type | Default | Description |
|---|---|---|---|
channel | int | 0 | RTT channel number (typically 0-15) |
read_some(timeout)- Read available data with timeout (returns bytes or None)write(data)- Write data to target (accepts bytes or str)
connect() first.
Examples
Flash Firmware and Reset
Chip Erase Before Programming
Read Memory
CLI Commands (Recommended)
For most use cases, the CLI provides a simpler interface:RTT Streaming
SEGGER Real-Time Transfer (RTT) enables high-speed bidirectional communication with embedded devices during debugging (faster than UART, no timing impact).| Method | Description |
|---|---|
read_some(timeout) | Read available data with timeout (returns bytes or None) |
write(data) | Write data to RTT (accepts bytes or str) |
lager debug <net> gdbserver --rtt-reset to stream RTT logs directly.
Supported Devices
J-Link supports a wide range of ARM Cortex-M and other microcontrollers. Common device names:| Manufacturer | Device Name | Description |
|---|---|---|
| Nordic | NRF52840_XXAA | nRF52840 |
| Nordic | NRF52833_XXAA | nRF52833 |
| Nordic | NRF5340_XXAA_APP | nRF5340 Application Core |
| Renesas | R7FA0E107 | RA0E1 Series |
| Renesas | R7FA2L1 | RA2L1 Series |
| STMicro | STM32F103C8 | STM32F1 Series |
| STMicro | STM32F407VG | STM32F4 Series |
| STMicro | STM32L476RG | STM32L4 Series |
Supported Hardware
| Debug Probe | Features |
|---|---|
| J-Link | JTAG/SWD debugging, flash programming |
| CMSIS-DAP | SWD debugging (via pyOCD backend) |
| ST-Link | SWD debugging (via pyOCD backend) |
Notes
- Debug nets must be configured with the target device name in the
channelfield - The CLI (
lager debug) is recommended for most use cases - Python Net API is intended for advanced automation scripts running on the Lager Box
- Always call
disconnect()when finished to release the debug probe - Use
erase()to perform a full chip erase and clear protection settings - RTT requires an active debug connection (see RTT Streaming section above)

