user15230: How can I write the bootloader and sketch code to an Arduino through the ISP and then write the sketch code again using the Arduino IDE later?
Currently, I can write the bootloader through the ISP and then write the sketch through the Arduino IDE.  This works just like normal.
I can also write the bootloader and sketch through the ISP.  The code runs like normal, but I can't load a new version of the sketch through the Arduino IDE.  It just timesout.
Here's what the IDE says when it attempts to upload the program:
avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM5
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

The Arduino IDE creates two hex files after compiling the sketch: one is just the compiled sketch (Sketch.ino.hex) and the other is the compiled sketch with the bootloader code appended to the end (Sketch.ino.with_bootloader.hex).  So, I feel like this should be possible because Arduino produces the file for me.

user15228: If you program via ISP, it erases the boot loader, because you do not need it. The whole point of the boot loader is to allow programming over USB. So if you want to use the normal Arduino USB input to program, burn the bootloader and then do not use the ISP.
Note my knowledge of this dates back to older arduino ~1.0 software, it is possible modifications have been made, but the above should still be true. If you have an ISP you do not need the bootloader at all.

user10794: Normally (using the IDE via the serial/USB interface) the bootloader is retained, and the bootloader itself replaces the main code. 
If you do ICSP programming then the first thing the programmer has to do is erase the entire chip (including the bootloader). Now nothing is stopping you putting the bootloader back as part of the programming sequence (it would add to the programming time slightly).
As Chris Stratton suggests, this is basically combining the .hex file for the sketch, and the .hex file for the bootloader. I'm not sure that literally concatenating them would work because there are a couple of other "record types" in the .hex file which might confuse the programmer if they were encountered twice - in particular the "end of file" record type.
However a strategy along these lines should give you a file that could be uploaded and put the bootloader back:

Take the .hex file from the compiler, and copy up to, but excluding, the "end of file" record to a temporary file.
Append the desired bootloader .hex file (including the "end of file" line).
Program the chip with the resulting file.

For larger chips (like the Atmega2560) you would need to be cautious about handling the "extended segment address" record because that sets the high-order byte of the address to be programmed.
The hex file format, as documented in my programmer sketch is:
Line format:

  :nnaaaatt(data)ss

  Where:
  :      = a colon

  (All of below in hex format)

  nn     = length of data part
  aaaa   = address (eg. where to write data)
  tt     = transaction type
           00 = data
           01 = end of file
           02 = extended segment address (changes high-order byte of the address)
           03 = start segment address *
           04 = linear address *
           05 = start linear address *
  (data) = variable length data
  ss     = sumcheck

            * We don't use these


user19322: I belive what you want to do is program a Arduino by ISP and retain the bootloader, I have done this on occasion by first loading the bootloader onto a chip, then upload the Arduino sketch, then i use the ISP programmer to read the whole flash back into hex file. 
This hex file is then used to program the rest of the chips for production. (If you feel this takes too much time, it is possible to strip the hex file down, but that might be a bit complicated)

15230: <p>How can I write the bootloader and sketch code to an Arduino through the ISP and then write the sketch code again using the Arduino IDE later?</p>

<p>Currently, I can write the bootloader through the ISP and then write the sketch through the Arduino IDE.  This works just like normal.</p>

<p>I can also write the bootloader and sketch through the ISP.  The code runs like normal, but I can't load a new version of the sketch through the Arduino IDE.  It just timesout.</p>

<p>Here's what the IDE says when it attempts to upload the program:</p>

<pre><code>avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM5
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
</code></pre>

<p>The Arduino IDE creates two hex files after compiling the sketch: one is just the compiled sketch (Sketch.ino.hex) and the other is the compiled sketch with the bootloader code appended to the end (Sketch.ino.with_bootloader.hex).  So, I feel like this should be possible because Arduino produces the file for me.</p>
 15228: <p>If you program via ISP, it erases the boot loader, because you do not need it. The whole point of the boot loader is to allow programming over USB. So if you want to use the normal Arduino USB input to program, burn the bootloader and then do not use the ISP.</p>

<p>Note my knowledge of this dates back to older arduino ~1.0 software, it is possible modifications have been made, but the above should still be true. If you have an ISP you do not need the bootloader at all.</p>
 10794: <p>Normally (using the IDE via the serial/USB interface) the bootloader is retained, and the bootloader itself replaces the main code. </p>

<p>If you do ICSP programming then the first thing the programmer has to do is erase the entire chip (including the bootloader). Now nothing is stopping you putting the bootloader back as part of the programming sequence (it would add to the programming time slightly).</p>

<p>As Chris Stratton suggests, this is basically combining the .hex file for the sketch, and the .hex file for the bootloader. I'm not sure that literally concatenating them would work because there are a couple of other "record types" in the .hex file which might confuse the programmer if they were encountered twice - in particular the "end of file" record type.</p>

<p>However a strategy along these lines should give you a file that could be uploaded and put the bootloader back:</p>

<ul>
<li>Take the .hex file from the compiler, and copy up to, but excluding, the "end of file" record to a temporary file.</li>
<li>Append the desired bootloader .hex file (including the "end of file" line).</li>
<li>Program the chip with the resulting file.</li>
</ul>

<p>For larger chips (like the Atmega2560) you would need to be cautious about handling the "extended segment address" record because that sets the high-order byte of the address to be programmed.</p>

<p>The hex file format, as documented in my <a href="http://www.gammon.com.au/uploader" rel="nofollow">programmer sketch</a> is:</p>

<pre><code>Line format:

  :nnaaaatt(data)ss

  Where:
  :      = a colon

  (All of below in hex format)

  nn     = length of data part
  aaaa   = address (eg. where to write data)
  tt     = transaction type
           00 = data
           01 = end of file
           02 = extended segment address (changes high-order byte of the address)
           03 = start segment address *
           04 = linear address *
           05 = start linear address *
  (data) = variable length data
  ss     = sumcheck

            * We don't use these
</code></pre>
 19322: <p>I belive what you want to do is program a Arduino by ISP and retain the bootloader, I have done this on occasion by first loading the bootloader onto a chip, then upload the Arduino <em>sketch</em>, then i use the ISP programmer to read the whole flash back into hex file. </p>

<p>This hex file is then used to program the rest of the chips for production. (If you feel this takes too much time, it is possible to strip the hex file down, but that might be a bit complicated)</p>
