USB Library
Merging Bootloader and Application Project Output

To “merge” the two projects together (so that the application firmware .hex file is not required to be programmed by the bootloader, but may be programmed either stand alone via ICSP or by the bootloader), the following can be done:

  1. Open and build the HID bootloader firmware project in the MPLAB X IDE.
  2. Open the application firmware project in the MPLAB X IDE.
  3. Add the “MPLAB.X.production.hex” file (generated by the HID bootloader firmware project) to the application firmware project as a “Loadable” file in MPLAB X. This can be done from the project view window and right clicking on the “Loadables” folder, and selecting the “Add Loadable File…” option.
  1. Build the application firmware project. After the project builds, MPLAB X will automatically run the “HEXMATE” utility in the background and generate a merged .hex file (which will contain both the bootloader firmware and application firmware). This merged .hex file can be programmed either stand alone with an ICSP™ programmer or using the bootloader.
If step number 4 above fails, this implies that there are overlapping but non-equivalent sections of the program memory values in the two hex files (from the HID bootloader firmware and the application project). Normally, this error will be caused by having slightly different configuration bit settings between the application firmware project and the HID bootloader firmware project. To fix this error, you must modify the two projects so that the configuration bits are 100% identical between the two or are only implemented in one of the firmware projects. 

 

Alternatively, it is possible to use the HEXMATE utility directly from the command line, instead of invoking it through the MPLAB X IDE through the "Loadables" feature to merge the hex files. When used at the command line, the HEXMATE utility supports a variety of advanced options, such as code offset shifting, giving "priority" to one hex file or another (ex: in the case of conflicts due to overlapping but non-identical .hex file content), merging more than two hex files at once, etc. To learn more about how to use the HEXMATE utility, please refer to the "HEXMATE" section in the MPLAB XC8 compiler user's manual.

MLA - USB Library Help Version : 2.16
http://www.microchip.com/mla