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":

majenko: I would guess at the first hit on google for "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:, which is actually incorrect, and should be updated to

Search for the file "stk500boot.c"

on my PC it's stored under


@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:


And then you should probably do a bit of web searching to see if there is a new and improved version. (there is. Slightly. and also in the arduino repository: )

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


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

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?