Search This Blog

Monday, March 26, 2012

64-bit Woes, Pickit 2, and pk2cmd

  Okay, so the old laptop finally died.  I'd been calling it the "ghetto laptop" for a few months.  Power issues, overheating, cracked the hinge on the lid, etc.  The cracked lid gave rise to the nickname ghetto laptop.  I had to open and close it by placing a flathead screwdriver in the security lock hole.  All it needed was some duct tape on the cover!  Then the DVD drive died.  Oh well.  Then the screen went out. 

   In panic, I ordered the third most expensive laptop I could find without doing any real research.  It's a great machine... unless you like Linux.  I do.  The problem is that it has an Optimus setup.  This means that it has an integrated Intel graphics card hooked directly to the monitor.  It also has a dedicated Nvidia graphics card with dedicated 1.5 GB of Ram.  This card is hooked *through* the Intel card.  The software is meant to handle the switching on/off of the 2 cards.  No one felt the need to provide these specs to the open source community, so Linux support is primitive at best at present.

   I managed to get everything setup, and I'm now running bumblebee.  Great work and thanks to the folks who are working on the bumblebee team!  This allows me to run normal stuff from the Intel card and start apps that need better graphics with the Nvidia card.

   I also decided that 64-bit OSes were common enough now that I would install one, too.  Turns out that this caused a few headaches.  One of the worst was with my Pickit 2 programmer.  The open source programming software, pk2cmd, would only work with my 16F88 chips!  I posted to the pickit-devel group on Google Groups.  I managed to attract the attention of two of the main developers of the software, Jeff Post and Xiaofan Chen.  After much testing, I ended up compiling pk2cmd as a 32 bit app.  It looks like some work would have to be done to make it work for my hardware and kernel under 64 bit.  As the programmer and software is pretty old, I doubt that much will (or should) be done.

   As notes to myself ( and anyone who may need this ), here's how I got it to compile as a 32 bit app under a 64 bit system.  As I don't really do C programming, this was more of a challenge than I expected.  The end solution is quite simple.

   I pulled in the libusb-devel packages, g++, etc. as recommended in the readme.  I also needed to pull in the libusb-0.1.so.4.4.4 library for 32 bit.  I altered the Makefile for 32 bit compilation by adding the switch '-m32' ( without the quotes ) to the  definition of OPTS:
OPTS=-Wall -m32 -D_GNU_SOURCE $(DBG)

With this, make linux was able to compile the program, but it could not find the library libusb.  So, I su-ed to root and found the 32-bit libusb-0.1.so.4.4.4 library in /lib.  I changed directories to /usr/lib and made a symbolic link to it as follows:

ln -s /lib/libusb-0.1.so.4.4.4 libusb.so

I then changed the LDFLAGS definition in the Makefile to look like this:
LDFLAGS=-L/usr/lib -lusb

With this, make linux was able to link the files and create the executable.  Su and make install had everything working the way it used to.  Huzzah!