Page 1 of 1
"chprintf" , STM32F303 Discovery
Posted: Wed Jul 26, 2017 3:19 pm
by bennydeber
Hi,
I 'm using a STM32F303 Discovery Board and I have done a project that works, but I would like to use chprintf and read the datas on terminal:
Code: Select all
for (i=0;i<=8;i++){
percentage = 500+i*1000;
chprintf(chp, "PERCENTAGE -> %d\n\r",percentage/100);
chThdSleepMilliseconds(1000);
}
I have included "chprintf.h",the port is correct and I use STLink V2 to print data on the terminal. I have to change something in the makefile?
Thank you all.
PS.
I have also tried this project (
http://www.playembedded.org/blog/en/201 ... -and-mems/) and the demo "USB_CDC", but both give me a lot of errors. As playembedded suggests, I connect the board through the User USB: at first my PC didn't recognize the device, after installing STM32 Virtual COM Port Driver, it seems to recognize it.
Re: "chprintf" , STM32F303 Discovery
Posted: Wed Jul 26, 2017 5:14 pm
by Giovanni
Hi,
chprintf() must also be included in the makefile togethr with memstream.c, see any demo that uses it.
Giovanni
Re: "chprintf" , STM32F303 Discovery
Posted: Wed Jul 26, 2017 5:26 pm
by RoccoMarco
Hi,
which version of ChibiOS are you using?
Re: "chprintf" , STM32F303 Discovery
Posted: Wed Jul 26, 2017 5:31 pm
by bennydeber
Giovanni wrote:Hi,
chprintf() must also be included in the makefile togethr with memstream.c, see any demo that uses it.
Giovanni
I have modified my makefile , but the situation doesn't change:
Code: Select all
CSRC = $(STARTUPSRC) \
$(KERNSRC) \
$(PORTSRC) \
$(OSALSRC) \
$(HALSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
$(CHIBIOS)/os/hal/lib/streams/memstreams.c \
$(CHIBIOS)/os/hal/lib/streams/chprintf.c \
main.c
RoccoMarco wrote:Hi,
which version of ChibiOS are you using?
the version is 17.7.
Re: "chprintf" , STM32F303 Discovery
Posted: Wed Jul 26, 2017 5:38 pm
by steved
There are three places in the makefile which need updating:
1. The list of included make files
2. The list of source files (which you have done)
3. The list of 'include' directories
If you are using 17.1.6, they are:
Code: Select all
1. include $(CHIBIOS)/os/hal/lib/streams/streams.mk
2. $(STREAMSSRC) \ # Adds all needed source files
3. $(STREAMSINC)
Earlier versions have similar requirements, but they may be expressed differently
Re: "chprintf" , STM32F303 Discovery
Posted: Wed Jul 26, 2017 5:40 pm
by RoccoMarco
The article has been written for 161, and inclusion was performed in a different way (as Steved said).
An error in demo from playembedded... ok it is possible. An error in USB-CDC demo is quite strange.
Can you post here the error you are receiving with USB_CDC? I will give a little try to the playembedded demo meanwhile.
Re: "chprintf" , STM32F303 Discovery
Posted: Wed Jul 26, 2017 5:57 pm
by bennydeber
RoccoMarco wrote:The article has been written for 161, and inclusion was performed in a different way (as Steved said).
An error in demo from playembedded... ok it is possible. An error in USB-CDC demo is quite strange.
Can you post here the error you are receiving with USB_CDC? I will give a little try to the playembedded demo meanwhile.
Sorry, I was wrong. USB_CDC starts, but the terminal is like this:

Re: "chprintf" , STM32F303 Discovery-RESOLVED
Posted: Thu Jul 27, 2017 3:10 pm
by bennydeber
Ok, USB_CDC works now:
I downloaded the latest version of ST-Link Utility and I did the firmware upgrade.
Now when I connect my board through USB USER and USB ST-LINK in
device manager there are two COMs:

.
The next steps are disconnect USB USER, run OpenOCD on ST-Link V2 and flash, play and select "COM7" as port in
terminal settings.
After this, I connect the second USB (in this way both usb are connected to my pc) and after I press Enter button.
Now I can choose one of the command (for example "help","exit" and so on...) and so I can see the output on the terminal
