-2

I have updated the question because I think it can be a bit confusing. I want to make an USB device with 2 different endpoints, an audio card and a serial port.

I want to use a Raspberry Pi Pico for this project with the TinyUSB library and I have tried to combine the dual_cdc example with the uac2_headset one in the cdc_uac folder on the example_cdc_uac2 branch, but although it compiles and its recognized by the host it doesn't work. That examples work well for me independently.

Here is an extract from the code:

enum
{
  ITF_NUM_CDC_0 = 0,
  ITF_NUM_CDC_0_DATA,
  ITF_NUM_CDC_1,
  ITF_NUM_CDC_1_DATA,
  ITF_NUM_AUDIO_CONTROL,       // FIXME: I have added here the AUDIO ITFs. Is it something wrong?
  ITF_NUM_AUDIO_STREAMING_SPK,
  ITF_NUM_AUDIO_STREAMING_MIC,
  ITF_NUM_TOTAL
};

#define EPNUM_CDC_0_NOTIF   0x81
#define EPNUM_CDC_0_OUT     0x02
#define EPNUM_CDC_0_IN      0x82

#define EPNUM_CDC_1_NOTIF   0x83
#define EPNUM_CDC_1_OUT     0x04
#define EPNUM_CDC_1_IN      0x84

#define EPNUM_AUDIO_OUT     0x01
#define EPNUM_AUDIO_IN      0x81

uint8_t const desc_fs_configuration[] =
{
  // Config number, interface count, string index, total length, attribute, power in mA
  TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),

  // 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
  TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_0, 4, EPNUM_CDC_0_NOTIF, 8, EPNUM_CDC_0_OUT, EPNUM_CDC_0_IN, 64),

  // 2nd CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
  TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_1, 4, EPNUM_CDC_1_NOTIF, 8, EPNUM_CDC_1_OUT, EPNUM_CDC_1_IN, 64),

  // Interface number, string index, EP Out & EP In address, EP size
  TUD_AUDIO_HEADSET_STEREO_DESCRIPTOR(2, EPNUM_AUDIO_OUT, EPNUM_AUDIO_IN),
};

I have executed dmesg command after putting in the device and it says the following:

[65995.165040] usb 1-3: new full-speed USB device number 48 using xhci_hcd
[65995.538127] usb 1-3: New USB device found, idVendor=cafe, idProduct=4012, bcdDevice= 1.00
[65995.538132] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[65995.538135] usb 1-3: Product: TinyUSB Device
[65995.538137] usb 1-3: Manufacturer: TinyUSB
[65995.538139] usb 1-3: SerialNumber: 123456
[65995.556877] cdc_acm 1-3:1.0: ttyACM0: USB ACM device
[65995.562864] cdc_acm 1-3:1.2: ttyACM1: USB ACM device
[65995.631858] xhci_hcd 0000:01:00.0: Trying to add endpoint 0x81 without dropping it.
[65995.631862] usb 1-3: Not enough bandwidth for altsetting 1
[65995.646855] xhci_hcd 0000:01:00.0: Trying to add endpoint 0x81 without dropping it.
[65995.646860] usb 1-3: Not enough bandwidth for altsetting 2
[65995.775643] xhci_hcd 0000:01:00.0: Trying to add endpoint 0x81 without dropping it.
[65995.775650] usb 1-3: Not enough bandwidth for altsetting 1
[65995.775653] usb 1-3: 6:1: usb_set_interface failed (-22)
[65995.775765] xhci_hcd 0000:01:00.0: Trying to add endpoint 0x81 without dropping it.
[65995.775769] usb 1-3: Not enough bandwidth for altsetting 1
[65995.775771] usb 1-3: 6:1: usb_set_interface failed (-22)
[65995.775883] xhci_hcd 0000:01:00.0: Trying to add endpoint 0x81 without dropping it.

I also have updated the code here by cloning the whole TinyUSB repository to make easier for the people who wants to help.

Thank you in advance and I hope it will be clearly now.

Angel
  • 1
  • 3
  • 1
    Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Oct 20 '22 at 14:48
  • 1
    How doesn't it work? Have you looked at what the host PC sees of it? What does that look like? What is it supposed to look like? Does the host at least do *something* with it? What does it do? Put some (non-blocking!) debug code in the pico. (blink some LED's, wiggle an oscilloscope probe, etc.) What do you expect that code to do? What does it actually do? Etc. – AaronD Oct 22 '22 at 17:38
  • Also important: does the example code work as-is? No modifications, just load it and run it. Does that work as expected for what it is? They don't always, as I've found out myself with the `uac2_headset` example. If not, debug that first, per my previous comment (I'm still working on that), THEN build on a known-working example. – AaronD Oct 22 '22 at 17:41
  • I have updated the question to try to answer your questions as best as possible, please ask me if you need more info about the problem. Thank you so much. – Angel Oct 23 '22 at 20:11
  • You are required to post your code here within your question and not a link to any other site [ask] – Rob Oct 23 '22 at 20:12
  • I tried to add the whole code at here first, but it's longer than 30.000 characters, the Stack Overflow limit. I have added an extract of the code about the usb descriptors code. Thank you for your comment Rob. – Angel Oct 24 '22 at 15:31
  • @Angel - you should include *relevant code* - you don't need to (and shouldn't) dump a massive code project into your question. Just what's needed to help clarify the issue you're having. But yes, you need to have your code (and inputs, outputs, errors, etc) in your question. – David Makogon Oct 24 '22 at 20:05
  • I think the problem can be in the extract of the code, because the EPNUM_CDC_0_NOTIF and EPNUM_AUDIO_IN has the same value. But I'm not sure about that because if I disable the first CDC device it also doesn't work. – Angel Oct 25 '22 at 21:05

2 Answers2

0

I have achieved to join this two samples into one by modifying the UAC2 example to a lower audio quaility. Previous test I made doesn't work because Raspberry Pi Pico USB is 1.1 and hasn't enough bandwidth.

Angel
  • 1
  • 3
0

You will note that CDC 0 NOTIF and AUDIO IN share the same endpoint number. I had pretty much exactly the same problem and changed the endpoint numbers like this...

#define EPNUM_CDC_NOTIF   0x83
#define EPNUM_CDC_OUT     0x04
#define EPNUM_CDC_IN      0x84
user16217248
  • 3,119
  • 19
  • 19
  • 37