Go Down

Topic: Arduino Mega 1280 - unable to program ( bootloader ) (Read 5103 times) previous topic - next topic

Hi all, I've recently started using the arduinos by ordering a UNO and a MEGA.
So far the experience has been very good, much better to prototype than using PICs + programmer :)

However, I've run into a problem on my MEGA board. I am not able to upload any programs to it and the indicator led (L) blinks at a rate of ~10Hz unless I keep the reset button depressed. I've tried the loopback test so I know the pc / arduino communications are (still) working.

My initial hunch was that the bootloader was somehow broken, so I tried to upload a new one using ArduinoISP.
However, avrdude reported:
avrdude: Device signature = 0x000000

So I copied the commandline and added -F, now the process continued, but there where errors. I tried several times, but they usualy gave errors regarding the fuse-state. And even when it did manage to finish, the MEGA would instantly go back to the ~10Hz blinking and not being able to accept new programming.

Have I somehow fried my MEGA? What other steps can I take to try and restore it?

thanks in advance!

- Arjan

CrossRoads

Get an bootloader device such as
http://www.mdfly.com/index.php?main_page=product_info&cPath=5_6&products_id=415
and reload the bootloader that way.

In programmers.txt, need to make a 2-line addition for it to show up on the menu.
I posted that yesterday and someone else posted the same programmer for $4.95 elsewhere.
Will be a handy tool for you.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

well, for 4,95 I guess I could give it a go.. but will this really be different from programming the bootloader through ArduinoISP ?

CrossRoads

Should be the same, but this definitely works, while you have shown the other not to work.

http://www.hobbyking.com/hobbyking/store/__21321__USBasp_AVR_Programming_Device_for_ATMEL_proccessors.html
Don't know it will need software update before using.

programmers.txt change:
usbasp.name=MDFLY   <<< will show up as MDFLY under TOOLS:PROGRAMMER in the IDE
usbasp.protocol=usbasp
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

It's been a while, but I have received my programmer.
This is what I get when I try to burn a bootloader without the mega 1280 attached

         Using Port                    : usb
         Using Programmer              : usbasp
avrdude: seen device from vendor ->www.fischl.de<-
avrdude: seen product ->USBasp<-
         AVR Part                      : ATMEGA1280
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65    10   256    0 yes    131072  256    512  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.



When I connect the programmer to my mega and try again, I get this message:

avrdude: Version 5.11, compiled on Sep  2 2011 at 18:52:52
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/arjan/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : usbasp
avrdude: error: could not find USB device "USBasp" with vid=0x16c0 pid=0x5dc

avrdude done.  Thank you.


When the mega is connected, it's light starts blinking at ~10Hz as it did before.

Any ideas?

CrossRoads

Go to this thread and ask Nick about supporting 1280 chips:
http://arduino.cc/forum/index.php/topic,105061.15.html
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Nick Gammon

My recent sketches all support that chip.

The ATmega640, ATmega1280, ATmega1281, ATmega2560 and ATmega2561. Amongst others.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

As it turns out, the programmer failed because the mega started when the icsp cable was attached. This power drain made the programmer stop working. Now that I have the programmer working by supplying power to the mega as well, things look a little different..


avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9703
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega1280.hex"
avrdude: writing flash (130838 bytes):

Writing | ################################################## | 100% 72.25s

avrdude: 130838 bytes of flash written
avrdude: verifying flash memory against /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega1280.hex:
avrdude: load data flash data from input file /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega1280.hex:
avrdude: input file /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega1280.hex contains 130838 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 69.07s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0xf000
         0xff != 0x0c
avrdude: verification error; content mismatch

avrdude done.  Thank you.


So not quite there yet.. Any ideas?
Should I try uploading a different bootloader, or would this make no difference?

Nick Gammon

Some programmers don't handle more than 64 Kb of flash correctly.

I did a more robust one as described here:

http://www.gammon.com.au/forum/?id=11635

I have just amended it to include the bootloader for the Atmega1280 from the 1.0 release of the IDE.

Just program that sketch onto a spare Uno or similar, connect up 6 wires as described on that page (I assume the board is similar to the Mega2560) and then run the sketch, answering the question in the terminal monitor.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

That's ironic, buying a programmer which is then superseded by the arduino ISP programming method..

Maybe a bit offtopic, but why on earth are these bootloaders so large?
optiboot for the UNO is much smaller and seems to get the job done just fine.

I'll try to reprogram it using ardiunoISP later and let you know what the results are :)

Nick Gammon

Quote
why on earth are these bootloaders so large?


For a start, they come in fixed sizes. Each one double the previous. So if it doesn't quite fit into 512 bytes, it has to be 1024. And if it takes 1025 then it needs 2048, and so on.

Second, some appear to offer extra features, like debugging (finding what is in memory, EEPROM etc.) not that I have ever used that.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

As suggested by Nick, programming using his method worked perfectly!

