Enabling "AVR/EDBG mode" on the MPLAB Snap & PICkit 4 on Linux
The MPLAB Snap device is a hybrid device - that is, it can present itself as an "MPLAB Snap ICD" device, as well as an EDBG (Embedded Debugger) device. The device is known to be in "AVR mode" when configured to present itself as an EDBG device. The device switches between these two modes via a firmware update, issued by Microchip software (the MPLAB IDE and IPE).
In order to use the MPLAB Snap to program and debug AVR microcontrollers, it must first be flashed into AVR mode.
This article was initially written for the MPLAB Snap device. The MPLAB PICkit 4 device operates in a similar manner to the Snap. All of the below can be applied to the MPLAB PICkit 4 device, but care must be taken when specifying the USB product ID for the PICkit 4 (because it differs to that of the Snap).
The USB product ID for the PICkit 4, when in AVR/EDBG mode, will be 8567 (0x2177). When not in AVR/EDBG mode, the product ID (with the Microchip Vendor ID) will be 36882 (0x9012).
lsusb commands specified below must be adjusted to use the correct
USB product ID (in hexadecimal form).
Bloom will fail to recognise the device until AVR mode has been enabled.
Confirm the device is not already in AVR/EDBG mode
Before flashing the device into AVR mode, it may be worth confirming that the device is not already in AVR mode. When in AVR mode, the device will use the Atmel vendor ID 1003 (0x03eb) and the product ID 8576 (0x2180). When the device is not in AVR mode, it will use the Microchip vendor ID 1240 (0x04d8) and the product ID 36888 (0x9018). Upon connecting the MPLAB Snap device, run the following command:
$ lsusb -d 04d8:9018;
If the device is not in AVR mode, the following string should be output:
Bus XXX Device XXX: ID 04d8:9018 Microchip Technology, Inc.
If no such string is output, the device is likely already in AVR mode. Skip to the Confirmation section to confirm this.
Installing MPLAB IPE
Bloom cannot flash the MPLAB Snap device into AVR mode - it must be done via Microchip's MPLAB IPE software. This can be installed via the MPLAB IDE installer. Download the installer from the Microchip website. Select the MPLAB IPE option and proceed with the installation.
Flashing the MPLAB Snap into AVR mode via MPLAB IPE
NOTE: MPLAB IPE may fail to flash the device with the EDBG firmware, if this is the first instance of use, for the particular device.
If the device is brand new or this is the first instance of use, since purchase, the device may first need to be flashed with the standard firmware before it can be flashed with the EDBG firmware. See the Flashing the device with the standard firmware section below for instructions.
Upon flashing the new device with the standard firmware, you can now proceed to flash the device with the EDBG firmware.
Open MPLAB IPE and select any target within the AVR 8-bit family.
The MPLAB Snap does not need to be connected to the selected target. It can remain disconnected throughout this process.
Select the 'Read' function. The device will now be flashed with the appropriate firmware. Ignore any errors relating to target connection. Once the device has been flashed, it will perform a hard USB reset. The device should now present itself as an EDBG device.
Flashing the device with the standard firmware
Upon flashing the device with the EDBG firmware, you will no longer be able to use it for programming/debugging operations with any target from the PIC family, until the device has been flashed with the standard firmware.
To flash the device with the standard firmware, simply follow the instructions above, but when selecting a target, be sure to select one from the PIC family, as opposed to one from the AVR family.
As mentioned above, the device will use a different vendor and product ID when in AVR mode. To confirm the operation was successful, run the following command with the device connected:
$ lsusb -d 03eb:2180;
If the device is in AVR mode, the following string should be output:
Bus XXX Device XXX: ID 03eb:2180 Atmel Corp.
Debugging AVR targets with the MPLAB Snap and PICkit 4
Once the device has been flashed with the EDBG firmware, it can be used in conjunction with Bloom, to perform debugging operations on over 200 AVR 8-bit targets.
Bloom exposes an interface to the connected target by means of a GDB server. Any IDE with remote GDB capabilities can interface with Bloom, in order to perform debugging operations on the target.
Bloom also exposes the target's GPIO pin states, register values and memories, via the Bloom Insight window. Users can manipulate GPIO output pins and register values, as well as inspect target RAM and EEPROM, whilst execution on the target is halted.
To begin debugging with the MPLAB Snap or PICkit 4, on Linux, follow the instructions at Getting Started with Bloom.