CN / EN
Doc Feedback
Thanks for your interest, welcome to contact us.
Thanks for your feedback

Debugging in Mirror Mode

In Mirror Mode, you shall set breakpoints after the application firmware is copied to RAM.

Note:

If breakpoints are set within the RAM address range, Keil uses software breakpoints to save hardware resources (replace the original commands with BKPT instructions). After you set breakpoints, the Bootloader copies the application firmware to an address where breakpoints are set. The BKPT instructions of the address then are overwritten by the application firmware, and applications cannot stop when running to the address. For more information, see the ARM Keil official document Breakpoints are not hit when debugging in RAM.

You should set breakpoints before executing the main() function of applications. Follow the steps below to set breakpoints:

  1. Add __BKPT(X) to the first line of the main() function. Example code is provided below:
    int main(void)
    {
        __BKPT(0);
        app_periph_init();                /*<init user periph .*/
    …
  2. Click Build on the Keil toolbar to compile and link code.
  3. Click (Start/Stop Debug Session) on the Keil toolbar to start debugging. The application stops at __BKPT(0) when it starts debugging.
  4. Set new breakpoints in the application.
  5. Press F10 (not F5) to step over the next code line, so that you can continue debugging code in a normal way.
Note:

Pressing F10 allows executing the next code line only; press F5 allows executing all the rest code lines. Keil only responds to F10 when it hits __BKPT.

Scan to follow

Open WeChat, use "Scan" to follow.