Skip to main content
Topic: AVRDude + Bus Pirate 40x speed improvement (Read 19108 times) previous topic - next topic

AVRDude + Bus Pirate 40x speed improvement

I've spent the past few days implementing some changes to the Bus Pirate firmware and also to avrdude to increase the verify speed performance.  Since I don't have an ATmega2560, I'm unable to write suitable code to be able to handle changing pages, so this code will only work with an AVR that has less than 64k memory words.

The attached two patches result in a ~40x speed increase of verify operations.

What I've done is implement a new command in binary SPI mode (0x06), which is what I've called "AVR Extended Commands" mode.  This has a few subcommands, and the most pertinent one is a AVR bulk memory read command.  I noticed that what causes the verify to be so slow is all the SPI transactions that need to go on, so I figured we should be doing that on the BP and not through software.

Anyway, the patch to AVRDUDE attached implements tvaughnan's fixes above, and also adds in a couple of fixes of my own, and then implements the ability of avrdude to use the new AVR Extended Commands mode in the BP firmware.

Patches can be applied to the latest SVNs of both avrdude and buspirate 6.0RC, and a more full writeup can be found at my blog (zencoding PERIOD blogspot PERIOD com), as well as links to precompiled binaries.

Re: AVRDude + Bus Pirate 40x speed improvement

Reply #1
Great update, thank you. This will go into the next firmware release. I have some other code to look at today too, we may not be far from the next release.
Got a question? Please ask in the forum for the fastest answers.

Re: AVRDude + Bus Pirate 40x speed improvement

Reply #2
Cheers for that :)

The BP patch shouldn't need much adjustment (if any) to be able to handle big AVR's like the Mega2560 (just call the bulk memory read one 64k word page at a time), but the AVRdude patch will need adjustment to be able to handle them.  I don't have one, otherwise I would have done it myself.

Hope it's of some use!

Re: AVRDude + Bus Pirate 40x speed improvement

Reply #3
Is there any hopes of this maybe being placed in a firmware for BPv3, like another extended 5.10 firmware without LCD, but enhanced so that it will be able to program AVRs better.

Re: AVRDude + Bus Pirate 40x speed improvement

Reply #4
This will go in the next firmware release.
Got a question? Please ask in the forum for the fastest answers.

Re: AVRDude + Bus Pirate 40x speed improvement

Reply #5
Added to the current development hardware version. Documented here: http://dangerousprototypes.com/docs/SPI_(binary)#AVR_Extended_Commands
Got a question? Please ask in the forum for the fastest answers.

Re: AVRDude + Bus Pirate 40x speed improvement

Reply #6
Cheers for that!

