Loading...
Pages: [1]   Go Down
Author Topic: Burning the bootloader with Macbook and STk500  (Read 523 times)
0 Members and 1 Guest are viewing this topic.
Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

Has anyone had success using either the tools>burn bootloader command, or the "burnbootloader.command" on a Macbook with a Keyspan USA19 and an STK500?

Wow, that was a mouthful.

The above does not work.. even with all the proper drivers installed. My best guess is a clue I found on the web: a comment that the central component, UISP, is not compatible with the new version 2.0 firmware on the STK500...

any advice is appreciated.

Daniel
« Last Edit: October 14, 2006, 10:23:39 pm by Daniel » Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 7
Posts: 3532
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You're right.  Arduino uses uisp, which doesn't support stk500v2.  We're hoping to switch to avrdude sometime soon, but in the meantime, you can use avrdude from the command line to burn the bootloader.  You can find instructions on the playground (http://www.arduino.cc/playground/Code/OSXISPMKII), in particular this shell script (which I haven't tested, but looks reasonable):

Code:
#!/bin/sh
IPATH=`echo $0 | sed s/[^\/]*$//`;
CMD="$IPATH/bin/avrdude"
OPTS="-p m8 -b 115200 -P usb -c avrispmkII"

# Erase chip write lock and fuses
$CMD $OPTS -e -U lock:w:0x3f:m -U lfuse:w:0xdf:m -U hfuse:w:0xca:m  

# Upload bootloader code
$CMD $OPTS -D -U flash:w:ATmegaBOOT.hex:i

# Lock boot section
$CMD $OPTS -U lock:w:0x0f:m
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks David,

that sounds exactly right. I will give it a try.

D
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

I got it working...

For those trying to burn the bootlader using a Mac with a new STK500, the easiest thing to do is to change the STK firmare to the older version.  Works like a charm once this is done, both from the burn.command and from the Arduino IDE menu.
Logged

Oakland California
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys,
I'm trying to program both a ATmega168 and the stock ATmega8 with the AVR USB MKII (think I got the name right there) that I bought from Digi-Key with avrdude and such, installled from Fink. When I try to burn, it looks like the USB programmer and avrdude hang for several minutes, then it tried to program the 168 (with the 8 bootloader, which I foolishly tried not knowing about the different 168 bootloader), or at least I think it was doing it, I got stuff on my Terminal window and the green outside LED on the programmer was going to a red/green from the normal green.

Now it looks like I've trashed my original ATmega8 that came with my Arduino and maybe the two 168s I bought and have tried (even with the 168 bootloader code).

My terminal sessions always start out like this after executing the shell command. Am I not doing something correctly here? Any and all help, much appreciated.

[doit:/sw] dave% /sw/burn-bootloader-usb.command; exit
avrdude: stk500v2_getsync(): error communicating with programmer: (0)

avrdude: AVR device initialized and ready to accept instructions

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


...then more commands and info, although everything whizzes by now, when the first couple of times I tried this part would take a minute or two. Still getting the 10 minute hang at the beginning.

Dave
Logged

