Arduino Mega R3, Bootloader not overwritten while trying ICSP programing ??

Hello,
I am trying to program the arduino mega r3 (atmega2560) using ICSP programer(Pocket AVR programmer from sparkfun ). I was able to upload the code using the programmer and arduino IDE (it worked fine). I assumed that the bootloader in it must have been over written by my new code. Later, I tried to upload bootloader into it and it failed. When i programmed the mega again with the USB cable it surprisingly worked fine XD. I now believe that the bootloader didn't get overwritten.

My question is that ,
why did the bootloader not get overwritten ? :astonished:
What should i do to remove the big delay caused by the bootloader ? :0
I want to program the atmega2560 using Arduino IDE and Pocket AVR programmer to use the controller(atmega2560) alone in a custom PCB. what all should i take care about while designing the PCB to be programmed via the ICSP header ? :slight_smile:

My apologies if the questions are raised in the forum before or if it doesn't make any sense.

Thank you in Advance,

why did the bootloader not get overwritten ?

Under File:Preferences, enable Verbose outputs, and try again. See what messages occur.

What should i do to remove the big delay caused by the bootloader ?

2 options:a) File:Upload Using Programmer - sketch overwrites bootloader and starts immediately after reset
b) Modify the bootloader code to have less delay.

I want to program the atmega2560 using Arduino IDE and Pocket AVR programmer to use the controller(atmega2560) alone in a custom PCB. what all should i take care about while designing the PCB to be programmed via the ICSP header ?

Bring Vcc, Reset, MOSI, MISO, SCK, Gnd to a 2x3 header in the standard pinout expected by programmers - check the Mega schematic.
Other things to address: 16 MHz crystal & 22pf caps, 0.1uF cap on Each VCC pin, 0.1uF cap on AVCC pin, 0.1uF cap on Aref pin, 10K reset pullup resistor, 1N4187 diode across reset resistor (anode to Reset pin, cathode to Vcc), especially important if using a mechanical reset switch.

Later, I tried to upload bootloader into it and it failed.

There's a bug in many ISP programmers when programming beyond the 128kbyte limit. It usually shows up as the programming failing verification even though the chip was correctly programmed.

The programmer can't write (or read) addresses greater than 64K.

The "Pocket AVR Programmer" is Sparkfun's rendition of Adafruit's USBTinyISP. From the adafruit website (USBTinyISP documentation): Works with any AVR ISP chip with 64K of flash (or less) - does not work with Atmega1281/1280/2561/2560.