Pages: 1 [2]   Go Down
Author Topic: Arduino Mega 1280 - unable to program ( bootloader )  (Read 3214 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To use the above, if you are using my bootloader uploader sketch ( http://www.gammon.com.au/forum/?id=11635 ) you need to change the file "bootloader_atmega1280.h" to read:

Code:
// File =  optiboot_atmega1280.hex
// Loader start: 1FC00, length: 1024
// MD5 sum = AC F8 70 89 5B 0B BE 36 34 12 BC 66 E7 89 63 7D

byte PROGMEM optiboot_atmega1280_hex [] = {
0x11, 0x24, 0x84, 0xB7, 0x14, 0xBE, 0x81, 0xFF, 0xF2, 0xD0, 0x85, 0xE0, 0x80, 0x93, 0x81, 0x00,
0x82, 0xE0, 0x80, 0x93, 0xC0, 0x00, 0x88, 0xE1, 0x80, 0x93, 0xC1, 0x00, 0x86, 0xE0, 0x80, 0x93,
0xC2, 0x00, 0x80, 0xE1, 0x80, 0x93, 0xC4, 0x00, 0x8E, 0xE0, 0xCB, 0xD0, 0x27, 0x9A, 0x86, 0xE0,
0x20, 0xE3, 0x3C, 0xEF, 0x91, 0xE0, 0x30, 0x93, 0x85, 0x00, 0x20, 0x93, 0x84, 0x00, 0x96, 0xBB,
0xB0, 0x9B, 0xFE, 0xCF, 0x1F, 0x9A, 0xA8, 0x95, 0x81, 0x50, 0xA9, 0xF7, 0xCC, 0x24, 0xDD, 0x24,
0x99, 0x24, 0x93, 0x94, 0xA5, 0xE0, 0xBA, 0x2E, 0xF1, 0xE1, 0xAF, 0x2E, 0xA6, 0xD0, 0x81, 0x34,
0x61, 0xF4, 0xA3, 0xD0, 0x08, 0x2F, 0xB3, 0xD0, 0x02, 0x38, 0x11, 0xF0, 0x01, 0x38, 0x11, 0xF4,
0x84, 0xE0, 0x01, 0xC0, 0x83, 0xE0, 0x91, 0xD0, 0x8D, 0xC0, 0x82, 0x34, 0x11, 0xF4, 0x84, 0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0xE0,
0xE8, 0xDF, 0xEE, 0x27, 0xFF, 0x27, 0x09, 0x94,
}; // end of optiboot_atmega1280_hex

Also in the main sketch change these lines:

Code:
  // Atmega2560 family
  { { 0x1E, 0x96, 0x08 }, "ATmega640",    64 * kb,   1 * kb },
  { { 0x1E, 0x97, 0x03 }, "ATmega1280",  128 * kb,   1 * kb,
        ATmegaBOOT_168_atmega1280_hex,
        0x1F000,      // start address
        sizeof ATmegaBOOT_168_atmega1280_hex,   
        256,          // page size (for committing)
        0xFF,         // fuse low byte: external clock, max start-up time
        0xDA,         // fuse high byte: SPI enable, boot into bootloader, 4096 byte bootloader
        0xF5,         // fuse extended byte: brown-out detection at 2.7V
        0x2F },       // lock bits: SPM is not allowed to write to the Boot Loader section.

to read:

Code:
  // Atmega2560 family
  { { 0x1E, 0x96, 0x08 }, "ATmega640",    64 * kb,   1 * kb },
  { { 0x1E, 0x97, 0x03 }, "ATmega1280",  128 * kb,   1 * kb,
        optiboot_atmega1280_hex,
        0x1FC00,      // start address
        sizeof optiboot_atmega1280_hex,   
        256,          // page size (for committing)
        0xFF,         // fuse low byte: external clock, max start-up time
        0xDE,         // fuse high byte: SPI enable, boot into bootloader, 1280 byte bootloader
        0xF5,         // fuse extended byte: brown-out detection at 2.7V
        0x2F },       // lock bits: SPM is not allowed to write to the Boot Loader section.

The changes above allow for the different bootloader name, start address, size, and fuses.

If possible, can you confirm that works OK? Then I can commit the changes.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 93
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nick, thank you for the answer, retrolefty is right with the WTD-problem.
The changing of the bootloader worked immediately, here is the result of a second run:
Code:

Atmega chip programmer.
Written by Nick Gammon.
Entered programming mode OK.
Signature = 0x1E 0x97 0x03
Processor = ATmega1280
Flash memory size = 131072 bytes.
LFuse = 0xFF
HFuse = 0xDE
EFuse = 0xF5
Lock byte = 0xEF
Clock calibration = 0x97
Bootloader address = 0x1FC00
Bootloader length = 504 bytes.
Type 'V' to verify, or 'G' to program the chip with the bootloader ...
Verifying ...
No errors found.
Done.
Type 'C' when ready to continue with another chip ...

But the uploading of (compiled) sketches doesn't work on the mega1280 now. I got the following result:
avrdude: stk500_getsync(): not in sync: resp=0x00

I didn't check yet Retrolefty's solution.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 93
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Retrolefty, thank you for your solution.
It worked and my sketches land now on the board!

P.S. I try now to change the bootloader at the Duemilanove to optiboot.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 93
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Now, it's a Uno :-)
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Retrolefty, thank you for your solution.
It worked and my sketches land now on the board!

Are you saying my bootloader didn't work? What was the difference between what Lefty said and my sketch? They both should have put the same bootloader onto the board.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You would also need to make the changes to boards.txt he suggested, but the change to the bootloader-uploader should have worked.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 93
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, the result of the uploading and verifing of the bootloader with your programmer and the sketch-uploading-problem resp. the updating of the boards.txt suggests, that your programmer works.
I wasn't aware of this interaction with the txt-file (and much more things).
I'm glad that my 1280 works now and has a working WTD.

Thank you and Retrolefty for your help!
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, in that case I committed that change to GitHub, so that is now the new loader for the Atmega1280 in my sketch.
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 332
Posts: 16568
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, in that case I committed that change to GitHub, so that is now the new loader for the Atmega1280 in my sketch.

That would be an improvement as the 'official' IDE distrubution seems to not care about adding/updating the 1280 bootloader hex file like they did for the 2560 board.

 One big caution however is that unless you embed some comments that prints to the serial monitor on your program when it burns the new mega1280 bootloader, the user must read/remember that he must also modify his copy of the boards.txt file in his arduino core directory?

Lefty
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good suggestion. I've added a note to the end of this post:

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

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 332
Posts: 16568
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good suggestion. I've added a note to the end of this post:

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

Nice!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

I can confirm that it works.
Today I uploaded a new bootloader to the old Mega with using Usbasp programmer and now the watchdog works fine  smiley-lol

------------------------------------------------------------
Edit: 30.12.2013 20:19

But I have question, it is possible to change the upload speed to the old value 57600, Now I have to used this:

Code:
mega.upload.speed=115200

I'm guessing that this speed is stored in the new bootloader, there is any easy way to change it ?
« Last Edit: December 30, 2013, 02:12:07 pm by rat- » Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 332
Posts: 16568
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

I can confirm that it works.
Today I uploaded a new bootloader to the old Mega with using Usbasp programmer and now the watchdog works fine  smiley-lol

------------------------------------------------------------
Edit: 30.12.2013 20:19

But I have question, it is possible to change the upload speed to the old value 57600, Now I have to used this:

Code:
mega.upload.speed=115200

I'm guessing that this speed is stored in the new bootloader, there is any easy way to change it ?

No easy way. The bootloader program is compiled with a fixed baud rate and to change optiboot to 57600 would require the bootloader source code to be edited and recompiled, which is not something you can do in the Arduino IDE environment.

Lefty
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


No easy way. The bootloader program is compiled with a fixed baud rate and to change optiboot to 57600 would require the bootloader source code to be edited and recompiled, which is not something you can do in the Arduino IDE environment.

Lefty

Yes, You have right smiley
 I used the uncle google.com and compile my own bootloader with baud rate 9600 (other shetch and watchdog works fine )

According with atmega1280 datasheet (and some "AVR ATmega Baudraten" http://www.gjlay.de/helferlein/avr-uart-rechner.html )


The baud rate 9600, introduces maximum errors during communication at the level of 0.2 %,  just us 76800 (what is better then 57600).

The test compilation with baud rate 115200, gives me warning:
Code:
#warning BAUD_RATE error greater than -2%

I am not user jet, what exactly  mean the different between  -3%  and 3%.

Tip:
Link to the optiboot bootlader https://code.google.com/p/optiboot/downloads/list .
« Last Edit: December 30, 2013, 06:39:51 pm by rat- » Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 332
Posts: 16568
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I am not user jet, what exactly  mean the different between  -3%  and 3%.

Asynchronous serial communications means the receiving end must create and use self timed mid-bit sampling for each of the incoming bits of a character. Any timing error of the speed actual being sent and what speed the receiver is expecting can cause the receiver to misread a bit within a character. Such sampling errors accumulate with each bit until the stop bit and next start bit restarts the sampling counter. So the closer the sender and receiver are in actual timing accuracy the better, however even a +/-2% error does not mean that there will be garbled characters.
Logged

Pages: 1 [2]   Go Up
Jump to: