I created a custom Arduino based off the Mega2560 R3. It uses the ATMega16U2 uC as the USB interface between ATMega2560 uC and the PC.
The bootloader on the 2560 is uploaded by using an Arduino Micro via ArduinoISP. I followed this tutorial from Instructables on uploading the bootloader/firmware for the 16U2 except I modified some parts for the 2560 instead of the UNO. Here is my added section in the /program Files (x86)/Arduino/hardware/arduino/avr/boards.txt
unorestore.name=MEGA2560 16U2 Restore Firmware unorestore.bootloader.tool=arduino:avrdude unorestore.bootloader.low_fuses=0xff unorestore.bootloader.high_fuses=0xd9 unorestore.bootloader.extended_fuses=0xf4 unorestore.bootloader.file=Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex unorestore.bootloader.unlock_bits=0x3F unorestore.bootloader.lock_bits=0x0F unorestore.build.mcu=atmega16u2 unorestore.build.f_cpu=16000000L unorestore.build.board=uno.build.board=AVR_MEGA2560 unorestore.build.core=arduino:arduino unorestore.build.variant=standard
The problem is after I upload a sketch (with a size say over 10 kB), I can't upload any new sketch and get this timeout error message instead as shown below. Not even a simple blink sketch. The TX and RX LED connected to the 16U2 uC that flashes during an sketch upload doesn't even blink once.
The only way I can get it take another sketch is to "re-flash" the bootloader on the 2560 uC via ArduinoISP. The TX and RX led now flashes during the sketch upload. Of course, this is a huge hassle as I don't want to do "re-flash" the 2560 bootloader every time I want to upload a sketch.
I don't have this problem on my Elegoo Mega2560 R3 clone board so I'm thinking it might be something wrong with my 16U2 firmware/bootloader. Anyone have any idea what else might be causing this?