AnsweredAssumed Answered

USB host problem

Question asked by arnogir on Jan 16, 2020
Latest reply on Jan 31, 2020 by arnogir



I'm facing a problem on USB stack.

Fisrt, my configuration:

K70, MQX with usb, not usbv2


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


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!


Please could you help me for this issue?