Thursday, November 21, 2013

Quick fix: MPLAB X Cannot Connect to PicKit2 or PicKit3

Problem

After an update of some software on a 64 bit Windows computer you might run into the following message when you start MPLAB X:


Also, when you try to program your device it fails.

PICkit2:
Loading code from F:/Projects/PIC/LilBang.X/dist/default/production/LilBang.X.production.hex...
Loading symbols from F:/Projects/PIC/LilBang.X/dist/default/production/LilBang.X.production.cof...
Loading completed
Connecting to programmer...
The programmer could not be started: Could not connect to tool hardware: PICkit2PlatformTool, com.microchip.mplab.mdbcore.pickit2.PICkit2DbgToolManagerPK2Error0022:  PICkit 2 not found

PICkit3:
Loading code from F:/Projects/PIC/Fws.X/dist/default/production/Fws.X.production.hex...
Loading symbols from F:/Projects/PIC/Fws.X/dist/default/production/Fws.X.production.cof...
Loading completed
Connecting to programmer...
The programmer could not be started: Could not connect to tool hardware: PICkit3PlatformTool, com.microchip.mplab.mdbcore.PICKit3Tool.PICkit3DbgToolManagerConnection Failed.

Note: Using the dedicated PICkit2 Programmer application works without any problem.

Reason

The java installation in "C:\Program Files (x86)\Microchip\MPLABX\sys\java\jre1.6.0_32-windows-x64" is missing. The same symptoms occur even if both 32 bit and 64 bit versions of the Java SE runtime are installed on the PC.

Fix

To restore normal functionality of MPLAB X, just copy the relevant Java files to "C:\Program Files (x86)\Microchip\MPLABX\sys\java\jre1.6.0_32-windows-x64\java-windows". It doesn't matter if the directory name doesn't match the actual version of Java. The directory name should not be changed.


This workaround worked fine with MPLAB X IDE v1.95 which is (at the time of writing this article) the latest.