Debugging problems on STM32G0B1 Nucleo board in conjunction with flash memory erasing/programming
I have a very strange behaviour when using the (on-board) ST-Link debugger on the STM32G0B1 Nucleo board using the Flash Programming example contained in the STMCubeG0 package (v1.5.0).
I use Keil MDK IDE v5.36, CMSIS- & STM32G0 device support packages are up to date.
Case #1:
I download the program directly (no debugging) and it *ALWAYS* works as expected
(=> LED pattern indicates success of erase, program & verify procedure).
Case #2:
I start a debug session and run the target, after the debugger automatically has ran to the main function.
After running the target, I noticed different behaviours:
a) Sometimes, after a few seconds, the debug session is terminated with an error message
(Cannot access target. Shutting down debug session.)
b) The application works as expected (erasing, programming & verify succeeded).
Update to case 2:
It looks like the debug session terminations do not occur when I reduce the debugger clock to, for instance, 0.050 MHz.
(Project options -> tab 'Debug' -> 'Settings' (on the right hand side) -> Clock Req.)
Case #3:
Same as case #2 but with a breakpoint set before the erase function call (main.c, line 143).
Program runs and stops at breakpoint location.
When I resume running the application, the erase procedure fails and it stays in the 'erase failed' while loop. (line 155-158).
Now I reset the CPU, the application automatically runs and stops at the breakpoint at line 143 again.
But now, when I resume the application, the flash procedures (erase, program & verify) succeed.
Further debugger resets (and auto run) always result in successful flash operation.
It looks like, in this case, the program fails only for the first time after starting the debug session.
Case #4:
I remove the flash erase (line 143) and flash program (line 170 line 169) function calls.
No problems occur during debugging. Neither with slow (0.050 MHz) nor with fast (10 MHz) debugger clock selection.
I also can use breakpoints without any problems.
It looks like there is some kind of problem with the debugger in conjunction with the flash erase/program procedures (on this type of board?).
I never had such problems on the F0, F1, F3 & F4 evaluation- and Nucleo boards.
Nucleo board label:
NUCLEO-G0B1RE
NUG0B1RE$AU1
On-board ST-Link firmware version:
V2J38M27
