Author Topic: 'Clear endpoint halt failed' on Freescale FRDM-KL25Z HID  (Read 23527 times)

bpaddock

  • Frequent Contributor
  • ****
  • Posts: 66
'Clear endpoint halt failed' on Freescale FRDM-KL25Z HID
« on: July 31, 2013, 01:06:36 pm »
I'm trying to bring up a Generic HID (this is not a keyboard or mouse) on a Freescale Freedom Board FRDM-KL25Z.

I've included a bus capture and the setup_endpoint() code below.

When I run the USB 2. 0 Command Verifier tool on Windows7x64 I always get:
"ERROR   Clear endpoint halt failed".  Other tests always pass.

These Halt tests take ten seconds to run, while all the other tests take one second to run.
This seems suspicious to me.  Is it normal for this Halt Feature test to take so long?

Below is three test runs of the Halt Endpoint Test, in Command Verifier.
First run is code returning the current status of the Halt bit, as the code should work.
Second run status always returns zero, and the third run status always returns 0x0001, to prove that changing the code changes the test results.

Halt Endpoint Test : Failed
INFO    Start time: Wed Jul 31 09:55:25 2013
INFO    Testing Interface number : 0 Alternate setting : 0
INFO    Testing EndPoint type : Interrupt, Address : 81
INFO    Endpoint is currently not halted
INFO    Endpoint is halted
ERROR   Clear endpoint halt failed
INFO    Cleared endpoint halt
FAIL    (1.2.91) A device that has Bulk/Interrupt endpoints must support the
        Halt Endpoint request on those endpoints.
INFO    Testing EndPoint type : Interrupt, Address : 2
INFO    Endpoint is currently not halted
INFO    Endpoint is halted
ERROR   Clear endpoint halt failed
INFO    Cleared endpoint halt
FAIL    (1.2.91) A device that has Bulk/Interrupt endpoints must support the
        Halt Endpoint request on those endpoints.
INFO    Stop time: Wed Jul 31 09:55:36 2013
INFO    Duration:  11 seconds.  {This is a lot longer than an of the other tests take.}
INFO    Stopping Test [ Halt Endpoint Test (Configuration Index 0):

     Number of: Fails (2); Aborts (0); Warnings (0) ]


This test is run with mGET_STATUS returning zero on all requests:

INFO    Start time: Wed Jul 31 10:02:30 2013
INFO    Testing Interface number : 0 Alternate setting : 0
INFO    Testing EndPoint type : Interrupt, Address : 81
INFO    Endpoint is currently not halted
ERROR   Endpoint could not be halted
ERROR   Clear endpoint halt failed
INFO    Cleared endpoint halt
FAIL    (1.2.91) A device that has Bulk/Interrupt endpoints must support the
        Halt Endpoint request on those endpoints.
INFO    Testing EndPoint type : Interrupt, Address : 2
INFO    Endpoint is currently not halted
ERROR   Endpoint could not be halted
ERROR   Clear endpoint halt failed
INFO    Cleared endpoint halt
FAIL    (1.2.91) A device that has Bulk/Interrupt endpoints must support the
        Halt Endpoint request on those endpoints.
INFO    Stop time: Wed Jul 31 10:02:41 2013
INFO    Duration:  11 seconds.  {This is a lot longer than an of the other tests take.}
INFO    Stopping Test [ Halt Endpoint Test (Configuration Index 0):

     Number of: Fails (2); Aborts (0); Warnings (0) ]

Test run with status always returning 0x0001:

Halt Endpoint Test : Failed
INFO    Start time: Wed Jul 31 10:14:29 2013
INFO    Testing Interface number : 0 Alternate setting : 0
INFO    Testing EndPoint type : Interrupt, Address : 81
INFO    Endpoint is currently halted
ERROR   Clear endpoint halt failed
ERROR   Could not clear endpoint halt
INFO    Endpoint is halted
ERROR   Clear endpoint halt failed
ERROR   Could not clear endpoint halt
FAIL    (1.2.91) A device that has Bulk/Interrupt endpoints must support the
        Halt Endpoint request on those endpoints.
