This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem with usb device custom class middelware

hi to all,
i am emulating a usb floppy, and i decide to use keil usb middleware with custom class(usb floppies most implement ufi class and it dose not implemented by keil) to done this project, but i have a problem with that.
in some place host driver decide to reset bulk in and out pipes, and as result it will reset host data toggle to DATA0 without sending any CLEAR_FEATURE to reset device data toggle.
below table is part of usb communication dump of my device:

device-endpoint   phase   data                                           desc
12.0               ctl    21 00 00 00  00 00 0c 00                       control-setup
12.0               out    23 00 00 00  00 00 00 00  fc 00 00 00          control-data
12.2               in     00 00 00 08  00 00 0b 40  03 00 02 00          bulk-in
12.1               in     00 00                                          interrupt-in
12.0               ctl    21 00 00 00  00 00 0c 00                       control-setup
12.0               out    00 00 00 00  00 00 00 00  00 00 00 00          control-data
12.1               in     3a 00                                          interrupt-in
12.2               reset                                                 reset bulk pipe
12.2               reset                                                 reset bulk pipe
12.0               ctl    21 00 00 00  00 00 0c 00                       control-setup
12.0               out    03 00 00 00  12 00 00 00  00 00 00 00          control-data
12                 SSTS                                                  timeout
12                 SSTS                                                  request flushed
12                 reset                                                 bus reset
12                 ok


as you can see every thing is ok until host decide to reset bulk pipes and as result it reset host toggle but device toggle is DATA1 and as result next data transfer in bulk in endpoint will timeout and then host reset usb pipe and this is my problem.
i know that this is mistake by host, but i know where host reset pipe and now i am searching for a way to reset data toggle of my device bulk endpoints.
i did not find any function or utility in keil usb middelware api to reset data toggle.
now any one know any way to done that???

Parents
  • Hi Alireza and Milorad,

    A) Wrong sequence
    In your log, just before the host put pipe-reset, the host puts TUR (Test Unit Ready) command

    12.0    ctl    21 00 00 00  00 00 0c 00                       control-setup
    12.0    out    00 00 00 00  00 00 00 00  00 00 00 00          control-data <-- TUR
    12.1    in     3a 00                                          interrupt-in <-- wrong
    

    In above sequence, your device sends error code to the interrupt IN EP, maybe because no media is mounted. It is the wrong part.
    - Your device should STALL the Control transfer at the STATUS stage, to make the host know that the command (TUR) fails.
    - And then, the host should pass REQUEST SENSE (RS) command, immediately.
    - - Your device returns sense data block of Sense Key - ASC:ASCQ = 02 - 3A:00 (NOT READY - MEDIUM NOT PRESENT)

    Supposed sequence is as follows,

    12.0    ctl    21 00 00 00  00 00 0c 00                       control-setup
    12.0    out    00 00 00 00  00 00 00 00  00 00 00 00          control-data <-- TUR
                                                          <-- STALL should be reported
    12.0    ctl    21 00 00 00  00 00 0c 00                       control-setup
    12.0    out    03 00 00 00  12 00 00 00  00 00 00 00          control-data <-- RS
    12.2    in     70 00 02 00  00 00 00 0A  00 00 00 00          bulk-in      <- sense data
                   3A 00 00 00  00 00
    12.1    in     00 00                                          interrupt-in
    

    B) Pipe reset

    > host driver decide to reset bulk in and out pipes, and as result it will reset host data toggle to DATA0 without sending any CLEAR_FEATURE to reset device data toggle.

    You are monitoring on a software sniffer (bus hound?). Software sniffers can't catch CLEAR_FEATURE(ENDPOINT_HALT) request on the bus, which is issued by USBDI (low-level system driver) as the result of pipe-reset request. Software sniffers catch the USB requests just at the entry of USBDI. They can't catch transfers under USBDI.

    I believe the host should send CLEAR_FEATURE(ENDPOINT_HALT) to your device.

    Tsuneo

Reply
  • Hi Alireza and Milorad,

    A) Wrong sequence
    In your log, just before the host put pipe-reset, the host puts TUR (Test Unit Ready) command

    12.0    ctl    21 00 00 00  00 00 0c 00                       control-setup
    12.0    out    00 00 00 00  00 00 00 00  00 00 00 00          control-data <-- TUR
    12.1    in     3a 00                                          interrupt-in <-- wrong
    

    In above sequence, your device sends error code to the interrupt IN EP, maybe because no media is mounted. It is the wrong part.
    - Your device should STALL the Control transfer at the STATUS stage, to make the host know that the command (TUR) fails.
    - And then, the host should pass REQUEST SENSE (RS) command, immediately.
    - - Your device returns sense data block of Sense Key - ASC:ASCQ = 02 - 3A:00 (NOT READY - MEDIUM NOT PRESENT)

    Supposed sequence is as follows,

    12.0    ctl    21 00 00 00  00 00 0c 00                       control-setup
    12.0    out    00 00 00 00  00 00 00 00  00 00 00 00          control-data <-- TUR
                                                          <-- STALL should be reported
    12.0    ctl    21 00 00 00  00 00 0c 00                       control-setup
    12.0    out    03 00 00 00  12 00 00 00  00 00 00 00          control-data <-- RS
    12.2    in     70 00 02 00  00 00 00 0A  00 00 00 00          bulk-in      <- sense data
                   3A 00 00 00  00 00
    12.1    in     00 00                                          interrupt-in
    

    B) Pipe reset

    > host driver decide to reset bulk in and out pipes, and as result it will reset host data toggle to DATA0 without sending any CLEAR_FEATURE to reset device data toggle.

    You are monitoring on a software sniffer (bus hound?). Software sniffers can't catch CLEAR_FEATURE(ENDPOINT_HALT) request on the bus, which is issued by USBDI (low-level system driver) as the result of pipe-reset request. Software sniffers catch the USB requests just at the entry of USBDI. They can't catch transfers under USBDI.

    I believe the host should send CLEAR_FEATURE(ENDPOINT_HALT) to your device.

    Tsuneo

Children