Bus Pirate 5/6/7 can now restore the bootloader of a Bus Pirate v3

I opened a PR that adds a binmode to the Bus Pirate 5/6/7 firmware to unbrick a Bus Pirate v3. It writes the v3’s bootloader v4.5 through its ICSP header:

If a v3 lost its bootloader, or you replaced its PIC24FJ64GA002 with a blank one, you used to need a separate programmer like a PICkit to bring it back. Now the Bus Pirate you already have does it, with four wires:

v3 JP2 BP5/6/7
1 PGC IO7
2 PGD IO6
3 GND GND
5 MCLR IO5

Pin 4 (3V3) can go to VOUT, but it’s optional. Run binmode, pick “Bus Pirate v3 unbrick” and confirm. About 10 seconds later the bootloader is written and the whole flash verified. It can then hold the v3 in bootloader mode, as the PGC-PGD jumper does, so you can load the firmware with pirate-loader right away.

I really like that a modern Bus Pirate can fix an old one. There are still lots of v3s out there, and a lost bootloader or a swapped PIC shouldn’t be the end of them.

I tested it on a Bus Pirate 6 and a v3.5, with a logic analyzer on the lines and 25 full runs. It also builds for the BP5,

3 Likes

hugo-docs updated

2 Likes

This is killer, however there is GPL code in there and it isn’t compatible with our MIT license codebase.

Is it the ds30 loader code? If there’s a description of the spec then do a clean room rewrite?

1 Like

Good idea. Almost all the code is from my MIT bp3unbricker project but the ds30 loader is GPL, I’m going to make a compatible MIT loader to see if I can pull it off, I’ll comment updates on this post.

1 Like

I just made short 5 cm Dupont cables for the Saleae. No housing. Heat shrink on every wire.

Setup ready to dev!

2 Likes

The Bus Pirate v3 unbrick binmode is ready to merge.

The GPL code is gone. The binmode now writes bp3mitloader, a new MIT bootloader for the Bus Pirate v3 that shares no code with ds30 Loader:

It uses the same protocol as bootloader v4.5 and sits in the same flash page, so nothing changes for users. pirate-loader, buzzloader and the v5.x, v6.x and v7.x firmware work with it as they are, and the firmware shows “Bootloader v4.6”. With no firmware it waits in the bootloader by itself. An upload cut halfway leaves it waiting too, so you don’t need the jumper to try again.

Firmware PR:

Docs PR, a new page with asciinema casts:

The bp3mitloader repo also has buzzloader for Windows, Linux and macOS, and buzzloader.py, the same loader in Python for any system. Without a Bus Pirate 5/6/7, bp3unbricker does the job with a Raspberry Pi Pico:

Tested on a Bus Pirate 6 with a Bus Pirate v3.5, on Windows 11 and on native Ubuntu 26.04:

  • 70 uploads of random data over the whole firmware area, read back word by word: no word different
  • 11000 malformed, cut and random packets: every answer was the expected one
  • 72 full rounds of binmode plus pirate-loader or buzzloader
  • v5.10, v6.1, v6.2, v6.3 and v7.1.12 loaded with both loaders
  • uploads stopped halfway, a USB cable pulled during an upload, a real PGC-PGD jumper, replugs
  • the ICSP traffic decoded with a logic analyzer: one erase and the 8 rows, each written once
  • all four firmware targets build, and the CI passes

@ian both PRs can be merged when you have time.

3 Likes

Wow, good feature updates. I like the resilience to being cut half way through.

1 Like

Merged.

Words. Words words.

1 Like