Basic commands and using PICkit 2 on Linux!

Now that we have the software installed and ready to use, it is time to get familiar with the basic commands to successfully load the program into the microcontroller. So let’s get started!

Checking version:

pk2cmd -?V

# Returned output:

Executable Version:    1.20.00
Device File Version:   1.55.00
OS Firmware Version:   2.32.00


Operation Succeeded

Auto-detect PIC:

pk2cmd -P

# Returned output:
Auto-Detect: Found part PIC16F887.


Operation Succeeded

Erase a device:

pk2cmd -P -E

# Returned output:
Auto-Detect: Found part PIC16F887.

Erasing Device...

Operation Succeeded

Blank check:

pk2cmd -P -C

# Returned output:
Auto-Detect: Found part PIC16F887.

Device is blank

Operation Succeeded

Program a device:

pk2cmd -PPIC16F887 -J -M -Ftest_write.hex

# Returned output:
PICkit 2 Program Report       
2-1-2021, 1:17:27
Device Type: PIC16F887

Program Succeeded.

Operation Succeeded

Power a device and release reset:

pk2cmd -P -A5 -T -R

# Returned output:
Auto-Detect: Found part PIC16F887.


Operation Succeeded

Read a device:

pk2cmd -PPIC16F887 -J -R -GFtest_read.hex

# Returned output:
Read successfully.            

Operation Succeeded
I believe this is enough to get started with PICkit 2 Development Programmer / Debugger on Linux OS.
Stay healthy and safe till the next time!

Install PICkit 2 Development Programmer / Debugger on Raspberry Pi OS.

To install PICkit 2 Development Programmer / Debugger on Raspberry Pi OS, we are gonna first prepare our system by installing dependencies, download source code for PICkit 2 command-line application, compile it, and at the end verify test installation.

So for that, we are gonna use these commands as follows:

Update and Install dependencies:

sudo apt update
sudo apt install build-essential libusb-dev

Download and unpack the source files:

wget https://ww1.microchip.com/downloads/en/DeviceDoc/pk2cmdv1.20LinuxMacSource.tar.gz
tar xzvf pk2cmdv1.20LinuxMacSource.tar.gz
cd pk2cmdv1.20LinuxMacSource

Building the application:

make linux

Installing the application:

make install

Adding device file location to PATH:

echo 'export PATH="$PATH:/usr/share/pk2"' >> ~/.bashrc

Reboot system and test installation:

pk2cmd -?v

# PICki2 not connected
Executable Version:    1.20.00
Device File Version:   1.55.00
OS Firmware Version:   PICkit 2 not found

# PICkit2 connected
Executable Version:    1.20.00
Device File Version:   1.55.00
OS Firmware Version:   2.32.00

Uninstall pk2cmd:

Remove file pk2cmd from /usr/local/bin:
sudo rm -R /usr/local/bin/pk2cmd

Remove all files from /usr/share/pk2/:
sudo rm /usr/share/pk2/*

Remove folder /usr/share/pk2/:
sudo rm -R /usr/share/pk2

Edit file .bashrc:
sudo nano ~/.bashrc

Find and Remove line :
export PATH="$PATH:/usr/share/pk2"

Stay healthy and safe till the next time!

Install PICkit 2 Development Programmer / Debugger on Debian 10 Buster 64-bit.

To install PICkit 2 Development Programmer / Debugger on Debian 10 Buster 64-bit, we need to install library packages for i386 architecture. That we can do with Multiarch. What is Multiarch? Multiarch lets us install library packages from multiple architectures on the same machine.

So for that, we are gonna use a couple of commands to print current architecture, check foreign architecture, and add a new architecture.

The first command is gonna print the current machine architecture:

dpkg --print-architecture
amd64

The second command is gonna print foreign machine architecture. If print nothing, means we don’t have foreign machine architecture added to our system:

dpkg --print-foreign-architectures

The next step is a way to add foreign machine architecture to our system:

dpkg --add-architecture i386

So now if we do check for other available architectures, it should print i386:

dpkg --print-foreign-architectures
i386

Now we need to install dependencies for compiling our source files:

sudo apt update
sudo apt install build-essential libusb-dev

That’s all for preparing the system. The next step is downloading and unpacking the source files:

wget https://ww1.microchip.com/downloads/en/DeviceDoc/pk2cmdv1.20LinuxMacSource.tar.gz
tar xzvf pk2cmdv1.20LinuxMacSource.tar.gz
cd pk2cmdv1.20LinuxMacSource

Building the application:

make linux

Installing the application:

make install

Adding device file location to PATH:

echo 'export PATH="$PATH:/usr/share/pk2"' >> ~/.bashrc

Reboot system and test installation:

pk2cmd -?v

# PICki2 not connected
Executable Version:    1.20.00
Device File Version:   1.55.00
OS Firmware Version:   PICkit 2 not found

# PICkit2 connected
Executable Version:    1.20.00
Device File Version:   1.55.00
OS Firmware Version:   2.32.00

Uninstall pk2cmd:

Remove file pk2cmd from /usr/local/bin:
sudo rm -R /usr/local/bin/pk2cmd

Remove all files from /usr/share/pk2/:
sudo rm /usr/share/pk2/*

Remove folder /usr/share/pk2/:
sudo rm -R /usr/share/pk2

Edit file .bashrc:
sudo nano ~/.bashrc

Find and Remove line :
export PATH="$PATH:/usr/share/pk2"

Stay healthy and safe till the next time!