Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


SWO ITM printf() output using ST-LINK utility while debugging

I have been able to get printf() to output via SWO by following the information in this post:

http://www.openstm32.org/forumthread2893Question

I did not change the linker flags, nor did I add the “arm semihosting enable” options to the start script.

Additionally, I made no changes to the syscalls.c file. Instead, I created my own _ _io_putchar() routine in my main.c file as follows:

  1. include // printf()


int __io_putchar(int ch) {
ITM_SendChar( ch );
return ( ch );
}

If I download the code and run it, I can use the ST-LINK utility “Print via SWO viewer” option and see my printf() calls executing. So all this is great so far.

What I can’t do, however, is see the output while I am single-stepping through the code. If the debugger is running (via the ST-LINK_V2 interface), the ST-LINK utility can’t find the ST-LINK_V2 adapter. If I start the ST-LINK utility before I start to debug the code, the debugger won’t start, eventually giving me the error message:

“Error in final launch sequence
Failed to execute MI command:
-target-select remote localhost:3333

Error message from debugger back end:
localhost:3333: The system tried to join a drive to a directory on a joined drive.
localhost:3333: The system tried to join a drive to a directory on a joined drive.”

What am I doing wrong? I assumed it would be possible to use the ITM printf() method while debugging.

Your assistance is greatly appreciated.

Thanks,

Dale

I don’t see you did anything wrong, but I can understand the result that you get.
The problem is that the driver of ST-LINK v2 does not designed for sharing by application
simultaneously. While you start debugging, the debugger app acquired the driver of ST-LINK v2 and the
app of ST utility can’t get the driver any more, and vice versa.


Hello,
Bluenow is right. Only one tool connected at a time.
- About SWO viewer, it is a way to get traces without running a debugger. Could be useful in production;
- To get the printf traces in the OpenOCD tab, you can activate the semihosting. Note that you have to pause the debug session to get updated data values;


you can ask openocd to save itm trace to a file but you may not be abble to view trace live
it seam using a named pipe as the file is not working under window
what is a way to work aorund it openocd/debug and get race frol usb and provdie it live to the file (pipe)

semi-hosting printf can do but not ideal and very slow (semi host config required to have debuger conected to work)

Disappointing.

Thanks, everyone, for helping me understand what is going on here.


I’m also disappointed. I like to see the debug messages while I debug my program. Is that such a strange wish?

My current workaround is: Output debug messages on a serial port and use a second cable to the PC to display them in a terminal program.

May be this can help a bit: ((https://github.com/rokath/trice |https://github.com/rokath/trice ))
If you try the RTTD variant, on a debug step over a TRICE macro you see immediately the output.

Please check if SWD is enabled in the STMcube. I got the same error that I could not debug. It is fixed by enabling it in the STM cube.

In the meantime (long ago) I figured out that openOCD can write trace messages into a text file. Append the following lines to the user defined debugger script:

tpiu config internal /path/to/debug.txt uart off 8000000
itm port 0 on


 

Newest Forum Posts

  1. Last day: drone bonus by Danielrug, 2025-04-19 16:55
  2. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  3. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  4. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  5. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  6. Insightful Perspectives on This Subject by davidsycle, 2025-03-04 05:45
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  9. Build a project in "release" mode by tang, 2025-02-20 10:36
  10. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35

Last-Modified Blogs