Serial over USB - printf() on F407

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
User avatar
Pito
Posts: 94
Joined: Tue Dec 24, 2019 1:53 pm

Serial over USB - printf() on F407

Post 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 8019 times
Last edited by Pito on Sat Jan 25, 2020 8:23 pm, edited 1 time in total.
Pukao Hats Cleaning Services Ltd.
BennehBoy
Posts: 135
Joined: Sat Jan 04, 2020 2:38 am
Answers: 1

Re: Serial over USB on F407

Post 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
User avatar
Pito
Posts: 94
Joined: Tue Dec 24, 2019 1:53 pm

Re: Serial over USB on F407

Post 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..
Pukao Hats Cleaning Services Ltd.
User avatar
Pito
Posts: 94
Joined: Tue Dec 24, 2019 1:53 pm

Re: Serial over USB - printf() on F407

Post 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
Pukao Hats Cleaning Services Ltd.
BennehBoy
Posts: 135
Joined: Sat Jan 04, 2020 2:38 am
Answers: 1

Re: Serial over USB - printf() on F407

Post by BennehBoy »

:D
User avatar
Pito
Posts: 94
Joined: Tue Dec 24, 2019 1:53 pm

Re: Serial over USB - printf() on F407

Post 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:
Pukao Hats Cleaning Services Ltd.
User avatar
fpiSTM
Posts: 1746
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Serial over USB - printf() on F407

Post 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..
User avatar
Pito
Posts: 94
Joined: Tue Dec 24, 2019 1:53 pm

Re: Serial over USB - printf() on F407

Post by Pito »

Thanks!
We have got plethora of flash in F4xx, no problem with printf!!
Pukao Hats Cleaning Services Ltd.
Post Reply

Return to “General discussion”