cancel
Showing results for 
Search instead for 
Did you mean: 

Did not get SWV prints in STM32CubeIDE

SDTAN0907
Associate II

Hii Everyone, I am trying to debug with SWO and SWV in STM32CubeIDE with NUCLEO-H753ZI. But, I am not getting any prints on SWV ITM Data console. As you can see all settings in the below attachments. My CPU system clock is running at 400Mhz. Anyone suggest me to get prints in SWV/ITM Data console.

SDTAN0907_0-1758694249404.pngSDTAN0907_1-1758694368626.pngSDTAN0907_2-1758694433406.png

 

SDTAN0907_3-1758694547143.png

 

16 REPLIES 16
PHolt.1
Senior III

There is a weird issue with that red button. Cube IDE has the wrong mouseover text on it. See

https://www.eevblog.com/forum/microcontrollers/stlink-debugger-configures-some-32f4-target-registers-e-g-swo-trace-macrocell/msg6054427/#msg6054427

But it works better if you Detach the SWV ITM tab and have it standalone. See above thread.

Also see e.g. here

https://community.st.com/t5/stm32-mcus-boards-and-hardware/32f417-how-to-use-swv-itm-swo-debug-output-without-cube-ide-or/td-p/843611/page/3

SWV ITM can be very hard to get working. It works better in the OpenOCD (not the default GDB Server) debugger mode (still with STLINK) as shown above. GDB Server works fine for normal flashing of the code, and breakpoints and such.

If you check PC Sampling (needed for statistical profiling) then the whole thing gets much less reliable. The debugger needs to be power cycled (USB unplugged and replugged) after each collection session, plus Cube exit and restart.

There is a config in Cube for the buffer size. I use 20MB.

Thank you for your reply,

I tried using OpenOCD for SWV debugging, but I still don't see any output in the SWV Viewer. I've attached my project files, OpenOCD config and GDB debugger settings, and SWV configuration. Could you please review them and let me know if there's any misconfiguration or missing setup that might be preventing the SWV prints from appearing?"

SDTAN0907_0-1759492960039.png

SDTAN0907_1-1759492989251.png

SDTAN0907_2-1759493078505.png

 

 

PHolt.1
Senior III

I use SWD frequency 8000kHz (not Auto). AFAICT the auto mode tries different speeds and it can discover a "working" speed which is marginal. I never go above 8000kHz, not even with the STLINK V3 MINIE which should be the fastest (but has other problems).

Also uncheck Enable Prescaler.

Last post here

https://community.st.com/t5/stm32-mcus-boards-and-hardware/32f417-how-to-use-swv-itm-swo-debug-output-without-cube-ide-or/td-p/843611/page/3

And ALWAYS EXIT AND RESTART CUBE IDE after any debugger related config change, plus unplug and replug the debugger USB cable. The parameters in the 1st form do not get picked up in the 2nd form except when Cube it restarted (you can prove this anytime).

I am right now testing the STLINK V3 MINIE and find that the SWV ITM debug works only if I fix the SWO clock to 1000kHz, not Auto. The debugger clock is still 8MHz. This is weird because this one has no isolation so should be super fast. And of course statistical profiling does not work at all. This is with a 12cm cable, too.

I tried with 8000KHz and different frequencies, unchecked Enable Prescaler. But still I don't get prints. I have observed one point, kept a break point at this line

bItmAvailable = 1 ;

Execution goes to that line, it means port 0 is not ready to accept new data. I don't understand why it is happening. You have any idea, Please guide me.

SDTAN0907_0-1759500703402.png

 

PHolt.1
Senior III

Are you calling the right function? Try this and output just one char or a string.

/*
 * Copied here from core_cm4.h.
  \brief   ITM Send Character
  \details Transmits a character via the ITM channel 0, and
           \li Just returns when no debugger is connected that has booked the output.
           \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted.
  \param [in]     ch  Character to transmit.
 */

static void ITM_SendChar_2 (uint32_t ch)
{
  if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) &&      /* ITM enabled */
      ((ITM->TER & 1UL               ) != 0UL)   )     /* ITM Port #0 enabled */
  {
    while (ITM->PORT[0U].u32 == 0UL)
    {
      __NOP();
    }
    ITM->PORT[0U].u8 = (uint8_t)ch;
  }
  return;
}


// This sends debug output to the SWV ITM / SWD debug interface
// was: __io_putchar(int ch) - this was for the old ST-supplied printf
int _putchar (int ch)
{
    ITM_SendChar_2(ch);
    return ch;
}

 The putchar is to make printf() output to SWV ITM but it depends on your printf() code.

You don't need the SWO config. The debugger does it for you: Your swoinit() is superfluous.

https://community.st.com/t5/stm32-mcus-boards-and-hardware/32f417-how-to-use-swv-itm-swo-debug-output-without-cube-ide-or/td-p/843611/page/3

https://www.eevblog.com/forum/microcontrollers/stlink-debugger-configures-some-32f4-target-registers-e-g-swo-trace-macrocell/msg6054105/#msg6054105

 

I am calling that function. Execution goes to this line also 

ITM->PORT[0U].u8 = (uint8_t)ch;

But, I don't get any prints. I have attached image and updated project file.

SDTAN0907_0-1759507167121.png

STM32CubeIDE Version : 1.19.0

STlink upgarde version info

SDTAN0907_1-1759507427496.png

STM32CubeMX Version : 6.15.0

 

In that case, check with a scope for data coming out of the SWO pin on the CPU.