Go Down

Topic: Broken Arduino Mega magically repears after uploading bootloader. (Read 1 time) previous topic - next topic

pico


I don't know much about fuse bits and surely not about getting and setting them. As I wouldn't know how to set these fuse bits I'm tempted to think it must have been the bootloader who sets them (wrongly). But when I go through the code I only find boot_lock_fuse_bits_get there seems to be no set function  :smiley-eek:


When you select "Burn Bootloader" from the rools menu, it actually performs two separate things: It 1) uploads a bootloader program (unless it is an attiny target), and 2) it sets the fuses to work with the bootloader.

These are two different avrdude commands. You have copied the "set fuses" avrdude command above.

It is possible that your programmer did not set the fuses corectly for whatever reason, but the new bootloader was OK. Or it is also possible that your programmer failed to load a new bootloader (so you still have the orginal one running), and it also screwed up the fuses.

Not all programmers can handle some of the trickiness of programming the 2560 chips, apparently. the problem is the extended memory space (16 bits defines a 64K memory space, so anything with more than 64K flash memory has to be "paged" in some fashion, and this scheme is where some programmers fall down, from various reports I've read on this forum.)

So there are two plausible scenarios. I'd start by researching the compatibility of your programmer with the 2560 chips.


WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

westfw

Quote
That avrdude command does NOT upload any bootloader, it merely resets fuses. So, if that repaired it, your problem was not a corrupted bootloader, it was corrupted fuse values.

It's more mysterious than that.  The avrdude command include "-e", which means "perform chip erase."
Since you sketch was "still running" after this, it's obvious that the chip was not in fact erased!

You said the programmer was an "AVR ISP"?  A real one with a serial port?  Was COM11 the serial port of the AVR ISP, or the serial port of the Arduino?  It looks (given that -e didn't do anything, and that you had to use "stk500v2" as the programmer type; avrisp is supposed to be an stk500v1 programmer) like you ended up talking to the MEGA bootloader instead of the AVRISP.  It (like most/all bootloaders) ignores fuse settings and chip-erase, and reports success.  However, this explains even less WHY what you did fixed your problem!

(Also, I'm not sure why it's uploadable at all, given that you have the serial port connect to both the usb boot port AND your external serial device on D0/D1.  If your device was "spewing data", that would surely interfere with bootloading.  It's somewhat designed for paralleling two devices, but the external device has to be not driving the MEGA's RXD line during boot (ie "turned off."))

Jantje

all
I have this AVR ISP https://www.olimex.com/Products/AVR/Programmers/AVR-ISP500/
COM11 is from the AVR ISP. The mega was not plugged in when I ran the command.


(Also, I'm not sure why it's uploadable at all, given that you have the serial port connect to both the usb boot port AND your external serial device on D0/D1.  If your device was "spewing data", that would surely interfere with bootloading.  It's somewhat designed for paralleling two devices, but the external device has to be not driving the MEGA's RXD line during boot (ie "turned off."))

At the time of running the command the mega was no longer connected to the Modem. I was informed that it is dangerous to have the USB connected and the serial port connected at the same time. One reason is that the router is 3.3 volt and the USB is 5Volt. As Mega's are expensive I never did so.
To repeat the story: When I had the problem
Swappped the mega by a UNO => all worked well.
Swapped the Uno for the mega => no more info
Conclusion Mega is the problem => disconnect Mega from rooter and try to find out what is wrong.
Plug mega in USB => port found but no messages on the serial monitor.
Try to upload sketch -> failed
Try to bootload with Arduino ISP failed
Try to bootload using AVR ISP=>failed
Tried the command with stk500v2 instead of stk500v1 => get the advice to use -F
Tried with -F => all works fine again.
(In this process I remember the -e I got advised and added that to)


It looks (given that -e didn't do anything, and that you had to use "stk500v2" as the programmer type; avrisp is supposed to be an stk500v1 programmer) like you ended up talking to the MEGA bootloader instead of the AVRISP.  It (like most/all bootloaders) ignores fuse settings and chip-erase, and reports success.  However, this explains even less WHY what you did fixed your problem!

My AVR ISP document states
Quote
Fully STK500v2 compatible;

I understand this as STK500v2 should be the protocol for my AVR ISP. But he; I really don't know what I'm talking about here  8).



So there are two plausible scenarios. I'd start by researching the compatibility of your programmer with the 2560 chips.

The documentation of my AVR ISP states the following on compatibility
Quote
SUPPORTED MICROCONTROLLERS:
The following AVR microcontrollers are supported for programming:
- Classic 8-bit AVRs
- megaAVR
- tinyAVR
- USB AVR

Someone uploaded a sketch to my Mega with a broken USB port with this AVR ISP so I guess it is compatible but I can't confirm with the above data.
I'm sure I have the new bootloader (uploaded with Arduino ISP) because I tested for the WDT to work. With the original bootloader it didn't work. The red led started blinking rapidly like Lefty described.
Note that I have upgraded the AVR ISP recently so it is running the latest and greatest sotware.

In the mean time I have connected the mega back to the router and it has been working ok for a longer period. I still don't feel comfortable though.

Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Jantje

Och yes  :D
I'm so happy I'm not the only one puzzled here  :D
Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Jantje

I never found the root cause but it hasn't happened again till today.
Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Go Up