
Bus Pirate firmware updates can be done from Linux or OSX using the Python PIC24F programmer developed by broeggle and JoseJX. The programmer works on all operating systems that support Python and pySerial: Linux, OSX, and Windows, too. Thanks for a great script!
Our step-by-step guide to the Python PIC24F programmer continues after the break.
Here’s some key stuff to get:
- The programmer works with Python 2.x, not 3.x.
- Get the pySerial module to give Python serial port access.
- Download the latest Python PIC24F programmer script. Future firmware releases (>2.0) will include the Python programmer script.
- Download the latest firmware. Copy the P24qp.ini configuration file and firmware .HEX to the same directory as the programmer script.
- Get a 0.1″ jumper to place between the PGC and PGD pins, as described in the Windows quick programmer tutorial.
Install Python 2.x and the pySerial module. Download the firmware and programmer, move the required files into a convenient directory.

Disconnect the Bus Pirate from the USB cable (and power supply if applicable). Place a jumper between the PGC and PGD pins (A), as described in the Windows quick programmer tutorial. Plug the Bus Pirate back in.
C:\>cd python26
C:\Python26>python P24qp.py
Bus Pirate Programmer v1.0
P24qp <command>
-a –auto=FILE – Erase, Program and Quit the Bootloader
-c –config=FILE – P24qp compatible configuration file
(Default: ./P24qp.ini)
-e –erase – Erase the flash programming
-f –finalize – Finalize the programming and go to user mode
-i –info – Information about the bootloader
-q –quiet – Quiet messages about writing progress
-r –read=FILE – Read programming from flash
-s –serial=DEVICE – Override serial device path
-t –reset – Reset the bootloader
-v – Enable verification of write commands
-w –write=FILE – Write programming file to flash
C:\Python26>
Run the programmer from the command prompt for a short description of the flags and options.
JoseJX recommends auto mode with verify, using the command:
P24qp.py -a <hexfile> -s <serial port> -v
Substitute <hexfile> with the name of the firmware .HEX file, something like v25-Firmware-v2.hex for the Bus Pirate v2go. Replace <serial port> with the device name you system assigned to the Bus Pirate’s FTDI USB->serial converter chip.
- Linux: /dev/ttyUSBx (/dev/ttyUSB0) or /dev/ttySx (/dev/ttyS1)
- OSX(?): /dev/cu.KeySerialx (/dev/cu.KeySerial1)
- Windows: COMx (COM3)
The serial port name can be tricky, hopefully these examples help. Replace ‘x’ with the number for your system. Look in the system dmesg to find the Bus Pirate on Linux, or in the control panel on Windows.
C:\Python26>python P24qp.py -a v25-Firmware-v2.hex -s COM5 -v
Using Serial Port COM5 @ 115200
Reading 4 bytes from address 0×00FF0000
Found PIC24FJ64GA002
Erase Flash:
Erasing 43 pages, starting at 0×00000000
Erase complete
Writing 256 bytes to address 0×00000000
Reading 256 bytes from address 0×00000000
Verification failed at 0×00000000: 0 != 4
Verification failed at 0×00000001: 4 != 12
Writing 256 bytes to address 0×00000080
Reading 256 bytes from address 0×00000080
Writing 256 bytes to address 0×00000100
…<<< This continues for awhile
Reading 256 bytes from address 0×0000AA80
Writing 256 bytes to address 0×0000AB00
Reading 256 bytes from address 0×0000AB00
Writing 256 bytes to address 0×0000AB80
Reading 256 bytes from address 0×0000AB80
Verified Okay.
Verification complete, switching to user mode
C:\Python26>
Ignore any verify errors at the beginning (0×0, 0×1) and between 0×400 and 0xbff, these are bootloader protected locations. A really nice thing about the Python programmer is that it knows to ignore errors in the protected bootloader section.
Tags: Bus Pirate, linux, python
-
One step missing… where you tie PGC & PGD together, otherwise worked fine for OS X!
-
P24qp.py is at http://the-bus-pirate.googlecode.com/svn/trunk/firmware/v2-nightly/P24qp.py instead of the the URL mentioned above. Other than that it worked. I’m now on fw 2.3-nightly :-)
-
Thanks for the guide; unfortunately, I keep getting verification errors outside of the protected areas. E.g.
…
Writing 256 bytes to address 0×0000A800
Reading 256 bytes from address 0×0000A800
Verification failed at 0×0000A8F8: 15 != 255
Verification failed at 0×0000A8F9: 0 != 255
Verification failed at 0×0000A8FA: 0 != 255
Verification failed at 0×0000A8FC: 0 != 255
Verification failed at 0×0000A8FD: 0 != 255
Verification failed at 0×0000A8FE: 0 != 255
Writing 256 bytes to address 0×0000A880
Reading 256 bytes from address 0×0000A880
…Would this indicate a problem with my Bus Pirate v3?
I’m using the python programmer scripts on Linux.
Thanks,
-Jason -
I wonder what the difference is in error reporting between the versions? I’m guessing that the python version is more verbose and isn’t ignoring one errors that Microchip’s updater doesn’t report. There could also be a minor error in the Python updater, but as you noted nobody has ever has ‘problems’*.
*For some values of problem.
-
I do have exactly the same error as Jason, but I’m using the microchip windows client. All the extra errors appears after 0xA800 (like jason). It looks like the pages are writeprotected like the bootloader (i.e. cannot erased, but written once??) Unlike what is suggested the errors are serious (weird text and such) and should never be ignored in my opinion!! flashing/clearing multiple times didn’t help and the error remains the same.
I got an BP from the preorder 2 from seeedstudio. More people with the same problem?
-
I found it already:
the option to preserve the fuses prevent the memory area (a800 and up) to be erased and thus written properly (the verify errors). disabling this option solves this. All the compiles I’ve done so far (as described in the how-to-compile wiki entry) include the fuses so it should be ok (stress on should ;)) I just tested it and it did work (no indept testing so far)
-
-
@Chris – thanks for the confirmation, we’ve been discussing this in the forum. Did you load one of the translations? They’re the only version that should reach past 0xa800. I try to verify each before release.
I’ll do some testing with erasing the configuration bits, I worry that a chip without config bits won’t have the wherewithal to get loaded again. How is the chip supposed to know what clock source to use with the bootloader if the config bits are erased? There may be some mechanism to address this, but I’d like to know for sure before recommending that everyone do it.
-
I have a BPv3:
Firmware v2.4-Seeed
DEVID:0×0447 REVID:0×3003 (A3)I can use it without a problem, but there is no way to update bootloader or anything.
I’ve used P24qp of v2tov41-bootloader-update-va3 package with all versions of python that are avalaible on Debian (2.1, 2.2, 2.3, 2.4, 2.5), and always got this:Using Serial Port /dev/ttyUSB1 @ 9600
Reading 4 bytes from address 0×00FF0000
RX Error: 0 bytes received
Error reading from device!
Device with ID: 65535 not listed in the config file!The port is there, the user have access, I can conect to de BP with any terminal, but looks like the pyton updater even doesn’t see the port.
¿Any clue.?
Thanks-
Hi Stendal,
Did you place a jumper between the PGC and PGD pins? Does the MODE LED light when you plug in the Bus Pirate with the jumper attached?
What command did you use to upload the bootloader update?
There’s also more help in the forum.
-
Yup, jumper atached and the BP lights up pwr and mode leds.
python P24qp.py -a BPv3-v2blupdaterVa3-v4.1.hex -s /dev/ttyUSB0
Thx for help
-
-
-
The link to the python installer seems to have changed to http://dev.gentoo.org/~josejx/bus_pirate/
But i can’t find any configuration file for it. I am trying to get the AVR STK500 installer to Bus Pirate v3 Firmware v3.0.
-
The latest python installer should be included in the firmware archive download. If you’re using v3.0 (and bootloader v2) be sure to use the STK500 firmware for the v2 bootloader. You can also upgrade to the new v4 bootloader:
http://dangerousprototypes.com/2010/01/18/how-to-bus-pirate-bootloader-v4-upgrade/
-


19 comments
Comments feed for this article