Pk2cmd manual installation

From Curuxa


If there is a pk2cmd in your distro's repository, use it instead of following this manual.

If there is no pk2cmd in your repositories but you are using Debian, Ubuntu, or any derivative, you can use repository.

If you can't find any other way to install pk2cmd, follow this tutorial.

Manual installation on x86

  1. Make sure you have libusb installed (also libusb-dev in some distros)
  2. Microchip provides x86 binaries for Linux 2.4 and 2.6. You can download them here (look for a file called PK2CMD Vx.xx Linux Kernel 2.x Executable Binary)
  3. Unzip it and you are ready to use it. It doesn't require installation, just cd into the unzipped directory and type ./pk2cmd in a command line

Manual installation on amd64 or other Operating Systems

Microchip DOES NOT provice amd64 binaries for Linux or any other operating system. You'll have to download pk2cmd sources and compile them. It's very easy!

Running script

Once you have downloaded the binaries or compiled them yourself, you can run pk2cmd from the directory it's placed in.

If you want to be able to run pk2cmd from anywhere without installing it (it's not recommended to install programs without using your package manager), you can store it somewhere save and run it from a script.

Create the following file, change MyPath as necessary and save it as /usr/local/bin/pk2cmd":

cd $MyPath
./pk2cmd $*
cd $MyOldPath

Remember to give it executable permissions (chmod +x /usr/local/bin/pk2cmd).

Setting up permissions

  1. Connect your PICkit2 to a Main Board and plug it into a USB port on your computer.
  2. If you have properly installed pk2cmd you can run the following commands without "./" at the beginning. If you have downloaded the binary or compiled it yourself, open a command-line and go to the directory you have unzipped or compiled pk2cmd. In that directory you should be able to find at least the following files:
    • pk2cmd
    • PK2DeviceFile.dat
    • PK2V023200.hex
  3. Run ./pk2cmd -P
  4. If you read the following...
$> ./pk2cmd -P
Auto-Detect: Found part PIC16Fxxx.
Operation Succeeded

...then everything works fine. Go to next section.

If you read...

$> ./pk2cmd -P
No PICkit 2 found.

...then you didn't plug your PICkit2 to your computer or you don't have the right permissions.

  1. To check if your permissions are the problem, login as root, go to the directory where pk2cmd is, and tun ./pk2cmd -P again
  2. If you still can't detect a microcontroller then there is a problem with the connection, your PICkit2 or your electronic circuit. If you can detect the microcontroller properly as root but not as a common user you have to follow this tutorial that explains how to configure your permissions properly.

After reboot, in case you still can use pk2cmd only as root but not as a normal user, setuid it. This is not a good practise but you might want to do it in case nothing else works:

$> cd /path/to/pk2cmd
$> su
[root password...]
$> chown root pk2cmd
$> chmod u+s pk2cmd

Now you should be able to run pk2cmd as user, but it will be executed with root permissions, so it should work.

See also