Oakland California
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey,
BTW, is it possible to irreparably hose an Atmega by doing a bad burn? Might I have 3 dead chips on my hands now? Where can I get a STK500, for doing a serial burn? It might be a better way to go than the USB route on the mac for now...
Dave
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 7
Posts: 3532
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can kill a chip with a programmer, but only as a result of using the wrong fuse settings (some of which will lock the chip, or make it expect a certain type of external clock source which it won't run without).  Uploading the wrong bootloader shouldn't hurt the chip, though it won't work. Can you post the contents of your burn-bootloader-usb.command?  
Logged

Oakland California
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here it is. The earlier attempts took longer when things started working, like the read flash would take like 20 seconds. Also note the "error communicating with programmer" message at the beginning.  Does this MKII programmer require 9 volts to the board when doing this? I was running the board off a battery that was running slightly below 8 volts...

[doit:/sw] dave% /sw/burn-bootloader-usb.command; exit
avrdude: stk500v2_getsync(): error communicating with programmer: (0)

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9307
avrdude: erasing chip
avrdude: reading input file "0x3f"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.04s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3f:
avrdude: load data lock data from input file 0x3f:
avrdude: input file 0x3f contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.04s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0xdf"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xdf:
avrdude: load data lfuse data from input file 0xdf:
avrdude: input file 0xdf contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xca"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xca:
avrdude: load data hfuse data from input file 0xca:
avrdude: input file 0xca contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 7
Posts: 3532
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you post the commands in the burn-bootloader-usb.command file, too?
Logged

Oakland California
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sure. Here's the one for the atmega 8:

#!/bin/sh
IPATH=`echo $0 | sed s/[^\/]*$//`;
CMD="$IPATH/bin/avrdude"
OPTS="-p m8 -b 115200 -P usb -c avrispmkII"

# Erase chip write lock and fuses
$CMD $OPTS -e -U lock:w:0x3f:m -U lfuse:w:0xdf:m -U hfuse:w:0xca:m  

# Upload bootloader code
$CMD $OPTS -D -U flash:w:ATmegaBOOT.hex:i

# Lock boot section
$CMD $OPTS -U lock:w:0x0f:m


....and here's the one for the atmega 168:

#!/bin/sh
IPATH=`echo $0 | sed s/[^\/]*$//`;
CMD="$IPATH/bin/avrdude"
OPTS="-p atmega168 -b 115200 -P usb -c avrispmkII"

# Erase chip write lock and fuses
$CMD $OPTS -e -U lock:w:0x3f:m -U lfuse:w:0xdf:m -U hfuse:w:0xca:m  

# Upload bootloader code
$CMD $OPTS -D -U flash:w:ATmegaBOOT_168.hex:i

# Lock boot section
$CMD $OPTS -U lock:w:0x0f:m

Seems the AVR mkII is doing something, even though it does its stuff fast now, I see the LEDs change color when it finally gets around to responding, but it does take a few minutes to start. Still no success on either the 8 or 168 chips smiley-sad

thanks for any and all...

Dave
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 7
Posts: 3532
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Weird, it seems like the command to actually write the bootloader hex file to the chip never executes.  What happens if you run the tree commands yourself at the command line?
Logged

Oakland California
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi again Mellis, and thanks for your help.

I don't know how to run the tree commands in the command line. Right now I've installed avrdude and usblib using Fink, in /sw/bin, but my command script and hex files are in /sw. Also, I got rid of the $IPATH argument in the command because trying to execute an IPATH from the command line didn't seem to have any effect. That might be part of my problem.

I could move everything into /sw/bin to make commands easier. is it a case of just expanding the CMD OPTS stuff and tacking the rest of the command onto it, like this?


(all stuff moved into /sw/bin)

./avrdude -p m8 -b 115200 -P usb -c avrispmkII -D -U flash:w:ATmegaBOOT.hex:i

Dave

(decent programmer but no command line whiz)
Logged

Oakland California
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, it looks like I got my ATmega 8 back in working order. Whew! All I did was the command below. Do I still need to write the lock stuff to it?

Man, the USB programmer sits there for like 5 minutes before doing its thing.

Now I'll try the 168...

Dave



doit:/sw/bin root# ./avrdude -p m8 -b 115200 -P usb -c avrispmkII -D -U flash:w:ATmegaBOOT.hex:i
avrdude: stk500v2_getsync(): error communicating with programmer: (0)

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.11s

avrdude: Device signature = 0x1e9307
avrdude: reading input file "ATmegaBOOT.hex"
avrdude: writing flash (8184 bytes):

Writing | ################################################## | 100% 33.78s

avrdude: 8184 bytes of flash written
avrdude: verifying flash memory against ATmegaBOOT.hex:
avrdude: load data flash data from input file ATmegaBOOT.hex:
avrdude: input file ATmegaBOOT.hex contains 8184 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 263.59s

avrdude: verifying ...
avrdude: 8184 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

doit:/sw/bin root#
Logged

Oakland California
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wasn't able to do the 168. Are the fuse commands exactly the same for it? I followed the same procedure for the 168 that I followed for the 8. Are the fuse burning commands identical? I didn't lock the flash memory, that seemed to not help things with the 8.

doit:/sw/bin root# ./avrdude -p atmega168 -b 115200 -P usb -c avrispmkII -e -U lock:w:0x3f:m -U lfuse:w:0xdf:m -U hfuse:w:0xca:m

avrdude: stk500v2_getsync(): error communicating with programmer: (0)

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9406
avrdude: erasing chip
avrdude: reading input file "0x3f"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3f:
avrdude: load data lock data from input file 0x3f:
avrdude: input file 0x3f contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0xdf"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xdf:
avrdude: load data lfuse data from input file 0xdf:
avrdude: input file 0xdf contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xca"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.04s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xca:
avrdude: load data hfuse data from input file 0xca:
avrdude: input file 0xca contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

doit:/sw/bin root#
doit:/sw/bin root# ./avrdude -p atmega168 -b 115200 -P usb -c avrispmkII -D -U flash:w:ATmegaBOOT_168.hex:i

avrdude: stk500v2_getsync(): error communicating with programmer: (0)

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9406
avrdude: reading input file "ATmegaBOOT_168.hex"
avrdude: writing flash (15916 bytes):

Writing | ################################################## | 100% 51.71s

avrdude: 15916 bytes of flash written
avrdude: verifying flash memory against ATmegaBOOT_168.hex:
avrdude: load data flash data from input file ATmegaBOOT_168.hex:
avrdude: input file ATmegaBOOT_168.hex contains 15916 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 512.72s

avrdude: verifying ...
avrdude: 15916 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Logged

Pages: [1]   Go Up
Print
 
Jump to: