Can't reload Duemilanove (atmega328) bootloader

I accidentally overwrote the bootloader in AVR studio, so I tried to reload it (using the bootloader file hardware/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex). However, in Arduino IDE, I get the error:

Binary sketch size: 976 bytes (of a 30720 byte maximum)

avrdude: stk500_getsync(): not in sync: resp=0x00 avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

The 328 still works fine--I am able to manually download the hex files from my previous projects using avr studio and a jtag2, but I'd much rather have the bootloader work again. However, the documentation that's scattered across the site is vague and/or outdated.

What do i do?

Alternatively, does anyone know if it's possible to add jtagice_mkii to the hardware options for burning a bootloader from the IDE? If the IDE just uses avrdude to burn the bootloader, surely this might work too. I think the problem might lie in the fuse settings, but I don't like playing with those too often (also, i'm pretty sure the 328 has different fuse settings due to the increased memory).

I wish my avrisp worked, but the IDE gives me some error about device usb not being found (which may potentially be an issue with my isp, which could be dead).

Until my bootloader can be fixed, my current build/program process consists of writing the code in the IDE, trying to program the device (but failing) since that causes the .hex file to be created, and then connecting up a jtag2 and programming it from avr studio. Frankly, it kind of sucks. Can anyone think of a better temporary measure for loading code that might work easier?

If you can use avrstudio to flash normal program code, why not flash the bootloader ?

There are hex-files distributed with the arduino software, the fuse settings can be extracted from the Makefile sitting in the same folder.

I tried burning the bootloader ("ATmegaBOOT_168_atmega328.hex"), and it verified once burned. However, the fuse settings are what trouble me---

The low fuse and high fuse match the values in the makefile. However, the extended fuse has the value 0xFD, while the makefile has the setting 0x05. The problem is that the only fuse that seems change the extended fuse is the Brown-out detection level fuse, and 0x05 is not an allowed option. Can't even set it to 0x05 manually.

Hm. According to the data sheet a value of 0x05 for the 328's EFUSE is a valid setting (2.7V BOD).

OK! I have fixed it! Here's what I did:

I uninstalled the Jungo drivers for my avrispmkii, and manually installed the ones that come with winavr/avrdude/whatever. After doing that, I no longer got an error saying that it was unable to find a usb device, and i was able to burn the bootloader.

Afterwords, I went into avr studio and, using the jtagice mkii, checked thef use settings. I'm getting extended: 0xFD high: 0xDA low:0xFF lockbit 0xFF

it is important to note that this is NOT the extended fuse setting in the bootloader makefile.

if any of the devs read this, i think figuring out this fuse setting discrepancy might be useful for others in the future.


^^^^ perhaps it's an error or inconsistency (i had heard one of the fuse settings chagned from the 168 to 328) within avr studio or something else, then, because avrdude gives 0xFD as the extended fuse setting for 2.7V brownout

I think this is the "non valid bits" problem again.

According to the data sheet only the lower 3 bits of the 328's EFUSE are valid. Bits 3-7 are reserved. If you take the avrstudio's 0xFD ( = B11111101 ) and ignore bits 3-7 you get B00000101 which is 0x05 in hex. I think avrdude does exactly that. So "0xFD = 0x05", problem is who knows which bits are valid ;-)

madworm: right. avrdude treats unused bits as 0, avr studio treats them as 1.


Can anyone tell how can I bootload a blank Atmega328 micro controller on Aurdino board ?


I believe you can also use an Arduino as an ISP.