Author Topic: Device unresponsive after WinUSB_ReadPipe()  (Read 13348 times)

ptrxtrnd

  • Member
  • ***
  • Posts: 8
Device unresponsive after WinUSB_ReadPipe()
« on: June 14, 2014, 02:12:25 am »
Hi,
I am new to this and trying to write a WinUSB application (windows 8.1, Visual Studio Express 2013) that reads from a Mass
Storage Device.

My problem is that the device (thumb drive) stops responding after the first issued ReadPipe() operation.

I can read the descriptors, send a control transfer to read the MAX LUN, and create a CBW to read the Capacity.  Finally
I send the ReadPipe() to read the response from the READ_CAPACITY request and it succeeds, I get 8 bytes in response.
But if I after this tries to send another WritePipe() or ControlTransfer(), the device does not respond. I have to remove it
and plug it in again.

What should I do to solve this situation?

/Peter

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Device unresponsive after WinUSB_ReadPipe()
« Reply #1 on: June 14, 2014, 10:36:48 am »
The OS assigns the mass-storage driver to the device. To use WinUSB, you would need to remove that driver and assign the WinUSB driver. However, Windows will fight you on that because the descriptors tell the OS that the device is a mass-storage device and thus the mass-storage driver is the correct one to use. Why do you want to use WinUSB?

ptrxtrnd

  • Member
  • ***
  • Posts: 8
Re: Device unresponsive after WinUSB_ReadPipe()
« Reply #2 on: June 14, 2014, 10:49:37 am »
It's just for learning to use WinUSB with a fully working device before I start working on my own USB device.


I have uninstalled the default driver for the thumb drive and told windows to use WinUSB instead as you suggest.
And as I wrote, the first WritePipe() and ReadPipe() works fine. But next operation fails.

/Peter
« Last Edit: June 14, 2014, 10:53:29 am by ptrxtrnd »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Device unresponsive after WinUSB_ReadPipe()
« Reply #3 on: June 14, 2014, 11:37:40 am »
Your WinUSB application will need to emulate what the mass-storage driver does. A protocol analyzer will show what is happening on the bus. But I would skip this step and start with a device where you can control the firmware. One way is with working HID-class firmware. Change the Product ID and change the descriptors to vendor-defined.

ptrxtrnd

  • Member
  • ***
  • Posts: 8
Re: Device unresponsive after WinUSB_ReadPipe()
« Reply #4 on: June 14, 2014, 11:41:29 am »
Yes, maybe this was wrong way to go.
Thanks for advice!

/Peter

Tsuneo

  • Frequent Contributor
  • ****
  • Posts: 145
Re: Device unresponsive after WinUSB_ReadPipe()
« Reply #5 on: June 15, 2014, 09:46:12 am »
Quote
It's just for learning to use WinUSB with a fully working device
For this purpose, USB sticks (Mass Storage Device) aren’t good one, because their implementation often have deviations (annormaries) from USB standard, which aren’t revealed under Windows MSC driver operation.

I recommend you cheap MCU kits and "bulk" USB examples from MCU manufacturers,

- NXP
LPCXpresso LPC11U24/37/68 - LPCOpen - LPCXpresso IDE
http://www.lpcware.com/content/nxpfile/lpcopen-software-development-platform-lpc11xx-packages-0
/lpcopen_v2_03_lpcxpresso_nxp_lpcxpresso_11u37h/nxp_lpcxpresso_11u37_usbd_rom_libusb

- Microchip
DM164127-2 - Low Pin Count USB Development Kit
http://www.microchip.com/pagehandler/en-us/devtools/mla/
\microchip\mla\v2013_12_20\apps\usb\device\vendor_basic\

- TI
EK-TM4C123GXL - TivaWare
http://www.ti.com/tool/sw-tm4c
\TivaWare_C_Series-2.1.0.12573\examples\boards\ek-tm4c123gxl\usb_dev_bulk

- ST Micro
STM32F4 Discovery - STM32CubeF4
http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/PF259243

etc.

Tsuneo

ptrxtrnd

  • Member
  • ***
  • Posts: 8
Re: Device unresponsive after WinUSB_ReadPipe()
« Reply #6 on: June 15, 2014, 02:08:11 pm »
BTW,
I found out what I did wrong: I forgot to read the CSW before sending next CBW.
Now its working!

/Peter