How to flash the Firebee's PIC microcontroller
The PIC microcontroller is a vital part of the Firebee. It monitors battery voltage, switch the Firebee on/off or reset it when the user operate the power/reset-button, maintains time and date, keep a backup of TOS' NVRAM and (soon) allows PS/2 keyboards and mice to be connected.
The microcontroller runs a program, and like every other piece of software this program has bugs and missing features. So you might want to update this program as new versions comes out.
This tutorial describes how to update the firmware in the Firebee's PIC microcontroller using a PICkit2 programmer with Linux. The same tool exists for OSX and this guide should apply for OSX as well.
Download the latest PIC firmware
The latest PIC firmware binary is available here
. The latest sourcecode can be downloaded from the Firebee project page
- Fixed a serious problem where the PIC messed up the PCI reset signal.
- It's now possible to power off the Firebee in software.
- This firmware now has a bootloader. This means that new versions of the PIC firmware can be uploaded to the PIC from the Firebee itself without any external hardware.
If your Firebee was shipped in Januar 2012 or later you already have the latest version and don't have to worry about this.
Get a PICkit2 programmer
Get it from Microchip
or take a look at eBay. There are several PICkit 2 clones on eBay, the one I have is called "Mini KIT 2 Programmer/Debugger" and is working just fine.
Modify/build a cable
Unfortunately the pinout of the PIC connector on the Firebee (six-pin header right next to the PIC itself) isn't the same as the connector on the PICkit, so you either have to make a cable or modify the one you got with your PICkit 2. The cable should be wired like this:
|PICkit 2 pin #||Firebee pin #
pk2cmd is Microchip's command line tool for programming PIC chips with the PICkit2 programmer. It's available for Linux and OSX from Microchip's PICkit 2 development page
For debian and derived systems (like Ubuntu) you can also download it here.
Flash the PIC
This is the easy part. Switch your Firebee off. Connect your PICkit2 to the Firebee using the cable to made/modified earlier. Now, check that things are actually working. Run pk2cmd:
You should now get a response similar to this:
Executable Version: 1.20.00
Device File Version: 1.55.00
OS Firmware Version: 2.32.00
If not, something's wrong. You might not have access to the USB port as a user, try to run pk2cmd as root ("sudo pk2cmd...") instead. If that doesn't help it's time to google.
Now check that the programmer is correctly connected to your Firebee and recognise the PIC:
pk2cmd will now try to detect the type of PIC in your Firebee. The following is the correct response:
Auto-Detect: Found part PIC18F4520.
If this is what you got you're fine. If not, check that the cable is wired and connected correctly. If the cable is OK but still not the response above, consult google.
Now it's time to flash the PIC:
pk2cmd -PPIC18F4520 -M -F/home/joska/Prosjekt/Firebee/firebee_pic-20120308.hex
Change the path to the firmware to the correct one on your system. For some reason pk2cmd needs a complete path, so "-Ffirebee_pic-20120308.hex" won't work even if you're in the same directory as the firmware.
When pk2cmd is finished you should verify that the programming went ok:
pk2cmd -PPIC18F4520 -Y -F/home/joska/Prosjekt/Firebee/firebee_pic-20120308.hex
This will compare the specified file with the contents of the PIC's flash memory. You should now get this response:
PICkit 2 Verify Report
Device Type: PIC18F4520
If not (very unlikely), try programming the chip again.
Jo Even Skarstein, 14/12/2013 email@example.com