Page 1 of 1

Serial over USB - printf() on F407

Posted: Sat Jan 25, 2020 7:56 pm
by Pito
Hi STM Core experts,
I've been trying to start with the STM core..

Build the Whetstone benchmark, with SerialUSB.begin(115200); and using printf(..).

The Arduino 1.8.11 IDE and 1.8.0 STM core installed today.
I do program the BlackF407 via J-link, SWD, it flashes ok (from 0x8000000).

My serial setting is - see below. Not sure how to setup it..
I cannot get a single output from the serial, it connects to TeraTerm as COM20 (STM CDC driver, works with BluePill fine) but nothing happens.
.
F407 setting.PNG
F407 setting.PNG (67.72 KiB) Viewed 10793 times

Re: Serial over USB on F407

Posted: Sat Jan 25, 2020 8:01 pm
by BennehBoy
Have you tried just print? I think there's a recent pr which allows printf to work on the CDC serial, but unless you use the repo version then it's not available. Unless my memory is failing me (again!)

See here -> https://github.com/stm32duino/Arduino_C ... 2/pull/867

Re: Serial over USB on F407

Posted: Sat Jan 25, 2020 8:05 pm
by Pito

Code: Select all

void setup() {

  delay(3000);
  SerialUSB.begin(115200);
  SerialUSB.println("Hello Whetstone benchmark!!");

  int count = 10, calibrate = 1;
  long xtra = 1;
  int section;
this works..

Re: Serial over USB - printf() on F407

Posted: Sat Jan 25, 2020 8:20 pm
by Pito
I've patched manually the Print.cpp lines 199-220, restarted arduino ide, built, flashed, and it works..

Code: Select all

##########################################
Single Precision C Whetstone Benchmark
Calibrate
       0.14 Seconds          1   Passes (x 100)
       0.71 Seconds          5   Passes (x 100)
       3.53 Seconds         25   Passes (x 100)

Use 70  passes (x 100)

          Single Precision C/C++ Whetstone Benchmark
Loop content                  Result              MFLOPS      MOPS   Seconds

N1 floating point     -1.12475013732910156        79.059              0.017
N2 floating point     -1.12274742126464844        57.366              0.164
N3 if then else        1.00000000000000000                  84.244    0.086
N4 fixed point        12.00000000000000000                 250.569    0.088
N5 sin,cos etc.        0.49909299612045288                   1.318    4.420
N6 floating point      0.99999982118606567        15.746              2.398
N7 assignments         3.00000000000000000                  13.617    0.950
N8 exp,sqrt etc.       0.75110614299774170                   1.489    1.749

MWIPS                                             70.908              9.872

Re: Serial over USB - printf() on F407

Posted: Sun Jan 26, 2020 9:03 am
by BennehBoy
:D

Re: Serial over USB - printf() on F407

Posted: Sun Jan 26, 2020 9:47 am
by Pito
Not sure what was actually wrong.. Might be I messed up something, first time with STM core and not using Arduino IDE for ages..
:ugeek:

Re: Serial over USB - printf() on F407

Posted: Sun Jan 26, 2020 10:08 am
by fpiSTM
that is normal.
printf() on 1.8 print only on an U(S)ART.
Originally, it was used only for debug purpose.
It has been extended to be able to use printf with the class Print but I didn't manage to use it with SerialUSB.
So, it was fixed here: https://github.com/stm32duino/Arduino_C ... e10280278f
It is available in the master and will be available in the next release thanks the boards manager..

Re: Serial over USB - printf() on F407

Posted: Sun Jan 26, 2020 11:04 am
by Pito
Thanks!
We have got plethora of flash in F4xx, no problem with printf!!