USB CDC HOST SPEED KL26

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB CDC HOST SPEED KL26

1,113 Views
matteodavanzo
Contributor II

Hi everybody,

I'm working with Freescale usb stack 4.1.1.

My setup is the following: one FDRMKL25Z that acts as CDC device and one FDRMKL26Z that acts as CDC host.

My test is very simple. I send 1 Mbyte of data in both direction and i misure the speed of the link.

At the moment i can achieve only 47 KByte/s and for my purposes this speed is too low.

Working with the CDC device connected to the PC i can achieve up to 300 KByte/s. So my opinion is that something on the usb host stack is not working properly.I see that the host stack spend a lot of time in the _usb_khci_task function and i don't understand why.

My program doesn't do anything else, it just send/receive data.

Any ideas?

Best regards,

Matteo Davanzo

Labels (2)
0 Kudos
5 Replies

730 Views
isaacavila
NXP Employee
NXP Employee

Hello Matteo,

What you are probably facing is the fact that when USB Device is not ready for sending data and "NAK" these transactions, USB Host does implement a delay in order to wait until device is ready for any further transaction.

There is a macro definition that defines the maximum quantity of NAKs received from device before implementing the delay. You can modify this macro to a higher NAK value and also reduce the delay size.

Please, do next changes:

  • In khci_kinetis.c file, locate _usb_khci_atom_tr function and modify int_32 delay_const variable to 1 instead of 10. (Line 223)
  • In host_cnfg.h file, locate USBCFG_DEFAULT_MAX_NAK_COUNT macro and modify it to 150 instead of 15. (Line 67)

Recompile the project and now it should be faster than before. For more information please see this post: https://community.freescale.com/thread/320155?q=usb%20transfer

I hope this can help you.

Best Regards,

Isaac

----------------------------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

----------------------------------------------------------------------------------------------------------------------------------------

0 Kudos

730 Views
matteodavanzo
Contributor II

Hi Isaac,

Thanks for the answer.

I've already do that, in my case i've completely removed the delay when a NAK occours and i've seen an improvement but not as big as i hope (47 KB/s).

I decided to move to the kinetis SKDS 1.3.0 and i've implemented a similar test. I can reach a throughput of 300 KB/s but what i've noticed is that it depends a lot from the size of the send from the device (on it i'm using stack 4.1.1) and from the expected size at the host in the receive function.

I also don't want to use the OSA layer because in my project purposes i'm not going to use an OS. Is there a simple way to avoid the OSA layer?

Thanks in advance,

best regards.

Matteo

0 Kudos

730 Views
isaacavila
NXP Employee
NXP Employee

Hello Matteo,

In fact, the OSA Layer is an abstraction for different available OS such as MQX, FreeRTOS, uCOSII and Baremetal as well, so you do not need to remove this layer due it adapts to the OS you are using (even if you decide to use baremetal). You can check that for baremetal examples OSA layer is still used and projects works well.

I hope this can help you,

Best Regards,

Isaac

730 Views
matteodavanzo
Contributor II

Hi Isaac,

Thanks for the answer.

Right, at the moment in my project i'm using the OSA and it works fine. My question was because in fact i'm trying to reduce as much as possible the RAM occupation and i've seen that the OSA makes a lot of memory allocation.

Thanks for your help

Best regards,

Matteo

0 Kudos

730 Views
mjbcswitzerland
Specialist V

Hello Matteo

I haven't done much work with USB-CDC host just yet (and see some optimisation possibilities) but using the uTasker stack and two FRDM-K64Fs connected as host/device I am seeing around 800kBytes/s rates in both directions (400kBytes/s when there is data transmission in both directions at the same time).

It is possibly a little slower for KL26 but I am wondering how you are allocating bandwidth in your case, since this is controlled by the host.

For example, I have seen that you may be using NAK interrupts to the host's IN polling, whereby I think that it is much more efficient to allow the host to continuously send IN tokens when it doesn't have anything to do.

When the host sends a lot of data (large block/burst) it should also reserve some bandwidth for the device rather than using up all for itself, so that the data throughput in both directions is symmetrical (when continuous in both directions). How does your system manage this?

Regards

Mark

0 Kudos