As you might remember, buspirate is a pic24-based device with a pic24 + ft232 for usb connectivity. pic24 runs (according to datasheet) at clocks up to 32Mhz. The price tag for my bpv3 hardware was something around 30$ at places like seeedstudio.
uISP on the other hand is way cheaper and simpler and contains only an atmega8 + a handful of passive components. It’s less than 5$ worth of components (and board!) and was designed by me a very long time ago as a super-cheap ISP programmer/devboard. Something I can give out to students to get started in electronics. uISP has NO HARDWARE USB. It just uses vusb stack. Yep, simple as that. The clock is 12Mhz on most boards and for this test I also made a super-special version with a 20Mhz crystal.
Now, can this cute little thingie outperform a much faster buspirate with hardware serial interface IC? Turns out it can, after all!
Or target test will be flashrom. Since I play around a lot of router-like hardware with SPI flashes, an SPI programmer is a must and it is my most widely used flashrom use case… I’ve finally made a neat-looking SPI flash adapter a few weeks ago, so here goes the fun part testing it out.
However buspirate was really slow to use. After updating the firmware to the latest things got better, but still 3m43s to read out a 2MiB SPI flash looked like a waste of time. So I ended up writing 2 firmwares for uISP:
- serprog-compatible SPI flash programmer
- custom flashprog firmware with much more efficient data transfer.
Now, not to bother you with tons of text, I’ll just post a nice pic with benchmark results. For this benchmark I used an 8MiB MX25L6445E SPI flash chip, so that flashrom’s delay loop calibration will be of as little interference as possible.
Serprog firmware can be found on github here. Just keep in mind, that cdc_acm via vusb uses bulk transfers, breaks USB specs, and doesn’t work for some USB hosts and is a LOT slower, even than buspirate. But requires no flashrom patches at all.
The flashprog firmware can be found on github here. As you can see it from the benches above – it beats buspirate even with the slowest possible clock – 12Mhz (6Mhz for SPI). But it requires patching flashrom. I designed it in a way that it can be easily customized to fit ANY avr hardware with usb or even STM32 or any other micro supported by antares. The protocol is very easy to extend, supports any number of SPI flashes connected to different SPI busses (yes, you can run several flashrom instances, one for each of the connected SPI flashes!) The flashrom patch has been submitted to flashrom development list, but it will take a while to have this accepted into the upstream.
Why is buspirate so damn slow?
Theoretically, ft232 can go at 250000(~30KiB/s) at least or even faster. (My 3d printer has no problem with that and sanguinololu has the very same chip onboard). Possibly even faster, I haven’t tested. Still they stick to 115200, that caps the max throughput at ~14 KiB/s. This gives us a theoretical ~9m28s to transfer 8MiBs. In reality we see 13m42.504s. The difference is made up by flashrom’s delay loop calibration, buspirate’s implementation of SPI transfers in firmware (I haven’t looked into their source code anyway, so I won’t be making any assumpsions whether it’s a code issue or a hardware limitation). 8Mhz they use for the SPI interface doesn’t really look like a bottleneck.