INFO    Testing EndPoint type : Interrupt, Address : 2
INFO    Endpoint is currently halted
ERROR   Clear endpoint halt failed
ERROR   Could not clear endpoint halt
INFO    Endpoint is halted
ERROR   Clear endpoint halt failed
ERROR   Could not clear endpoint halt
FAIL    (1.2.91) A device that has Bulk/Interrupt endpoints must support the
        Halt Endpoint request on those endpoints.
INFO    Stop time: Wed Jul 31 10:14:50 2013
INFO    Duration:  21 seconds. {Even longer time.}
INFO    Stopping Test [ Halt Endpoint Test (Configuration Index 0):

     Number of: Fails (2); Aborts (0); Warnings (0) ]

Bus capture:

[Removed previous enumeration messages to keep this a reasonable length.]
2.087820167,GET_INTERFACE
2.087820167,DATA0,81,0A,00,00,00,00,01,00,DD,C8,
2.087828792,ACK
2.087837083,IN Add:2 EndPoint:0
2.087840375,NAK
2.087849083,IN Add:2 EndPoint:0
2.087852375,DATA1,00,40,BF,
2.087856750,ACK
2.087862917,OUT Add:2 EndPoint:0
2.087866167,DATA1,00,00,
2.087869458,ACK
2.089087625,SETUP Add:2 EndPoint:0
2.089090875,GET_STATUS
2.089090875,DATA0,82,00,00,00,81,00,02,00,1F,11,
2.089099500,ACK
2.089108875,IN Add:2 EndPoint:0
2.089112167,DATA1,00,00,FE,4F,
2.089117208,ACK
2.089130125,OUT Add:2 EndPoint:0
2.089133375,DATA1,00,00,
2.089136667,ACK
2.090311167,SETUP Add:2 EndPoint:0
2.090314417,SET_FEATURE
2.090314417,DATA0,02,03,00,00,81,00,00,00,25,11,
2.090323042,ACK
2.090331333,IN Add:2 EndPoint:0
2.090334625,DATA1,00,00,
2.090338250,ACK
2.090811167,SETUP Add:2 EndPoint:0
2.090814417,GET_STATUS
2.090814417,DATA0,82,00,00,00,81,00,02,00,1F,11,
2.090823042,ACK
2.090831750,IN Add:2 EndPoint:0
2.090835042,DATA1,01,00,FF,DF,
2.090840083,ACK
2.090849000,OUT Add:2 EndPoint:0
2.090852250,DATA1,00,00,
2.090855542,ACK
2.092060875,SETUP Add:2 EndPoint:0
2.092064125,CLEAR_FEATURE
2.092064125,DATA0,02,01,00,00,81,00,00,00,06,D1,
2.092072750,ACK
2.092081792,IN Add:2 EndPoint:0
2.092085083,DATA0,00,00,
2.092088708,ACK
[Long gap of only Start of Frames here. Why?]
7.095046917,SETUP Add:2 EndPoint:0
7.095050167,GET_STATUS
7.095050167,DATA0,82,00,00,00,81,00,02,00,1F,11,
7.095058792,ACK
7.095067167,IN Add:2 EndPoint:0
7.095070458,DATA1,00,00,FE,4F,
7.095075417,ACK
7.095081000,OUT Add:2 EndPoint:0
7.095084250,DATA1,00,00,
7.095087542,ACK
7.097046667,SETUP Add:2 EndPoint:0
7.097049917,GET_STATUS
7.097049917,DATA0,82,00,00,00,02,00,02,00,36,95,
7.097058542,ACK
7.097066917,IN Add:2 EndPoint:0
7.097070208,DATA1,00,00,FE,4F,
7.097075167,ACK
7.097080750,OUT Add:2 EndPoint:0
7.097084000,DATA1,00,00,
7.097087292,ACK
7.098296708,SETUP Add:2 EndPoint:0
7.098299958,SET_FEATURE
7.098299958,DATA0,02,03,00,00,02,00,00,00,0C,95,
7.098308583,ACK
7.098317292,IN Add:2 EndPoint:0
7.098320583,DATA1,00,00,
7.098324208,ACK
7.099546167,SETUP Add:2 EndPoint:0
7.099549417,GET_STATUS
7.099549417,DATA0,82,00,00,00,02,00,02,00,36,95,
7.099558042,ACK
7.099566917,IN Add:2 EndPoint:0
7.099570208,DATA1,01,00,FF,DF,
7.099575333,ACK
7.099584083,OUT Add:2 EndPoint:0
7.099587333,DATA1,00,00,
7.099590625,ACK
7.100800375,SETUP Add:2 EndPoint:0
7.100803625,CLEAR_FEATURE
7.100803625,DATA0,02,01,00,00,02,00,00,00,2F,55,
7.100812250,ACK
7.100820875,IN Add:2 EndPoint:0
7.100824167,DATA0,00,00,
7.100827792,ACK
[Long gap of only Start of Frames here. Why?]
12.104906625,SETUP Add:2 EndPoint:0
12.104909875,GET_STATUS
12.104909875,DATA0,82,00,00,00,02,00,02,00,36,95,
12.104918500,ACK
12.104926958,IN Add:2 EndPoint:0
12.104930250,DATA1,00,00,FE,4F,
12.104935291,ACK
12.104944041,OUT Add:2 EndPoint:0
12.104947291,DATA1,00,00,
12.104950583,ACK
[Nothing but Start of Frames from here on.]

