Author Topic: Indicate Reset Recovery form host?  (Read 17307 times)

eng.Buffon

  • Member
  • ***
  • Posts: 23
Indicate Reset Recovery form host?
« on: March 06, 2012, 08:51:12 pm »
hi guys hi everyone

i program my firmware (for MSD) as when there is an unsupported command it STALL the Bulk-endpoint,

the host supposed to react when there is stall on endpoint , the host send supposed to send MSD_RESET request then CLEAR_FEATURE HALT on endpoint 1 (in/out)


so now i wanna know as i Stall the endpoint in the first step what am i supposed to do?? am i supposed to capture RESET signal and CLEAR_FEAture??

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Indicate Reset Recovery form host?
« Reply #1 on: March 06, 2012, 11:11:55 pm »
After a bulk endpoint returns STALL, to resume communications with the endpoint, the host must issue a Clear_Feature(ENDPOINT_HALT) control request to the endpoint.

Jan

eng.Buffon

  • Member
  • ***
  • Posts: 23
Re: Indicate Reset Recovery form host?
« Reply #2 on: March 07, 2012, 08:59:42 am »
this command CLEAR_FEATURE(endpoint HALT) executed successfully but the problem is the firmware didn't enter the MSD_RESEt State before going to CLEAR_Feature(endpoint HALT)

as from Universal Serial Bus Mass Storage Class Bulk-Only Transport  section 5.3.4 Reset Recovery that said:

Quote
For Reset Recovery the host shall issue in the following order: :
(a) a Bulk-Only Mass Storage Reset
(b) a Clear Feature HALT to the Bulk-In endpoint
(c) a Clear Feature HALT to the Bulk-Out endpoint

so why the step(a) didn't happen?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Indicate Reset Recovery form host?
« Reply #3 on: March 07, 2012, 10:54:29 am »
Perhaps a Reset Recovery wasn't required.

In any case, devices shouldn't expect any sequence of events, requests, etc. from the host. The device just needs to respond to whatever the host does.

Jan

eng.Buffon

  • Member
  • ***
  • Posts: 23
Re: Indicate Reset Recovery form host?
« Reply #4 on: March 07, 2012, 02:01:01 pm »
ok how can i response to the MSD_RESET as i try that

Code: [Select]
void USBCheckMSDRequest(void)
{
     byte recipient;
     byte bIntfID;
     word wValue;
     

     recipient = SetupPacket.bmRequestType & 0x1F;
     bIntfID = SetupPacket.wIndex0;

     if(recipient != USB_SETUP_RECIPIENT_INTERFACE) return;

    if(bIntfID != 0) return;

     switch(SetupPacket.bRequest)
     {
          case MSD_RESET:
               //First make sure all request parameters are correct:
               //MSD BOT specs require wValue to be == 0x0000 and wLength == 0x0000
               if(((SetupPacket.wValue0 != 0) && (SetupPacket.wValue1 !=0)) || (SetupPacket.wLength != 0))
                {
                    return; //Return without handling the request (results in STALL)
                }
                requestHandled = 1;
                //The MSD reset should re-initialize status
                //so as to prepare for a new CBW.  Any currently ongoing command
                //block should be aborted, but the STALL and DTS states need to be
                //maintained (host will re-initialize these seperately using
                //CLEAR_FEATURE, endpoint halt).
                MSD_State = MSD_WAIT;
                MSDCommandState = MSD_COMMAND_WAIT;
                MSDReadState = MSD_READ10_WAIT;
                MSDWriteState = MSD_WRITE10_WAIT;
                MSDCBWValid = True;
               
                //Need to re-arm MSD bulk OUT endpoint, if it isn't currently armed,
                //to be able to receive next CBW.  If it is already armed, don't need
                //to do anything, since we can already receive the next CBW (or we are
                //STALLed, and the host will issue clear halt first).
                if(!(ep1Bo.Stat & UOWN))
                {
                       MSDInitEndpoint();
                }
                break;

          case GET_MAX_LUN:
          //portd=255;
                //First make sure all request parameters are correct:
                //MSD BOT specs require wValue to be == 0x0000, and wLengh == 1
                if(((SetupPacket.wValue0 != 0) && (SetupPacket.wValue1 !=0)) || (SetupPacket.wLength != 1))
                {
                     break;  //Return without handling the request (results in STALL)
                }
                requestHandled = 1;
                //If the host asks for the maximum number of logical units
                //  then send out a packet with that information
                controlTransferBuffer[0] = MAX_LUN;
                outPtr = (byte*)&controlTransferBuffer;
                wCount = 1;
                transferType=0;
                break;
     }

}

as when i tried to let for example do

Code: [Select]
portd=255;
when entering the MSD_RESET condition as an indicator it didn't change it still
Code: [Select]
portd=0;
all i wanna know when the host send MSD_RESET or he didn't send it at all?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Indicate Reset Recovery form host?
« Reply #5 on: March 07, 2012, 02:07:29 pm »
See the USB mass storage bulk-only spec for details about the request, including the request's bRequest value, which tells the device that the host is sending the request.

Jan

eng.Buffon

  • Member
  • ***
  • Posts: 23
Re: Indicate Reset Recovery form host?
« Reply #6 on: March 07, 2012, 02:36:07 pm »
all i wanna know how the device deals with the unsupported command?