1.1.7.1 Debugging UART, I2C, SPI and CAN Bootloaders for CORTEX-M based MCUs

The UART, I2C, SPI and CAN bootloaders for CORTEX-M based MCU's are designed to run from SRAM to support

  • Simultaneous Flash memory write and reception of the next block of data

  • Self update

bootloader_ram_layout
  • For debugging these bootloaders make use of software breakpoints instead of Hardware breakpoints

Steps to enable software breakpoints and start debugging

  • Enable software breakpoint from the project configuration dashboard by clicking on the button as shown below

arm_bootloader_debug_enable_soft_breakpoint
  • Software breakpoints inside main() when running from SRAM do not work when set before starting the debugger.

    • For them to work first set a Breakpoint in startup_xc32.c file as it is running from flash

arm_bootloader_debug_set_startup_breakpoint
  • Start the debugger from MPLAB IDE and the software break point in startup file will be hit

arm_bootloader_debug_startup_breakpoint_hit
  • Once the breakpoint is hit in startup file, then set breakpoints anywhere you want, like in main() function as shown below

arm_bootloader_debug_set_main_breakpoint
  • Resume the debugger and you should be able to now debug as usual

arm_bootloader_debug_main_breakpoint_hit