Programming under Linux using Pickit 2

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

Post Reply
KeithSloan
Posts: 114
Joined: Fri Jul 27, 2007 10:50 am
Been thanked: 1 time
Contact:

Programming under Linux using Pickit 2

Post by KeithSloan »

Some time ago I brought a PICkit 2 Debug Express see http://www.microchip.com/stellent/idcpl ... ts=pickit2 as part of an offer from Practical Electronics. I also brought the AC164110 RJ-11 to ICSP adapter to go with it. The idea was to use it for debugging and programming straight from MPLAB.

Only a few days ago did I realise that Microchip provide software to use the PICkit2 as a programmer from Linux.
The software pk2cmd is command line and can be found at above link down the page where it states Downloads - Linux and Mac OSX software. I use Ubuntu 10.04 and downloaded and installed the PK2CMD V1.20 Linux Kernel 2.6 Executable Binary
http://ww1.microchip.com/downloads/en/D ... 2-6.tar.gz. It took some fiddling to get pk2cmd to work without being root. I later found some better instructions of achieving this at http://tuxtronics.com/node/3.

Okay now I need an IDE and C Compiler.

These where easy to find and install. For IDE I used piklab http://piklab.sourceforge.net/and for C Complier SDCC
http://sdcc.sourceforge.net/. Both of these pieces of software installed via the Ubuntu synaptic software manager. So it was just a case of starting the software manager and doing a search for the application name and subsequent selection for install and apply.

The version of piklab does not support the later pickit2 firmware, so I just configured a custom programmer
settings | Configure Programmer | Custom Programmer with the following values

Read | pk2cmd -PPIC%DEVICE -GFtemp.hex
Erase | pk2cmd -PPIC%DEVICE -E
Program | pk2cmd -PPIC%DEVICE -M -T -F%PROJECT.hex
Verify | pk2cmd -PPIC%DEVICE -Y -F%PROJECT.hex
Blank Check | pk2cmd -C -PPIC%DEVICE
Run | pk2cmd -PPIC%DEVICE -T -R
Stop | pk2cmd -PPIC%DEVICE

Note: You have to get pk2cmd to run as a user in order for it to work with piklab.

The first stage of testing was to plug the Pickit2 into a USB port and to plug the 44-pin Demo Board into the PicKit 2.
I used the program from http://jsmerritt.blogspot.com/2009/06/g ... h-pic.html to test it.

I had some problems with compiling the code following a cut and paste into a Piklab New Project. I have not got to the bottom of the problem, but resolved by creating a new project and pasting the values for Config1 and Config2 but not altering the coding
word at _CONFIG1 CONFIG1 and word at _CONFIG2 CONFIG2.

Having proved the Pickit2 with the demo board it was time to move onto my Matrix Multimedia Programmer. The first thing to do is to remove the USB cable and Power cable. I have a EB-006-00-6 which unlike the latest version EB-006-00-7 does not have a direct link for the PicKit2 to plug into. I had to move the 3 x 3 header to the ICD2 setting ( Jumpers 12-14) I then had to use the AC164110 RJ-11 to ICSP adapter to plug into the Pickit2 and then to use the short RJ11 cable to the EB-006.

Whilst not able to use the PicKit2 ICD facilities I can at least program from Ubuntu/Linux. Now I need to do some learning about GPSIM see http://gpsim.sourceforge.net/ to get some debugging facilities.

Matrix Mulitimedia have in the past stated that they will not port anything to Linux because they use BoostC which only runs under Windows. Well the Piklab documentation clearly states that BoostC will run under Wine in Linux. and installation details can be found at http://sourceforge.net/apps/mediawiki/p ... ourceboost

So now at least I can develop using Ubuntu/Linux.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Programming under Linux using Pickit 2

Post by Benj »

Hi Keith,

Thats great thanks for posting the information. I have always been a fan of Linux and its great to see that the PicKIT 2 can work with the command line tool under Linux. I did originally get Flowcode v3 working under Wine so when I next power up my Linux system I will have a crack at getting v4 working under Linux. If I get this up and running then I will post my findings so that other users can follow in Linux development.

Thanks again.

Post Reply