<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1596188457259603&amp;ev=PageView&amp;noscript=1">
TruePERSPECTIVES_logo.png

STM32 debugging using the ST-LINK debug probe from STMicroelectronics

Posted by Magnus Unemyr on Apr 9, 2015 9:40:00 AM

Many STM32 developers use ST-LINK as their JTAG/debug probe. In particular, it is soldered onto many STM32 starter kits and evaluation boards, including the STM32 Discovery Kits and Nucleo boards. But it is also offered as a low-cost stand-alone JTAG/debugger probe as well.

So what debugging capabilities can you expect when hooking up the C/C++ debugger in your IDE to your STM32 board using the ST-LINK JTAG/debug probe? Considering its price, it is a very useful and convenient debug solution, but it also doesn’t offer the performance or all of the more advanced capabilities of for example the SEGGER J-Link or J-Trace debug probes.

STboard

To start with, ST-LINK supports STM32 debugging using both JTAG and SWD modes. Why does this matter?

JTAG mode is sufficient for simple run-stop/single-step debugging; but SWD mode is needed if you want to use the real-time event- and data tracing capabilities offered by the Serial Wire Viewer (SWV) debugger capabilities in the Cortex-M core. SWV event- and data tracing is offered by Cortex-M cores using the 1-pin SWO trace output pin (which is available in SWD mode but not in JTAG mode).

And so, if you want to exploit some super-useful debugger capabilities offered by the Cortex-M core in your STM32 project, you need to debug your board in SWD mode rather than in JTAG mode. And trust me, you really want use Serial Wire Viewer (SWV) event- and data tracing!

SWV is a low cost solution, enabling a vast set of advanced debugger capabilities, including:

  • Single-channel and multi-channel printf() redirection to a debugger console
  • Software instrumented tracing
  • Real-time variable watch
  • Graphical oscilloscope-styled variable value chart plots
  • Memory and variable access history log
  • Performance analysis using statistical profiling
  • Execution time measurement
  • Interrupt and exception event logging
  • Interrupt and exception statistics
  • Interrupt and exception nesting analysis
  • General event logging

All of these advanced SWV event- and data trace debugger capabilities are offered by ST-LINK, provided you debug in SWD mode and provided that your IDE’s debugger support it. And why should you not employ these very capable debugging techniques in your toolbox when they incur no extra hardware cost?

Compared to SEGGER J-Link/J-Trace and some other high-end debug probes however, the ST-LINK offers lower Flash download performance, and lacks some other advanced capabilities. And of course, SEGGER J-Trace adds support for ETM/ETB instruction tracing, enabling you to record execution history for later analysis. ETM/ETB instruction tracing is not supported by ST-LINK (which is quite natural considering its low-cost), at least not at the time of writing this article.

To provide a good STM32 debugging experience, not only a debugger probe like ST-LINK or SEGGER J-Link is needed; you also need to have a compiler/debugger IDE with matching capabilities.

Our Atollic TrueSTUDIO Pro C/C++ IDE is a great fit for professional STM32 development; it supports both ST-LINK and SEGGER J-Link/J-Trace really well, and it has outstanding support for SWV event- and data tracing, as well as ETM/ETB instruction tracing.

Furthermore, Atollic TrueSTUDIO Pro adds an STM32 hard fault crash analyzer as well, telling you why the software brought the CPU to a hard fault condition, what C/assembler line made it happen, and under what circumstances. Hard faults can easily occur for example by division by zero, illegal memory access due to pointer errors, etc.

It is worth noting that most ECLIPSE and GNU (gcc/gdb) tools do not support SWV event- and data tracing, ETM/ETB instruction tracing or hard fault crash analysis. Atollic TrueSTUDIO Pro (which is based on ECLIPSE and GNU gcc/gdb) do however support all these technologies thanks to commercially developed proprietary extensions.

Furthermore, Atollic TrueSTUDIO fully supports both the ST-LINK and Segger J-Link/J-Trace debugger probes, as well as virtually all STM32 devices, STM32 evaluation and starter kit boards, including the STM32 DiscoveryKits, STM32 EVAL boards, and STM32 Nucleo boards. Atollic TrueSTUDIO also works well with the STM32CubeMX device driver generator product from STMicroelectronics.

Read more about STM32 development here:
12 great tools and techniques for STM32 developers

You can also download our whitepaper:

Read our STM32 development whitepaper!


 

Topics: ECLIPSE, ARM Cortex, GNU tools (GCC/GDB), Debugging, Atollic TrueSTUDIO, ST-LINK