I went to the playground and also did some searching on the forum and assembled what I thought was all the info I needed to burn bootloader to bare ATmega168s with Mac OSX and an AVRISP MKII. I followed the instructions, downloaded and built usblib (0.1.2) and avrdude (5.4). I took the script offered and followed some other web links and got the fuses set up right ... my script is below:

The result below ... Now I never set the port, I left the generic term "usb" ... the reason for this nothing ever shows up in /dev/tty ... I look ("ls /dev/tty*" shows nothing added, I rebooted as one suggested) but nothing. I go to "About This Mac" and "More Info" and Apple System Profiler says it has "AVRISP mkii" on its USB bus. The AVRISP MKII has the small green light on indicating it is happy with the NG board and its power and connection. As soon as I start the script the larger green light near the USB becomes active and various blinks and a couple of minutes later I get the results below ....

It ran, and it worked, I have a working bootloader, even loaded a program to it, thanks Dave ... bbbuuuttttttt ....I noticed the time it took to verify 512 seconds ... is that right? Add to that the "communications error", each time avrdude had to be invoked there was about 2-3 minutes of floundering around before it started writing. The whole process took over 20 minutes, why did it abort the script the first time and not the second time?

OK, I just added all the calls onto one line in yet another version of "burn.command" so that avrdude has to "find" the avrisp mkii only once, and it worked. The total time was significantly less. After 6 minutes it started displaying output coming in near the end of the writing flash ... verifying still took 512 seconds ... total time was under 16 minutes

I cleaned up my files and tarred the results if anyone wants to give it a try ... I guaranty nothing. I can say that it runs on m MacBookPro 2 GHz Core Duo under OSX 10.4.10 with all updates. It has avrdude 5.4 with usblib support and was compiled under Xcode 2.4.1. It will burn an ATmega168 using an AVRISP MKii

The tar.gz file is 275K and will unpack to 1.4 MB. It has the hexfile for the 168, the script, the executables, usblib support and man pages for avrdude. Unpack it into /Applications/arduino-0008, it will come out as a folder called "bootloader-usb". Go to a terminal window and cd to the directory and excecute the script by typing

I had a similar problem: a very long delay when I first ran avrdude before it started to do anything. I had to actually patch avrdude to fix it. Arduino 0009 (which should come out tomorrow) will include the patched version and a "Burn Bootloader" command.

I submitted a bug to avrdude: https://savannah.nongnu.org/bugs/?19882 but haven't heard anything. You might want to add a comment explaining your experience (with the long delay on startup). These things sometimes get fixed faster if multiple people report them.

I had a similar problem: a very long delay when I first ran avrdude before it started to do anything. I had to actually patch avrdude to fix it. Arduino 0009 (which should come out tomorrow) will include the patched version and a "Burn Bootloader" command.

I submitted a bug to avrdude: https://savannah.nongnu.org/bugs/?19882 but haven't heard anything. You might want to add a comment explaining your experience (with the long delay on startup). These things sometimes get fixed faster if multiple people report them.

OK, will do ... but back to my question about the time it took to burn and to verify the flash, 51 seconds and 512 seconds .... is that right? 512 seems awfully long!

I added a call to date at the start and finish of the script and burnt several 168s with the bootloader. It is quite consistent at 15 minutes plus 4-8 secs second total time to run, the flash write is 51.7 seconds and verify is 512 seconds ... I hope your patched avrdude in 0009 works better.

I seem to recall an issue where some avrispmkII programmers have their clock period unusually long, which leads to long programming times. Maybe this link could shed some light, or at least get you started in the right direction.

51 seconds to burn and 512 seconds to verify the flash does seem very long. That sounds like it might be a result of what kg4wsv suggested: that the avrispmkii is configured with a slow clock period. The delay at startup though, is because (assuming it's the same as it was in my case) avrdude tries to sync with the avrispmkii 33 times, and each one has a long timeout.

51 seconds to burn and 512 seconds to verify the flash does seem very long. That sounds like it might be a result of what kg4wsv suggested: that the avrispmkii is configured with a slow clock period. The delay at startup though, is because (assuming it's the same as it was in my case) avrdude tries to sync with the avrispmkii 33 times, and each one has a long timeout.

OK, but is there any way to put the "sck 10" into a command line option for a script?

aaaannnddddd .... to add some more fuel for pondering ... I just strated up to burn some chips and did ONE THING different ... instead of plugging the USB cable into the side of he MacBookPro I plugged it into a spare port on my Belkin 7 port USB hub ... and, voila, no 5 minute wait, it immediately started doing its thing. Total time start to finish was just under 10 minutes (essentially just under 1 min for burn, just over 8 min for verify, and the rest for locks and fuses) and quite repeatable I am on my fifth chip .... how does this fit in with your theories?

... wheee ... are we having fun yet? -grin- this is making me sweat, but I am an old dog learning new tricks!

OK, but is there any way to put the "sck 10" into a command line option for a script?

If I understand correctly, issuing that command causes it to be written to EEPROM in the avrispmkII, so it should be a one shot deal.

FYI, on a recent project I flashed and verified a 7k program in a few seconds from a PPC powerbook, so what you are seeing isn't normal (but I think you already knew that ). I was burning directly from the powerbook's USB port, while on battery even.

OK, but is there any way to put the "sck 10" into a command line option for a script?

If I understand correctly, issuing that command causes it to be written to EEPROM in the avrispmkII, so it should be a one shot deal.

FYI, on a recent project I flashed and verified a 7k program in a few seconds from a PPC powerbook, so what you are seeing isn't normal (but I think you already knew that ). I was burning directly from the powerbook's USB port, while on battery even.

You may also want to check the firmware on your avrispmkII.

-j

ALL RIGHT!!!!!! Now we have it ..... under 1 sec burn, under 8 seconds verify .... 22 seconds ... start to finish .... the "sck 10" did the trick. Dave, should I write this up for the Playground?