2024-08-08 06:58 PM
I am developing software on Windows using STM32CubeIDE and STM32CubeProgrammer.
I have a question about how to run Debug using the st-link gdb server in a CLI environment.
I want to capture the results of Google Test running on the firmware via SWO output and retrieve them using STM32CubeProgrammer.
However, when I run Debug, the process stops before completion, and I am unable to determine the cause or solution.
[gdb server command line]
> C:\ST\STM32CubeIDE_1.12.1\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.win32_2.0.500.202301161003\tools\bin\ST-LINK_gdbserver.exe -p 61234 -l 1 -d -z 61235 -s -cp C:\ST\STM32CubeIDE_1.12.1\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.600.202301161003\tools\bin -m 0 -g --frequency 24000 -t
attached file: gdb server console log.txt
Cube Programmer SWO capture
st-link gdb server in STM32CubeIDE (GUI) works correctly.
I am investigating whether there are any issues with the startup parameters of the gdb server or CubeProgrammer.
If you have any ideas on how to resolve this, I would greatly appreciate your help. Thank you in advance.
My environmental information is as follows:
CubeIDE(Windows11) - ST-Link/v2 - device
STM32CubeIDE:Version: 1.12.1 Build: 16088_20230420_1057 (UTC)
STM32CubeProgrammer: v2.16.0
ST-LINK FW: V2J41S7
Device: STM32H7Ax/7Bx
2024-08-20 06:42 AM
Hello @u1kano,
In CubeIDE GUI, you can check the command line that's being used by going to "Run>Debug Configuration>Debugger>GDB Server Command Line Options>Show Command line".
Let me know if you find this helpful.
Aziz
2024-08-20 11:57 AM - edited 2024-08-28 12:14 AM
partial duplicate of
- when blurring parts of a screenshot, use a contrasting color to make it clear. combined with the heavy tiles windows it makes it very hard to read.
- why do you have two gdb sessions and 3 cubeProgrammer sessions going all at once?
- what is the order of operations the screenshot is meant to explicate?
- what exactly do you mean by "run Debug"?
- what exactly do you mean by the "process stops without completion"? do you mean gtest output piped over SWO seeming to hang?
- what is the cause of the "vRun" errors shown in your screenshot?
Once you've answered those questions....
- are you able to differentiate between the test suite stopping half way and the test suite running to completion but the SWO output borking half way? can you toggle a LED at the end of the test suite and see?
- When the test suite seems to hang, did you break with gdb and examine what the CPU is doing?
- If instead of running the test suite you simply print a running counter, does the output still hang?
- Post the code you use to forward the gtest output over SWO. Is this code safe for when the output rate is faster than the SWO can support? is there a busy loop there which can lead to a deadlock? Did you copy-paste some random snippet from the internet? some of those are very naive and can fail in distasteful ways.
- What happens if you increase the SWV frequency? where did the 280 in your screenshot come from and what does it stand for? 280KHz? SWV can usually be run at least as high as 2Mhz and even 4Mhz. Simply raising the SWV freq is not a robust solution if overrun is really the problem, but if raising the rate makes the issue go away it would at least be confirmation of the root cause.
2024-08-27 10:27 PM
I apologize for the delayed response despite your earlier reply. Thank you also for the advice you provided.
I will respond regarding some of the points I have confirmed, and I would appreciate it if you could continue providing advice.
- why do you have two gdb sessions and 3 cubeProgrammer sessions going all at once?
The screenshots appear strange because I stitched multiple screenshots together. In reality, there is only one GDB session and one CubeProgrammer session running.
- what is the order of operations the screenshot is meant to explicate?
I just wanted to explain that the Google Test results on the right side of the screenshot were cut off.
- what exactly do you mean by "run Debug"?
I would like to run Google Test within the firmware by executing the following steps.
- Download the compiled program (ELF file) to the debugger.
- Run the program using a gdb session.
- what exactly do you mean by the "process stops without completion"? do you mean gtest output piped over SWO seeming to hang?
Yes, I mean gtest output piped over SWO to hang.
- what is the cause of the "vRun" errors shown in your screenshot?
The cause of the issue has not been identified yet.
I would like to respond based on the points I have confirmed regarding some of the advice you provided.
- post the code you use to forward the gtest output over SWO. Is this code safe for when the output rate is faster than the SWO can support? is there a busy loop there which can lead to a deadlock? Did you copy-paste some random snippet from the internet? some of those are very naive and can fail in distasteful ways.
I have directly implemented ITM_SendChar in the write system call.
I think it is equivalent to the official STM document.
__attribute__((weak)) int _write(int file, char* ptr, int len)
{
(void)file;
#ifdef DEBUG
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++) {
ITM_SendChar(*ptr++);
}
#endif
return len;
}