Package: pyedbglib
pyedbglib - Python EDBG protocol librarypyedbglib is a low-level protocol library for communicating with Microchip CMSIS-DAP based debuggersOverviewpyedbglib is available:install using pip from pypi:https://pypi.org/project/pyedbglibbrowse source code on github:https://github.com/microchip-pic-avr-tools/pyedbglibread API documentation on github:https://microchip-pic-avr-tools.github.io/pyedbglibread the changelog on github:https://github.com/microchip-pic-avr-tools/pyedbglib/blob/main/CHANGELOG.mdUsagepyedbglib is a library which can be used by Python applications to communicate with Microchip microcontrollers via Microchip CMSIS-DAP based debuggers.The protocol is documented in theEDBG communication protocol.Supported debuggerspyedbglib supports:PKOB nano (nEDBG) - on-board debugger on Curiosity NanoMPLAB PICkit 4 In-Circuit Debugger (when in 'AVR mode')MPLAB Snap In-Circuit Debugger (when in 'AVR mode')Atmel-ICEPower DebuggerEDBG - on-board debugger on Xplained Pro/UltramEDBG - on-board debugger on Xplained Mini/NanoJTAGICE3 (firmware version 3.0 or newer)Note: Each debugger may implement a subset of protocols and commands.Example"""Example usage of pyedbglib to read debugger firmware version and target voltage"""frompyedbglib.hidtransport.hidtransportfactoryimporthid_transportfrompyedbglib.protocols.housekeepingprotocolimportJtagice3HousekeepingProtocolfrompyedbglib.versionimportVERSIONaspyedbglib_version# Report library versionprint("pyedbglib version{}".format(pyedbglib_version))# Make a connection using HID transporttransport=hid_transport()transport.connect()# Create a housekeeperhousekeeper=Jtagice3HousekeepingProtocol(transport)housekeeper.start_session()# Read out debugger firmware versionmajor=housekeeper.get_byte(Jtagice3HousekeepingProtocol.HOUSEKEEPING_CONTEXT_CONFIG,Jtagice3HousekeepingProtocol.HOUSEKEEPING_CONFIG_FWREV_MAJ)minor=housekeeper.get_byte(Jtagice3HousekeepingProtocol.HOUSEKEEPING_CONTEXT_CONFIG,Jtagice3HousekeepingProtocol.HOUSEKEEPING_CONFIG_FWREV_MIN)build=housekeeper.get_le16(Jtagice3HousekeepingProtocol.HOUSEKEEPING_CONTEXT_CONFIG,Jtagice3HousekeepingProtocol.HOUSEKEEPING_CONFIG_BUILD)print("Debugger firmware is version{}.{}.{}".format(major,minor,build))# Read out target voltagetarget_voltage=housekeeper.get_le16(Jtagice3HousekeepingProtocol.HOUSEKEEPING_CONTEXT_ANALOG,Jtagice3HousekeepingProtocol.HOUSEKEEPING_ANALOG_VTREF)print("Target voltage is{:.02f}V".format(target_voltage/1000.0))# Tear downhousekeeper.end_session()transport.disconnect()Notes for Linux® systemsHIDAPI needs to build using packages: libusb-1.0.0-dev, libudev-devUSB devices need udev rules to be added to a file in /etc/udev/rules.dExample of udev rules for supported debuggers:# HIDAPI/libusb:# JTAGICE3SUBSYSTEM=="usb",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="2140",MODE="0666"# Atmel-ICESUBSYSTEM=="usb",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="2141",MODE="0666"# Power DebuggerSUBSYSTEM=="usb",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="2144",MODE="0666"# EDBG - debugger on Xplained ProSUBSYSTEM=="usb",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="2111",MODE="0666"# EDBG - debugger on Xplained Pro (MSD mode)SUBSYSTEM=="usb",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="2169",MODE="0666"# mEDBG - debugger on Xplained MiniSUBSYSTEM=="usb",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="2145",MODE="0666"# PKOB nano (nEDBG) - debugger on Curiosity NanoSUBSYSTEM=="usb",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="2175",MODE="0666"# PKOB nano (nEDBG) in DFU mode - bootloader of debugger on Curiosity NanoSUBSYSTEM=="usb",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="2fc0",MODE="0666"# MPLAB PICkit 4 In-Circuit DebuggerSUBSYSTEM=="usb",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="2177",MODE="0666"# MPLAB Snap In-Circuit DebuggerSUBSYSTEM=="usb",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="2180",MODE="0666"pyedbglib also provides helper functions for accessing serial ports.  The user has to be part of the 'dialout' group to allow this.  This can be done by executing:sudoadduser$USERdialoutIt may also be necessary to grant read+write permission to the port, for example:sudochmoda+rw/dev/ttyACM0