So a while ago
hack-a-day introduced a really awesome DIY project called
The Bus Pirate which is small device for interfacing with all sorts of different chips and devices using a host of protocols. The really slick part is that despite the small size it's extremely flexible due to being a microprocessor with reprogrammable firmware that can be updated to add even more useful features and support more chips/protocols as times goes on.
The one drawback for myself was the use of surface mount components and a PIC uC instead of the simplistic single-sided etched PCBs with through-hole parts and AVR family of uCs I have more familiarity with, so I kept an eye on it in jealous awe until I found someone offering a
through-hole version and quickly ordered one up, soldered things together, and
had some fun using a MAX7219 to drive a 2-segment LED I had lying around. Getting it working in OS X was fairly trivial thanks to good old ZTerm, which amazes me that it is both still around, still works (even in Snow Leopard!), and is EXACTLY THE SAME as it was 20 years ago when I used it to dial BBSs on a borrowed Mac 512.
Anyway, someone has already documented
getting up and running with a Bus Pirate in OSX with ZTerm so I won't bother to reiterate what's already been said there, except that I believe I had to disable Xon/Xoff flow control to get the Through Hole v1a version working right with my particular USB->RS232 adaptor (I have a couple, each is uniquely quirky in some way or another). What I did want to do though is lay out a little documentation that I myself could refer to about reprogramming the firmware on a Bus Pirate from OS X.
To begin with, the main steps for doing so from OS X/Linux
are outlined here and I'm just gonna deal with the OS X specifics. It's A LOT nicer than using the Windows P24QP.exe programmer which I found somewhat tricky in actual execution, even if for no other reason than not having to drag everything over to my wintendo for a minute then move everything back on the workbench.
First, open up a terminal and type 'python --version' just to be safe and sure you're running 2.x and not 3.x. 10.5.8 currently has 2.5.1 and Snow Leopard (A421a) has 2.6.1 so unless you went and installed 3.x yourself you're likely fine.
Second, install
the pySerial module by downloading it in .zip form (2.5rc1 as of this writting). Unzip it either from OS X's GUI or from the command line with 'unzip pyserial-2.5-rc1.zip' and then cd into it's directory and install by typing 'sudo python setup.py install'.
Third you'll want to grab the P24qp.py Python programmer from
here, the P24qp.ini file from
here and lastly the HEX firmware file - v2.0 firmware for v1a hardware (for Spiffie's through hole version)
here and 2.5 firmware for v2go hardware (for hack-a-day's first Seeed Studio run) from
here. (those are all direct links you can wget or curl). Get all that stuff together in a single directory.
Now, with the pieces assembled, we'll need to use a standard jumper (I grabbed one off a nearbye harddrive) between ICSP header pins 4 & 5 (on the v1a PTH 4 = PGD & 5 = PGC while on the v2go they're reversed and 4 = PGC & 5 = PGD, but same pins are being connected so that is trivial) - on the v1a PTH they're labelled and located just under the screenprinted word "Logic" and on v2go they're the ones adjacent to the ICSP screenprinting on the top layer.
For v1a PTH I'm using a Prolific PL2303 chipset adaptor I got off eBay a while ago for a few bucks, and ended up modifying with a wire to connect SHIELD between the USB and the DB connectors' shell, and run it with
the opensource driver. I actually have two of these PL2303 adaptors and one of them just plain doesn't want to work, but it has always been "picky" although "flakey" is a more apt description. For the v2g0 you'll instead need
the FTDI driver installed if you haven't already done so, which you likely have if you've connected to it from your Mac in ZTerm.
Now attach the USB->RS232 adaptor for v1a + external power, or just the mini-usb cable to the v2go and to your Mac, and with that taken care of it's time to get programming!
Before we do though, we will need to find the serial port, a quick and dirty method is just typing 'ls -ltr /dev' and looking at the output towards the bottom of the screen for something like 'tty.usbserial' and 'cu.usbserial' for v1a/PL2303 adaptor and 'tty.usbserial-A7004Iqz' and 'cu.usbserial-A7004Iqz' for the v2go's onboard FTDI chip.
With that key piece of info you'll now want to be in the same directory as the P24qp.py and P24qp.ini files you downloaded and type 'python P24qp.py -a <firmware.hex> -s /dev/<serial port> -v' replacing
<firmware.hex> with
v1a-Firmware-v2.hex for v1a PTH or
v25-Firmware-v2.hex for v2go, and replacing
<serial port> with
cu.usbserial for Prolific PL2303 adaptors with v1a PTH and
cu.usbserial-A7004Iqz for FTDI/v2go. So for my v1a PTH w/PL2303 adaptor I used 'python P24qp.py -a v1a-Firmware-v2.hex -s /dev/cu.usbserial -v' and for my v2go I used 'python P24qp.py -a v25-Firmware-v2.hex -s /dev/cu.usbserial-A7004Iqz -v'.
That should do it and now text should be flying across the screen as the update does it's thing! Ignore the usual errors between 0x400 and 0xbff as they are related to the bootloader's protected area, and any other errors should be automatically taken care of by the programmer itself, resending any bits that fail verification. If you get an error 65535 about the chip not being found/recognized and no update happening at all, you likely just forgot the jumper on ICSP header pins 4&5. Anything else you should ask in
the forums, but I have successfully reprogrammed both my v1a and v2go units using this method and happily don't have to go back to using the Windows P24qp.exe programmer anymore!