Connecting to your Device

Connecting Example

# Connect to the gateway
gateway = lager.Lager()

# Connect the gateway to your device
# This starts an OpenOCD session
# (connecting to an stm32f1x via the gateway's 20 pin JTAG connector)
device = gateway.connect("stm32f1x", interface="ftdi", transport="jtag")
print(f"Connected to device: {device}")

# Don't forget to close the connection
device.close()

Do More with your Device

# Connect to device
device = gateway.connect("stm32f1x", interface="ftdi", transport="jtag")

# Halt the device
device.reset(halt=True)

# Erase your device
# 64k flash, start address 0x08000000
device.erase(0x08000000, 65536)

# Flash a hex file on to the device
# The file(s) must be in the same folder as the script you're running
hexfiles = [lager.Hexfile("olimex-h103.hex")]
device.flash(hexfiles=hexfiles)

# Start running the new code
device.run()