[STM32GENERIC/HAL] SerialUSB TX speed problem

Discussions about the STM32generic core
Post Reply
User avatar
Pito
Posts: 1240
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

[STM32GENERIC/HAL] SerialUSB TX speed problem

Post by Pito » Mon Jul 17, 2017 8:15 am

This is a short sketch to demonstrate the problem, fixed by steve's patch in libmaple:

Code: Select all

// USBSERIAL TX PROBLEM DEMONSTRATION
// Pito 7/2017

#include "Arduino.h"

void setup() {
  Serial.begin(115200);
  delay(3000);
}

#define TXCHARS 10000

void loop() {
  uint32_t i;
  uint8_t x = 85;
  uint32_t elapsed = micros();

  for (i = 0; i < TXCHARS; i++) {
    Serial.write(x);
  }

  elapsed = micros() - elapsed;
  Serial.println("***");
  Serial.print("USB TX speed = ");
  Serial.print((1000.0 * TXCHARS) / elapsed, 2);
  Serial.println(" KBytes/sec");
  delay(1000);
}
With F103ZE @72MHz:
Current STM32Generic:

Code: Select all

***
USB TX speed = 1.00 KBytes/sec
Fixed libmaple by Steve:

Code: Select all

***
USB TX speed = 213.34 KBytes/sec
It seems the current version sends 1byte per USB packet (1ms packet period).
The previous libmaple gave the same number.

As Victor has demonstrated the F103 can receive 300-500kB/sec the question is whether the TX speed cannot
be even higher than 213kB/sec..
Last edited by Pito on Wed Jul 19, 2017 3:54 pm, edited 6 times in total.
Pukao Hats Cleaning Services Ltd.

stevestrong
Posts: 1327
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: [STM32GENERIC] SerialUSB TX speed problem

Post by stevestrong » Mon Jul 17, 2017 8:31 am

Pito wrote:
Mon Jul 17, 2017 8:15 am
Fixed libmaple:

Code: Select all

***
USB TX speed = 213.34 KBytes/sec
... the question is whether the TX speed cannot be even higher than 213kB/sec..
Of course it can, but for that you should use:

Code: Select all

Serial.write(buf,nr_bytes);

danieleff
Posts: 300
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: [STM32GENERIC/HAL] SerialUSB TX speed problem

Post by danieleff » Mon Jul 17, 2017 3:08 pm

A few weeks back I also added buffered USB TX, https://github.com/danieleff/STM32GENER ... 8154715833, https://github.com/danieleff/STM32GENER ... b86394c84e

Your code gives me:
USB TX speed = 308.41 KBytes/sec

User avatar
Pito
Posts: 1240
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: [STM32GENERIC/HAL] SerialUSB TX speed problem

Post by Pito » Wed Jul 19, 2017 11:10 am

Great! I will try, I updated my local on 24.6. so maybe I miss your patch..

BTW, I've compiled the test for Black F407 @168MHz under my old libmaple (patched manually with steve's patch) and I get 1013-1064kB/sec..
Last edited by Pito on Wed Jul 19, 2017 5:14 pm, edited 1 time in total.
Pukao Hats Cleaning Services Ltd.

User avatar
Pito
Posts: 1240
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: [STM32GENERIC/HAL] SerialUSB TX speed problem

Post by Pito » Wed Jul 19, 2017 11:25 am

I've replaced the cores and the system with your latest and I get (Black F407ZE @168MHz)

Code: Select all

***
USB TX speed = 64.87 KBytes/sec
Blue F013ZE @72MHz

Code: Select all

***
USB TX speed = 64.45 KBytes/sec
Update: with newest libmaple from RG repo, F103ZE @72MHz

Code: Select all

***
USB TX speed = 224.12 KBytes/sec
Update1: with newest libmaple from RG repo, F407 @168MHz

Code: Select all

***
USB TX speed = 208.22 KBytes/sec
Pukao Hats Cleaning Services Ltd.

User avatar
Pito
Posts: 1240
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: [STM32GENERIC/HAL] SerialUSB TX speed problem

Post by Pito » Fri Jul 21, 2017 7:47 am

@Daniel: what compiler version do you use? Even with your vanilla repo I cannot get more than 64kB..
Pukao Hats Cleaning Services Ltd.

danieleff
Posts: 300
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: [STM32GENERIC/HAL] SerialUSB TX speed problem

Post by danieleff » Fri Jul 21, 2017 8:12 am

I think it is 6-2017-q1-update from https://developer.arm.com/open-source/g ... /downloads, newest is 6-2017-q2-update

Also CDC_SERIAL_BUFFER_SIZE is still 128 in STM32/cores/arduino/usb/cdc/usbd_cdc_if.h , upping that might help.

User avatar
Pito
Posts: 1240
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: [STM32GENERIC/HAL] SerialUSB TX speed problem

Post by Pito » Fri Jul 21, 2017 9:25 am

Ok, with CDC_SERIAL_BUFFER_SIZE 512 I get now with F407

Code: Select all

***
USB TX speed = 260.60 KBytes/sec
The standard compiler.

With CDC_SERIAL_BUFFER_SIZE 2048 I get with F407 730-994KB/sec.

Code: Select all

***
USB TX speed = 994.73 KBytes/sec
Update: with maybe more realistic scenario - with 1mil chars sent to TeraTerm terminal (Win7)

Code: Select all

#define TXCHARS 1000000
I get with F407ZE @168MHz

Code: Select all

Buff  TX kB/sec
512    256
1024   400
2048   410
4096   420
8192   800
16k    950
28k   1060
32kB buff does not fit into F407 :?

And for F103ZE @72MHz

Code: Select all

Buff  TX kB/sec
512    256
1024   330
2048   358
4096   358
8192   358
16k does not fit..
Pukao Hats Cleaning Services Ltd.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest