1.13 Combining the Application and Bootloader Hex Files for Production
Overview When creating the production image, it is often desired to have a single .hex file that has both the initial bootloader and application code combined. This makes it easy to program the device in the factory in its final shippable form. This section will describe how to combine the bootloader and application .hex files for production.
- Combining the bootloader and application .hex files for production
-
A script is generated in the application project folder that can be run to combine the application and bootloader project named "combineAppAndBootloaderHex.bat" or "combineAppAndBootloaderHex.sh". Running this script will combine the application and bootloader .hex files into one .hex file that can be used for production.
- Adding script to combine files automatically on compile
-
The script to combine the application and bootloader .hex files can be run automatically on build. To combine the files automatically, add the script file to the post build step.
-
Open the application project
-
Right click on the project properties.
-
Select the "Building" node from the Categories tree pane on the left of the window.
-
Check the "Execute this line after build" box.
-
If the bootloader verification method is "Not Blank"
-
add "cd mcc_generated_files/boot && combineAppAndBootloaderHex.bat" (without quotes) if you are on a Windows machine
-
add "cd mcc_generated_files/boot && combineAppAndBootloaderHex.sh" (without quotes) if you are on a Linux/Unix/Mac machine.
-
follow the instructions according to the verification method post build scripts first
-
add "&& combineAppAndBootloaderHex.bat" (without quotes) to the end of that line.
For example: "cd mcc_generated_files/boot && postBuild.bat $(MP_CC_DIR) && combineAppAndBootloaderHex.bat"
-
-
- Adding script to combine files automatically on compile
-
The script to combine the application and bootloader .hex files can be run automatically on build. To combine the files automatically, add the script file to the post build step.
-
Open the application project
-
Right click on the project properties.
-
Select the "Building" node from the Categories tree pane on the left of the window.
-
Check the "Execute this line after build" box.
-
If the bootloader verification method is "Not Blank"
-
add "cd mcc_generated_files/boot && combineAppAndBootloaderHex.bat" (without quotes) if you are on a Windows machine
-
add "cd mcc_generated_files/boot && combineAppAndBootloaderHex.sh" (without quotes) if you are on a Linux/Unix/Mac machine.
-
follow the instructions according to the verification method post build scripts first
-
add "&& combineAppAndBootloaderHex.bat" (without quotes) to the end of that line.
For example: "cd mcc_generated_files/boot && postBuild.bat $(MP_CC_DIR) && combineAppAndBootloaderHex.bat"
-
-
- Troubleshooting - HexMate fails to run
-
If HexMate fails when the script is run, then HexMate is not in the system path. There are three possible resolutions:
-
Modify the system path to include a path to the folder containing the HexMate file. This can be found in the MPLAB X installation folder under the "mplab_platform/bin" sub-folder.
-
The script can be modified to include the full path to the HexMate tool. Open the script and add the path to the front of the call to the HexMate call.
-
Invoke the script from the build flow in MPLAB X. When a script is invoked in the MPLAB X build process, it has the MPLAB X path already added to the path. To do this, follow the instructions in the "Adding script to combine files automatically on compile" section above.
-
- Loadable Projects
-
This bootloader project uses assembly files rather than linker files to perform the memory partitioning and interrupt/reset forwarding. This allows the bootloader project and application project to be built and run completely independently from each other, but still work together. This approach, however, prevents the projects being combined using the loadable projects feature. Trying to do so will result in link errors. This feature is not currently supported.