cancel
Showing results for 
Search instead for 
Did you mean: 

Use Serial Wire Viewer on Cube Programmer for STM32 F405 Feather

vs13
Associate III
I want to read the serial output from the STM32 F405 Feather using the SWV on Cube Programmer, but I do not receive Serial output from the board. I am running the .hex file from this Arduino sketch on the board:

 

#include <SWOStream.h>
SWOStream s(2000000, SWO_Async, 0, false); //swoEnable = false

void setup() {
  delay(150);
}

void loop() {
  s.print("Serial is alive!");
  delay(500);
}

 

I have searched through the board documentation over and over and I can't find what clock frequency to use in my program and in the SWV terminal on Cube Programmer, so if anyone could point me in the right direction, it would be appreciated!
1 ACCEPTED SOLUTION

Accepted Solutions

That looks just like the cheap chinese ones. I know because I had one and to avoid the risk of damaging it during  modding, I just spent a few bucks and got a better quality one which just worked.  Are you sure you bought that from ST?

 

https://www.eevblog.com/forum/microcontrollers/quick-hack-to-get-swo-on-st-link-clones/

 

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.

View solution in original post

13 REPLIES 13

It needs to know the speed your MCU is clocking and the speed the SWCLK is clocking.

Here it's assuming 2 MHz, going to depend on the settings you have in STM32 Cube Programmer

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III

@vs13 To see SWO output you don't need any sketches etc. The debugger or CubeProgrammer will set up the SWO automatically. All it needs to know is the SystemCoreClock value. Just provide it the value, call ITM_SendChar (or redirect printf to SWO) and enjoy.

 


@Pavel A. wrote:

All it needs to know is the SystemCoreClock value. Just provide it the value, call ITM_SendChar (or redirect printf to SWO) and enjoy.

 


I can't find the SystemCoreClock value of this board anywhere in its documentation. Do you know where I could look for it?


@Tesla DeLorean wrote:

It needs to know the speed your MCU is clocking and the speed the SWCLK is clocking.

Here it's assuming 2 MHz, going to depend on the settings you have in STM32 Cube Programmer


There is a clock speed of 168 MHz printed on the board that I've just changed the code and my settings to use, but I'm still not getting the output that I expect. I've attached my settings.

It should be a variable in your system all the same, but the SWOStream implementation has it as a default parameter in any case

https://github.com/koendv/SerialWireOutput/blob/master/SWOStream.h#L29

Typically the Debug Pod sets the baud rate knowing the connection speed it has with the device, and the MCU clock it's dividing down to meet that.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

You need a Debugger Pod like an ST-LINK or J-LINK to connect to the SWD Debugging ports, and SWV Serial channel.

You can't manifest this via the USB DFU connection.

You'd want to attach a 10-pin debug header to the board to facilitate an SWD connection

f405_swd_debug_header.jpg

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
BarryWhit
Lead II

Just to be sure : 

1. Are you using an ST-LINK (or clone) which provides an external SWO pin? the most common cheap chinese knock-off ones do not, unless you physicall mod them (cut a trace, run a jumper wire from the chip to the connector).

2. If your ST-LINK support the SWO pin, did you connect the SWO pin on your board to the appropriate pin on your ST-LINK? The SWO ping is not needed for debug/programming, but SWO is required for using the SWV facilities in CubeIDE.

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.

@BarryWhit wrote:

Just to be sure : 

1. Are you using an ST-LINK (or clone) which supports SWO, the most common cheap chinese knock-off ones do not support SWO out of the box, unless you install some jumper wires.

2. Did you connect the SWO pin on your board to the appropriate pin on your ST-LINK? This is a third optional debug pin, needed specifically for SWV.


I've attached a picture of my ST-Link. It should be genuine as I bought it through ST's website, but I don't see a SWO pin on the ST-Link or my STM32F405. 

That looks just like the cheap chinese ones. I know because I had one and to avoid the risk of damaging it during  modding, I just spent a few bucks and got a better quality one which just worked.  Are you sure you bought that from ST?

 

https://www.eevblog.com/forum/microcontrollers/quick-hack-to-get-swo-on-st-link-clones/

 

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.