Author Topic: Audio device enumeration problem  (Read 33859 times)

JimR

  • Member
  • ***
  • Posts: 8
Audio device enumeration problem
« on: February 08, 2011, 06:58:00 pm »
Hi, I'm trying to design a USB stereo audio recording interface using a PIC18F4550, with the objective of making it compatible with the Windows usbaudio.sys driver (so no vendor drivers are needed). I have adapted Microchip's demo 'audio microphone' firmware, but have struck trouble: when my device is plugged into a USB port of a PC (running WinXP pro, SP3), the enumeration process seems to stall after my device supplies its config descriptors.

Needless to say Windows reports that there was an installation problem, and when I go into Device Manager it tells me that 'This device cannot start (Code 10)'.

I have used USBTrace (eval version so far) to capture the 153-transaction sequence, but as this is my first foray into USB device programming (let alone trying to program a device with an isochronous IN endpoint), I'm at a loss to interpret what I'm seeing. Can you please offer any suggestions as to how to interpret the trace sequence to find the cause of the 'stall'?

By the way, as far as I can see the device is sending back the correct descriptors.
 

mdlayt

  • Member
  • ***
  • Posts: 40
Re: Audio device enumeration problem
« Reply #1 on: February 08, 2011, 07:08:10 pm »
"Easy" solutions include starting from a known good, and using a bus monitor.

And try a host tester (eg USB 2.0 CV).

I found this was the hardest thing about USB development because Microsoft gives so little information about the problem.  I'm guessing it is either you aren't following the applicable spec, or you said one thing and later did another.

A key clue may be, exactly how far are you making it before the error (compared with a working device)?  You may be able to figure that out from an oscilloscope and debug firmware (eg with test points).

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Audio device enumeration problem
« Reply #2 on: February 08, 2011, 10:24:36 pm »
mdlayt has good advice.

If the host acks all of the returned descriptors but doesn't send a Set_Configuration request, there is something wrong in the descriptors.

Does the device return STALL, and if so in response to what request, or are you just saying enumeration quits?

If you post your descriptors, someone might see something.

Jan

JimR

  • Member
  • ***
  • Posts: 8
Re: Audio device enumeration problem
« Reply #3 on: February 09, 2011, 03:33:22 pm »
Hi Jan and mdlayt,

Thanks for both of your helpful replies. The device doesn't seem to return a STALL -- enumeration just seems to quit, After a series of Get_Descriptor requests from the host and returned descriptors from the device (acknowledged). I've been through the descriptors a couple of times, but if there's an error I can't find it...

I'll try to post a listing of both the descriptors and the USBTrace log file (in text form), in the hope that someone may be able to spot my errors.

By the way, Jan, many thanks for your book 'USB Complete Fourth Edition' -- it has already helped me quite a bit.

One further question:  where can you find the explicit data that usbaudio.sys expects to get from an audio device?

Regards,
JimR

[attachment deleted by admin]

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Audio device enumeration problem
« Reply #4 on: February 10, 2011, 10:25:12 am »
Search for this document from Microsoft:

USB Audio Devices and Windows

Jan

JimR

  • Member
  • ***
  • Posts: 8
Re: Audio device enumeration problem
« Reply #5 on: February 10, 2011, 04:49:05 pm »
Hi Jan,

and thanks for that pointer into the Microsoft information labyrinth. I found that document and have downloaded it -- hopefully it will help me find where I have gone wrong in my descriptors. ::)

Regards,

JimR

  • Member
  • ***
  • Posts: 8
Re: Audio device enumeration problem
« Reply #6 on: March 08, 2011, 11:52:15 pm »
Hi all,

It's me again. I'm still having problems. Now the 'control' (EP0) part of the device installs correctly as a Composite Device, but the audio streaming part (EP1 -- an isochronous IN endpoint) still won't play. Device manager says it 'cannot start' (Error Code 10).

I've checked and re-checked my config descriptors, and they all seem OK.

Any more suggestions?   ???

From JimR -- one very frustrated newbie.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Audio device enumeration problem
« Reply #7 on: March 09, 2011, 09:54:46 am »
The host sends a Set_Configuration request and the device returns ACK?

