How to record PIC microcontrollers desde Linux (pk2cmd)

Hello everyone, I am going to show you how to record a .hex file in a pic microcontroller using pk2cmd in a few simple steps:

Download links are at the end of the post

1. Download the program pk2cmd.
2. Unzip the file.
3. Using a terminal enter the directory of the downloaded source code.
4. Before compiling, you have to install other programs that are necessary, so we run as superuser:

sudo apt-get install build-essential
sudo apt-get install libusb++-dev

5. Now you can compile the source code using:

make linux

6. And then, as superuser, install it with the command:

sudo make install

7. Once installed, add a line to the hidden file ".Bashrc" which is in your home folder (/ home / username). For this I run, as a normal user:

gedit /home/nombre_usuario/.bashrc

I add the following line to the end of the file:

export PATH = $ PATH: / usr / share / pk2

8. Finally "I execute", as a normal user, the lines of the file ".bashrc" using

source /home/nombre_usuario/.bashrc

With this the "pk2cmd" program should have been installed and configured to be used.

Testing the installation

To test that the installation and configuration work, a first way is, with the PicKit2 connected to the USB port, execute, as a normal user, the command:

pk2cmd /?v

How to record a .hex with pk2cmd

To verify that it autodetects the PIC that we have connected in the PicKit2:

pk2cmd -p

To read the .hex file that the PIC currently has recorded (in this case I save it on my desktop with the name "actual.hex"):

pk2cmd -p -gf/home/usuario/direccion/actual.hex

To save to the PIC the new file «file.hex» that I have on my desktop:

pk2cmd -p -m -f/home/usuario/direccion/archivo.hex

Here is a tutorial made by me :).

Download pk2cmd
Download manual in pdf

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   edwarddiaz said

    Good tip! There is also Piklab to do this as another option :).

    1.    Fernando said

      Hello, the manual is no longer available?

  2.   jvk85321 said

    Excellent, but I am missing the type of recorder for which it is used (which model of usb programmer). There are many. It seems to me that it works for the pickit2 and their clones. Correct me if i'm wrong

    PikLab is a great option, but it is for KDE3, and the tricks no longer work for KDE4 libraries, although with aliens you can pass a version of fedora to debian and ubuntu. There is a tutorial there, so I did it on my Ubuntu 13.04

    atte
    jvk85321

    1.    maikelmg said

      If it is for the pickit2. It happened to me to put it. Thanks for reminding me.

    2.    truko22 said

      I use piklab in Chakra with KDE 4.12.2 and the sdcc compiler (it lacks a lot) but I don't know how to configure a pickit2 clone.

  3.   NauTiluS said

    Hello friend, thanks for this post.

    I also want to get rid of the doubt, what type of chip i / o programmer can I use with this application.

    1.    maikelmg said

      It's for the PICKit 2 🙂 if that's what you mean.

  4.   take_no_more said

    And if you add GPSIM + GPUTILS it is a good alternative to MPLAB ..
    On the other hand, now with MPLABX being multiplatform we can use the manufacturer's tool from our Linux machines. It is up to the end user

  5.   vidagnu said

    Excellent tutorial, I already saved it in my favorites!

    Regards,
    Oscar

  6.   Carlos said

    Very nice article, thank you!

    I've been working with PIC microcontrollers on Linux for quite some time. Fortunately, Microchip tools have been cross-platform for some time and can be used for free (MPLABX, the Netbeans-based IDE, and its XC8, XC16 and XC32 compilers).

    For me MPLABX is the ideal, it is a good quality tool and I have installed it without problems in several Linux distributions.

    Regards!

  7.   agarcia said

    Thank you very much for the exposed work, I think it will help me to introduce myself a little more in Linux.

    Please can you put the link back to: download the manual in pdf, because dropbox tells me that it is disabled.

    regards

    1.    maikelmg said

      Ready friend, thank you very much for your comment, I have uploaded the links again. Greetings from Ecuador.

  8.   Miguel Alejandro Quinonez Gudino said

    Excellent tutorial! 😀 I just use an Arch based distro, everything works on arch linux too?

    1.    bitl0rd said

      Sure, you find it in AUR.

  9.   Daniel said

    Hello, sorry to bother you, I am starting to handle the pic with linux since I previously did it with win.
    I tell you that I was able to install the pk2cmd and I have a clone of the pickit.
    I could do the programming perfectly but I couldn't find anywhere how to configure whether the pic would use an external clock or the internal clock.
    this is done from the x2007 address. but I don't know how I previously used the upp628 in win and it was programmed in a visual way after having the hex open.
    If you have any info, I appreciate it.
    finally I program in asm

    Thank you

  10.   Javier Garcia Prieto said

    Is the program no longer available? If I click on the link, it indicates that there is a dropbox error!