1.4.7.2 Debugging Bootloader and Application to be bootloaded
Open the bootloader project to be debugged in the MPLAB IDE
Make sure that the application to be bootloaded and debugged is added as a loadable project to bootloader project
Adding the application as loadable allows MPLAB X to create a unified hex file and program both bootloader and application in thier respective memory locations
Bootloader in bootloader space
Application in application space
Open the application project in the IDE and disable post build script exection if any as shown below
Having this binary conversion post build script enabled will result in build error during debugging as there will be no hex file generated
Set breakpoint as required in application project. Below is a an example snapshot
Start debugger for the bootloader project using the IDE. This should program both bootloader and application
Once the debugger is started the bootloader first runs and then jumps to application code. You should see the application breakpoint hit if application code is running
Additional Information (For MIPS based MCUs)
When combining the Bootloader and Application Hex files in MPLAB X IDE, an error may be generated if the device Configuration words are different. This will be shown as a data conflict error, and the address given will match an address in the device Configuration words.
This can be resolved by discarding the Device Configuration settings from application linker file as shown below
/DISCARD/ : { *(.config_*) }
Note: Bootloader application uses the first 16 bytes of RAM for the application to trigger bootloader. While initiating debugging, MPLAB X IDE uses the beginning of RAM for debugging usage, so it collides with the RAM reservation for Bootloader trigger. As a solution either user needs to move the 16 bytes to reserve for bootloader trigger at the end of RAM or remove the 16 bytes reserved in linker temporarily for debugging.
Linker error for debugging:
c:\program files\microchip\xc32\v4.30\bin\bin\gcc\pic32mx\8.3.1\..\..\..\..\bin/pic32m-ld.exe: section .data VMA [0000000080000010,000000008000026f] overlaps section reserve_data_0_kseg0 VMA [0000000080000000,000000008000036f]