Monday, June 30, 2008

PIC Development, Linux Style

In this article Steven Moughan shows us how to setup for PIC microcontroller development on Linux. Steve writes the following…

PICs are great, they really are… they have great features, decent instruction sets,
there’s lots to choose from, their manufacturer released a great IDE (MPlab) what could go wrong? Unfortunately the PIC is somewhat lacking when it comes to development software for Linux, and by this I mean IDEs and compilers. Here I will be dealing with getting your very own uC lab set up using Ubuntu Linux and some freely available tools.

By the end of this article we are going to have the following…

  1. An IDE to develop in (PIKlab).
  2. A C compiler to develop with (Hi-Tech C Lite)
  3. A PIC simulator and some utilities to help debugging (GPsim and GPutils)

This article was submitted by Steven Moughan as part of the “Hobby parts for articles” program.

Ok, so first you’re going to need something to write in… alright so gedit is good but it’s no IDE. The guys over at are doing a great job creating an IDE with similar functionality as MPlab, this is good no? Unfortunately for us (Ubuntu users) it’s developed for systems that run the KDE window manager (roll on Kubuntu). The first obstacle we are going to have to overcome is the lack of Qt libraries and KDE libraries in the base Ubuntu install. To do this we are going to make use of the Ubuntu repositories and the command line tool ‘apt-get’. Essentially the Ubuntu repositories store all the information for software that is available officially from Ubuntu and they also store the .deb files (don’t worry: you don’t have to know what they are), by using apt-get you can automatically install or remove software from your system with very little effort, to make this even better Ubuntu will let you know when there are updates available for whatever software you have installed on your system, as long as it’s done this way (or through Synaptic but that’s another beast altogether).

Installing Qt:

  1. In the command line interface (CLI) type in “sudo apt-get update” in order to update the available packages.
  2. Now that your list of repositories is up to date, you can type the following into the CLI:
    sudo apt-get install libqt3-mt

Installing KDE libraries:

  1. Use “sudo apt-get install kdelibs” to install the basic KDE libraries.
  2. Use “sudo apt-get install kdelibs4c2a” to install the core libraries & binaries for KDE.
  3. Use “sudo apt-get install kdelibs-data” to install the extra stuff for the kde libraries.

Ok, now your system should have the prerequisites for installing PIKlab, so its time to head on over to the PIKlab web site and get to downloading the latest package. We’re getting close now! Oh no! What do you mean there are no .deb packages?!? Fear not… a little command line utility called “alien” is here to save us! Depending on the options you chose when installing Ubuntu, alien may or may not be installed, if its not, yep, you guessed it, you can run “sudo apt-get install alien” and within a few seconds it will be here to rescue us.

What you need to do now is download the latest RPM package for PIKlab from their website. Now you can issue the command “alien ” and alien will generate the .deb file that we are going to cherish so fondly. Now the last thing we need to do to get PIKlab installed is issue the following command “sudo dpkg -i “.

Congratulations, take a break, the hard part is over now… We have a working IDE installed and ready. The bonus feature from this is that PIKlab will also work with the PicKit 1 and the PicKit 2 (although it does need some tweaking). In order to launch PIKlab now you can simply open a CLI and enter “piklab“.

Now that’s over, we can move on to installing HT Soft PIC C Lite. It’s free although a little restricted, and you will have to register to download it. Once you have the file downloaded, you’re going to fire up another CLI and navigate to where you downloaded the file and execute “chmod +x “, this will make the file executable, then the following command will begin the installation : “./“. After following the on-screen instructions you should now have HT Soft PIC C Lite installed.

Ok, now we have an IDE and a compiler… What else do we need? How about something that will help us debug our code? We’re going to install the GPsim and GPutils tools—these are great tools. GPsim is the “GNU PIC Simulator” and GPutils are the “GNU PIC utilities”. They are very useful, especially GPsim as it has loads of add-on modules such as HD44780 controllers and the like. So now that you know what it is we can go get it installed on our system.

Again “apt-get” is going to be our savior. First we’re going to install GPsim, to do this we use “sudo apt-get install gpsim“. Next we’re going to do GPutils… you get the idea of this apt-get thing yet? I’m going to leave this one to you.

Ok, now we have our IDE, compiler and simulator set up, the rest is up to you…

Thanks for reading!

No comments: