It is summer on the northern hemisphere, and I've decided to target a smaller system than I've been used to in the last couple of years. In particular, I've decided to finally open my dear old PICkit II. The goal is to be able to work with this board from within a Linux environment.
The PICkit II sports a PIC16F690 device. The debug dongle supplied supports many more devices and is a very handy tool to have around if you work with PIC processors. The PIC16F690 comes with 7kB of program FLASH, 256B of RAM and 256B of EEPROM; hardly enough to run Linux, but just right to do small monitoring or automation tasks.
To my joy, the PICkit II is now supported on Linux by Microchip (the makers of the PIC processors). The tools are supplied "as-is," and do not expect to be popular in the support department for not following the main road, but still, it is better than nothing. Also, they are free, but only as in free beer. To download the tool, look for PK2CMD for Linux (simply search for Linux) on the PICkit II page.
The recommended file to download is the source code package, as the binary was built back in 2009 on CentOS 4.7. To build the binary, untar the source code package, enter the resulting directory and run make linux, followed by sudo make install. On my Debian system, I needed to have build-essential and libusb-dev installed to get the compilation to succeed. The resulting installation ends up in /usr/local/bin/ and /usr/share/pk2/. You will also have to setup a couple of udev rules for the USB device to be properly detected, as shown in this blog. The only issue not discussed there that I ran into was updating the software of the PICkit II programmer itself, i.e. the OS Firmware Version returned from pk2cmd -?V. I had to surrender and used the Windows version to get that updated properly (and it took three attempts there as well). Rest assured - I did not brick the device by trying - more than once.
The pk2cmd tool lets me interface the PICkit II programmer, i.e. to download software to the PIC device. Now, all that is missing are the tools to actually create software. Here, a fully open source toolchain is available. To my joy, it was already packaged for Debian, so a simple apt-get install gputils gpsim takes care of that.
The gputils package contains gpasm and gplink - an assembler and linker compatible with the PIC16F690 device. The gpsim package contains a simulator for PIC circuits. However, it does not support our specific PIC device. Still, it is great for experimentation and detailed debugging in a controlled environment (no reality present to bite you).
The PIC instruction set can be described as, let's be kind, odd. It is very far from symmetrical, and exposes the bare metal in various ways. If you have studied microprocessor architecture 101 or something similar, you will see many familiar concepts in the flesh. Still, for those of us who cannot stand this, there is the SDCC - Small Device C Compiler.
The SDCC also comes prepackaged for Debian and other distros. It supports the PIC device in question, but also MCS51, DS80, Z80 and HC08. The PIC support is divided into PIC14 and PIC16, where the number indicates the bits in each instruction. Just to amuse themselves, the Microchip engineers made the PIC16F690 device a PIC14 processor.
Well, the summer weather is great and I've got my LED flashing here, so I leave you with a list of tools and hopefully you will be able to use this to take the next leap in automation and PIC-based development.
Johan Thelin is a consultant working with Qt, embedded and free
software. On-line, he is known as e8johan.
|Android Candy: Intercoms||Apr 23, 2015|
|"No Reboot" Kernel Patching - And Why You Should Care||Apr 22, 2015|
|Return of the Mac||Apr 20, 2015|
|DevOps: Better Than the Sum of Its Parts||Apr 20, 2015|
|Play for Me, Jarvis||Apr 16, 2015|
|Drupageddon: SQL Injection, Database Abstraction and Hundreds of Thousands of Web Sites||Apr 15, 2015|
- "No Reboot" Kernel Patching - And Why You Should Care
- Android Candy: Intercoms
- DevOps: Better Than the Sum of Its Parts
- Return of the Mac
- Drupageddon: SQL Injection, Database Abstraction and Hundreds of Thousands of Web Sites
- Designing Foils with XFLR5
- Non-Linux FOSS: .NET?
- Play for Me, Jarvis
- Consent That Goes Both Ways