Blocked in an infinite loop in lpcusblib_MassStorageHost example

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

Blocked in an infinite loop in lpcusblib_MassStorageHost example

440 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by silvenebu on Thu Jun 18 00:46:31 MST 2015
Hey guys,
I work for a project with an LPC1768 and LPCOpen V2.10.
I use the MassStorageHost example and Freertos V8.2.1 to build an USB Mass storage HOST.
All works fine in a normal use. But I have made test for different "not normal" device removal because I must ensure that the aplication not crash when someone remove the USB Key before the end of the USB Task.
And i have noticed that if the key is unattached when the task has finished to enumerate the key and executes "MS_Host_RequestSense", in the EVENT_USB_Host_DeviceEnumerationComplete, the task is blocked in an infinite loop : "while(!Pipe_IsStatusOK(portnum))" (Line 331 MassStorageClassHost.c).
I think it's because the USB_Host_DeEnumerate ISR close all the pipe when the device is unattached.

Do you know if there is a proper way for prevent this trouble when device is removed before the end of the task without change the files of LPCUSB Lib. ?
If not it would be a good idea to change this in the next release.

Thank you for your help
Best Regards
Labels (1)
0 Kudos
2 Replies

357 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by silvenebu on Fri Jun 19 01:33:38 MST 2015
Many thanks to you,
your solution works perfectly.
As you have specified for the moment the new lib USBD doesn't support the USB HOST.
So meanwhile we use LPCUSB Lib.
Thanks for advice and warnings.
0 Kudos

357 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pnhnkvr on Thu Jun 18 02:48:48 MST 2015
Hey,

It seems to me that the lpcusblib is not that stable (apparently it is not supported http://www.lpcware.com/content/forum/lpcusblib-usbd-library-confusion). Just a heads up. I know there are not many other free USB host stack for NXP mcus.

Related to your problem. Instead of 

while(!Pipe_IsStatusOK(portnum)) //(Line 331 MassStorageClassHost.c)

you should have

while (!(Pipe_IsOUTReady(portnum)))  //(Line 306 MassStorageClassHost.c)
{
if (USB_HostState[portnum] == HOST_STATE_Unattached)
       return PIPE_RWSTREAM_DeviceDisconnected;
}


The correct code is for  LPC177X_8X or LPC407X_8X, so you have to check that the USB_HostState[portnum] will be updated.

Ps. For additional heads up. I had a huge headache with write operation - more precisely in the MS_Host_SendCommand() //(Line 173 MassStorageClassHost.c)
If you are trying to write (SCSI_CMD_WRITE_10) more than the stack can fit in endpoint's buffer (see PipeInfo and BufferSize, it will discard excessive bytes, i.e. does not write the excessive bytes the mass storage.
0 Kudos