2022-12-19 02:05 AM
Hello here,
I tried to use SWV for debug plotting in my project.
I have STM32F103TBU6 and ST-Link V2.
I turn on Trace Async Sw:
My clock:
In main.c I defined "stdio.h" and _write func:
/* USER CODE BEGIN 0 */
int _write(int file, char *ptr, int len) {
int i = 0;
for (i = 0; i < len; i++) {
ITM_SendChar((*ptr++));
}
return len;
}
uint8_t count = 0;
/* USER CODE END 0 */
After I made while cycle with printf:
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void) {
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_I2C1_Init();
MX_USART1_UART_Init();
MX_SPI1_Init();
/* USER CODE BEGIN 2 */
while (1) {
count++;
printf("Hi count=%d\r\n", count);
HAL_Delay(250);
}
Setting up debug:
Start debug:
STMicroelectronics ST-LINK GDB server. Version 7.0.0
Copyright (c) 2022, STMicroelectronics. All rights reserved.
Starting server with the following options:
Persistent Mode : Disabled
Logging Level : 1
Listen Port Number : 61234
Status Refresh Delay : 15s
Verbose Mode : Disabled
SWD Debug : Enabled
InitWhile : Enabled
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
-------------------------------------------------------------------
STM32CubeProgrammer v2.11.0
-------------------------------------------------------------------
Log output file: C:\Users\wooffie\AppData\Local\Temp\STM32CubeProgrammer_a09776.log
ST-LINK SN : 404219003213344A414D4E00
ST-LINK FW : V2J37S7
Board : --
Voltage : 3.23V
SWD freq : 4000 KHz
Connect mode: Under Reset
Reset mode : Hardware reset
Device ID : 0x410
Revision ID : Rev X
Device name : STM32F101/F102/F103 Medium-density
Flash size : 64 KBytes
Device type : MCU
Device CPU : Cortex-M3
BL Version : --
Memory Programming ...
Opening and parsing file: ST-LINK_GDB_server_a09776.srec
File : ST-LINK_GDB_server_a09776.srec
Size : 27.70 KB
Address : 0x08000000
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 27]
Download in Progress:
File download complete
Time elapsed during download operation: 00:00:01.754
Verifying ...
Download verified successfully
Now SWV:
Pressing "Start Trace" and resume code.
And I see nothing in SWV tabs =(
What wrong in my program?
With best regards,
Egor
Solved! Go to Solution.
2022-12-19 02:28 AM
PB3/SWO pin connectivity required.
2022-12-19 02:28 AM
PB3/SWO pin connectivity required.
2022-12-21 12:48 AM
Ogh, thank a lot. My fault...
2022-12-26 01:46 AM
This programmer should be enough for SWV trace? I can't find some more info about it :p
2022-12-26 05:17 AM
if you can solder a thin wire - just mod your old stlinkV2 :
https://lujji.github.io/blog/stlink-clone-trace/
works fine.
here statistics:
2022-12-26 05:22 AM
Yes, I will do it. But I need "plan b" if it wont work as well. As I understand in ST-Link as shown upper have SWO and JNRST pins, right? And I can use it for SWV Data Trace...
2024-02-07 09:35 PM - edited 2024-02-07 09:36 PM
how we can connect PB3/SWO pin.