Page 1 of 1

Stm32duino Blue Pill STlink and IDE serial monitor ?

Posted: Thu Feb 13, 2020 9:52 am
by jmf11
Hello,

I'm playing with a Blue Pill, configured with a ST-Link (the one embedded in another nucleo board). I succeeded to download and have working the Blinky example.

I wonder if this config allows to use the Arduino IDE serial monitor window, back through the ST-Link connection (on the dedicated blue pill connector). My first understanding is NO, but I have read some sentences on the net that make me think that it could be not that clear.

Purpose would be simple debugging "Arduino like", with prinf to the IDE serial monitor.

This seems to be the best place to ask the question :-)

Best regards,

JMF

Re: Stm32duino Blue Pill STlink and IDE serial monitor ?

Posted: Thu Feb 13, 2020 7:25 pm
by jmf11
Hello,

I had thought that my question above would call an easy and fast answer. Seems that it is not exactly the case.

Is my question not clear ? or does not make sense ? I had in mind that writing from arduino boards to the IDE serial console was a sort of must have...

My previous experience is with CubeMX and the ST environment. I have only little experience with Arduino and its IDE.

Best regards,

JMF

Re: Stm32duino Blue Pill STlink and IDE serial monitor ?

Posted: Fri Feb 14, 2020 12:52 am
by hobbya
The STlink on the nucleo board can emulate a virtual com port which can be connected to the serial port of your bluepill.

Re: Stm32duino Blue Pill STlink and IDE serial monitor ?

Posted: Fri Feb 14, 2020 4:02 am
by ag123
for an st-link, you can literally debug away as it is swd. otherwise, normally serial is accessible as usb serial available in both official core and libmaple core. i.e. connect usb, Serial.print() outputs to the serial monitor

to use st-link for serial printing i think you may need swo, that isn't quite often done (so far no one has reported trying it here), but i think it can be done.
libmaple don't have it supported in the core i think. i'm not sure about official core for swo use,but it may be available in the cmsis library linked. i think it is a different api from Serial.print() as well.

the original st-link v2 probably has a serial com port in it, but based on the documents it apparently requires connecting to a uart port on the board (e.g. PA9, PA10)
https://www.st.com/resource/en/applicat ... 354244.pdf

to an extent using a st-link serial uart for debugging is the same as if you use another usb-serial (uart) dongle to connect to the uart port. debug can then be achieved quite easily by printing to the uart serial port e.g. Serial1 (pa9, pa10) in libmaple that is. i've not tested it on official core.

if you are using libmaple core as well, thiere is an example sketch which can turn another stm32f103 (e.g. pill / maple mini) board into a usb-serial dongle.
https://github.com/rogerclarkmelbourne/ ... -w-signals
you may want to deactivate the esp8266 command processor as shown in the readme
https://github.com/rogerclarkmelbourne/ ... -over-uart

it is possible to have both core official + libmaple co-exist in the Arduino IDE

Re: Stm32duino Blue Pill STlink and IDE serial monitor ?

Posted: Fri Feb 14, 2020 6:33 am
by fpiSTM
Well, it is possible but this will require some config and use of an extra pin usage (SWO PB3). You will have to use semihosting
https://www.st.com/content/ccc/resource ... 354244.pdf
SWO.png
SWO.png (19.3 KiB) Viewed 8065 times
Some read:
https://www.openstm32.org/forumthread2893
https://wiki.dlang.org/Minimal_semihost ... o_World%22

I never tested.
Your best bet is to use Serial over USB or an Hardware Serial as suggested by ag123

Re: Stm32duino Blue Pill STlink and IDE serial monitor ?

Posted: Fri Feb 14, 2020 8:13 am
by jmf11
Thanks all to have clarified the thing a lot for me.

I understand (which was my main, possibly stupid, question) that this is not possible through the SWD wire. So can't serial.print to the PC and IDE through the blue pill end "ST-Link" connector.

But I understand I should be able to easily serial.print to the PC by just connecting the blue pill USB to the PC.

Will try this WE.

Thanks for this help.

Best regards,

JM

Re: Stm32duino Blue Pill STlink and IDE serial monitor ?

Posted: Fri Feb 14, 2020 6:46 pm
by jmf11
Works ! Thanks to have helped.

Config is:
- power from the Blue Pill USB
- use ST-ling to load the program, using the dedicated connector for SWD/SWCLK
- IDE configured with
- USART support: Disabled (no serial support)
- USB support CDC (generic serial supersede USART)
- ST-Link on COM1
- Blue Pill USB appears as COM3

=> I can Serial.print to the monitor.

Strange thing is that in the IDE, the same COM3 appears many times in the drop down menu. One seems added each time I reset the Blue Pill. Looks strange, but maybe normal.

Best Regards,

JMF