Categories

Bus Pirate: Firmware upgrades

Posted on Friday, July 24th, 2009 in Bus Pirate by Ian

overview

See the latest version in the documentation wiki.

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.

This entry was posted on Friday, July 24th, 2009 at 12:00 pm and is filed under Bus Pirate. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

4 Responses to “Bus Pirate: Firmware upgrades”

  1. Brett says:

    Here’s a cool tip if you’re flashing your BP often with the P24QP application and you have to change the COM port setting and/or speed….

    Edit the P24QP.INI file that is in the same directory as the application itself.

    If your COM port setting needs to be changed as per step 1 in the image above, change the line that says
    portindex=2
    to be what your COM port is, in my case COM5, so my file says:
    portindex=5

    If you have succeeded in programming at a faster speed, you can default the setting to that as well !! In my case it seems to work at 115200 as Ian does, so I want it to default to that. Change the line that says
    bitrateindex=4
    to be:
    bitrateindex=8
    (the index values are 4=9600, 5=19200, 6=38400, 7=57600, 8=115200)

    There you go. Save the file, and start P24QP, and voila! No more changing the port and speed. In my case I kept forgetting to change the speed before I connected to the device, which requires you to unplug the device and re-start the bootloader to get the additional speed – now, no longer a probelm !

    Enjoy!

  2. me says:

    The Pirate bus may be great but I wouldn’t know because the drivers WILL NOT INSTALL under Windows 7. Then to make matters worse I try to join the forums to get help and the verification requires you look at a schematic and enter two different component values, I CAN”T READ schematics I’am a beginner, Who thought this up! Before buying this product look at all the web pages and steps required to upgrade the firmware!

    • Ian says:

      Hello,

      I’m really sorry about the problems with the Bus Pirate and forum registration.

      I’ll register an account for you on the forum. If you would like to register yourself, you may be able to read the values from the table at the bottom of the page instead of the schematic.

      Which driver are you trying to install for the Bus Pirate? I believe this is the driver package for Windows 7, I’m not sure if you need 32 or 64 bits:
      http://www.ftdichip.com/Drivers/VCP.htm

      This is the same driver and chip on the Arduino, it is well supported and we should be able to figure out any bugs.

      Best regards,

      ian

Leave a Reply

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recent Comments

  • Inyaki: Hi, Would you si king to point me the corsair's single 12v rail supplies? I am interested on it but I can't find it.....
  • peter: In the middle of the geek reading I get a tweet. Here I am
  • icserny: Unfortunately the DIY PCB homepage.is no longer available. Something happened...
  • Lukas: Yes, that's also how I do it, use an extension cable or ar least a 'spacer', i.e. a male and female header soldered directly together....
  • Ja: This looks very interesting. Unfortunatelly looks like the website Is not working now.