Piklab

Installation on Debian-based Distributions

Including Ubuntu 18.04, 17.10, 16.04 and Older


Piklab is a mature and extraordinarily well-designed IDE (integrated development environment) for Microchip's PIC series of microcontrollers. Piklab is more convenient (and faster!) than Microchip's own MPLAB. The more recent MPLAB-X is a lumbering behemoth -- obviously designed to capture all possible applications, its complexity for even the most basic projects would make Rube Goldberg blush. The older MPLAB was Windows-only, which probably gave rise to Piklab in the first place.

Note to the maintainer(s) of Piklab: Yes, I mean you, Nicolas Hadacek... and any potential candidate for maintaining or upgrading Piklab... this software is GREAT. And there is still a need for it!

This guide is a list of steps it took me to install Piklab on Ubuntu 14.04 through 18.04 with a separate set of instructions for older Ubuntu 11.10 and 12.04. It is likely going to work with Ubuntu 11.04, Mint 12, and similar distributions. There are, however, no more straightforward solutions for 20.04LTS.

Acknowledgements: Adnan Mustafic contributed significantly to this list. Similar instructions can be found at the Big Bang blog (broken link, my apologies).


Installation on Ubuntu 20.04


This ... is a problem. Apparently, Ubuntu dropped KDE4/QT4 support in 20.04LTS, and the libraries cannot be retrieved using the regular repositories. This is a shame, because it affects other QT4-based software as well. To my knowledge, those libraries don't even conflict, so there does not even appear to be a good reason to discontinue QT4 support. What gives?

The alien method described below for Ubuntu 18.04 still works in that it creates the .deb package. However, starting Piklab fails, because Piklab cannot find the libkde3support.so library (part of KDE4/QT4). This leaves two options:

Unfortunately, unless there is enough interest for a QT5 version of this software, Piklab is dead.


Installation on Ubuntu 18.04 and older versions back to 14.04


The instructions differ for Ubuntu 18.04 and versions older than 14.04, because kdelibs4c2a is no longer installable starting with 14.04 -- it conflicts with kdelibs-bin. Fortunately, there is now a new Piklab version (0.16.x) that is QT4 compatible. Presently, it is available only as rpm, so we'll convert it to a deb package. This process has been tested on various Ubuntu platforms from 14.xx to 18.04.

First, get your version of Piklab here.

Next, install the program alien, for example with

sudo apt-get install fakeroot alien
We need fakeroot in the next step, that is, the creation of a deb package. Depending on the Piklab version you downloaded, the version numbers may differ. Adjust the version numbers ("-0.16.1...") accordingly.
fakeroot alien --scripts -d piklab-0.16.1-6.fc20.x86_64.rpm 
The result is a new package, piklab_0.16.1-7_amd64.deb. You can now use dpkg to install:
sudo dpkg -i piklab_0.16.1-7_amd64.deb
Click on this link to download the .deb file that I created by following the above steps. No warranty, and ... YMMV.

To install the command-line utilities related to the PIC family: Install gputils and sdcc. Look for related stuff you may like, such as JAL. This can be done with Aptitude. Alternatively, use

sudo apt-get install sdcc gputils

Note: I have experienced crashes in Kubuntu 18.04 in which the attempt to open a source file caused the error "Could not find katepart: Install Kate. Application 'piklab' crashing...". This problem can be remedied by installing katepart (used as text editor plugin):

sudo apt-get install katepart

To install the bootloaders: Download MPLAB 8 from the Microchip web site and install it, for example, under WINE. Choose a suitable location for the hex8 files, for example with

sudo mkdir /usr/share/kde4/apps/piklab/hex8
Use the WINE desktop to copy all files from C:\Program Files\Microchip\MPLAB IDE\ICD2 to the new directory /usr/share/kde4/apps/piklab/hex8. Next, open Piklab, choose "settings" and "configure programmers". Select the ICD2 programmer, set to USB port, and select the "specific" tab. There, enter /usr/share/kde4/apps/piklab/hex8 in the Firmware Directoy entry field.

Now, ensure that the new files in .../hex8/ are world-readable:

sudo chmod -R a+r /usr/share/kde4/apps/piklab/hex8

To enable non-privileged USB access: Create a new file in /etc/udev/rules.d as follows:

sudo nano /etc/udev/rules.d/99-microchip_icd2.rules
and copy and paste the folowing two lines into the file:
SUBSYSTEM=="usb" ATTR{idVendor}=="04d8" ATTR{idProduct}=="8000" GROUP="plugdev" SYMLINK+="mcidc2"
SUBSYSTEM=="usb" ATTR{idVendor}=="04d8" ATTR{idProduct}=="8001" GROUP="plugdev" SYMLINK+="mcidc2"
for your convenience, you may download the file 99-microchip_icd2.rules by right-clicking on this link. Just copy the file into /etc/udev/rules.d

Finally, add your login name to the group "plugdev" in /etc/group. Start Piklab and try to connect to the ICD-2.


Installation on Ubuntu 11.04 Through 13.10


The original compatibility issue turned up when the QT/KDE developers replaced the aging QT3/KDE3 with the newer QT4/KDE4 version, but without maintaining backward compatibility. Consequently, most Linux distributions, such as Ubuntu 11.04 and later, no longer support software that is based on QT version 3. This includes Piklab.

(OK, let's be more precise: QT4/KDE4 has a compatibility library, libkde3support.so, which gave rise to the elegant fakeroot-alien solution described for Ubuntu 18.04 above. Since 20.04, QT4/KDE4 support has been dropped and KDE3 support is therefore no longer available).

These instructions are valid for all distributions that allow concurrent installation of the QT4 and QT3 libraries, and the main challenge is to get all required QT3 libraries installed.

  1. Install the command-line utilities related to the PIC family: This can be done with Aptitude. Alternatively, use "sudo apt-get install sdcc gputils"
  2. Install several packages that are available in the Ubuntu repositories: Once again, this can be done with Aptitude. Aptitude has the advantage that is selects packages compatible with your architecture and distribution.
  3. Next, obtain packages that are not in the repositories. Links are provided here for the amd64 architecture. You can search for the i386 versions by subsituting i386 for amd64 in the file names. This completes the installation of package dependencies for Piklab
  4. Obtain a Piklab Debian package. One valid name to search for is "piklab_0.15.7-1_amd64.deb".
  5. Now install Piklab: "sudo dpkg -i piklab-0-15.xxx-xxx.xxx.deb", where you need to replace the xxx by whatever version you downloaded
  6. Start Piklab by typing "piklab" in a shell.
If you got to this point, Piklab is ready and needs to be configured for the programmer or debugger that you use. For the ICD-2 debugger, two steps are necessary. The proprietary bootloaders from Microchip needs to be installed, and a rule to access the ICD-2 via USB needs to be created.

To install the bootloaders: Download MPLAB 8 from the Microchip web site and install it, for example, under WINE. Choose a suitable location for the hex8 files, for example with

sudo mkdir /usr/share/apps/piklab/hex8
Use the WINE desktop to copy all files from C:\Program Files\Microchip\MPLAB IDE\ICD2 to the new directory /usr/share/apps/piklab/hex8. Next, open Piklab, choose "settings" and "configure programmers". Select the ICD2 programmer, set to USB port, and select the "specific" tab. There, enter /usr/share/apps/piklab/hex8 in the Firmware Directoy entry field.

To enable non-privileged USB access: Create a new file in /etc/udev/rules.d as follows:

sudo nano /etc/udev/rules.d/99-microchip_icd2.rules
and copy and paste the folowing two lines into the file:
SUBSYSTEM=="usb" ATTR{idVendor}=="04d8" ATTR{idProduct}=="8000" GROUP="plugdev" SYMLINK+="mcidc2"
SUBSYSTEM=="usb" ATTR{idVendor}=="04d8" ATTR{idProduct}=="8001" GROUP="plugdev" SYMLINK+="mcidc2"
Finally, add your login name to the group "plugdev" in /etc/group. Start Piklab and try to connect to the ICD-2.


Compiling from Source (all Distributions up to 18.04)


Compiling Piklab from source is straightforward, provided that you install the necessary development files and cmake. Specifically, you'll need

(Note that these libraries are no longer available in 20.04)

Get the source tarball and unpack it as usual:

tar xzvf piklab-0.16.2.tar.gz
cd piklab-0.16.2/
cmake .
make
The cmake step generates the necessary makefiles (and reveals any missing development packages). The make step then genrates the binaries that can be found relative to the above path in As usual, 'sudo make install' copies the files to their respective destinations. In my specific case, see below, it was sufficient to replace /usr/bin/piklab and /usr/bin/piklab-prog by the newly compiled binaries, so I was able to rely on a prior installation from the alien-made .deb package.

Adding a new PIC Processor

Compiling from source was particularly important for me when I wanted to add a microcontroller that was not supported. I knew that the family was supported, but the PIC18f13k50 was not. Quite importantly, the gputils toolchain supports the 18f13k50, and it is sufficient to explain to Piklab that this chip is a valid option. This chip needs to be added to a series of files:

Recompiling gave me a Piklab binary that was able to program the PIC18F13k50 via ICD-2 programmer.

Trouble in 18.04: The compiler threw an error, something about compressing a large constant (2147577989) into an int type and failed in parallel.cpp, line 157. I was able to continue compiling by changing the appropriate struct from int to unsigned long in parallel.h:

private:
  int     _fd;
  QString _device;
  struct RequestData {
    int read, write;
  };
  static const RequestData REQUEST_DATA[Nb_RequestTypes];
  uchar _images[Nb_RequestTypes];
was modified to
private:
  int     _fd;
  QString _device;
  struct RequestData {
    unsigned long read, write;
  };
  static const RequestData REQUEST_DATA[Nb_RequestTypes];
  uchar _images[Nb_RequestTypes];
However, I do not know if this has any side effects when parallel port programmers are used. Perhaps the programmers/maintainers take notice. They never responded to my messages, unfortunately.