Arduino Mega 2560 Bootloader Source Code

Hey all , I am in the process of creating a bootloader for the Mega 2560. So for that I need to analyse and make changes in the bootloader code for the Mega . Can anyone please tell me where to find the source code. I saw in the arduino folder and was only able to find the .HEX file and the stkv2 protocol.

Thanks in advance

I would guess at the first hit on google for "optiboot": http://code.google.com/p/optiboot/

majenko: I would guess at the first hit on google for "optiboot": http://code.google.com/p/optiboot/

I don't believe that opiboot will work with the 2560 chip/board, something about the longer address protocol needed to write to the higher address range that the 2560 has. I have a version of optiboot that runs fine on a mega1280 chip/board but that's as large a address space that optiboot will work with.

Alternatively, the Bootloader page on the Arduino website points you to: http://code.google.com/p/arduino/source/browse/#svn/trunk/hardware/bootloaders, which is actually incorrect, and should be updated to https://github.com/arduino/Arduino/tree/master/hardware/arduino/bootloaders

Search for the file "stk500boot.c"

on my PC it's stored under

.......\arduino-1.5.4\hardware\arduino\avr\bootloaders\stk500v2

@majenko : Yes the first hit would be optiboot. I did look into it. But as retrolefty replied, there are some issues with the code and Mega2560.

@CaptBlaubaer : I also saw the stk500boot.c file in my arduino. But i believe it is not the actual bootloader file. It is the protocol that the bootloader uses to generate the .hex file ( the actual file to be burnt into the arduino). Look at the other .hex files. It is generated with this file.

If you look in boards.txt, it will have a pointer to the bootloader currently in use:

mega2560.bootloader.file=stk500v2/stk500boot_v2_mega2560.hex

And then you should probably do a bit of web searching to see if there is a new and improved version. (there is. Slightly. https://github.com/msproul/Arduino-stk500v2-bootloader and also in the arduino repository: https://github.com/arduino/Arduino/tree/master/hardware/arduino/bootloaders/stk500v2 )

@westfw : So you mean to say that the stk500v2.c is the main bootloader file ? So the .hex file was created from this ?

Yes.

@westfw : Can u please look into this and tell me whether it is feasible and if yes, any tips ?

http://forum.arduino.cc/index.php?topic=197925.msg1460333#msg1460333

ive recently managed to adapt optiboot to work with m2560. one of my clients has been nagging me to do this for some time now. it was not an easy job but the bigger minumum boot area did allow space for things like debug monitor, battery check, bios routines, etc..

ive been meaning to do this for quite some time and there were a couple failed attempts trying to use the maniac 1284 as starting point. thanks to w for pointing me to a better version of optiboot.

@john1993: Can you share more, what exactly you did?