I'm back to having a working mega :)

thanks all, with special thanks going out to Nick for making the bootloading sketch!

michael--g


http://www.gammon.com.au/forum/?id=11635


Thank you for the description and your sketch, which I also use. For the "upload" I use a Duemilanove with your programmer-sketch v1.18. The signature is "0x1E 0x97 0x03". The IDE is 1.0.5.
I try now to upload the 2560 and optiboot-bootloader onto a Mega 1280. It's because of the watchdog problem, that I have with the old bootloader. It's a bit unconventional, but I simply renamed the 2560-bootloader to "ATmegaBOOT_168_atmega1280.hex" and pushed it to the Mega. Well, it worked - but the bootloader semms not to work - uploading of a sketch is not possible. I get the following error:
avrdude: stk500_getsync(): not in sync: resp=0x00

Nick, do you please have a hint how to program it right?




Nick Gammon

You can't just rename the bootloader. Each chip would have different addresses (eg. where in flash the bootloader has to go).

There is already a 1280 bootloader in my uploader program. What is wrong with that one?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

retrolefty

#14
Sep 07, 2013, 02:09 am Last Edit: Sep 07, 2013, 02:52 am by retrolefty Reason: 1
There is a modified optiboot loader hex file available that runs on the mega1280 chip. That fixes both the WDT problem and the bootloader monitor !!! problem that the original mega bootloader has. I think WestFW that did the recompile, but if you can't find a link I will post it here:

optiboot_atmega1280.hex
Code: [Select]

:020000000404F6
:020000021000EC
:10FC0000112484B714BE81FFF2D085E08093810077
:10FC100082E08093C00088E18093C10086E08093F9
:10FC2000C20080E18093C4008EE0CBD0279A86E0AA
:10FC300020E33CEF91E0309385002093840096BB55
:10FC4000B09BFECF1F9AA8958150A9F7CC24DD2444
:10FC500099249394A5E0BA2EF1E1AF2EA6D0813479
:10FC600061F4A3D0082FB3D0023811F0013811F499
:10FC700084E001C083E091D08DC0823411F484E12E
:10FC800003C0853419F485E0AAD084C08535A1F479
:10FC90008CD0082F10E089D0E82EFF24FE2CEE2413
:10FCA000E02AF12A8F2D881F8827881F8BBFEE0C32
:10FCB000FF1C8DD067016EC0863521F484E08FD0A3
:10FCC00080E0D9CF843609F042C06FD06ED0082FC3
:10FCD0006CD080E0C81680EED80620F483E0F601F0
:10FCE00087BFE895C0E0D2E060D089930C17E1F7B8
:10FCF000F0E0CF16F0EEDF0620F083E0F60187BFDC
:10FD0000E89565D007B600FCFDCFA601A0E0B2E003
:10FD10002C9130E011968C91119790E0982F8827C4
:10FD2000822B932B1296FA010C0197BEE8951124B1
:10FD30004E5F5F4FF3E0A030BF0751F7F601B7BE4B
:10FD4000E89507B600FCFDCFA7BEE89523C0843731
:10FD5000A1F42BD02AD0E82E28D039D0E6010E2DE0
:10FD6000FE0186911AD021960150D1F70894C11C4A
:10FD7000D11CEA94CE0CD11C0DC0853731F427D0AC
:10FD80008EE10BD087E909D075CF813511F488E079
:10FD900018D01DD080E101D061CF982F8091C00094
:10FDA00085FFFCCF9093C60008958091C00087FF27
:10FDB000FCCF8091C00084FD01C0A8958091C60051
:10FDC0000895E0E6F0E098E1908380830895EDDF08
:10FDD000803219F088E0F5DFFFCF84E1DECF1F939A
:10FDE000182FE3DF1150E9F7F2DF1F91089580E04B
:08FDF000E8DFEE27FF2709946C
:040000031000FC00ED
:00000001FF


You will also have to modify the mega1280 section of the boards.txt file in your arduino core:

Quote

##############################################################

megao.name=Arduino Mega1280 Optiboot
megao.upload.protocol=arduino
megao.upload.maximum_size=130048
megao.upload.speed=115200
megao.bootloader.low_fuses=0xff
megao.bootloader.high_fuses=0xdc
megao.bootloader.extended_fuses=0xf5
megao.bootloader.path=optiboot
megao.bootloader.file=optiboot_atmega1280.hex
megao.bootloader.unlock_bits=0x3F
megao.bootloader.lock_bits=0x0F
megao.build.mcu=atmega1280
megao.build.f_cpu=16000000L
megao.build.core=arduino
megao.build.variant=mega


Works great.

Lefty

EDIT: found this link:
https://code.google.com/p/optiboot/source/browse/optiboot/bootloaders/?r=8559b64fd093d3976cae58778a1540256cde5c8e#bootloaders%2Foptiboot

Go Up