I used this method to burn a bootloader on my atmega2560
it works great, but the problem is that i can only upload a sketch once, then i have to burn the bootloader again, cause when i try uploading a second time i got timeout error.
anyone know how to solve that ? i tried pushing reset button when start uploading but did not work.
Usually the "can only upload once after burning bootloader" symptom is caused by your board's auto-reset circuit not working.
Normally you need to do a hardware reset of the microcontroller to activate the bootloader, then start an upload before the bootloader times out and starts the user application. However, after burning bootloader the bootloader is perpetually activated so no reset is necessary, meaning the first upload will work with or without a reset.
The auto reset circuit is the DTR pin of the USB-TTL serial chip connected to the reset pin of the ATmega2560 via a 0.1 uF capacitor. In combination with the pullup resistor on that pin, it generates a reset pulse when the serial connection is opened.
To test this, you could see whether uploads work after a manual reset. The tricky thing is that when you press the "Upload" button in the Arduino IDE, it first compiles your sketch before starting the actual upload. If you reset the microcontroller immediately after pushing the button, the bootloader will have timed out by the time the upload actually starts. The way to get the timing right is:
Select Sketch > Upload from the Arduino IDE's menus to start an upload (or click the upload button or whatever you prefer).
Watch the black console window at the bottom of the Arduino IDE window until you see something like this:
Sketch uses 444 bytes (1%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables.
Maximum is 2048 bytes.
Immediately press and release the reset button. The upload should now finish successfully.
But this is for when you are creating a circuit from a bare chip. The situation is a bit different if you have a regular Arduino Mega board because you don't have so much access to the circuit.