Uno R3 won't even run Blink after re-burning bootloader

I've been trying to upload sketches to my Uno R3 using an stk500v2 compatible ISP (the Olimex AVR-ISP500-TINY).

I can burn the bootloader onto the 328p no problem using the following command, where /dev/ttyACM0 is the ISP device;

avrdude -c stk500v2 -P /dev/ttyACM0 -p m328p -v -e -U flash:w:ATmegaBOOT_168_atmega328.hex -U lock:w:0x0F:m

From reading through the avrdude documentation, many tutorials on the web & the avrdude commands that the Arduino IDE attempts when setup to upload sketches using the ISP, I think the following command should work to upload a sketch;

avrdude -c stk500v2 -P /dev/ttyACM0 -p m328p -v -U flash:w:Blink.cpp.hex

This seems to upload successfully, but the Uno doesn't then start blinking. Instead, the L LED lights up & remains lit. I have tried changing the pin used for the LED from 13 (the onboard LED) to 8 (an LED on a breadboard).

Sample output of the first command here and of the second command here.

Update - Another discovery, not sure how diagnostic it is. If I burn the regular 328 bootloader, the IDE cannot even upload a sketch over USB. If I burn the 328 pro 8MHz bootloader however, the IDE successfully uploads the sketch but it doesn't then run.

Sounds like your chip is not set up to use a 16 MHz crystal. Do you have a 16 MHz crystal attached to it?

Try adding your programming to the IDE by creating a 'programmers.txt' file in the 'hardware' folder of your sketch folder.

It's a standard Uno R3, so there is a SPK16.000G oscillator on the board. It should work 'out of the box' with the IDE, which it did before I started playing about with the ISP - I just want to return it to such a state so I can actually get sketches working on the thing!

Update - I'm beginning to think I'm running into the 'blinking LED' issue described http://forum.sparkfun.com/viewtopic.php?f=32&t=25611 & Arduino Forum & in the comments Installing an Arduino Bootloader - SparkFun Learn

Can somebody confirm the 'correct' behaviour of the L LED when everything is working correctly?

If I burn the ATmegaBOOT_168_atmega328.hex bootloader & cycle the power, L blinks once per second. I can't upload sketches via the IDE & USB with this bootloader burnt.

If I burn the ATmegaBOOT_168_atmega328_pro_8MHz.hex bootloader & cycle the power, L blinks once per half second (presumably because it's an 8MHz bootloader & the Uno R3 has a 16MHz oscillator). I can't upload sketches via the IDE & USB with this bootloader burnt.

If I burn the optiboot_atmega328.hex bootloader & cycle the power, L blinks quickly 3 times & then turns on & remains on. I can upload sketches via the IDE & USB with this bootloader burnt, but they don't run correctly when I cycle the power. If I upload Blink (using digital pin 8 for an LED on a breadboard), when I cycle the power L blinks 3 times & then turns on permanently, at which point the LED on pin 8 turns on permanently - it doesn't blink.

If I upload Blink using the ISP & then cycle the power, L lights up permanently & the LED on pin 8 lights up permanently. I don't know whether this replaces the bootloader or not, however the reset is much faster so it may do.

One final point, I have set the fuses as follows, can anybody tell me whether these are the correct values?

avrdude -c stk500v2 -P /dev/ttyACM1 -p m328p -vvvv -U efuse:w:0x05:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m

To get the Arduino UNO R3 back to normal:

Add your programmer to a programmers.txt file as I suggested before.

Hook your programmer to the Arduino UNO.

Select "Arduino UNO" from Tools->Boards

Select your programmer from Tools->Programmers

Select Tools->Burn Bootloader.

'Burn Bootloader' in the IDE simply calls avrdude with the settings defined in boards.txt for the particular board being used. I have already called avrdude with the settings defined in boards.txt for my Uno many times, doing it via the IDE isn't going to change anything.

But I'm getting nowhere so I'll humour the idea.

Firstly, here are the settings for the Uno from boards.txt;

uno.name=Arduino Uno
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
uno.upload.speed=115200
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
uno.build.variant=standard

My avrdude syntax;

avrdude -c stk500v2 -p m328p -b 115200 -P /dev/ttyACM0 -vvvv -e -U efuse:w:0x05:m -U hfuse:w:0xDE:m -U lfuse:w:0xFF:m -U lock:w:0x3F:m

avrdude -c stk500v2 -p m328p -b 115200 -P /dev/ttyACM0 -vvvv -U flash:w:/array_flatline/PhD/Arduino/arduino-1.0/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.hex -U lock:w:0x0F:m

IDE's avrdude syntax;

/home/cj/arduino-1.0/hardware/tools/avrdude -C/home/cj/arduino-1.0/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -cstk500v2 -P/dev/ttyACM0 -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xde:m -Ulfuse:w:0xff:m

/home/cj/arduino-1.0/hardware/tools/avrdude -C/home/cj/arduino-1.0/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -cstk500v2 -P/dev/ttyACM0 -Uflash:w:/home/cj/arduino-1.0/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.hex:i -Ulock:w:0x0F:m

As you can see, they are the same. The -C flag in the IDE's commands is ignored because the conf file it references doesn't exist so it just uses the default.

I did actually burn the bootloader from the IDE & as I expected it made no difference - Blink still does not run.

Things just got stranger.

This doesn't work (the LED connected to pin 8 turns on & remains on);

void setup() {
    pinMode(8, OUTPUT);
}

void loop() {
    digitalWrite(8, HIGH);
    delay(1000);
    digitalWrite(8, LOW);
    delay(1000);
}

But this does work (the LED connected to pin 8 blinks). The only difference is that I've added Serial.begin() to the setup().

void setup() {
    pinMode(8, OUTPUT);
    Serial.begin(9600);
}

void loop() {
    digitalWrite(8, HIGH);
    delay(1000);
    digitalWrite(8, LOW);
    delay(1000);
}

WTF?!

Another update for anybody reading along or coming via Google. This morning I received a 'clone' Arduino R3 from Hong Kong (an 'EKitsZone Uno'). I didn't touch the programmer or do anything to the bootloader & it presents the same behaviour - Blink without the Serial.begin doesn't work, with Serial.begin does work, so it is very unlikely that there is anything wrong with my official R3.