USB transfers slower with MQX 4.2 vs. MQX4.0

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

USB transfers slower with MQX 4.2 vs. MQX4.0

1,801 Views
mattvario
Contributor I

I recently switch to MQX 4.2 from MQX 4.0 and the USB transfers have slowed considerably.

I modified MQX 4.0 per this link: https://community.freescale.com/thread/320155?q=usb%20transfer , which is changing delay_const in khci.c and USBCFG_DEFAULT_MAX_NAK_COUNT in host_cnfg.h. This sped up the USB transfers. I also did this with MQX 4.2 but it is much slower than 4.0.

I used _time_get_ticks to measure the time to open, write and close files on the USB with the following results:

                  

MQX            4.0          4.2

File open:     70 ms      80 ms

File write:     350 ms    1270 ms

File close:    0 ms        50 ms

How can I modify MQX 4.2 to perform as MQX 4.0 does?

Thanks,

Matt Housey

Labels (1)
0 Kudos
12 Replies

1,169 Views
isaacavila
NXP Employee
NXP Employee

Hello Matt,

Just for your reference, MQX 4.2.0.2 Patch has fixed the issue on USB transfer speed for MQX 4.2 (MQX-5644). You can give a look to this patch: MQX™ Classic Software Solutions|NXP

I hope this can help!

Regards,

Isaac

0 Kudos

1,169 Views
isaacavila
NXP Employee
NXP Employee

Hello Matt,

After an exhausting search for this issue, we could finally identify the root cause for this issue:

The performance drop is caused by the delay when NAK occurs in _usb_khci_atom_tr

case 0x0a: // NAK

res = KHCI_ATOM_TR_NAK;

if (retry)

_time_delay(delay_const * (pipe_desc_ptr->G.NAK_COUNT - retry));

break;

This NAK will occur when the host send out the request when the USB sticks is not ready to handle the request yet. So it depends on the interval of host sending the request and how fast the USB stick can handle the request.

The interval of host sending the request is different on MQX 4.0 and MQX 4.2; the interval of MQX 4.2 is small than MQX 4.0, so for some USB stick, it can handle the request so fast then it replies a NAK. And once the NAK occurs, the _time_delay would cause a huge delay before next transfer could begin, then thoughput drops a lot.

Actually both MQX 4.0 and MQX 4.2 have the same issue, but the NAK occurs more frequent on MQX 4.2 than MQX 4.0. That's why MQX 4.0 seems to have better performance than MQX 4.2.

You can remove this _time_delay and set USBCFG_DEFAULT_MAX_NAK_COUNT to (3000) to avoid such a huge delay to improve the performance on both MQX 4.0 and MQX 4.2.

In summary, comment the line _time_delay(delay_cont * (pipe_desc_ptr->G.NAK_COUNT - retry)); in khci.c file and also modify in usb_cnfg.h file tje USBCFG_DEFAULT_MAX_NAK_COUNT to 3000 instead of 150.

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

1,169 Views
isaacavila
NXP Employee
NXP Employee

Hi Matt,

I will contact MQX's development team and ask them about it. Could you please mention which MCU you are using?

Best Regards,

Isaac

0 Kudos

1,169 Views
mattvario
Contributor I

Hi Isaac,

I'm using the K70. I appreciate your efforts in contacting the MQX team, I am under a deadline and would like to get this resolved as soon as possible.

Thanks,

Matt

0 Kudos

1,169 Views
isaacavila
NXP Employee
NXP Employee

Hi Matt,

I am already in touch with an Engineer that could help me to solve this, but he needs to know what kind of application you are doing and MQX's USB Stack you are using (There are two stacks, USB and USBv2).

I suppose your are using TWR-K70F120M with Host USB stack. That could mean that you are using USB Stack (Version One). Could you please corroborate this? If you have any question on how to know which USB Stack version you are using please see figure below:

USB Stack.jpg

Best Regards,

Isaac Avila

0 Kudos

1,169 Views
mattvario
Contributor I

Isaac,

I am using the USB Host Stack (Version 1). In 2011 I started development TWR-K70F120M until our hardware was built. The operation that I am doing is transfering files (less than 250k per file) from an SD card to a USB. This may be more than you are asking for, but here is a link to our product: http://reganscientific.com/bot3000e%20sales.htm.

Thanks,

Matt

0 Kudos

1,169 Views
isaacavila
NXP Employee
NXP Employee

Hi Matt,

I apologize for all these questions about your test, but this information was required for MQX team' member.

He is trying to reproduce same results as yours and he wants to avoid misunderstanding on this.

USB stack for K70 supports either Full Speed and High Speed, would you please confirm the one used? Also it should be good for us if you attach some code used on your test (or a project, in case you consider it to be confidential, you can open a service request on: New Service Request and this issue will be treated confidentially)

Once it is done, you also can tell us used IDE.

Sorry for this inconvenience, but we try to get same results as you and find the root cause of it.

Regards,

Isaac Avila

0 Kudos

1,169 Views
mattvario
Contributor I

Isaac,

I am using IAR Embedded Workbench. Also, I am using Full Speed for the USB Stack, however, it appears that the issue is related to the call to write the file to the USB is giving up control of the processor (i.e. - calling _time_delay or some other task blocking call) and that is slowing down things down considerably. The time it takes to write files is nowhere near Full Speed.

How do I create a confidential Service Request? Please send a link or description and I will send some code.

Thanks,

Matt

0 Kudos

1,169 Views
isaacavila
NXP Employee
NXP Employee

Hi Matt,

Link was not updated on previous reply, so here you have the link and follow the process for creating the service request.

New Service Request

If you have any doubt, please let me know it.

Isaac Avila

0 Kudos

1,169 Views
mattvario
Contributor I

Isaac,

I made a service request which included some source files. Please let me know that you received it.

Thanks,

Matt

0 Kudos

1,169 Views
isaacavila
NXP Employee
NXP Employee

Hi Matt,

I already received it, We will be in touch through that service request.

Regards,

Isaac

0 Kudos

1,169 Views
isaacavila
NXP Employee
NXP Employee

Matt,

Thanks alot for your information, I will take this information so we could find solution to your problem. As soon as I got an update, i would inform you about it.

Regards,

Isaac

0 Kudos