<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Do you the mistake in my USB descriptor?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/43370/do-you-the-mistake-in-my-usb-descriptor</link><description> 
Hello, 
I am trying to add a second MSC interface to my USB device, but
despite that the second interface is identified by Windows, I get a
problem notification (the respective endpoint is never addressed). I
just don&amp;#39;t see what&amp;#39;s wrong. Do you? Thanks</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Do you the mistake in my USB descriptor?</title><link>https://community.arm.com/thread/133387?ContentTypeID=1</link><pubDate>Tue, 17 Mar 2009 11:34:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3af76013-b83f-4cba-ae6e-9fd3e48bd670</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
thanks for the tip, Tsuneo. I will do the SCSI unmount thing
first, then toggle the soft connect pin.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do you the mistake in my USB descriptor?</title><link>https://community.arm.com/thread/133364?ContentTypeID=1</link><pubDate>Tue, 17 Mar 2009 10:59:19 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:443d1c42-8204-483d-acf1-250c42041b5f</guid><dc:creator>Tsuneo Chinzei</dc:creator><description>&lt;p&gt;&lt;p&gt;
Oops, I missed to append &amp;quot; break;&amp;quot; to each cases in above switch
statement :-)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;quot;I could have done the same with the soft-connect pin of the
LPC2478.&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
When soft-connect is applied to mounted drive, Windows will
complaint with surprised removal.&lt;br /&gt;
Unmount (Eject) the drive on a PC application first.&lt;/p&gt;

&lt;p&gt;
Eject USB disks using C#&lt;br /&gt;
&lt;a href="http://www.codeproject.com/KB/system/usbeject.aspx"&gt;www.codeproject.com/.../usbeject.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
Tsuneo&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do you the mistake in my USB descriptor?</title><link>https://community.arm.com/thread/133299?ContentTypeID=1</link><pubDate>Tue, 17 Mar 2009 10:45:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2d6c0672-3cef-4f8e-8640-05a6ff99b2e6</guid><dc:creator>Tsuneo Chinzei</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;b&gt;Multiple LUN implementation&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
Based on this Keil example,&lt;br /&gt;
LPC2368 / LPC2378 USB Mass Storage Device Example (and for
LPC2458/2468)&lt;br /&gt;
&lt;a href="http://www.keil.com/download/docs/336.asp"&gt;http://www.keil.com/download/docs/336.asp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
Get_Max_LUN request returns the last LUN supported.&lt;br /&gt;
LUN numbering starts with zero.&lt;/p&gt;

&lt;pre&gt;
mscuser.c

&lt;b&gt;#define MSC_NUM_OF_LUNS    2                       // support two drives on this MSC IF
#define MSC_LAST_LUN       (MSC_NUM_OF_LUNS - 1)   // LUN start with zero&lt;/b&gt;

/*
 *  MSC Get Max LUN Request Callback
 *   Called automatically on Get Max LUN Request
 *    Parameters:      None (global SetupPacket and EP0Buf)
 *    Return Value:    TRUE - Success, FALSE - Error
 */

BOOL MSC_GetMaxLUN (void) {
  EP0Buf[0] = &lt;b&gt;MSC_LAST_LUN;    // return the last LUN&lt;/b&gt;
  return (TRUE);
}
&lt;/pre&gt;

&lt;p&gt;
CBW.bLUN holds the target LUN for the SCSI commands.&lt;/p&gt;

&lt;pre&gt;
/*
 *  MSC Get Command Block Wrapper Callback
 *    Parameters:      None (global variables)
 *    Return Value:    None
 */

