2023-05-19 05:48 AM
Hi!
So i am new to this STM32 family. I purchased a blackpill with STM32F401CCU6. I am trying to get the printf working on it. I followed multiple resources to get it working which included the ITM Data Trace, OpenOCD semihosting, UART, etc. Some changed the clock frequency some set it to the default. It is very confusing for me. I am currently stuck in getting the printf working. Is my choice wrong to use the blackpill as my first STM? I tried in rust and it is working fine I didnt setup OpenOCD and all but used the "defmt" crate to output messages. In C the blinky code is working properly but I need receive the data from the STM32. If STM doesnt have a printf then any equivalent function could also be fine. I just want to be able to get debug messages.
In openocd I am getting the following error
Error in final launch sequence:
Failed to execute MI command:
load C:\\Users\\kanak\\STM32CubeIDE\\workspace_1.12.0\\hello_world_semihosting\\Debug\\hello_world_semihosting.elf
Error message from debugger back end:
Error erasing flash with vFlashErase packet
Failed to execute MI command:
load C:\\Users\\kanak\\STM32CubeIDE\\workspace_1.12.0\\hello_world_semihosting\\Debug\\hello_world_semihosting.elf
Error message from debugger back end:
Error erasing flash with vFlashErase packet
Failed to execute MI command:
load C:\\Users\\kanak\\STM32CubeIDE\\workspace_1.12.0\\hello_world_semihosting\\Debug\\hello_world_semihosting.elf
Error message from debugger back end:
Error erasing flash with vFlashErase packet
Error erasing flash with vFlashErase packet
Thanks!
2023-05-19 06:22 AM
A NUCLEO or DISCO board would perhaps have been a better choice, with SWD and USART prewired correctly, and ST-LINK/2-1 integrated
ITM_SendChar() expects SWO/PB3 plumbed, and that the ST-LINK and MCU agree about what speeds things are running, so the "baud" rate of the connection can be appropriately set.
Test the USART / SWO functionality independently of the printf() / puts(), if it doesn't work at the most basic level, it's not going to work when you layer more complexity on top.
2023-05-19 10:44 PM
I am able to get the output using USART by connecting a serial cable. Is there any way to use the ST-Link to do the printf() instead of any other adapter?