11 Python Tools
A number of Python-based utilities are published on pypi.org that are useful when working with the Nano Debugger.
11.1 pydebuggerupgrade
pydebuggerupgrade is a CLI and library for upgrading the firmware on the Nano Debugger.
Why you Might use it
Use pydebuggerupgrade to keep your Nano Debugger firmware up to date.
Example
$ pydebuggerupgrade latest
Upgrading nedbg (ATML3203081800012252) to 'latest'
Upgrade to firmware version '1.33.76' successful| Property | Value |
|---|---|
| Download link | pypi.org/project/pydebuggerupgrade/ |
| Source code | - |
| Documentation | - |
| Command line interface | Yes |
| Library | Yes |
| Supported kit types | Nano Debugger based |
| Supported device types | All |
11.2 pykitinfo
pykitinfo is a lightweight Python utility for reading out useful information regarding connected development kits and debuggers, including the Nano Debugger.
Why you Might use it
The pykitinfo CLI is especially useful when you have multiple Nano Debugger kits connected to a computer and need a quick lookup of which kit is mapped to which Virtual Serial Port.
Example
$ pykitinfo
Looking for Microchip kits...
Compatible kits detected: 1
Kit ATML3203081800012252: 'AVR-IoT WG' (ATmega4808) on COM163| Property | Value |
|---|---|
| Download link | pypi.org/project/pykitinfo/ |
| Source code | github.com/microchip-pic-avr-tools/pykitinfo |
| Documentation | microchip-pic-avr-tools.github.io/pykitinfo/ |
| Command line interface | Yes |
| Library | Yes |
| Supported kit types | Various |
| Supported device types | All |
11.3 pyedbglib
pyedbglib is a library that provides access to the protocols and sub-protocols embedded in the CMSIS-DAP interface of the Nano Debugger.
Why you Might use it
pyedbglib might be useful when building your own tools or utilities.
Example (Python library)
"""
Example usage of pyedbglib to read debugger firmware version and target voltage
"""
from pyedbglib.hidtransport.hidtransportfactory import hid_transport
from pyedbglib.protocols.housekeepingprotocol import Jtagice3HousekeepingProtocol
from pyedbglib import __version__ as pyedbglib_version
# Report library version
print("pyedbglib version {}".format(pyedbglib_version))
# Make a connection using HID transport
transport = hid_transport()
transport.connect()
# Create a housekeeper
housekeeper = Jtagice3HousekeepingProtocol(transport)
housekeeper.start_session()
# Read out debugger firmware version
major = 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 voltage
target_voltage = housekeeper.get_le16(Jtagice3HousekeepingProtocol.HOUSEKEEPING_CONTEXT_ANALOG,
Jtagice3HousekeepingProtocol.HOUSEKEEPING_ANALOG_VTREF)
print ("Target voltage is {:.02f}V".format(target_voltage/1000.0))
# Tear down
housekeeper.end_session()
transport.disconnect()| Property | Value |
|---|---|
| Download link | pypi.org/project/pyedbglib/ |
| Source code | github.com/microchip-pic-avr-tools/pyedbglib |
| Documentation | microchip-pic-avr-tools.github.io/pyedbglib/ |
| Command line interface | No |
| Library | Yes |
| Supported kit types | Various |
| Supported device types | All |
11.4 pymcuprog
pymcuprog is a lightweight Python utility for erasing, reading and writing non-volatile memories on devices connected to the Nano Debugger and other Microchip standalone debuggers.
Why you Might use it
The pymcuprog CLI is especially useful when you want to check connectivity to a device ("ping"), or perform simple read and write operations from the command line.
Example
$ pymcuprog ping
Connecting to anything possible
Connected to nEDBG CMSIS-DAP from Microchip (serial number ATML3203081800012252)
Debugger firmware version 1.21.37
Debugger hardware revision 0
Device mounted: 'atmega4808'
No device specified. Using on-board target (atmega4808)
Pinging device...
Ping response: 1E9650
Done.| Property | Value |
|---|---|
| Download link | pypi.org/project/pymcuprog/ |
| Source code | github.com/microchip-pic-avr-tools/pymcuprog |
| Documentation | microchip-pic-avr-tools.github.io/pymcuprog/ |
| Command line interface | Yes |
| Library | Yes |
| Supported kit types |
|
| Supported device types |
|
11.5 pydebuggerconfig
pydebuggerconfig is a utility for configuring the Nano Debugger.
Why you Might use it
Use pydebuggerconfig when creating custom hardware with the Nano Debugger.
Example
$ pydebuggerconfig write -b board-configs/ATmega4809-CNANO.xml | Property | Value |
|---|---|
| Download link | pypi.org/project/pydebuggerconfig/ |
| Source code | - |
| Documentation | - |
| Command line interface | Yes |
| Library | Yes |
| Supported kit types | Nano Debugger |
| Supported device types | All |
11.6 pycmsisdapswitcher
Why you Might use it
Use pycmsisdapswitcher to switch your PICkit™ 4, PICkit™ 5, PICkit™ Basic, Snap, or PKOB4 into CMSIS-DAP v2 mode.
Example
$ pycmsisdapswitcher --appsource path_to_appfile | Property | Value |
|---|---|
| Download link | pypi.org/project/pycmsisdapswitcher/ |
| Source code | - |
| Documentation | - |
| Command line interface | Yes |
| Library | Yes |
| Supported kit types | PKOB4 |
| Supported device types | All |
11.7 pykitcommander
pykitcommander manages interactions with applications running on kits that use the Nano Debugger.
Why you Might use it
Use pykitcommander when you want to load an application onto an MCU and communicate with it using the Virtual Serial Port.
| Property | Value |
|---|---|
| Download link | pypi.org/project/pykitcommander/ |
| Source code | github.com/microchip-pic-avr-tools/pykitcommander |
| Documentation | microchip-pic-avr-tools.github.io/pykitcommander/ |
| Command line interface | No |
| Library | Yes |
| Supported kit types | Various |
| Supported device types | All |