void MSC_GetCBW (void) {
  DWORD n;

  for (n = 0; n &amp;lt; BulkLen; n++) {
    *((BYTE *)&amp;amp;CBW + n) = BulkBuf[n];
  }
  if ((BulkLen == sizeof(CBW)) &amp;amp;&amp;amp; (CBW.dSignature == MSC_CBW_Signature)) {
    /* Valid CBW */
    CSW.dTag = CBW.dTag;
    CSW.dDataResidue = CBW.dDataLength;
    if ((CBW.bLUN &lt;b&gt; &amp;gt; MSC_LAST_LUN&lt;/b&gt;) || (CBW.bCBLength &amp;lt; 1) || CBW.bCBLength &amp;gt; 16) {
fail: CSW.bStatus = CSW_CMD_FAILED;
      MSC_SetCSW();
    } else {
      ...
&lt;/pre&gt;

&lt;p&gt;
Handle these SCSI command for the specified drive by CBW.bLUN&lt;br /&gt;
If the command does the same process for the two drives, you don&amp;#39;t
need to modify these handlers.&lt;br /&gt;
mscuser.c&lt;br /&gt;
- MSC_TestUnitReady()&lt;br /&gt;
- MSC_Inquiry()&lt;br /&gt;
- MSC_ModeSense6()&lt;br /&gt;
- MSC_ModeSense10()&lt;br /&gt;
- MSC_ReadFormatCapacity()&lt;br /&gt;
- MSC_ReadCapacity()&lt;/p&gt;

&lt;p&gt;
These command handler should be modified to process the target
drive by the CBW.bLUN (0 or 1)&lt;br /&gt;
mscuser.c&lt;br /&gt;
- MSC_RequestSense()&lt;br /&gt;
- MSC_RWSetup()&lt;br /&gt;
- MSC_MemoryRead()&lt;br /&gt;
- MSC_MemoryWrite()&lt;br /&gt;
- MSC_MemoryVerify()&lt;/p&gt;

&lt;p&gt;
For example, this MSC_MemoryRead() returns different memory
location depending on LUN.&lt;/p&gt;

&lt;pre&gt;
/*
 *  MSC Memory Read Callback
 *   Called automatically on Memory Read Event
 *    Parameters:      None (global variables)
 *    Return Value:    None
 */

void MSC_MemoryRead (void) {
  DWORD n;
&lt;b&gt;  DWORD drive_offset;

  switch ( CBW.bLUN ) {
     case 0:  drive_offset = 0;
     case 1:  drive_offset = MSC_MemorySize;
  }&lt;/b&gt;
  if (Length &amp;gt; MSC_MAX_PACKET) {
    n = MSC_MAX_PACKET;
  } else {
    n = Length;
  }

  if ((Offset + n) &amp;gt; MSC_MemorySize) {
    n = MSC_MemorySize - Offset;
    BulkStage = MSC_BS_DATA_IN_LAST_STALL;
  }

  USB_WriteEP(MSC_EP_IN, &lt;b&gt;&amp;amp;Memory[Offset + drive_offset]&lt;/b&gt;, n);
  Offset += n;
  Length -= n;

  CSW.dDataResidue -= n;

  if (Length == 0) {
    BulkStage = MSC_BS_DATA_IN_LAST;
  }

  if (BulkStage != MSC_BS_DATA_IN) {
    FIO2CLR = LED_RD;            /* Turn Off Read LED */
    CSW.bStatus = CSW_CMD_PASSED;
  }
}
&lt;/pre&gt;

&lt;p&gt;
Tsuneo&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do you the mistake in my USB descriptor?</title><link>https://community.arm.com/thread/133221?ContentTypeID=1</link><pubDate>Tue, 17 Mar 2009 09:56:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:351a6311-6338-40ec-9652-1ec2024ac2da</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Tsuneo,&lt;/p&gt;

&lt;p&gt;
Thanks for your help. I managed to get it to work - quite
entertaining to see my controller single MSC interface mapped to TWO
explorer windows :-)&lt;br /&gt;
By due to memory usage reasons we are probably going to use the soft
connect pin of the LPC2478 for the duration of the file creation. we
can do it with 2 drives, but it would mean a separate piece of RAM
for our own FAT (RL-ARM&amp;#39;s RAM drive is already occupied...!) and
correct operation on hosts starting at XP SP3 (I thought it was
implemented before?).&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do you the mistake in my USB descriptor?</title><link>https://community.arm.com/thread/133219?ContentTypeID=1</link><pubDate>Tue, 17 Mar 2009 06:40:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7cc5b6f3-a449-47ca-9944-0d72f6431a19</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Tsuneo,&lt;br /&gt;
I understand what you mean. I report a maximum number of LUNs of 1,
but my drives are not mapped in explorer. Can you say something about
this? Have I forgotten something? I am using Windows XP SP3, which
seems to support multiple LUNs.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do you the mistake in my USB descriptor?</title><link>https://community.arm.com/thread/133220?ContentTypeID=1</link><pubDate>Tue, 17 Mar 2009 04:52:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ae0d00e8-cd0f-4502-bb77-7b8d9183cfdf</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Tsuneo,&lt;br /&gt;
Thanks for your reply. I managed to get it to work using SCSI
commands that unmount the drive while the device updates the file
system but I am not satisfied. I could have done the same with the
soft-connect pin of the LPC2478. I am interested in the LUN solution:
I had a look at the Keil USB software and to the best of my judgment,
it is not supported. apart from that, what do you mean by &amp;quot;Just
dispatch the drive by LUN at SCSI handler&amp;quot; ?&lt;/p&gt;

&lt;p&gt;
thanks for your advise&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do you the mistake in my USB descriptor?</title><link>https://community.arm.com/thread/133129?ContentTypeID=1</link><pubDate>Tue, 17 Mar 2009 03:59:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5ec11a31-3afa-4326-a2f2-1ce57b627881</guid><dc:creator>Tsuneo Chinzei</dc:creator><description>&lt;p&gt;&lt;p&gt;
The two MSC interfaces work independently.&lt;br /&gt;
That is, you have to implement two pairs of these handlers, so as the
pairs work independently.&lt;br /&gt;
- Bulk endpoint handler&lt;br /&gt;
- BOT handler (CBW-CSW)&lt;br /&gt;
- SCSI command handler&lt;/p&gt;

&lt;p&gt;
Maybe some of the handlers for the second interface are still
mixed up with the first one.&lt;/p&gt;

&lt;p&gt;
When you implement it with multiple LUN (Logical Unit Number) on a
single MSC interface, it&amp;#39;s much simpler. Just dispatch the drive by
LUN at SCSI handler. You don&amp;#39;t need to touch to any other part of the
implementation.&lt;/p&gt;

&lt;p&gt;
Tsuneo&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do you the mistake in my USB descriptor?</title><link>https://community.arm.com/thread/133005?ContentTypeID=1</link><pubDate>Tue, 17 Mar 2009 00:25:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:55a1748d-32d1-482f-bfa2-67ec710d1cc9</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hello Tsuneo,&lt;/p&gt;

&lt;p&gt;
Yes I did all that - I am now working with logical endpoints 2 and
5, which are bulk only for the LPC2478. both are now addressed, but
the second interface hangs the system and eventually reports an
error. So I understand that in theory, I can map a device to 2
drives?&lt;br /&gt;
But, what if I want to unmount the device using SCSI commands? Am I
current in assuming the I need to fail the &amp;quot;test unit ready&amp;quot; command,
and to report an unmount in the ensuing &amp;quot;request sense&amp;quot;? Sorry for
the basic question, I never had to work with SCSI before.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do you the mistake in my USB descriptor?</title><link>https://community.arm.com/thread/132832?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2009 15:35:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a234be76-1929-49be-9e10-0339a5b74cce</guid><dc:creator>Tsuneo Chinzei</dc:creator><description>&lt;p&gt;&lt;p&gt;
In addition to Martin,&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;the respective endpoint is never addressed&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
On the usbcfg.h,&lt;br /&gt;
- Did you set the number of interfaces, USB_IF_NUM, to 2?&lt;br /&gt;
- Did you enable the Endpoint Event, USB_EP_EVENT, for the
endpoint?&lt;/p&gt;

&lt;p&gt;
Keil provides easy user interface to set up these parameters -
Configuration Wizard.&lt;br /&gt;
Open usbcfg.h on uVision, and click on the bottom tab to switch to
Configuration Wizard.&lt;/p&gt;

&lt;p&gt;
Tsuneo&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do you the mistake in my USB descriptor?</title><link>https://community.arm.com/thread/132603?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2009 05:47:39 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6556856d-31e6-485c-ab94-6b6453c4bdb0</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Ho, thanks Martin. I will certainly avail myself to do that right
away! or: TRTFM !&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do you the mistake in my USB descriptor?</title><link>https://community.arm.com/thread/132311?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2009 05:45:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:679cda43-d60a-4807-a463-3d4287ae78e3</guid><dc:creator>Martin G&amp;#195;&amp;#188;nther</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hello Tamir Michael,&lt;/p&gt;

&lt;p&gt;
I assume that you are using a LPC24xx.&lt;/p&gt;

&lt;p&gt;
Please note that logical endpoint 3 (physical endpoint 6,7) is a
isochronous Endpoint and not a bulk endpoint.&lt;/p&gt;

&lt;p&gt;
Please check &lt;i&gt;Chapter 13: LPC24XX USB device controller, 4.
Fixed endpoint configuration&lt;/i&gt; in the LPC24xx user manual for
endpoint configuration.&lt;/p&gt;

&lt;p&gt;
Best Regards,&lt;br /&gt;
Martin Guenther&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>