Endpoint feature source:

static void usb_setup_endpoint( endpoint_t *const ep_ptr, USB_SETUP *const setup_ptr )
{
  uint16_t status_u16 = 0U;

  uint_fast8_t const ep_u8 = (setup_ptr->wIndex & 0x0FU);

  switch( setup_ptr->bRequest )
    {
    case mCLR_FEATURE:
      ep_ptr->features_u8 &= (uint8_t) ~FEATURE_ENDPOINT_HALT_MASK;

      /* Clear_Feature(ENDPOINT_HALT) resets the ednpoint's data toggle to DATA0: */
      ep_ptr->data01_u8 = BD_DATA0_MASK;

      // USB0_ENDPT( ep_u8 ) &= ~USB_ENDPT_EPSTALL_MASK; /* Commented out for testing to see if problem is hardware or returned status */

      usb_tx( ep_ptr, 0U, NULL ); /* ACK */
      break;

    case mSET_FEATURE:
      ep_ptr->features_u8 |= (uint8_t) FEATURE_ENDPOINT_HALT_MASK;

      //  USB0_ENDPT( ep_u8 ) |= USB_ENDPT_EPSTALL_MASK; /* Commented out for testing to see if problem is hardware or returned status */

      usb_tx( ep_ptr, 0U, NULL ); /* ACK */
      break;

    case mGET_STATUS:
      if( 0 != (FEATURE_ENDPOINT_HALT_MASK & ep_ptr->features_u8) )
        {
          status_u16 = FEATURE_ENDPOINT_HALT_MASK;
        }

      //      status_u16 = 0x0000U; // TESTING run two
      //      status_u16 = 0x0001U; // TESTING run three
      usb_queue_tx( ep_ptr, 2U, (uint8_t *const) &status_u16 ); /* Processor is Little Endian */
      break;

    default:
      iprintf("%u:EP[%u] ? R:0x%02X V:%u I:%u St:%u\r\n", __LINE__, ep_u8, setup_ptr->bRequest, setup_ptr->wValue, setup_ptr->wIndex, device_state_u8 );
      ep_stall( ep_u8 );
      break;
    }
}

Clear_Feature(ENDPOINT_HALT) is being done in SetConfig and SetInterface per the spec.

Any insights?


Barry Twycross

  • Frequent Contributor
  • ****
  • Posts: 263
Re: 'Clear endpoint halt failed' on Freescale FRDM-KL25Z HID
« Reply #1 on: July 31, 2013, 03:56:26 pm »
If your device uses the same USB core as the one I'm working on, it definitely had issues clearing STALLs. I'm currently not able to do that by manipulating BDT entires and have to use the register bit instead.

What you really need to help diagnose this problem is a real bus trace from a real hardware based bus analyzer.

bpaddock

  • Frequent Contributor
  • ****
  • Posts: 66
Re: 'Clear endpoint halt failed' on Freescale FRDM-KL25Z HID
« Reply #2 on: August 01, 2013, 07:36:02 am »
Part is the Kinetis MKL25Z128.

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KL2&nodeId=01624698C9E3EC

What I'm confused about is it does not matter if I stall the end point or not, the results are the same.
Simply returning the status after the clear has the issue with the Halt test.

