Replies: 11 comments
-
What is Your log is hard to read, please use usbtreeview and look error from device manager. The latest master have some RP2040 audio fixes. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply...
apologes - I am testing the audio in Max by Cyling74 - this is the error it provided when thw audio froze.
Device USB\VID_CAFE&PID_4011&MI_00\7&332144be&1&0000 was configured. Driver Name: usbaudio2.inf here is the dump from usbtreeview: =========================== USB Port2 =========================== Connection Status : 0x01 (Device is connected)
Vendor ID : 0xCAFE (Unknown Vendor)
Device Description : USB Composite Device
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\CAFE40110100
Connection Index : 0x02 (Port 2)
Connection Index : 0x02 (2)
bLength : 0x12 (18 bytes) ConfigDescriptor 1 Error : WAIT_TIMEOUT
none
I thought I was on the latest master, but I will check |
Beta Was this translation helpful? Give feedback.
-
verfied that I am on the latest master, but no luck |
Beta Was this translation helpful? Give feedback.
-
Lastest master have some fundamental changes to audio class, especially transfers occurs in ISR now. Please start with one of the example and adapt to your needs, your code is a little too old. If device manager shows Ok then it looks like some audio specific control request didn't goes well, you can use Wireshark or other capture tools to check the bad request. |
Beta Was this translation helpful? Give feedback.
-
Thank you for you quick responses. - I think that's where I am struggling - I noticed the updated doc that added the
but I haven't found an example that describes how to implement this on a rp2040. In the example files, as far as I can tell, there isn't any indication of that being implemented. Sorry if I am missing something and thank you again for your help... |
Beta Was this translation helpful? Give feedback.
-
Personally I only use industrially proven MCUs instead of RP2xxx so I can't give you more details. But as far as I can tell pico-sdk handle interrupts differently, you can ignore this part written for general purpose MCU. |
Beta Was this translation helpful? Give feedback.
-
OKay thanks- then it sounds like I am using the API correctly? If it was an issue of depcrecated code then why would it work on Mac and not Windows? |
Beta Was this translation helpful? Give feedback.
-
I've no idea how Max by Cyling74 works and the meaning of its error message. I think the easiest way is build and test 4ch_mic example. Your code has some issues such as set a buffer size of only 1x endpoint size and queue 2 silent frames on streaming start. |
Beta Was this translation helpful? Give feedback.
-
Thank you again — However, I went back and tried to get the 4ch_mic example to work with the Pico SDK, and I have actually never been able to get that working. I am not using I²S, but rather data from the ADCs using DMA. I assume that shouldn’t be a real issue, because the 4ch_mic example has a dummy buffer that produces waveforms on the four channels. That being said, in the examples from the Pico SDK, a working version of the 4ch_mic example is not available. I also haven’t seen any evidence online of anyone getting the 4ch_mic example to work with the Pico SDK. The way I got my code working was by building up from: This has been working fine. As for the feedback — very appreciated, but: Your code has some issues such as setting a buffer size of only 1× endpoint size. Actually, the formula for two channels is: Where: Using Queue 2 silent frames on streaming start. This was removed with no change. I have some further details in regards to the behavior: TinyUSB v0.18.0 This seems to be a Windows-specific issue. I’ve combed through the 4ch_mic example, and aside from the two things you mentioned I don’t see any other substantial differences. So it looks like an API change is causing the problem. It seems to me that, if there were serious implementation issues such as endpoint sizes being wrong or ISRs not being implemented correctly, the device would enumerate on macOS at all. But I have been rolling with this code for a year now. I would think more likely, the issue is buried in the descriptors, which appear to be handled differently across operating systems. If you do know of a working version of the 4ch_mic example for the pico SDK that woudl be very appreciated. Thank you for any insights you can provide. |
Beta Was this translation helpful? Give feedback.
-
I too ran into an issue with the Pico and UAC2 in TinyUSB v0.18. There was a PR here that solved the issue, I turned it into a patch that can be applied to v0.18. My project is using UAC2 (stereo) + CDC. |
Beta Was this translation helpful? Give feedback.
-
If you read the commit history and PRs of https://github.com/hathach/tinyusb/commits/master/src/portable/raspberrypi/rp2040/dcd_rp2040.c you can see many people have audio working. Please update tinyusb to master then: cd /home/code
git clone https://github.com/raspberrypi/pico-sdk
cd /home/code/tinyusb
python tools\get_deps.py rp2040
cd /home/code/tinyusb/examples/device/audio_4_channel_mic
cmake --preset raspberry_pi_pico -DPICO_SDK_PATH=/home/code/pico-sdk
cmake --build --preset raspberry_pi_pico |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Operating System
Windows 11
Commit SHA
version 0.18.0 bundled by pico
Board
RP2040 custom board
Firmware
full code example is available here: https://github.com/mdhosale/tinyUSBv18bugRP2040
this code is from a larger project but was tested and verified before uploading.
I am using a custom descriptor to get 2-channel out from USB - but from what I can tell it aligns with the format of the 1 and 4 channel descriptor embedded in the API
What happened ?
UAC2 and CDC composite work with TinyUSB v0.17.0 on windows 11 but not on TinyUSB v0.18.0
It does work on MacOS - not tested on Linux
tusb_init();
to
with no luck -
tusb_init();
should be backwards compatible with v0.018How to reproduce ?
In the latest SDK the code does not work on Wondows 11.
to fix - I rolled back the TinyUSB Library without rolling back the pico SDK by navigating to:
../pico-sdk/lib/tinyusb
and doing the following:
make clean and compile and the USB enumerates and runs on Windows 11 (and Mac)
If I roll back to USB v0.18 by navigating to:
../pico-sdk/lib/tinyusb
and doing the following:
make clean and compile and the USB enumerates but the audio freezes on Windows 11; while the USB still enumerates and runs on Mac
Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)
I am receiveing this error on WIndows 11 and v0.18.0:
adportaudio_start:
error Invalid device from portaudio opening streamhere's the dump from USB Device Viewer on Windows 11:
[Port2] : USB Composite Device
Is Port User Connectable: yes
Is Port Debug Capable: no
Companion Port Number: 4
Companion Hub Symbolic Link Name: USB#ROOT_HUB30#5&16684953&0&0#{f18a0e88-c30c-11d0-8815-00a0c906bed8}
Protocols Supported:
USB 1.1: yes
USB 2.0: yes
USB 3.0: no
Device Power State: PowerDeviceD0
Port is USB4 Capable: No
Device is tunneled through USB4: No
English product name: "testing"
ConnectionStatus:
Current Config Value: 0x01 -> Device Bus Speed: Full (is not SuperSpeed or higher capable)
Device Address: 0x01
Open Pipes: 3
bLength: 0x12
bDescriptorType: 0x01
bcdUSB: 0x0200
bDeviceClass: 0xEF -> This is a Multi-interface Function Code Device
bDeviceSubClass: 0x02 -> This is the Common Class Sub Class
bDeviceProtocol: 0x01 -> This is the Interface Association Descriptor protocol
bMaxPacketSize0: 0x40 = (64) Bytes
idVendor: 0xCAFE = Vendor ID not listed with USB.org
idProduct: 0x4011
bcdDevice: 0x0100
iManufacturer: 0x01
English (United States) "Test"
iProduct: 0x02
English (United States) "testing"
iSerialNumber: 0x03
*!*ERROR: No String Descriptor for index 3!
bNumConfigurations: 0x01
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x83 -> Direction: IN - EndpointID: 3
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0008 = 0x08 bytes
bInterval: 0x10
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x04 -> Direction: OUT - EndpointID: 4
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x84 -> Direction: IN - EndpointID: 4
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
bLength: 0x09
bDescriptorType: 0x02
wTotalLength: 0x00D3 -> Validated
bNumInterfaces: 0x04
bConfigurationValue: 0x01
iConfiguration: 0x00
bmAttributes: 0x80 -> Bus Powered
MaxPower: 0x32 = 100 mA
bLength: 0x08
bDescriptorType: 0x0B
bFirstInterface: 0x00
bInterfaceCount: 0x02
bFunctionClass: 0x01 -> Audio Interface Class
bFunctionSubClass: 0x00
*!*CAUTION: This appears to be an invalid bFunctionSubClass
bFunctionProtocol: 0x20
iFunction: 0x00
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x00
bInterfaceClass: 0x01 -> Audio Interface Class
bInterfaceSubClass: 0x01 -> Audio Control Interface SubClass
bInterfaceProtocol: 0x20
*!*WARNING: must be set to PC_PROTOCOL_UNDEFINED 0 for this class
iInterface: 0x04
English (United States) "UAC2"
bLength: 0x09
bDescriptorType: 0x24 (CS_INTERFACE)
bDescriptorSubtype: 0x01 (HEADER)
bcdADC: 0x0200
wTotalLength: 0x4003
bInCollection: 0x00
bLength: 0x08
bDescriptorType: 0x24
08 24 0A 04 01 01 01 00
bLength: 0x11
bDescriptorType: 0x24
11 24 02 01 01 02 03 04 02 00 00 00 00 00 04 00
00
bLength: 0x0C
bDescriptorType: 0x24
0C 24 03 03 01 01 01 02 04 00 00 00
bLength: 0x12
bDescriptorType: 0x24 (CS_INTERFACE)
bDescriptorSubtype: 0x06 (FEATURE_UNIT)
bUnitID: 0x02
bSourceID: 0x01
bControlSize: 0x0F
*!*WARNING: bLength is greater than number of bmaControls (bLength > ( 7 + (ch + 1) * n)
*!*WARNING: Either bLength or bControlSize are invalid. The calculated logical channel count is -1. ((bLength - 7)/ n) - 1
bLength: 0x12
bDescriptorType: 0x24
12 24 06 02 01 0F 00 00 00 0F 00 00 00 0F 00 00
00 00
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x01
bAlternateSetting: 0x00
bNumEndpoints: 0x00
bInterfaceClass: 0x01 -> Audio Interface Class
bInterfaceSubClass: 0x02 -> Audio Streaming Interface SubClass
bInterfaceProtocol: 0x20
*!*WARNING: must be set to PC_PROTOCOL_UNDEFINED 0 for this class
iInterface: 0x00
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x01
bAlternateSetting: 0x01
bNumEndpoints: 0x01
bInterfaceClass: 0x01 -> Audio Interface Class
bInterfaceSubClass: 0x02 -> Audio Streaming Interface SubClass
bInterfaceProtocol: 0x20
*!*WARNING: must be set to PC_PROTOCOL_UNDEFINED 0 for this class
iInterface: 0x00
bLength: 0x10
bDescriptorType: 0x24
10 24 01 03 00 01 01 00 00 00 02 00 00 00 00 00
bLength: 0x06
bDescriptorType: 0x24 (CS_INTERFACE)
bDescriptorSubtype: 0x02 (FORMAT_TYPE)
bFormatType: 0x01 (FORMAT_TYPE_I)
bNrChannels: 0x02
bSubframeSize: 0x10
bBitResolution: 0x07 (7)
bSamFreqType: 0x05 (Discrete)
tSamFreq[1]: 0xC40581 (12846465 Hz)
tSamFreq[2]: 0x080100 (524544 Hz)
tSamFreq[3]: 0x000125 (293 Hz)
tSamFreq[4]: 0x000000 (0 Hz)
tSamFreq[5]: 0x0B0800 (722944 Hz)
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1
bmAttributes: 0x05 -> Isochronous Transfer Type, Synchronization Type = Asynchronous, Usage Type = Data Endpoint
wMaxPacketSize: 0x00C4 = 0xC4 bytes
bInterval: 0x01
bLength: 0x08
bDescriptorType: 0x25
08 25 01 00 00 00 00 00
bLength: 0x08
bDescriptorType: 0x0B
bFirstInterface: 0x02
bInterfaceCount: 0x02
bFunctionClass: 0x02 -> This is Communications (CDC Control) USB Device Interface Class
bFunctionSubClass: 0x02
bFunctionProtocol: 0x00
iFunction: 0x00
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x02
bAlternateSetting: 0x00
bNumEndpoints: 0x01
bInterfaceClass: 0x02 -> This is Communications (CDC Control) USB Device Interface Class
bInterfaceSubClass: 0x02
bInterfaceProtocol: 0x00
iInterface: 0x05
English (United States) "CDC"
-> This is a Communications (CDC Control) USB Device Interface Class
bLength: 0x05
bDescriptorType: 0x24
05 24 00 20 01
-> This is a Communications (CDC Control) USB Device Interface Class
bLength: 0x05
bDescriptorType: 0x24
05 24 01 00 03
-> This is a Communications (CDC Control) USB Device Interface Class
bLength: 0x04
bDescriptorType: 0x24
04 24 02 06
-> This is a Communications (CDC Control) USB Device Interface Class
bLength: 0x05
bDescriptorType: 0x24
05 24 06 02 03
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x83 -> Direction: IN - EndpointID: 3
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0008 = 0x08 bytes
bInterval: 0x10
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x03
bAlternateSetting: 0x00
bNumEndpoints: 0x02
bInterfaceClass: 0x0A -> This is a CDC Data USB Device Interface Class
bInterfaceSubClass: 0x00
bInterfaceProtocol: 0x00
iInterface: 0x00
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x04 -> Direction: OUT - EndpointID: 4
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x84 -> Direction: IN - EndpointID: 4
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
Screenshots
No response
I have checked existing issues, discussion and documentation
Beta Was this translation helpful? Give feedback.
All reactions