USB host problem

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

USB host problem

1,091 Views
arnogir
Senior Contributor II

Hello

 

I'm facing a problem on USB stack.

Fisrt, my configuration:

K70, MQX 4.2.0.2 with usb, not usbv2

 

So when USB is plugged, like done in HVAC demo, I do following:

_io_usb_mfs_install(..)

usb_fs_ptr->DEV_FD_PTR = fopen(block_device_name, 0);

Wtih the same key, sometime return will be null, sometime return will be OK.

 

I debug on under layer:

_io_fopen -> _io_usb_mfs_open -> _io_usb_mfs_open_internal.

In this function, we wait a semaphore (_lwsem_wait_ticks(&info_ptr-> COMMAND_DONE, ...)

 

This semaphore is post in _io_usb_ctrl_callback.

 

When all work, in  io_usb_mfs_open_internal we wait COMMAND_DONE, then the _io_usb_ctrl_callback is called (from _task_build_internal/_usb_khci_task/_usb_khci_process_tr_complete_io/_usb_ctrl_callback.

 

But when not working, the function _io_usb_ctrl_callback is called before the fopen call the lwsem wait.

So the post not trig the wait semaphore...

 

To resume, if the _lwsem_post arrive before the _lwsem_wait_ticks, we will blocked!

 

Then, I use the linker file ddrdata.ld. Now if I use the sramdata.ld, all work perfectly! (file linked bellow)

I was already this problem few years ago, but finally I was seen My USB clock was bad configured to 50MHz instead of 48MHz, then at this time, USB work. Now, I again the problem and my clock is Ok!

https://community.nxp.com/message/848668?commentID=848668#comment-848668

Please could you help me for this issue?

Thank

0 Kudos
6 Replies

948 Views
arnogir
Senior Contributor II

Hello

To try debug, I activated the define

_HOST_DEBUG_

Where I never work without this define, with, USB stick work sometime (about 70% of time)

Then I attached Trace when work and not work.

It is not easy to me to understand all sublayer...

Info: when work, I copy 3 files from USB to nandflash (C:\ to a:\)

Please, thank for your help, It is very important for me, our project is in mass production!

0 Kudos

948 Views
arnogir
Senior Contributor II

5 years ago, I was facing with the same problem but on MQX 4.1.

https://community.nxp.com/message/455760?commentID=455760#comment-455760

I was coment the #define KHCICFG_4BYTE_ALIGN_FIX  ino :\Freescale\Freescale_MQX_4_1\usb\host\source\host\khci\khci.h:

Today I comment the same line, This fall work, according key, her format size, FAT32 / 16, formatted into 4Kb, 16Kb etc..

This seem random, but with that, the probability to work seem to be better, without be 100%.

In one key, 1 time is Ok, One time during the Open MFS, it generate error of Not DOS DISK. the next tie it is ok, and then next time there is the error..

:-(

Which Stack size do you advice for USB task? (I have another problem: is to get the MQX plugin for KDS...)

0 Kudos

948 Views
danielchen
NXP TechSupport
NXP TechSupport

The difference between the intflash_sramdata and the intflash_ddrflash is the location of the gloale data. With SRAM data link file, the globad data is placed in sram, including USB descriptor and buffer.

With DDR link file, usb descriptor and buffer are placed in DDR memory.

USB protocol requires very high timing restrict, from your test, DDR can not fulfill it.

Regards

Daniel

0 Kudos

948 Views
arnogir
Senior Contributor II

Hello,

If I don't make mistake, the USB Descriptor and buffer are palced into SRAM wathever we use the sramdata.ld or ddrdata.ld:

sram.ld:

ram         (RW): ORIGIN = 0x1FFF0000, LENGTH = 0x00020000  /* SRAM - RW data */
.......
.data :
    {
        . = ALIGN(128);
        _data_start = .;
        __VECTOR_TABLE_RAM_START = .;
        KEEP(*(.vectors_ram))

        . = ALIGN(512);
        __BDT_BASE = .;
        *(.usb_bdt)
        __BDT_END = .;

        *(.data*)
        . = ALIGN(4);
        __UNCACHED_DATA_START = .;
        _data_end = .;
    } > ram AT> rom

ddrdata

sram        (RW): ORIGIN = 0x1FFF0000, LENGTH = 0x00020000  /* SRAM - RW data */
....
.sram_data :
    {
        . = ALIGN(512);
        __BDT_BASE = .;
        *(.usb_bdt)
        __BDT_END = .;
        __SRAM_POOL = .;
        __UNCACHED_DATA_START = .;
    } > sram

?

Is there some other USB data ram which need to be into the SRAM which is not under section .usb_bdt ?

0 Kudos

948 Views
arnogir
Senior Contributor II

Hello

Thank for your back!

Your explanation seems perfectly plausible to me. How do you advise me to modify the "DDR" linker file in order to place only the data relating to USB in SRAM?
0 Kudos

948 Views
arnogir
Senior Contributor II

PLease find linker files!

0 Kudos