USBee DX is what I currently have available for doing bus captures, which is what I used in the one I posted.


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: 'Clear endpoint halt failed' on Freescale FRDM-KL25Z HID
« Reply #3 on: August 01, 2013, 10:39:06 am »
I don't see any problem with the code.

These are the only requirements I'm aware of, so verify that these are true:

After completing a Clear Feature(ENDPOINT HALT), the specified endpoint should reset its toggle to DATA0 and return ACK or NAK to new traffic. On receiving a Get Status request for the endpoint, the device should return bit 0 = 0.

(I haven't decoded the bus data you posted.)

Tsuneo

  • Frequent Contributor
  • ****
  • Posts: 145
Re: 'Clear endpoint halt failed' on Freescale FRDM-KL25Z HID
« Reply #4 on: August 01, 2013, 05:14:38 pm »
Hi bpaddock,

On your USBee DX trace, your firmware works as you expect, except for the "long gaps".
I'm not sure, why the USB20CV reports error with this trace.
Maybe, in the "long gaps", something occurs on the PC, not on your device.
I ran "Halt Endpoint Test" on USB20CV (R1.4.9.6) with a HID device.
It finished instantly within 1 sec. Such a "long gaps" were not seen.

Run USB20CV on another PC.
Or, run another version of USB20CV

http://www.usb.org/developers/tools/
(x86)
http://www.usb.org/developers/tools/USB20CV_Releasex86_1.4.9.7.msi  (corrupted)
http://www.usb.org/developers/tools/USB20CV_Releasex86_1.4.9.6.msi
(x64)
http://www.usb.org/developers/tools/USB20CV_Releasex64_1.4.9.7.msi
http://www.usb.org/developers/tools/USB20CV_Releasex64_1.4.9.6.msi

By the way, "USB20CV_Releasex86_1.4.9.7.msi" on USB.org is corrupted.
Try another one.

Tsuneo

bpaddock

  • Frequent Contributor
  • ****
  • Posts: 66
Re: 'Clear endpoint halt failed' on Freescale FRDM-KL25Z HID
« Reply #5 on: August 02, 2013, 07:51:35 am »
Thank you for analyzing the bus trace and testing.
I'll come up with an other test machine and run CV on there.

I don't like to run Command Verifier on my development machine due to it taking control of the keyboard and mouse.
The CV documentation says that the keyboard and mouse will still work "on the root hub".  This machine reports seven root hubs.
How do you find the one that the keyboard would work with, without trying each port?



Tsuneo

  • Frequent Contributor
  • ****
  • Posts: 145
Re: 'Clear endpoint halt failed' on Freescale FRDM-KL25Z HID
« Reply #6 on: August 02, 2013, 11:46:17 am »
Quote
it taking control of the keyboard and mouse.

Keyboard and mouse work as usual, even while USB20CV is running.
USB Command Verifier Version 1.4.9 Release Notes (USB20CV Release Notes.rtf)
- This version of the tool supports the use of mouse and keyboard plugged directly into the root ports of the USB 2.0 host controller on your system.


I can't remember the exact USB20CV version, but this feature was introduced many years ago.

Tsuneo

bpaddock

  • Frequent Contributor
  • ****
  • Posts: 66
Re: 'Clear endpoint halt failed' on Freescale FRDM-KL25Z HID
« Reply #7 on: August 02, 2013, 11:59:45 am »
I read that in the release notes before installing CV as well.

Alas, installing the latest version 1.4.9 x64 of CV on my development machine turned off the keyboard and mouse, which are plugged into the ports on the mother board designated for them.  Rather than play 'find then right socket on the right hub' I moved CV to a Toshiba Satellite C655 laptop that did not have a USB keyboard/mouse.

I had to revert to a previous Windows Restore point to recover via Safe Mode.

According to USB Tree View my keyboard is indeed plugged into a Root Hub on the PC.


Tsuneo

  • Frequent Contributor
  • ****
  • Posts: 145
Re: 'Clear endpoint halt failed' on Freescale FRDM-KL25Z HID
« Reply #8 on: August 02, 2013, 12:43:05 pm »
You are unlucky.
To run USB20CV, I always pick up PCs with Intel chipset.

http://www.usb.org/developers/tools/
USB20CV R1.4.9.7
This software is provided courtesy of Intel Corporation.


Tsuneo