I am having an issue with the pin 13 of the arduino mega 2560 board. It is the one tied up with the yellow led and for some reason on reset the pin pulses two times with a period of 200ms.
I believe this is something hardcoded into the bootloader because I couldn't find anything that explains this behavior in the AtMega2560 datasheet. But I couldn't find the source code for the arduino mega bootloader to prove that.
Does anyone have any experience with this behavior? Or anyone could help me with flashing another bootloader?
Edit: The sketch i'm using to test this is the BareMinimum example.
Think this might be the answer to your problem. refers to the Uno but expect it may apply to the Mega.
With all those pins on the Mega, wonder why pin13 is causing you a problem ?
The LED on pin 13 is used by the optiboot loader (the one used on UNO):
at Arduino boot time (the LED blinks a few times)
when uploading a sketch to Arduino
I haven't checked other bootloaders, they may provide the same behavior as the optiboot.
For optiboot, there are optional defines (at compile time) to modify this behavior:
LED_START_FLASHES defines the number of flashes of pin 13 LED at boot time (can be set to 0)
LED_DATA_FLASH will use pin 13 LED during sketch upload if defined at compile-time
These defines are explained in hardware/arduino/bootloaders/optiboot/optiboot.c from within your Arduino IDE install directory.
If you want to change these, you will have to recompile the optiboot loader first and then burn it to your Arduino through an ISP programmer.
The Mega bootloader is located at {Arduino IDE installation folder}/hardware/arduino/avr/bootloaders/stk500v2.
I think the relevant line is 137:
//#define REMOVE_BOOTLOADER_LED // no LED to show active bootloader
So you just need to uncomment that line, recompile the bootloader, then burn the new bootloader to your Arduino. A makefile is included in that folder to make this a bit easier but the bootloader source hasn't been changed in years so it's possible it won't compile with the latest tool versions.
I managed to do as pert post and compiled the bootloader for mega2560. Now I have the stk500boot_v2_mega2560.hex file but I am not able to flash it.
I was only able to flash the stock bootloader through Nick Gammon's Board Programmer. The Arduino as ISP is not working for me, it gives me 'avrdude: stk500_recv(): programmer is not responding'.
But to flash the compiled flash from Nick Gammon's Board Programmer I need to convert the hex to a byte array through his script 'convertHexToByteArray.py' and I am getting 'Error: Unkown bootloader start address.'.
So, I got the Arduino as ISP to work. It seems that you need to press the reset button when you get the programmer not responding message.
But now I cannot upload sketchs to the arduino with the modified bootloader. It says that the signature of the arduino is for the atmega1280 while it is expecting atmega2560.
I attached the logs because os the characters limit of the post.