Please help burn a bootloarder for dead Arduino Mega

Hello,

I need to burn the boot-loader on my Arduino Mega. I have sparkfun’s pocket AVR Programmer and I have WINAVR installed. every time I try to program the boot-loader, i get a device initialization error saying that the device signature is invalid… I’m not very experienced and I just want my Arduino Mega up and running again… Thank you

your input on AVR type match what chip you have?

Can you read signature?

I originally tried to burn the bootloader through arduino but whenever i tried it would give an initialization error. So i tried programming it through cmd. When i open avrdude through cmd and follow the instructions stated on the product page for the code (avrdude -c usbtiny -B 1 -patmega328 -U flash:w:main.hex) I noticed that it would just give me an initialization error. I figured since I’m programming a Arduino Mega, I should change the chip to m1280(ATmega1280) so now my code looks like(avrdude -c usbtiny -B 1 -pm1280 -U flash:w:main.hex). After doing that I still get the same error… I have the avr’s drivers installed on my notebook running windows 7 ( i have already disabled driver signing) the usb is connected to the avr programmer and the 6 pin cable is connected to the iscp header on the mega. My mega does power on when i plug the programmer in. I honostly have no clue what else to do. The only reason why i’m trying to reprogram the bootloader is because I believe something happen to it while i was working on a project. It used to work perfectly fine, but now every-time i plug in my mega, the atmega chip heats up like crazy. I cant program the board through arduino.

I use an Atmel USB programmer, not what you have. But step 1 would be to use the command to query device ID and assure that works and returns the expected chip ID.

If it doesn’t work, perhaps the “fuse” settings in the AVR have been screwed up (can only be done with a programmer) for the internal/external oscillator choices, or boot size/enable.

Of course, some hardware fault is always possible.

I’m assuming the programmer you have is not a parallel port kind.

The programmer i have is the one that is on sparkfun’s site…(http://www.sparkfun.com/commerce/produc … ts_id=9231). How would i query the device?

it would be an avrdude command

wow i know this is an old thread but hopefully this will help someone else who’s having similar errors

  1. Device heats up like crazy – CHECK YOUR POWER CONNECTIONS(!!!) AVR’s heat up like MAD when you have GND and VCC reversed. In fact, every time i make a power connection on a new board i put my finger in the chip so i can feel it heating up in the event i have a power line reversed or there’s a short. I’ve never experienced an AVR heating up ‘like crazy’ over anything other than VCC<–>GND reversal. if you disconnect the power line quickly you can save your chip, if it heats too much for too long it’ll be fried for good. Check with avrdude every time you experience the heating to ensure the chip is still OK – just type in $avrdude -c usbtiny -p atmega328p (substitute atmega328p for atmega1280 in this situation, and whatever applicable programmer). If the chip is still good you’ll see the [#######] 100% bar, if it’s fried you’ll get an initialization failure

  2. Good chip, good connections, but still get initialization error: This is what i check when this happens

a-1.) Disconnect SPI devices that might be attached to your chip. I know specifically the 23K256 RAM will prevent you from programming the ATMega328…technically this shouldn’t be in the failure to initialize category, though…avrdude reports the device initializes but will show an unexpected device signature or fuse bit (i forget which)… either way arduino will not burn a bootloader because of the unexpected reading (it’s actually receiving response from the atmega, but reading from the 23k256).

a.) Check that you’re getting 5V at VCC and GND

b.) Check that the RESET line goes directly to the RESET pin. For debugging purposes i make sure the RESET pin is connected ONLY to the ICSP RESET line.

c.) Make sure you have good connection to the 16MHz crystal and two 22pF ceramic capacitors – the ATMega168, 328, and 1280 require the clock to be connected. You may get the [####]100% once in a hundred attempts without a clock, but it goes out of sync quickly. ATtiny’s don’t need a crystal.

d.) Check that MISO, MOSI, and SCK are making good connections and not miss-placed

e.) Try putting a 0.1uF capacitor (non-polar) in parallel with VCC and GND

f.) If all else fails, disconnect EVERYTHING from the chip except VCC, GND, RESET, MISO, MOSI, SCK, and crystal+caps (if atmega). People recommend connecting both all the GND pins and AVCC, which is probably good advice, but i’ve always had success connecting just one VCC and one GND. If you put a volt-ohm meter with short detector setting up to the GND pins you’ll find they’re tied together, same with VCC pins. having all of them hooked up just ensures constant power if one pin jiggles and loses connection for a millisecond. AVCC supplies voltage to power the internal ADC, which you don’t need it for SPI but it probably won’t hurt to connect it.

g.) still doesn’t work? connect another chip because yours is probably fried.

additional note – when you get the initialization failure, check the read device signature. if it’s 00000’s then the chip is not responding to avrdude’s request. if it’s reporting a device signature that’s just wrong then check the chip you typed in the avrdude command to ensure you selected the right one. if you’ve selected the right one, make sure no slaves are present on the SPI bus. if the microcontroller is the only chip connected, make sure there are no current leaks or other sources for interference that would garble the MISO (Master-IN, Slave-OUT) line because the signal being sent from the mcu might be getting interference which would flip bits resulting in distorted bytes coming in to avrdude which would mean wrong values.

I get an initialization error. I’m pretty sure I fried the chip. The bad thing is that the chip isn’t removable. I don’t know what to do. I bought another regular arduino a while after and the same thing happened again. I’m willing to send it anywhere so it can be fixed. At least that way, someone with a little more experience can take a look at the boards… Please someone help!!!

I hope i’m not too late to offer this insight – i had the exact same problem flashing the bootloader using a USBTinyISP.

This is what’s happening – the programmer can’t handle the size of the bootloader for the Arduino Mega.

This is what you can do:

  1. Buy a new programmer – i bought an AVRISP mkii and couldn’t be happier with it. they’re $34 at mouser ( http://www[dot]mouser[dot]com/ProductDetail/Atmel/ATAVRISP2/?qs=2mdvTlUeTfBRoycsKqwYpg%3d%3d or search for 556-ATAVRISP2 )

  2. Upload sketches using your programmer. Open the preferences file for Arduino (preferences.txt) and add or change a line (depending on if it already exists or not). This is what you want:

upload.using=usbtinyisp

but change ‘usbtinyisp’ to the name of your programmer, according to avrdude. to go back to uploading via usb, change it back to this:

upload.using=bootloader

and restart Arduino. it’s a pain because you have to change the preferences.txt file (while Arduino is closed), and if you want to switch methods you have to close Arduino, change the .txt file, and reopen Arduino. Another downside is that it’s considerably slower. An upside though is that the sketches start faster since the chip doesn’t go through the arduino bootloader process of listening on the serial line after resets.

In conclusion, either get a new programmer or start uploading programs to your mega with your ISP programmer. Some people claim the bootloader uploads fine even with the error, but i’ve observed this to be completely untrue (as you are also discovering). I assume they’re doing the flashing process with an actual Arduino Mega board, so when their programmer cuts out the remainder of the existing bootloader still exists, allowing everything to run as it did.

wait, if the programmer can’t handle the size of the bootloader, how can it handle the sketches? Cause my sketches are pretty big.

also, I tried to change the perference file, to tell Arduino to upload via usbtinyisp, but I am getting the same error as when I tried to load the bootloader

avrdude: initialization failed, rc=-1

Double check connections and try again, or use -F to override

this check.

A cheap/unreliable in-system programmer (ISP) is like having a bent/dull screwdriver. It’s well worth the $35 or so for a reliable one.

as

Buy a new programmer – i bought an AVRISP mkii and couldn’t be happier with it. they’re $34 at mouser ( http://www[dot]mouser[dot]com/ProductDetail/Atmel/ATAVRISP2/?qs=2mdvTlUeTfBRoycsKqwYpg%3d%3d or search for 556-ATAVRISP2 )