overview

The Bus Pirate has a bootloader that accepts software updates over the USB connection and writes them to the memory of the PIC 24FJ64GA002 microcontroller. Without a bootloader, we’d have update the firmware through the ICSP header using a ‘real’ programmer like an ICD2 or PICKIT2.

This guide explains how to update the Bus Pirate firmware using the bootloader and the Windows quick programmer utility.

Before you begin

Grab the latest firmware archive from the project download page, extract it to a folder. The firmware archive has the quick programmer utility (P24QP.exe) and .HEX firmware files for each Bus Pirate version.

If you get an error about a missing comdlg32.ocx when you run the quick programmer, install the sample code from Microchip application note AN1157.

jumper

Connect the PGD and PGC pins of the ICSP header to trigger the bootloader (A). A standard 0.1″ jumper works best, but any conductive material will work. The PIC flips the PGD pin high and low 20 times, if PGC matches PGD then the bootloader starts. If there’s no connection between PGC and PGD, then the normal Bus Pirate firmware starts.

If there’s no firmware on the PIC, the bootloader starts automatically. You don’t need a jumper between the PGC and PGD pins on a ‘fresh’ chip. This also applies to Hack a Day v2go preorder 2, which shipped with bootloader only.

Bootloader V2 uses the mode LED present on all Bus Pirate hardware to indicate that the bootloader is active and ready for firmware (B).

If the bootloader accidentally starts without a connection, place a jumper between GND and PGC. This will hold PGC low and ensure a mismatch.

Upgrading the firmware via bootloader

overview

1. Change the quick programmer COM port to match your Bus Pirate.

com-select

Find the COM port number assigned to your Bus Pirate. Right-click the quick programmer COM number and set the correct port. You can also try to increase the programming speed.

Disconnect the Bus Pirate from the USB cable or power supply if you haven’t already. Put a jumper between the PGC and PGD pins of the Bus Pirate ICSP header. Connect the Bus Pirate to the USB port.

2. Press the connect to device button to open a connection to the bootloader.

3. Click the open HEX file button. Find the firmware for your Bus Pirate version and load it.

4. Click erase device to clear the old firmware. Don’t skip this step or the new firmware might not work correctly.

5. Click write device to send new firmware to the Bus Pirate. This process will take about 3.5 minutes at 9600bps. Ignore verify errors between 0x400 and 0x0bfe, that’s the bootloader location and it doesn’t get updated.

Most PICs will bootload at higher speeds, experiment with the speed setting to see the maximum rate you can achieve. We normally bootload at 115200bps.

6. Click normal execution mode to complete the update. Click yes to the warning, we re-enter the bootloader using the jumper.

7. Disconnect the Bus Pirate from the PC, remove the jumper that connects PGC and PGD, and then re-attach the Bus Pirate. This complete hardware reset returns any resources used by the bootloader to their default state. The firmware update is complete.

Notes

The bootloading process isn’t particularly perilous. The bootloader protects itself from being over written. If bootloading is interrupted or there’s an error, you can usually just start the process over again. There is a brief instant after pressing the play button when a fatal error could occur, but it’s difficult to make it happen in practice.

If you’re starting with a new PIC microcontroller, you’ll need to program the bootloader firmware first through the ICSP header using a ‘real’ programmer like an ICD2 or PICKIT2.

Advertisements