I'm working on device that is using AtMega2560 as main microcontroller and AtMega16u2 as USB/Serial converter. This is identical as can be found in Arduino Mega R3 (including bootloader).
When I connect device to PC, wait few seconds and open Serial communication everything works great.
Problem occurs when I open Serial communication and start sending data immediately after powering on microcontroller. In this situation AtMega2560 prevents to start.
I know that this is happening because AtMega2560 bootloader waits if there is new sketch waiting to be uploaded to it.
Is there any solution to force AtMega2560 to start even if it starts receiving serial data immediately after powering? Maybe modifying firmware of Atmega16u2 ?
Do you need the bootloader? If you connect an ISP programmer to your ATmega2560 and do a Sketch > Upload Using Programmer then your uploaded program will overwrite the bootloader. Of course then you can't do uploads via serial.
How "immediately" do you really need to start sending data? I believe the optiboot bootloader has a shorter delay after startup than the standard bootloader used on the Arduino Mega. You can easily install optiboot on your board using this hardware package: