xCore200 UAC2 Demo record only silence under Linux Topic is solved

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
lorenzochiesi
Active Member
Posts: 34
Joined: Mon Sep 05, 2016 4:20 pm

xCore200 UAC2 Demo record only silence under Linux

Post by lorenzochiesi »

Hi all,

I'm developing an USB audio interface for an embedded linux system based on quad-core Freescale cortex A9 running custom linux distribution based on Yocto with kernel 3.10.

I know that the support for UAC2 in linux has some problem as documented in this post
https://www.xcore.com/forum/viewtopic.php?f=8&t=1719
but what I see sems different.

I use a xCore200 MC Audio version2 running the supplied UAC2 project with no code modification. I customized only the makefile building the test application with the following options (I don't need any mixer or volume control and I want to avoid risk that linux don't understand mixer descriptor or badly initialize volume so I disable it at all):

-DI2S_CHANS_DAC=8 -DI2S_CHANS_ADC=8
-DNUM_USB_CHAN_OUT=8 -DNUM_USB_CHAN_IN=8
-DMIDI=0 -DSPDIF_TX=0 -DSPDIF_RX=0
-DADAT_TX=0 -DADAT_RX=0 -DDSD_CHANS_DAC=0 -DMAX_FREQ=96000
-DOUTPUT_VOLUME_CONTROL=0 -DINPUT_VOLUME_CONTROL=0 -DMIXER=0
-DHID_CONTROLS=0

I tested my system under OSX and perfectly record audio signals from 8 input channels. In the osx control panel no volume or mute control is accessible as expected.

Then I tested my system connected to my embedded linux system.
Linux correctly enumerate USB device and also ALSA seen it without any kernel suspect error or warning message.
alsamixer correctly see the device without any accessible control as expected.
arecord also see the device, so I can try to record with the following command:
arecord -D hw:CARD=x20 -f S32_LE -r 48000 -c 8 testrec.wav

!The recorded has the expected format and length but is completely filled of 0!

First though was that my linux system don't correctly handle this kind of device, so I tested a commercial product I have that is based on XMOS L2 processor and (probably) contain nothing more than the example code I'm using:
https://www.minidsp.com/products/usb-au ... sbstreamer

The surprise is that this system perfectly work!!

So I can't understand where the problem can be.

Further test done using a PC with Linux Ubuntu 14.04 and different kernel version show the same problem (interface recognized but recorded file filled with 0).
Only upgrading to the very last kernel 4.4.0-47 the system start record correctly.

I can't figure why the MiniDSP interface work on my linux box and not the xCore MC Audio v2 board (that perfectly work under OSX)!

Can some update to the USB library occurred on porting to xC200 have determined this issue compatibility with linux driver?

Many thanks, Lorenzo


View Solution
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

That's an interesting failure.. We don't actually test for Linux as part of the regression so issues wouldn't necessarily come up. However we are seeing more and more people connect us to an ARM linux host (eg. RPI or other ARM based apps processor) and it works fine. For example, I recorded a 10ch 16KHz audio sample just now using linux kernel 4.4.26-v7 and it all looked good. This is with the latest version of the ref design running on the Xcore 200 multichannel board.

Do you have access to a USB analyzer? Are they zeros on the bus? If so I can only assume it's a descriptor thing...
lorenzochiesi
Active Member
Posts: 34
Joined: Mon Sep 05, 2016 4:20 pm

Post by lorenzochiesi »

This problem seems not limited to ARM linux: as I reported I experiment the same on UBUNTU 14.04 LTS with standard kernel (3.13 I think)....only lastest kernel update (4.4.0-47) seems fix the problem.

The test you suggest was exactly what I'd like to do...unfortunately I'm not expert on USB debug and I don't have any specific hardware.
I see that wireshark has an extension for analizing USB traffic and I'll try it on an UBUNTU PC.

Any other advice is strongly appreciated, I need to solve this in very short time :-(

By the way I tested this application also on a beaglebone black with Debian linux and 4.4? kernel and a lot of packet loss problem arise: I suppose is due to high frequency interrupt rate of UAC2 (8kHz). Forcing fallback to UAC1 with (1kHz interrupt I think) solve the problem and recordings are perfect but bandwith so limited.

Lorenzo
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

Hmm - well I trialled 16ch at 192KHz/32b (2x54Mbps streams at the same time) on the RPI3 and it coped quite nicely, so something odd with the Beagle bone.

If I was in your shoes, I'd be checking the descriptors - particularly the streaming interface (normally number 2 Alt1) and it's associated endpoints to see how they compare between the working and non-working devices.

It's quite fiddly to do this but there are some tools built in to help. From bash, you can do something like:

Code: Select all

pi@raspberrypi:~ $ lsusb
Bus 001 Device 004: ID 20b1:0008 XMOS Ltd 
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Then:

Code: Select all

lsusb -D /dev/bus/usb/001/004 
Device: ID 20b1:0008 XMOS Ltd 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 ?
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x20b1 XMOS Ltd
  idProduct          0x0008 
  bcdDevice            6.f1
  iManufacturer           1 
  iProduct                3 
  iSerial                 0 
  bNumConfigurations      2
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          408
    bNumInterfaces          5
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower                0mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         3
      bFunctionClass          1 Audio
      bFunctionSubClass       0 
      bFunctionProtocol      32 
      iFunction               0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol     32 
      iInterface              3 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               2.00
        bCategory               8
        wTotalLength          183
        bmControl            0x00
      AudioControl Interface Descriptor:
        bLength                 8
        bDescriptorType        36
        bDescriptorSubtype     10 (CLOCK_SOURCE)
        bClockID               41
        bmAttributes         0x03 Internal programmable Clock 
        bmControls           0x07
...
lorenzochiesi
Active Member
Posts: 34
Joined: Mon Sep 05, 2016 4:20 pm

Post by lorenzochiesi »

Here is the result of the suggsted command connecting my xCore200 MC Audio platform builded with UAC2 8 audio channel I/0 only (no midi, HID, mixer, volume control)

It give me exactly the same result on the following platform:
- Ubuntu 14.04.1 kernel 3.13.0-85 (Recording is silent)
- Ubuntu 14.04.1 kernel 4.4.0-47 (Recording perfectly working)

Code: Select all

Device: ID 20b1:0008 XMOS Ltd 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 ?
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x20b1 XMOS Ltd
  idProduct          0x0008 
  bcdDevice            6.f2
  iManufacturer           1 XMOS
  iProduct                3 xCORE USB Audio 2.0
  iSerial                 0 
  bNumConfigurations      2
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          329
    bNumInterfaces          4
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower                0mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         3
      bFunctionClass          1 Audio
      bFunctionSubClass       0 
      bFunctionProtocol      32 
      iFunction               0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol     32 
      iInterface              3 xCORE USB Audio 2.0
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               2.00
        bCategory               8
        wTotalLength           83
        bmControl            0x00
      AudioControl Interface Descriptor:
        bLength                 8
        bDescriptorType        36
        bDescriptorSubtype     10 (CLOCK_SOURCE)
        bClockID               41
        bmAttributes         0x03 Internal programmable Clock 
        bmControls           0x07
          Clock Frequency Control (read/write)
          Clock Validity Control (read-only)
        bAssocTerminal          0
        iClockSource            9 XMOS Internal Clock
      AudioControl Interface Descriptor:
        bLength                 8
        bDescriptorType        36
        bDescriptorSubtype     11 (CLOCK_SELECTOR)
        bUnitID                40
        bNrInPins               1
        baCSourceID( 0)        41
        bmControls           0x03
          Clock Selector Control (read/write)
        iClockSelector          8 XMOS Clock Selector
      AudioControl Interface Descriptor:
        bLength                17
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             2
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bCSourceID             40
        bNrChannels             8
        bmChannelConfig   0x00000000
        bmControls    0x0000
        iChannelNames          11 Analogue 1
        iTerminal               6 xCORE USB Audio 2.0 
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID            20
        wTerminalType      0x0301 Speaker
        bAssocTerminal          0
        bSourceID               2
        bCSourceID             40
        bmControls         0x0000
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                17
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0201 Microphone
        bAssocTerminal          0
        bCSourceID             40
        bNrChannels             8
        bmChannelConfig   0x00000000
        bmControls    0x0000
        iChannelNames          19 Analogue 1
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID            22
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bSourceID               2
        bCSourceID             40
        bmControls         0x0000
        iTerminal               7 xCORE USB Audio 2.0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              4 xCORE USB Audio 2.0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              4 xCORE USB Audio 2.0 
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           2
        bmControls           0x00
        bFormatType             1
        bmFormats         0x00000001
          PCM
        bNrChannels             8
        bmChannelConfig   0x00000000
        iChannelNames          11 Analogue 1
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            4
        bBitResolution         24
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x01a0  1x 416 bytes
        bInterval               1
        AudioControl Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         2 Decoded PCM samples
          wLockDelay              8
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       2
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              4 xCORE USB Audio 2.0 
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           2
        bmControls           0x00
        bFormatType             1
        bmFormats         0x00000001
          PCM
        bNrChannels             8
        bmChannelConfig   0x00000000
        iChannelNames          11 Analogue 1
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            2
        bBitResolution         16
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x00d0  1x 208 bytes
        bInterval               1
        AudioControl Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         2 Decoded PCM samples
          wLockDelay              8
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       3
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              4 xCORE USB Audio 2.0 
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           2
        bmControls           0x00
        bFormatType             1
        bmFormats         0x80000000
        bNrChannels             8
        bmChannelConfig   0x00000000
        iChannelNames          11 Analogue 1
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            4
        bBitResolution         32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x01a0  1x 416 bytes
        bInterval               1
        AudioControl Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         2 Decoded PCM samples
          wLockDelay              8
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              5 xCORE USB Audio 2.0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              5 xCORE USB Audio 2.0 
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink          22
        bmControls           0x00
        bFormatType             1
        bmFormats         0x00000001
          PCM
        bNrChannels             8
        bmChannelConfig   0x00000000
        iChannelNames          19 Analogue 1
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            4
        bBitResolution         24
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes           37
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Implicit feedback Data
        wMaxPacketSize     0x01a0  1x 416 bytes
        bInterval               1
        AudioControl Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         2 Decoded PCM samples
          wLockDelay              8
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       254 Application Specific Interface
      bInterfaceSubClass      1 Device Firmware Update
      bInterfaceProtocol      1 
      iInterface             10 XMOS DFU
      Device Firmware Upgrade Interface Descriptor:
        bLength                             9
        bDescriptorType                    33
        bmAttributes                        7
          Will Not Detach
          Manifestation Tolerant
          Upload Supported
          Download Supported
        wDetachTimeout                    250 milliseconds
        wTransferSize                      64 bytes
        bcdDFUVersion                   1.10
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          329
    bNumInterfaces          4
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower                0mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         3
      bFunctionClass          1 Audio
      bFunctionSubClass       0 
      bFunctionProtocol      32 
      iFunction               0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol     32 
      iInterface              3 xCORE USB Audio 2.0
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               2.00
        bCategory               8
        wTotalLength           83
        bmControl            0x00
      AudioControl Interface Descriptor:
        bLength                 8
        bDescriptorType        36
        bDescriptorSubtype     10 (CLOCK_SOURCE)
        bClockID               41
        bmAttributes         0x03 Internal programmable Clock 
        bmControls           0x07
          Clock Frequency Control (read/write)
          Clock Validity Control (read-only)
        bAssocTerminal          0
        iClockSource            9 XMOS Internal Clock
      AudioControl Interface Descriptor:
        bLength                 8
        bDescriptorType        36
        bDescriptorSubtype     11 (CLOCK_SELECTOR)
        bUnitID                40
        bNrInPins               1
        baCSourceID( 0)        41
        bmControls           0x03
          Clock Selector Control (read/write)
        iClockSelector          8 XMOS Clock Selector
      AudioControl Interface Descriptor:
        bLength                17
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             2
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bCSourceID             40
        bNrChannels             8
        bmChannelConfig   0x00000000
        bmControls    0x0000
        iChannelNames          11 Analogue 1
        iTerminal               6 xCORE USB Audio 2.0 
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID            20
        wTerminalType      0x0301 Speaker
        bAssocTerminal          0
        bSourceID               2
        bCSourceID             40
        bmControls         0x0000
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                17
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0201 Microphone
        bAssocTerminal          0
        bCSourceID             40
        bNrChannels             8
        bmChannelConfig   0x00000000
        bmControls    0x0000
        iChannelNames          19 Analogue 1
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID            22
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bSourceID               2
        bCSourceID             40
        bmControls         0x0000
        iTerminal               7 xCORE USB Audio 2.0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              4 xCORE USB Audio 2.0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              4 xCORE USB Audio 2.0 
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           2
        bmControls           0x00
        bFormatType             1
        bmFormats         0x00000001
          PCM
        bNrChannels             8
        bmChannelConfig   0x00000000
        iChannelNames          11 Analogue 1
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            4
        bBitResolution         24
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x01a0  1x 416 bytes
        bInterval               1
        AudioControl Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         2 Decoded PCM samples
          wLockDelay              8
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       2
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              4 xCORE USB Audio 2.0 
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           2
        bmControls           0x00
        bFormatType             1
        bmFormats         0x00000001
          PCM
        bNrChannels             8
        bmChannelConfig   0x00000000
        iChannelNames          11 Analogue 1
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            2
        bBitResolution         16
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x00d0  1x 208 bytes
        bInterval               1
        AudioControl Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         2 Decoded PCM samples
          wLockDelay              8
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       3
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              4 xCORE USB Audio 2.0 
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           2
        bmControls           0x00
        bFormatType             1
        bmFormats         0x80000000
        bNrChannels             8
        bmChannelConfig   0x00000000
        iChannelNames          11 Analogue 1
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            4
        bBitResolution         32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x01a0  1x 416 bytes
        bInterval               1
        AudioControl Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         2 Decoded PCM samples
          wLockDelay              8
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              5 xCORE USB Audio 2.0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              5 xCORE USB Audio 2.0 
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink          22
        bmControls           0x00
        bFormatType             1
        bmFormats         0x00000001
          PCM
        bNrChannels             8
        bmChannelConfig   0x00000000
        iChannelNames          19 Analogue 1
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            4
        bBitResolution         24
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes           37
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Implicit feedback Data
        wMaxPacketSize     0x01a0  1x 416 bytes
        bInterval               1
        AudioControl Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         2 Decoded PCM samples
          wLockDelay              8
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       254 Application Specific Interface
      bInterfaceSubClass      1 Device Firmware Update
      bInterfaceProtocol      1 
      iInterface             10 XMOS DFU
      Device Firmware Upgrade Interface Descriptor:
        bLength                             9
        bDescriptorType                    33
        bmAttributes                        7
          Will Not Detach
          Manifestation Tolerant
          Upload Supported
          Download Supported
        wDetachTimeout                    250 milliseconds
        wTransferSize                      64 bytes
        bcdDFUVersion                   1.10
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 ?
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  bNumConfigurations      2
Device Status:     0x0001
  Self Powered

Also an my Quad Core ARM cortex A9 (Recording is silent) gives very similar result:
the only differences is: "bDeviceSubClass 2"
instead of: "bDeviceSubClass 2 ?"

Mean something?

At the moment I can't test the miniDSP devices that correctly work on my ARM system that I have gived back to the owner :-(

Any thoughts from this info?
You have tested on rasperrypi using MC Audio board?
Can you send me your code to test from my side?

Lorenzo
lorenzochiesi
Active Member
Posts: 34
Joined: Mon Sep 05, 2016 4:20 pm

Post by lorenzochiesi »

Hi,

Attached the output of lsusb command run on my linux ARM board with:
- XC MC AUDIO (Record only silence)
- miniDSP USBStreamer (Perfectly work)

Comparing the files result in significant differences...can you help me to interpretate it and try understand if this can explain observed behaviour?
Attachments
lsusb_XC200_MC_AUDIO.txt
(25.4 KiB) Downloaded 449 times
lsusb_XC200_MC_AUDIO.txt
(25.4 KiB) Downloaded 449 times
lsusb_miniDSP_USBStreamer.txt
(30.92 KiB) Downloaded 416 times
lsusb_miniDSP_USBStreamer.txt
(30.92 KiB) Downloaded 416 times
lorenzochiesi
Active Member
Posts: 34
Joined: Mon Sep 05, 2016 4:20 pm

Post by lorenzochiesi »

Hi everybody,

After some day of debug I solved the described problem finding probably a small bug....following some consideration that can be useful to some other...

At a certain point of my debugging I discovered that my board record audio on any linux kernel and platform but only if before some audio was played on the interface.

Checking with scope the reset signal of ADC and DAC I discovered that:
- at power on the both reset signal are low.
- running after power on a recording command (arecord ...) the ADC reset still remain low, so IS2 are low too and 0 will recorded
- running a playback command (aplay, speaker-test, ) the ADC reset line will be relased, so following recording commands work properly

Digging into the code I find that both ADC and DAC are configured and getted out from reset only in the same function AudioHwConfig(). because the DAC reset is relased I'm shure that the recording command result in running this function.

The only possible reason for the ADC reset to remain asserted is due to the variable "dsdMode" that at boot seems not initialized with DSD_MODE_OFF, despite my code not use DSD. This result in skipping ADC configuration keeping ADC in reset state.

As soon as a playback request is issued the dsdMode will correctly set to DSD_MODE_OFF, resulting in proper work of successive recording request.

At the moment I solved my problem adding this code immediately before to evaluate dsdMode to ensure that is properly set also at first execution:

Code: Select all

    #if(DSD_CHANS_DAC == 0)
    dsdMode = DSD_MODE_OFF;
    #endif

    if((dsdMode == DSD_MODE_NATIVE) || (dsdMode == DSD_MODE_DOP))
    { 
...
Probably a better fix should be done but this for me work perfectly :-)


Now all run smootly up to 16 ADC channel 96kHz on a quad core ARM embedded platform (similar to raspberry3)

I tested it also on beaglebone black (single core ARM sitera ) and I can confirm that don't work very well: interrupt of UAC2 is too fast for this processor and also with 8 channel 48kHz some usb packet will be dropped (1 every second as average).

Regards,
Lorenzo
Last edited by lorenzochiesi on Thu Nov 24, 2016 7:18 pm, edited 1 time in total.
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

Well done on fault finding and thanks for posting the results!

So the descriptor thing was a red herring then? That's why a USB analyser is so handy because you can check the signal at different points along the path. However, in this case, a scope probe on the I2S ADC lines would have told the story too..

I checked the ref design and dsdMode can only get set by:

1) DoP headers being detected when in PCM mode (or lack of DoP headers when in DoP mode)
2) When (command == SET_STREAM_FORMAT_OUT), which ultimately comes from a channel communication from EP0 when the output interface is changed to the Native DSD interface. The value is stored in

