XC16Bootloaders - How do you generate a hex file combining a bootloader and an application project?

A hex file can be created that contains both the application and the bootloader. Merging the bootloader and application hex files can be done as follows:

First, make a hex file for the bootloader and then load it into your application project. A unified hex file will be made by the compiler. Please read section 5.4 of the MPLAB® X IDE User's Guide which can be downloaded from the 'Documentation' tab of the product landing page.

Steps to be followed (from Section 5.4 of the User's Guide):

  1. In the project tree, there is a branch called loadables in MPLAB X IDE.
  2. Open the first project
  3. Right-click on loadables in the project tree and add the second project.
  4. Perform a build or debug. That will merge both project hex files or elf files for debugging.

Check to make sure that the two projects do not overlap in memory. If they do, you will get an error. When combining the Bootloader and Application projects in MPLAB X IDE, make sure that both the bootloader's configuration and the application's configuration bits are the same. Otherwise, this will generate a data conflict error with a given address. To resolve this, match the bootloader's configuration bits with the application's configuration bits.

Please note that his method doesn't work for all PIC® MCUs. We do not have a document listing which ones work. The only way to verify for now is by testing it. For an XC16 application, if there is a data conflict at the IVT, in the XC16 linker options uncheck the box for creating the default ISR.
Here's a forum post that has some good discussion on "Merging Bootloader and Application Hex files": http://www.microchip.com/forums/m441306.aspx.

© 2018 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.