burn sketch only once - 2nd time doesnt work

hi,
a few days ago i got a bunch of new atmega168 controller with a bootloader on it.
after inserting one of this chips into my NG board, i can load a sketch (blink LED example)
as normal into the chip and the program works correctly. when i try to re-load a sketch
(it doesn't matter if i made any changes in the sketch or not) it will not work for the second
time. i can not re-programm the chip. this happens now on the third chip and i assume that this case will happen to all
of the newly bought controllers. i tried all different timeintervals between "loading to board" and
pushing the reset button. the TX and RX LED's flash shortly once and then, when the LED's normaly
do toggle, only the RX is flashing once and then i get the error "programmer is not responding".

i use the arduino NG on Mac os X (10.3.9) with arduino 0008 (tried also 07) and an atmega168
inserted.

i appreciate any suggestions.
r.

where did you get the atmega168s? Maybe the bootloader fuse is not set?

i ordered them from Adafruit.com which is supposed to be an "official"
distributer for arduino-chips.....

adafruit is selling "official boards". i don't know if there is something like official arduino chips. they're just atmegas with the bootloader "burned" onto. anyway, the fuse settings was a good guess i think: after the bootloader is written to the chips memory, you normally set a fuse to make this part of the memory read-only.

how do your boards/chips with the program behave upon startup? if you connect a led to pin 13 and ground, does it still blink 3 times? if it's the standard NG bootloader it should say "hello" like that (try it with one "unprogrammed" atmega as well) and wait for about 10 seconds before executing the real program.

if it doesn't, and starts your program right away, you may have overwritten the bootloader. as far as i know these chips should be re-burnable in that case, but adafruit will surely recognize their fault.

good luck,
kuk

Just to clarify kuk's comments:

to protect areas of memory, like the bootloader, you use LOCK-BITS.

Fuse bits are like cofiguration bits that indicates how the Atmega168 will behave. I think one of the fuse bits is used to indicate if the bootloader is executed after power up or not... so first time it gets executed because it is the only code in there, but after you program a sketch, as there is other code in the chip, it always executes the sketch and not the bootloader.

As kuk said, the led in port 13 is a good diagnostic tool that indicates if the bootloader is being executed after power up.

@ nkcelectronics:
yep, you're right with the lock-bits. actually im just finding this out myself right now. got myself an avrisp-mkII today. 3 hrs and still no bootloader burned. either avrdude on os x can't find the input file or windows (via paralells desktop) crashes upon flash writing :frowning:

anyway. it's hard to pinpoint a problem in this multilayerd computer setup.

i just managed to get the same behaviour with the first two atmega168s that i burned by accident. after uploading a program the bootloader wouldn't execute anymore. it turned out to be a fuse setting ("Boot Reset Vector Enabled") that i left untouched... the bootloader wasn't overwritten but merely not started as nkcelectronics just explained. i knew this thread would be helpful for me in some way . thank you

i have now successfully burned my first two bootloaders onto fresh atmegas .

maybe you can ask adafruit for a discount on a programmer rather than sending back the "faulty" chips to get them set right. circumventing the bootloader is a nice feature. if you have control over it i mean.

kuk, thanks for all those news. i will follow your suggestion and i am wishing you
lots of fun with the right fuse-settings.
best, r.

rroo: I'd also post about this on adafruit's forums. It sounds like the chips they're selling have the correct bootloader, but the wrong fuses. Only the chips that come on the Arduino boards are burned by us, the replacements are done by adafruit and could have different settings. They might need to change them.

i ordered them from Adafruit.com which is supposed to be an "official"
distributer for arduino-chips.....

mm, i sell arduinos but there is no such thing as an official distributor for "arduino chips"
i sell arduino bootloader-compatible chips
http://www.adafruit.com/index.php?main_page=product_info&cPath=19&products_id=56

regardless, ive been using these chips no problem for a while but there's certainly a chance you got bad ones. if you send mail to support@adafruit.com i can arrange to have them replaced.

limor