Skip to main content
Lars Beiderbecke
Senior III
August 19, 2018
Solved

Debugger throws error at some breakpoints

  • August 19, 2018
  • 2 replies
  • 1276 views

I'm trying to debug an application running on a STM32F722 on a custom board. Right now I'm using Atollic TrueStudio and (an original) J-Link EDU.

Flashing works totally fine, but when I try to debug, the debugger will throw an error when hitting some breakpoints. In fact, the debugger stops normally at breakpoints in main.c and functions called from main.c, but when reaching breakpoints in functions triggered from external interrupts, it fails with this message:

ERROR: Can not read register 15 (R15) while CPU is running  [when BP is hit]

Reading all registers

ERROR: Can not read register 0 (R0) while CPU is running

ERROR: Can not read register 1 (R1) while CPU is running

ERROR: Can not read register 2 (R2) while CPU is running

ERROR: Can not read register 3 (R3) while CPU is running

ERROR: Can not read register 4 (R4) while CPU is running

...

The complete debug log as well as the debug script are attached.

The even weirder part is that this has happened before when using a Nucleo board and its ST-Link. There's still an unanswered post about this in the forum (https://community.st.com/s/question/0D50X00009XkWwASAV/nucleo-debugging-jtag-status-contains-invalid-mode-value-communication-failure). Back then I "solved" the issue by reverting to an older version of my code that didn't have this problem, and even though I wrote new code, this never happened again, until now.

Since it happened with a Nucleo and my custom board, and with a ST-Link and a J-Link, I have a feeling that neither board nor debug probe is the issue here. Could it be a MCU configuration issue, or a bug in the code generation by GCC?

I searched the internet high and low but couldn't find anything that resembles my problem. Thus, I would greatly appreciate some hints here, as my project would be dead otherwise.

This topic has been closed for replies.
Best answer by Lars Beiderbecke

For the record, I accidentally reconfigured my SWD pins with this statement:

GPIOA->MODER = 0x00005555;     

2 replies

Lars Beiderbecke
Senior III
August 19, 2018

Just a small update: I discovered that the error is not triggered by reaching a breakpoint, but by reaching a certain, unknown position in code. What could throw off the debugger so much that it raises the error message above?

Lars Beiderbecke
Lars BeiderbeckeAuthorBest answer
Senior III
August 19, 2018

For the record, I accidentally reconfigured my SWD pins with this statement:

GPIOA->MODER = 0x00005555;