What are the functions in the composite device?

Were you able to test the Microchip example firmware and if so did it work?

Jan


JimR

  • Member
  • ***
  • Posts: 8
Re: Audio device enumeration problem
« Reply #8 on: March 09, 2011, 03:54:39 pm »
Hi -- me again,
This time with a plain text version of the enumeration log file (much shorter, of course).
Your system tells me that my first posting this morning was accepted, even though I can't see it.
But the html log file was refused, so now I'm attaching the plain text version...

Sorry for all the hassle.
JimR

[attachment deleted by admin]

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Audio device enumeration problem
« Reply #9 on: March 09, 2011, 09:55:44 pm »
I don't see a Set_Configuration request.

I don't see a composite device, just a single audio function with two interfaces

Were you able to test the Microchip example firmware and if so did it work and what did you change?

Jan

JimR

  • Member
  • ***
  • Posts: 8
Re: Audio device enumeration problem
« Reply #10 on: March 10, 2011, 05:09:01 pm »
Thanks for those comments/questions, Jan. You are quite correct in pointing out that there is no Set_Configuration request. Nor is there a composite device evident, at that aborted stage of enumeration. I may be wrong, but my understanding is that with any device having more than one interface, it first calls it a composite device and then re-labels it later in the transactions. In any case, when I look in Device Manager, it shows a composite device 'installed' at the appropriate USB port and supposedly working normally, but it also shows an audio device in the 'games and media' section, with the yellow exclamation mark and 'Error -- device cannot start' in the properties. I assume from this that the control interface (EP0) has installed correctly, but the isochronous audio streaming interface (EP1) has not. Does that sound right?
Yes, I did test the Microchip 'audio microphone demo' firmware, and it does work correctly (as far as it goes). But it is only an emulator program, which sends a short voice message ("Hello") when you press a button on the demo board. It sends the message in mono only, and at a sampling rate of 8kHz. Because my project is to operate in stereo and at a sampling rate of 48kHz, I made the following changes (almost entirely in the usb_descriptors.c file):
1. I changed the bNrChannels parameter in the Input Terminal descriptor and the Microphone Type I Format descriptor from 0x01 to 0x02.
2. I changed the wChannelConfig parameter from 0x00,0x00 to 0x03,0x00.
3. I changed the tSamFreq parameter in the Type I Format descriptor to 0x80,0xBB,0x00 to specify the new sample rate.
4. I changed the manufacturer and product text strings.
Just in case you would be prepared to check the enumeration log for the Microchip demo firmware and compare it with the one for my device, I'm attaching it. I'm blessed if I can see why that one works, yet mine doesn't...
Thanks again for your help, Jan.


[attachment deleted by admin]

JimR

  • Member
  • ***
  • Posts: 8
Re: Audio device enumeration problem
« Reply #11 on: March 12, 2011, 04:35:15 pm »
Hi again,

I forgot to mention that I did of course have to make quite a few changes in the function in my main program which handles reception of the stereo audio data stream from the ADC and then packaging it for sending to the host via USB packets...

I'm pretty sure that part works OK, though. My problem still seems tied in with the refusal of the host to accept all of my configuration descriptors.

Best wishes,
JimR

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Audio device enumeration problem
« Reply #12 on: March 13, 2011, 12:26:18 pm »

JimR

  • Member
  • ***
  • Posts: 8
Re: Audio device enumeration problem
« Reply #13 on: March 13, 2011, 08:06:50 pm »
Hi again,

Thanks for that suggestion. But are you suggesting I would be advised to change over to that device, with its built-in and preconfigured USB interface, instead of persevering with the PIC?  I am starting to lean in that direction, I must admit.

Can I ask if you did get a chance to look at the enumeration log for the Microchip demo firmware that does work, and if so could you see any significant differences?  I'd just like to know if I'm still just too dumb to program a USB device...

Best wishes,
JimR

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Audio device enumeration problem
« Reply #14 on: March 14, 2011, 04:13:45 pm »
The TI data sheet is just another source of info for comparison.

Audio isn't the easiest class to implement. My experience with it is limited. I haven't studied your enumeration logs in detail. You could try changing the descriptors gradually from the working ones.

Jan