Code: Select all

const unsigned g_dataFormat_Out[OUTPUT_FORMAT_COUNT] 
So I'm struggling to see how dsdMode gets set to the wrong value in just audio configuration. Obviously something wasn't write (hence your issue). Were you able to print dsdMode and see what it got set to?

Thanks!
lorenzochiesi
Active Member
Posts: 34
Joined: Mon Sep 05, 2016 4:20 pm

Post by lorenzochiesi »

I'm trying to see contents of dsdMode before putting it to DSD_MODE_OFF:
I modified my patch in this way and tried to enable a brakpoint on assignation inside if

Code: Select all

    
    #if(DSD_CHANS_DAC == 0)
    if (dsdMode != DSD_MODE_OFF){
        dsdMode = DSD_MODE_OFF;
    }
    #endif
Unfortunately I can't find a way to have this brakpoint works: it give always warning message: "Unresolved breakpoint"

I try to modify build flags from makefile reducing optimization from -O3 to -O2 (-O1 and -O0 won't build at all) or removing -g flag (debug is enabled or disabled by -g??) without any success.
Why this happen?

Is there any other simple way to print debug message on a debug console?

Sorry for this simple question but I'm pretty new to XMOS IDE

Lorenzo
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

Yep - breakpoints can be an issue at -O2 and above because the compiler starts doing crazy optimisations which mean lines of source don't match up terribly well with instructions.

My preferred approach is to print using xscope (very fast printing + minimal intrusiveness).

http://www.xcore.com/forum/viewtopic.php?f=47&t=4088

You can put a simple & lightweight print in like:

Code: Select all

#include <print.h>
printintln(dsdMode);
and then run with Target I/O option as "xscope"

xscope printing is already enabled by default in USB audio..
Post Reply