<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Blocked in an infinite loop in lpcusblib_MassStorageHost example in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Blocked-in-an-infinite-loop-in-lpcusblib-MassStorageHost-example/m-p/582540#M20689</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by silvenebu on Thu Jun 18 00:46:31 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hey guys,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I work for a project with an LPC1768 and LPCOpen V2.10.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I use the MassStorageHost example and Freertos V8.2.1 to build an USB Mass storage HOST.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;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).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think it's because the USB_Host_DeEnumerate ISR close all the pipe when the device is unattached.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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. ? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If not it would be a good idea to change this in the next release.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your help&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Best Regards &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 20:23:50 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T20:23:50Z</dc:date>
    <item>
      <title>Blocked in an infinite loop in lpcusblib_MassStorageHost example</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Blocked-in-an-infinite-loop-in-lpcusblib-MassStorageHost-example/m-p/582540#M20689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by silvenebu on Thu Jun 18 00:46:31 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hey guys,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I work for a project with an LPC1768 and LPCOpen V2.10.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I use the MassStorageHost example and Freertos V8.2.1 to build an USB Mass storage HOST.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;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).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think it's because the USB_Host_DeEnumerate ISR close all the pipe when the device is unattached.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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. ? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If not it would be a good idea to change this in the next release.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your help&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Best Regards &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:23:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Blocked-in-an-infinite-loop-in-lpcusblib-MassStorageHost-example/m-p/582540#M20689</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Blocked in an infinite loop in lpcusblib_MassStorageHost example</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Blocked-in-an-infinite-loop-in-lpcusblib-MassStorageHost-example/m-p/582541#M20690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by pnhnkvr on Thu Jun 18 02:48:48 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hey,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;It seems to me that the lpcusblib is not that stable (apparently it is not supported &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.lpcware.com%2Fcontent%2Fforum%2Flpcusblib-usbd-library-confusion" rel="nofollow" target="_blank"&gt;http://www.lpcware.com/content/forum/lpcusblib-usbd-library-confusion&lt;/A&gt;&lt;SPAN&gt;). Just a heads up. I know there are not many other free USB host stack for NXP mcus.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Related to your problem. Instead of&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;I&gt;while(!Pipe_IsStatusOK(portnum)) //(Line 331 MassStorageClassHost.c) &lt;/I&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;you should have&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;I&gt;while (!(Pipe_IsOUTReady(portnum)))&amp;nbsp; //(Line 306 MassStorageClassHost.c) &lt;BR /&gt;{&lt;BR /&gt;if (USB_HostState[portnum] == HOST_STATE_Unattached)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return PIPE_RWSTREAM_DeviceDisconnected;&lt;BR /&gt;}&lt;/I&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The correct code is for&amp;nbsp; LPC177X_8X or LPC407X_8X, so you have to check that the USB_HostState[portnum] will be updated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ps. For additional heads up. I had a huge headache with write operation - more precisely in the &lt;/SPAN&gt;&lt;I&gt;MS_Host_SendCommand() //(Line 173 MassStorageClassHost.c) &lt;/I&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are trying to write (&lt;/SPAN&gt;&lt;I&gt;SCSI_CMD_WRITE_10&lt;/I&gt;&lt;SPAN&gt;) more than the stack can fit in endpoint's buffer (see &lt;/SPAN&gt;&lt;I&gt;PipeInfo&lt;/I&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;I&gt;BufferSize&lt;/I&gt;&lt;SPAN&gt;, it will discard excessive bytes, i.e. does not write the excessive bytes the mass storage.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:23:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Blocked-in-an-infinite-loop-in-lpcusblib-MassStorageHost-example/m-p/582541#M20690</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Blocked in an infinite loop in lpcusblib_MassStorageHost example</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Blocked-in-an-infinite-loop-in-lpcusblib-MassStorageHost-example/m-p/582542#M20691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by silvenebu on Fri Jun 19 01:33:38 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks to you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;your solution works perfectly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As you have specified for the moment the new lib USBD doesn't support the USB HOST.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So meanwhile we use LPCUSB Lib.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for advice and warnings.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:23:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Blocked-in-an-infinite-loop-in-lpcusblib-MassStorageHost-example/m-p/582542#M20691</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:23:51Z</dc:date>
    </item>
  </channel>
</rss>

