Go Down

Topic: Optiboot Atmega2560 Issue (Read 3185 times) previous topic - next topic

chinnaobi

Hi All,

I have been trying to use this Optiboot(https://github.com/majekw/optiboot/tree/m2560/optiboot) for Atmega 2560. I know this bootloader is for writing the flash from application, but my use with this is to upload the sketches with Stk500 V1protocol.

I have burned the bootloader to Mega2560 using Atmel Ice, boot loader burned successfully. Also I have changed the fuse bit

BOOTSZ from 4096W_1F000 to 1024_1FC00.
BOOTRST is still set to 1

Observation 1:

Arduino Ide with the board type selected as Optiboot On Mega2560, which uses STK500 V1 on COM port , was able to upload sketch. But there is a verification error and the Sketch really doesn't load after finish writing(avrdude is using this command line avrdude -CC:\arduino-1.6.7\hardware\tools\avr/etc/avrdude.conf -v -patmega2560 -carduino -PCOM13 -b115200 -D -Uflash:w:C:\Users\Sumanth\AppData\Local\Temp\build4fc144f385b06dee29b5212dbaa60d2b.tmp/presenece.ino.hex:i).

avrdude: verification error, first mismatch at byte 0x0003
         0xc1 != 0x00

I am using the avrdude 6.2 to write as suggested with the change at http://savannah.nongnu.org/bugs/?40897.

I couldn't understand why the sketch is not loading and that verification error.

Observation 2:

I compiled a sketch with IDE and took the [SketchName].with_bootloader.hex from temp folder and used Atmel ICE to write the concatenated Application and the Bootloader hex file. After successfull writing flash.

This loaded the sketch correctly.

Any inputs are greatly appreciated. Thanks

westfw

The STK500v1 protocol used by optiboot does not allow more than 128kbytes of code.
except STK500v1 is occasionally used with large devices anyway, by using the "raw spi command" feature of the protocol to change the high byte of the uploaded address.
however, Optiboot is stripped down for minimum size, and does not support the "raw spi command" feature.

Therefore, you can't use Optiboot on an ATmega2560, even though it works on an ATmega1280.


pert

Therefore, you can't use Optiboot on an ATmega2560, even though it works on an ATmega1280.
My understanding was that majek's Optiboot fork(https://github.com/majekw/optiboot) supports ATmega2560 when used with avrdude 6.1 or greater: https://github.com/Optiboot/optiboot/pull/159. I haven't tried it.
I have been trying to use this Optiboot(https://github.com/majekw/optiboot/tree/m2560/optiboot) for Atmega 2560. I know this bootloader is for writing the flash from application
If you're using the m2560 branch, it doesn't have any of the code for writing to flash. If you want that feature you should use the supermaster branch, which also has the ATmega2560 support code merged.

westfw

Quote
my understanding was that majek's Optiboot fork(https://github.com/majekw/optiboot) supports ATmega2560
Whoops.  I forgot about that!  (And I didn't notice that that's the one the OP was using.)
Never mind.

pert

It's funny because as I was writing the comment I'm thinking "wait, I'm trying to correct something westfw said about Optiboot, I'm bound to be wrong about this". Thanks for all the work you've done on Optiboot!
Per

majek

I have been trying to use this Optiboot(https://github.com/majekw/optiboot/tree/m2560/optiboot) for Atmega 2560.

Arduino Ide with the board type selected as Optiboot On Mega2560, which uses STK500 V1 on COM port , was able to upload sketch. But there is a verification error

avrdude: verification error, first mismatch at byte 0x0003
         0xc1 != 0x00
Check https://github.com/majekw/optiboot/issues/2

Branch m2560 doesn't have precompiled hex for this processor, so maybe should I add it?
If you compiled it yourself, please provide .lst file (with assembler commands, addresses etc) and compiler type and version (you could reopen github issue and put it there). Maybe is it some compiler related issue?

And as pert wrote earlier - this branch doesn't have flash writing support. For flash writing and other features including Atmega2560 support use supermaster branch which contains precompiled and tested hex for your cpu.

chinnaobi

Thanks for the replies guys, really helpful.

Actually I was using supermaster branch, but I was compiling it myself.

Hi Majek,


It seems you are right, when I used pre-compiled hex that comes with the supermaster branch, surprisingly everything worked fine. I could upload sketches with IDE using the USB com port.

So, it looks like the compile I have been using might be wrong. I was using Arduino IDE  0023 to compile. The hex file I compiled is very different with the pre-compiled one.

Attached is the last file.

What compiler should I use ??

chinnaobi

#7
Jul 05, 2016, 07:43 am Last Edit: Jul 05, 2016, 07:52 am by chinnaobi
After experimenting with different compiler, found it is really that issue.

Arduino 0023 -- uses avr-gcc (WinAVR 20081205) 4.3.2

The optiboot bootloader compiled wiht above Arduino IDE, isn't working, has verification errors.

After some searching I used

Arduino 1.6.7 -- with copied Win-AVR 20100110 utils/bin to arduino-1.6.7\hardware\tools\avr\utils\bin, this uses avr-gcc (GCC) 4.8.1

Optiboot Bootloader compiled with IDE 1.6.7, worked fine for me on atmega 2560.

Thanks majek for pointing me in right direction.

majek

Just for the record - problem was that earlier versions of avr-gcc don't declare RAMSTART for Atmega2560 and code assumes in this case incorrect value. It explains why Optiboot for Atmega2560 compiled with Arduino 1.6.x works fine.
I put fixes in my branches, so it should compile and work fine also on older avr-gcc.

Tvixen

Is this still valid information, or has it become possible to burn a Optiboot 8.0 bootloader into a Mega2560 ?

CrossRoads

I've been using this one from IDE 1.8.5:

Mega2560-prod-firmware-2011-06-29.hex


Is that what you are referring to?

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.

pert


Tvixen

Thanks for the information ....Seems the wiki about Optiboot needs some update  ;D

Juraj

Thanks for the information ....Seems the wiki about Optiboot needs some update  ;D
this could be useful for you, if you want to change the bootloader of Mega

https://github.com/jandrassy/my_boards

Tvixen


Go Up