This bootloader firmware is intended to be built with the XC8 compiler
v1.21 or later (in PRO mode).


This firmware can be used in conjunction with the same host software program
as provided in the Microchip Libraries for Applications (MLA) v2013-06-15, available
from www.microchip.com/mla

Upon installation, the Windows executable is located under:

C:\[MLA install folder]\USB\Device - Bootloaders\HID\Software Windows Executable



This bootloader firmware is intended to occupy the program memory region
0x000-0xFFF.  The application firmware is
supposed to occupy the 0x1000-[end of flash] region of program memory.

In order to fit within the 0x000-0xFFF region, this project must be 
built with the PRO mode optimizations enabled.


If you build an application firmware project that needs to be programmable 
by this bootloader firmware, there are two linker setting changes that are 
required to the application project.

1. Under the build configuration-->XC8 global options-->XC8 linker-->Option categories:Additional options
   the "Codeoffset" must be set to: 0x1000
   See the "Required_Application_Project_Codeoffset_Linker_Settings_for_XC8.png" image for example view.

2. Under the build configuration-->XC8 global options-->XC8 linker-->Option categories:Memory model,
   the "ROM ranges" must be set to: default,-0-FFF,-1006-1007,-1016-1017
   See the "Required_Application_Project_ROM_Ranges_Linker_Settings_for_XC8.png" image for example view.

In addition to the above, make certain that all configuration bit settings
between the bootloader firmware project, and the application firmware project,
match 100% exactly.  If they do not match, modify one or both projects until they do.


Once the above changes are made to the application project, the output
hex file will no longer work when programmed stand alone, but it will be programmable
by the HID bootloader firmware.


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 project.
2.  Open the application firmware project.
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.
4.  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 #4 above fails, this implies that there are overlapping but non-equivalent sections
of 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), so that the hex
merge operation can succeed.










