2020-03-26 03:50 AM
Hi.
NUCLEO-F303RE has STLink onboard with integrated Virtual COM port, which seems very nice solution. Sadly Virtual COM (UART2) doesn't seem to work properly while debugging session is active. I made simple app, which just prints simple string to UART2 and entering endless loop. It works fine when flashed to MCU and reset pressed. I can see my "welcome prompt" string in terminal (connected to /dev/ttyACM0). But if I start debug session with openOCD ("serial wire" debug option) it outputs some garbage to terminal instead of "welcome prompt". Debugging itself works fine. After stopping openocd session and resetting, Virtual COM port works fine again.
Tried to minimize baud rate to 9600bps - it doesn't helps.
So, is this a known limitation of STLink with integrated Virtual COM port? Am I doing something wong here? Is there any workaround?
Of course I can use separate USB-UART converter and pretty sure it's going to work, but I'd prefer to minimize number of devices and wires if possible.
2020-03-26 06:06 AM
I've used the VCP interface while debugging on a large number of STM32F4 and STM32H7 boards and it's always worked great. Both ST-Link V2, ST-Link V2/1 and ST-Link V3. This is with OpenOCD. Just a data point.
2020-03-26 11:04 AM
Could it be that your debugging session startup script sets/changes some clock setting that your code doesn't touch and this messes the UART baud rate? If you have a scope, look at the UART2 TX line in both cases and see if the bit rate is what you expect. Like @TDK I've used the VCP on the STLink with no issues on many different boards, though granted not with an F3xx CPU.
2020-03-26 11:15 AM
>>So, is this a known limitation of STLink with integrated Virtual COM port?
Works fine in Windows with Keil, so assuming it's your OS or drivers, and perhaps some semaphore, mutex or ownership of resources there.
2020-03-26 12:45 PM
I've seen something similar, but on a different MCU. A few things to try:
2020-03-26 02:00 PM
Today investigated the issue more. Found out culprit and workarounds. The cuprit seems to be an openOCD. I'm not sure if this is the cause, but there are some warnings at startup about clock:
/opt/stm32/openocd/bin/openocd -c "tcl_port disabled" -s /opt/stm32/openocd/share/openocd/scripts -c "gdb_port 3333" -c "telnet_port 4444" -f board/st_nucleo_f3.cfg -c "program \"/home/kotnia/projects/rotenc_stm32/cmake-build-debug-stm32_gcc8/rotenc_stm32.elf\"" -c "init;reset init;"
Open On-Chip Debugger 0.10.0+dev-00925-g0819541 (2019-08-31-22:04)
Info : clock speed 1000 kHz
Info : STLINK V2J36M26 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.257255
Info : stm32f3x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
What is interesting is VCP starts to work correctly after second reset. So first workaround would be:
While being acceptable it's not very convenient. So I decided better solution would be to use ST-gdbserver, which may be found in stm32CubeIDE package (thanks to @Panometric for the advice). ST-gdbserver works just fine and quite convenient to use with my IDE.
Thanks everyone who tried to help!
p.s.
I was too lazy to experiment with UART clock. Sorry.
2020-03-26 02:17 PM
I also have virtual COM port of ST-LINK V2-1 on STM32F769I-DISCO and NUCLEO-F767ZI working simultaneously with the debugger up to at least 921'600 bps without problems. Also I've done that with both firmwares - the original one and J-Link OB conversion.
It could still be your UART and/or other code on MCU...
2020-07-01 03:17 AM
I have the same issue.... I think it is related with some recent changes in st-link firmware.
Indeed, I use the Nucleo F103 with VCP in many contexts since years (and "student-proof" contexts!... which is.... instructive ^^).
Recently, the VCP is sometimes impossible to open...
Some serial-terminal-software indicates the port is still in use.
I investigated and found this:
So the problem seems appear when datas are send to the "ST-link-f103" during openocd is running on the host.
My context: OpenWorkbenchForSTM32 (using OpenOCD+GDB) + external serial terminal.
I guess this problem is appears recently in the ST-Link firmware.
Sorry... my "answer" is not relly an answer... but it could help to focus (/correct?) this f**ing problem!
2020-07-01 04:23 AM
i've hae had a similar problem, but with simulink in PiL mode. try to disconnect the sw4stm32, or in general eclipse, before you start to flash the program.on the stm. Only after, open your preferite terminal.
2020-11-25 11:26 AM
I've had the same issues - any solution?