2020-10-26 01:59 AM
On a serial product after a firmware update, there are some sporadic cases, where we get a hang up situation. It would be very helpful to know where exactly the program is stuck. According to ES0346 Rev. 6 chapter 2.8 it is possible to access program counter even with RDP set. How can I exactly read the value with CubeProgrammer + ST-Link (or alternatively with J-Link).
2020-10-26 05:26 AM
There is, but I have never tested it myself
The gdb server supports -g, --attach
"This attaches to the running target. Attach is aimed to be used to connect to a running program in the device without doing a reset or downloading a new program."
How this works with a stuck MCU i am unsure but it is the place to start
Breg
2020-10-26 06:52 AM
If you're using STM32CubeIDE:
To debug your program without downloading it:
Go to Debug Configurations... -> Startup -> select load image -> Edit... -> uncheck Download
To debug without resetting the device:
Go to Debug Configurations... -> Debugger -> in Reset Behavior, select "None"
2020-10-26 07:00 AM
Try to hotplug attach with a debugger. In gdb "info regs" will give you the registers, or to only read the PC " p $pc". Most important is, can you attach? Second important probaby ist that you do it manually and not rely on some IDE to show you the values. Probably that wil step into some read protection.
2020-10-26 09:25 AM
Instrument the obvious places code goes to die. Like the HardFault_Handler and Error_Handler, and anywhere you have unbounded while loops, so you're not working blind.
Perhaps check what routines are interrupted by the SysTick, see if it is stuck somewhere, or off in some unexpected code paths.
2020-10-27 05:30 AM
Thank you for your reply, I tried to use the CUBE programmer with command line interface instead of gdb, as this seemed to be the easier way with the call STM32_Programmer_CLI.exe -c port=SWD HOTPLUG -coreReg
which should do the same. But I allways get a PC value of 0xFFFFFFFE, even if I connect a device running in normal programm execution. Perhaps I will try the gdb-server.
2020-10-27 05:31 AM
I use IAR, but I will try a similar path there,
thanks
2020-10-28 02:48 AM
I will do these things, but as a first step, I would like to find out, where exactly the code hangs. So I tried to get the program counter with:
STM32_Programmer_CLI.exe -c port=SWD mode=HOTPLUG -coreReg PC
this gives the register values, and other values like SP make sense, but PC is always FFFFFFFE?!
Do you have some hint how to really get the PC?
2020-10-28 10:04 AM
The picture stille says "Software reset". Reset would destroy PC.
2020-10-28 05:13 PM
To fix this you'll have to change the code. If you can debug it in a secure laboratory, consider turning off RDP while you're debugging.