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
Table 11-1 11-2 11-3 11-4 11-5 11-6 11-7. In a Nutshell
PropertyValue
Download linkpypi.org/project/pydebuggerupgrade/
Source code-
Documentation-
Command line interfaceYes
LibraryYes
Supported kit typesNano Debugger based
Supported device typesAll

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
Table 11-1 11-2 11-3 11-4 11-5 11-6 11-7. In a Nutshell
PropertyValue
Download linkpypi.org/project/pykitinfo/
Source codegithub.com/microchip-pic-avr-tools/pykitinfo
Documentationmicrochip-pic-avr-tools.github.io/pykitinfo/
Command line interfaceYes
LibraryYes
Supported kit typesVarious
Supported device typesAll

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()
Table 11-1 11-2 11-3 11-4 11-5 11-6 11-7. In a Nutshell
PropertyValue
Download linkpypi.org/project/pyedbglib/
Source codegithub.com/microchip-pic-avr-tools/pyedbglib
Documentationmicrochip-pic-avr-tools.github.io/pyedbglib/
Command line interfaceNo
LibraryYes
Supported kit typesVarious
Supported device typesAll

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.
Table 11-1 11-2 11-3 11-4 11-5 11-6 11-7. In a Nutshell
PropertyValue
Download linkpypi.org/project/pymcuprog/
Source codegithub.com/microchip-pic-avr-tools/pymcuprog
Documentationmicrochip-pic-avr-tools.github.io/pymcuprog/
Command line interfaceYes
LibraryYes
Supported kit types
  • Curiosity Nano
  • Standalone CMSIS-DAP v1 debuggers
Supported device types
  • AVR devices
  • PIC devices with Curiosity Nano boards
  • Limited support of select SAMD devices

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            
Table 11-1 11-2 11-3 11-4 11-5 11-6 11-7. In a Nutshell
PropertyValue
Download linkpypi.org/project/pydebuggerconfig/
Source code-
Documentation-
Command line interfaceYes
LibraryYes
Supported kit typesNano Debugger
Supported device typesAll

11.6 pycmsisdapswitcher

pycmsisdapswitcher is a utility for switching firmware on certain Microchip debuggers and kits.
Important: pycmsisdapswitcher does NOT work for the Nano Debugger - use pydebuggerupgrade

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            
Table 11-1 11-2 11-3 11-4 11-5 11-6 11-7. In a Nutshell
PropertyValue
Download linkpypi.org/project/pycmsisdapswitcher/
Source code-
Documentation-
Command line interfaceYes
LibraryYes
Supported kit typesPKOB4
Supported device typesAll

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.

Table 11-1 11-2 11-3 11-4 11-5 11-6 11-7. In a Nutshell
PropertyValue
Download linkpypi.org/project/pykitcommander/
Source codegithub.com/microchip-pic-avr-tools/pykitcommander
Documentationmicrochip-pic-avr-tools.github.io/pykitcommander/
Command line interfaceNo
LibraryYes
Supported kit typesVarious
Supported device typesAll