I've finally got hold of an Arduino Mega 2560, so I've updated the patches to handle memory page swapping, and also updated them to suit the latest versions of avrdude (5.11) and the Bus Pirate firmware (6.1 r1676).  The patches below have been tested with an ATmega328p (which doesn't have more than one memory page) and with an ATmega2560 (which does).

The AVR Extended Commands protocol version didn't change, so an avrdude compiled for the previous version of my update will just work as expected.  The avrdude patch is more to bring it in line with the latest version.

The post on my blog has been updated, you can find precompiled firmware and avrdude binaries there.

Enjoy!

Re: AVRDude + Bus Pirate 40x speed improvement

Reply #7
Did you commit the avrdude patches upstream with the avrdude team ?
Afaik there will soon be a V 6.0 release out , and maybe this can be included.

/Bingo

Re: AVRDude + Bus Pirate 40x speed improvement

Reply #8
Hello,
I'm still having problems with programming going RIDICULOUSLY slowly, running:
Quote
avrdude: Version 5.11.1, compiled on Apr 28 2012 at 16:13:32
and
Quote
Bus Pirate v3.a
Firmware v6.1 r1676  Bootloader v4.1
DEVID:0x0447 REVID:0x3043 (24FJ64GA002 B5)
These are, afaik the latest (release) versions of everything. I'm using my own avrdude.conf file because the most current still doesn't include support for atmega328 (non-p). I just copied the atmega328p section and changed the device signature, which should be all that is necessary since the only difference is that the p version is pico-power.

Here's how it is going:
Quote
./avrdude -c buspirate -P /dev/tty.usbserial-PirateV3 -p atmega328 -U flash:w:main.hex:i -C myAvrdude.conf -D

Detecting BusPirate...
**
BusPirate: using BINARY mode
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.10s

avrdude: Device signature = 0x1e9514
avrdude: reading input file "main.hex"
avrdude: writing flash (32754 bytes):

Writing | #################                                  | 33% 348.61s

At this rate it will take 17 minutes to program 32K. Am I missing something here?

Thanks,
shea

Re: AVRDude + Bus Pirate 40x speed improvement

Reply #9
Hi Shea,

I think it depends on how much of the program space the software can skip. I can program a bootloader into an Arduino in a few seconds, but it is mostly blank space. If your firmware is huge it could take a while, but 17 minutes does seem like a long time. Is there a programming speed option in AVRDude that you can increase?

You could also try the STK500v2 firmware for the Bus Pirate, it should be much faster:
http://dangerousprototypes.com/docs/Bus ... e_firmware
Got a question? Please ask in the forum for the fastest answers.

Re: AVRDude + Bus Pirate 40x speed improvement

Reply #10
[quote author="Bingo"]Did you commit the avrdude patches upstream with the avrdude team ?
Afaik there will soon be a V 6.0 release out , and maybe this can be included.[/quote]

No, I haven't.  However, I'll go and do so.

[quote author="hyperspasm"]./avrdude -c buspirate -P /dev/tty.usbserial-PirateV3 -p atmega328 -U flash:w:main.hex:i -C myAvrdude.conf -D

Detecting BusPirate...
**
BusPirate: using BINARY mode
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.10s

avrdude: Device signature = 0x1e9514
avrdude: reading input file "main.hex"
avrdude: writing flash (32754 bytes):

Writing | ################# | 33% 348.61s[/quote]

Your log indicates you possibly aren't using the version of avrdude which supports the AVR Extended Commands set.  Re-run avrdude with the '-v' flag, and you should see something say "AVR Extended Commands version 1" dropped to stderr.

The version of the binary that I supplied (and the one I made the patch for) is avrdude version 5.11 compiled on Mar 6.

Re: AVRDude + Bus Pirate 40x speed improvement

Reply #11
Hi jyoung,
Thanks for the response. I guess I was under the impression that the current release of avrdude already had your patches applied. I went back and downloaded that avrdude-5.11 source tarball and patched it with the patch you posted above, and that made a TREMENDOUS improvement. I'm getting write speeds of ~550 bytes per second, which I think is still pretty slow, but it has moved into the realm of tolerable.

Thanks again for your help,
shea

Re: AVRDude + Bus Pirate 40x speed improvement

Reply #12
Glad it worked out for you.  I've submitted the patches up to the AVRDUDE development mailing list, so with any luck it'll be in the official AVRDUDE in the future.

Re: AVRDude + Bus Pirate 40x speed improvement

Reply #13
Current (as of last week) "40X" firmware/Enhanced avrdude works for ATtiny84.

Gives a "verification failure" with ATtiny167 pgms > 8K . Less than 8K works.

Same setup, substituting an AVRISP mkII for the BP, works. Since this uses

the same "conf" file entry, presumably that eliminates it as the problem...

best regards

Re: AVRDude + Bus Pirate 40x speed improvement

Reply #14
I'm trying to take advantage of this speed improvement, and I believe I'm not getting it.

I have a Bus Pirate v3.6 with the firmware

I compiled the most recent version of avrdude from their website. Here's the output when I run it:

avrdude: Version 6.0.1, compiled on Nov 16 2013 at 07:50:22

...

Attempting to initiate BusPirate binary mode...
BusPirate binmode version: 1
BusPirate SPI version: 1
avrdude: Paged flash write enabled.
AVR Extended Commands not found.
avrdude: AVR device initialized and ready to accept instructions

As I understand it, these extended commands were supposed to be part of the latest builds, but they don't seem to be there. I'm confused.

Thanks for any advice,

Mike