Skip to content

Using Programmers

A Rockface programmer tool loads firmware, or some other data, into a programmable device or memory. For example it may be used for loading firmware into a microcontroller's flash memory, or it may be used for writing a non-volatile flash chip.

In the rockface python library, programmer tools are represented using the rockface.tools.programmer.Programmer type:

py
from rockface import Rig
from rockface.tools.programmer import Programmer

rig = Rig.find_by_name("my-rig")
prog = rig.tools["prog"]

assert isinstance(prog, Programmer)

Examples continue from the above

For brevity, the rest of the examples on this page will continue on from the above example, with the prog variable set to a Programmer instance.

Loading a File

To load a file into a target device using the programmer, use its flash_file method:

py
with open("firmware.hex", "rb") as firmware:
	prog.flash_file(firmware)

The call will block until the device is programmed.

Resetting the Target

When the target device of the programmer tool is capable of being reset, the reset_target method can be used to reset it:

py
prog.reset_target()