Sunday, March 22, 2015

Chip programming with Linux 1 - PICkit version2 clone under Linux / Freebsd / Mac OS


Description    : Installing PICkit version2 clone for Linux / Mac.


            











Compatibility : Linux kernel 2.4 or 2.6. ( Tested )
                                   FreeBSD                        ( NOT Tested
                          Mac OSX 10.4                ( NOT Tested
                          Mac OSX 10.5                ( NOT Tested )
                          OS X Mavericks 10.9.2  ( Tested )

Steps :

1. Login as root

Command  : su
                  
2. PICkit version2 clone drivers for Linux / Mac

Commands : yum install gcc-c++
                     yum install libusb1-devel
                     yum install libusb-devel


3. Download PICkit version2 clone software for Linux / Mac

URL : Pickit2 Tool for Linux

4. Change directory to download location

Command : cd /home/developer64/Downloads/

5. Extract source code

Command : tar zxvf pk2cmdv1.20LinuxMacSource.tar.gz

6. Change directory to source code folder

Command : cd pk2cmdv1.20LinuxMacSource

7. Check your Linux kernel vernal version

Command : uname -r  

My Linux kernel version is 2.6.32-504.12.2.el6.x86_64


8. Build the source code

This software comes with source code. So you can view the source code and change according to your Operating System. It is written in C++ and you can improve the source code according your requirement.

 
Command for Linux Kernel version start with 2.6 : make linux  
  
Command for Linux Kernel version start with 2.4 : make linux-old

Command for FreeBSD                                         : make freebsd

Command for Mac OS 10.4                                   : make mac104

Command for Mac OS 10.5                                   : make mac105


9. Copy relevant files to /usr/local/bin


Command : cp pk2cmd /usr/local/bin
                   cp PK2DeviceFile.dat /usr/local/bin/
                   cp PK2V023200.hex /usr/local/bin/


10. Now check your software version

Command : pk2cmd -?V

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

 

Cheers we have successfully installed. Yet to configure it. It says  PICkit 2 not found as PICkit2 device not connected with my computer

           
11. Create Driver Manager Empty Rule File

Command : echo "" > /etc/udev/rules.d/99-pickit2.rules

12. Open the file
  
Command : gedit /etc/udev/rules.d/99-pickit2.rules

13. Add bellow rule content to /etc/udev/rules.d/99-pickit2.rules and save the file
  
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device",SYSFS{idVendor}=="04d8" , SYSFS{idProduct}=="0033", MODE="0666"


14. Now reload Linux Driver Manager Rules
  
Command : udevadm control --reload-rules

15. Now connect your PICkit2 USB device without PIC chipset

16. Check the device connectivity with your computer
  
Command : pk2cmd -?V

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


                    Operation Succeeded

Cheers. It says Operation Succeeded

16. Mount your PIC Chipset in right direction on your device.

Refer bellow picture.

17. Now connect your PICkit2 USB device 













17. Run Auto detection command. This will identify PIC Chipset

Command : pk2cmd -P


Result       :  Auto-Detect: Found part PIC16F877A.

                    Operation Succeeded


My PIC chip is PIC16F877A



18. Erasing chipset

Command : pk2cmd -P PIC16F877A -X -E
 
Result       :  Erasing Device...

                    Operation Succeeded


19. Installing hexadecimal file in to chipset. 
      Hexadecimal file will include all execution steps of the firmware. 
      We will discuss how to write small program for LED display, Sensor  
      readings, Motor controllers and etc..

      We will be able to write firmware based on Micro C language Micro C IDE.
      Then we will convert it in to HEX file.


For the moment we will use existing HEX file PK2V023200.hex located in same place pk2cmdv1.20LinuxMacSource


Command : pk2cmd -P PIC16F877A -X -M -F PK2V023200.hex
 
Result       :  PICkit 2 Program Report
                    22-3-2015, 23:29:55
                    Device Type: PIC16F877A

                    Program Succeeded.

                    Operation Succeeded

Now it says, it wrote given Hex file in to chipset called PIC16F877A.


19. Verify Hex file against Chipset memory issues


Command : pk2cmd -P PIC16F877A -Y -F PK2V023200.hex
 
Result       :  PICkit 2 Verify Report
              22-3-2015, 23:44:49
              Device Type: PIC16F877A

              EEData Memory Errors

              Address   Good     Bad
              000000    0000EA   000000


It seems everything is OK.


20. Power ON Chipset


Command : pk2cmd -P PIC16F877A -T
 
Result       :  Operation Succeeded
Now you can see power indicator LED is working


21. Power OFF Chipset


Command : pk2cmd -P PIC16F877A
 
Result       :  Operation Succeeded
Now you can see power indicator LED is NOT working




In next post we will install Micro C IDE, C compilers dedicated to Micro C IDE. Then we will develop some hobby circuits such as LED controllers, Motor controllers, sensor readers and many more.

Thank you. 

19 comments:

  1. Thank you so much man! I Tested on Mac OSX Mavericks 10.9.2 and it works fine for the moment. I just had to change some commands and install some packages but, despite that, it works perfectly. I would like now to know where I can find your post about installing Micro C to develop some programs. Thanks a lot!

    ReplyDelete
    Replies
    1. Excellent. I will update compatibility notes for Mac OSX Mavericks 10.9.2. Going to finish next post on Compilers, Integrated Development Environments and will do some experiments with blinking LED circuit.

      Delete
  2. It is safe to say that you are looking for the best touchscreen laptop under 300 in 2020? The correct method to buy tablets is through the online sites. There are various sites that include enormous measure of biggest screen tablets.

    ReplyDelete
  3. Nice post. I learn something new and challenging on sites I stumbleupon on a daily basis. It will always be exciting to read through articles from other writers and use something from their web sites.
    cryptocurrency

    ReplyDelete
  4. I must thank you for the efforts you've put in penning this blog. I am hoping to check out the same high-grade content from you in the future as well. In fact, your creative writing abilities has motivated me to get my own website now ;)
    I'm more than happy to find this page. I wanted to thank you for your time for this wonderful read!! I definitely enjoyed every bit of it and I have you bookmarked to check out new things in your web site.
    Yumbo centre Gran Canaria

    ReplyDelete
  5. Commercial Locksmith Services
    You’ve made some good points there. I looked on the internet for additional information about the issue and found most people will go along with your views on this website.
    Nice post. I learn something totally new and challenging on websites I stumbleupon every day. It’s always useful to read through articles from other authors and practice something from other sites.

    ReplyDelete
  6. I am happy you take pride in what you compose. This makes you stand way out from numerous different authors that push ineffectively composed substance.

    Utility Kilts

    ReplyDelete
  7. I am happy you take pride in what you compose. This makes you stand way out from numerous different authors that push ineffectively composed substance.

    How To Build Hybrid Kilt - Complete Helping Guide

    ReplyDelete
  8. I got what you mean , a debt of gratitude is in order for posting .Woh I am cheerful to discover this site through google.
    Graphic Designing in Lahore

    ReplyDelete
  9. An intriguing dialog is cost remark. I feel that it is best to compose more on this matter, it may not be a forbidden point however for the most part people are insufficient to chat on such subjects.
    To the following. Here's to you.
    Best Cheap Perfumes for Ladies 2021

    ReplyDelete
  10. I was more than happy to uncover this great site. I need to thank you for your time due to this fantastic read!!
    I definitely enjoyed every bit of it and I have you bookmarked to see new information on your blog.
    Classified Ads WordPress Theme

    ReplyDelete
  11. Is it alright to post a portion of this on my site fundamentally present a hyperlink on this website page?

    freetress equal eternity

    ReplyDelete