John,
Remember your avrdude thread from back in November?
http://arduino.cc/forum/index.php/topic,133005.0.html
I'm the guy that built an updated avrdude 5.11.1 windows binary from the SVN sources
for you to speed up your 1284 bootloader development - I'm very familiar with avrdude and usbasp.
For others, if you are going to be burning many bootloaders,
I highly recommend getting a later avrdude as it dramatically
speeds up the process since it will only burn the bootloader code space and not all the flash
from zero up to the bootloader.
3-4 seconds for fast SCK, 30 seconds for slow SCK compared to
30 seconds with fast SCK and about 7 minutes with slow SCK with the avrdude that ships with IDE.
(the windows binary I built and config file is attached as a zip image near the end of the thread linked above)
Just to refresh my understanding of things, and to look at the -B option and SCK clock modes
on USBasp a bit closer,
I went back and had a look at both the avrdude source code and the usbasp source code.
The recent avrdude (past few years and what ships with Arduino)
will always try to set the SCK speed on usbasp before connecting to the chip to talk to it.
It either sets it to an auto clock mode (0, which is fast) or sets
it to a value from the avrdude.conf file or a value from the -B command line option.
The -B overrides the setting.
If the usbasp device firmware does not support setting the isp SCK through
the USB USBasp command interface, avrdude will report a warning.
From the avrdude code in usbasp.c
int nbytes =
usbasp_transmit(pgm, 1, USBASP_FUNC_SETISPSCK, cmd, res, sizeof(res));
if ((nbytes != 1) | (res[0] != 0)) {
fprintf(stderr, "%s: warning: cannot set sck period. please check for usbasp firmware update.\n",
progname);
return -1;
}
The avrdude code first does a SETISPSCK command and then does a CONNECT.
If you look at the official usbasp releases on the fischle site,
http://www.fischl.de/usbasp/
support for this SETISPSCK command started in the 2009-02-28 release.
Prior to that, the usbasp firmware either ran in hardware ISP or software
ISP depending on a hardware jumper.
According to the official schematic that jumper is hooked up to PC2 and is called JP3.
It grounds PC2 to set software SPI mode.
From the USBasp firmware in main.c
Pre 2009-02-28
/* set SCK speed */
if ((PINC & (1 << PC2)) == 0) {
ispSetSCKOption(ISP_SCK_SLOW);
} else {
ispSetSCKOption(ISP_SCK_FAST);
}
post 2009-02-28
if (data[1] == USBASP_FUNC_CONNECT) {
/* set SCK speed */
if ((PINC & (1 << PC2)) == 0) {
ispSetSCKOption(USBASP_ISP_SCK_8);
} else {
ispSetSCKOption(prog_sck);
}
The pre 2009 code supported "slow" (s/w isp) or "fast" (h/w ISP)
and the new code supports a forced slow rate (which also uses s/w ISP)
or the value/rate sent from the -B option which defaults to to a fast h/w ISP
if not sent.
This rate/mode is controlled by the jumper - Installed == slow, removed == fast or -B mode
depending on the firmware.
This jumper setting check is in the top part of the code for the CONNECT
command. This means that even if on newer firmware that supports the
-B option which uses the SETISPSCK command, the jumper will override that
setting. (avrdude does the CONNECT after SETISPSCK)
Now that we know how avrdude and the firmware works, lets take a look
at how it interacts with a blank AVR chip.
Every single blank m328p AVR chip that I've programmed required using a slower SCK clock.
The default USBasp SCK clock rate is too fast for the default internal clock that the AVR
shipped with.
I've not programmed a large quantity, only around 10 or so, but this was true for all them.
The SCK clock had to be slowed down when using either an AVR dragon or the USBasp device I have.
Using the internal clock is controlled by fuses inside the AVR so yes the target fuses
can affect whether or not the USBasp device can program the AVR - or at least
make it not work with all the USBasp defaults.
Note: according to the datasheet the m328p clkdiv8 fuse is programmed when shipped
which gives a 1mhz clock by default for blank chips, so I assume that the SCK clock
will need to be slowed down for all blank m328p chips and not that mine were
somehow "unluckily" slow.
Since the firmware on my USBasp appears to be old and out of date, it requires using slow SCK jumper to slow
down the clock. (the -B option does not work as there appears to be no support for SETISPSCK in my device firmware)
The USBasp device I have also has it's jumper headers labeled differently from the official schematic.
On my USBasp device, I short out the header pins labeled j2 rather than j3.
From my experience, here is my take away from all this
when using USBasp devices.
If you have old USBasp firmware you will ALWAYS get the SCK warning.
In order to burn a bootloader into a blank chip, the SCK will need to be slowed down.
If you have old USBasp firmware, you must use the slow SCK jumper to slow the clock down.
Not all USBasp devices label their slow SCK jumper the same or use the same label as in the official schematic.
If you have newer firmware you can use the -B option, but.....
from what I've seen so far, the Arduino IDE does not use the -B option when it burns a bootloader, so if
using the IDE, it looks like you will still need to use the jumper.
As an alternative you can use the avrdude commandline interface where you can spedify the -B option.
If the AVR is running faster than the 1Mhz default, then no jumper or -B option should be needed
but the avrdude SCK warning will still show up.
--- bill
Now I need to go update my USBasp device to the latest firmware so I can eliminate
the ugly warning message.