Why would anybody downgrade a PICkit5 to a PICkit4 or a PICkit Basic to a MPLAB SNAP?

Nobody would do that being in their right mind if the intention is to use the debugger/programmer in connection with MPLAB X. But if you want to use an open-source GDB server, such as AVaRICE, Bloom, or PyAvrOCD, then you cannot make use of the most recent Microchip debug probes. So, if you bought one of these new debug probes with the idea of using them with open-source software, you lost. And in this case, it might be a worthwhile idea to look into downgrading such a debug probe.

Faking a Hardware Tool Recovery

Assuming that the hardware of the PICkit 4 and 5, on one hand, and SNAP and the PICkit Basic, on the other hand, are close enough, one could try to upload the older firmware on the new hardware. The key to that is the Hardware Tool Emergency Boot Firmware Recovery action that you find in the Debug menu of MPLAB X. I outlined the procedure already in the blog post on how you turn SNAP into an AVR debug probe. The only difference is now that you pretend to have a different piece of hardware, for which you go through the recovery procedure. An alternative to using MPLAB X is the Python script pycmsisdapswitcher, which you can use to recover and switch to different firmwares.

In both cases, you first need to bring the debug probe into recovery mode. This means:

  1. While there is a USB connection to the host, you need to press the reset button for 4 seconds (small hole right of the USB receptacle on PICkit5 and left hole above MPLAB logo on PICkit Basic).
  2. Wait for 15 seconds.
  3. Disconnect USB for 2 seconds.
  4. After reconnecting, the debug probe is in recovery mode.

When using pycmsisdapswitcher, you now have to type:

pycmsisdapswitcher --action recover --target <target> --fwtype mplab

<target> can be pickit4 or snap (when downgrading). Afterward, the debug probe should pretend to be the mentioned target.

In MPLAB X, you have to go through all the steps that the IDE tells you. In the end, you once have to upload or download something to a target chip. This will trigger the download of the current firmware.

When all is done, you need to do the avrdude trick of switching to AVR mode:

avrdude -c pikit4_isp -x mode=avr

or

avrdude -c snap_isp -x mode=avr

And then you can use the debug probes with above mentioned debuggers.

Theory and Reality

And does it work? Yes, but not always. First of all, switching from one model to another does not always succeed in the first run. And sometimes one method succeeds, then the other. And in my case, it seems to be impossible to reflash the PICkit5 with the PICkit5 firmware. I have no idea why. After downgrading, the debug probes can indeed be used as if they were the older model. In summary, I would consider the move of downgrading PICkit5 or PICkit Basic only as a last resort. And only do it if you do not need to switch back to the original firmware.