USB Audio on xcore-200 USB slicekit

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
Post Reply
Unchyu2
Member++
Posts: 29
Joined: Tue Jun 17, 2014 11:40 am

USB Audio on xcore-200 USB slicekit

Post by Unchyu2 »

Hello,

I am trying to port the USB Audio 2.0 firmware to the newly acquired xCore-200 USB slicekit but but no success.

Basically I have modified the app_usb_aud_skc_u16 project by importing SLICEKIT-XU216.xn and adding the requiered connections:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
  <Type>Board</Type>
  <Name>sliceKIT Core Board (XU216)</Name>
  <Declarations>
    <Declaration>tileref tile[2]</Declaration>
    <Declaration>tileref usb_tile</Declaration>
  </Declarations>
  <Packages>
    <Package id="0" Type="XS2-UnA-512-FB236">
      <Nodes>
        <Node Id="0" InPackageId="0" Type="XS2-L16A-512" OscillatorSrc="1" SystemFrequency="500MHz">
          <Boot>
            <Source Location="bootFlash"/>
          </Boot>
          <Tile Number="0" Reference="tile[0]">
            <Port Location="XS1_PORT_1B" Name="PORT_SQI_CS"/>
            <Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK"/>
            <Port Location="XS1_PORT_4B" Name="PORT_SQI_SIO"/>
            <!-- XUD Ports -->
            <Port Location="XS1_PORT_1H"  Name="PORT_USB_TX_READYIN"/>
            <Port Location="XS1_PORT_1J"  Name="PORT_USB_CLK"/>
            <Port Location="XS1_PORT_1K"  Name="PORT_USB_TX_READYOUT"/>
            <Port Location="XS1_PORT_1M"  Name="PORT_USB_RX_READY"/>
            <Port Location="XS1_PORT_1N"  Name="PORT_USB_FLAG0"/>
            <Port Location="XS1_PORT_1O"  Name="PORT_USB_FLAG1"/>
            <Port Location="XS1_PORT_1P"  Name="PORT_USB_FLAG2"/>
            <Port Location="XS1_PORT_8B"  Name="PORT_USB_TXD"/>
            <Port Location="XS1_PORT_8C"  Name="PORT_USB_RXD"/>
            <!-- Audio Ports -->
            <Port Location="XS1_PORT_16B"  Name="PORT_MCLK_COUNT"/>
            <Port Location="XS1_PORT_1F"  Name="PORT_MCLK_IN2"/>
          </Tile>
        <Tile Number="0" Reference="tile[1]">
                <Port Location="XS1_PORT_1A"  Name="PORT_I2S_BCLK"/>
                <Port Location="XS1_PORT_1M"  Name="PORT_SPDIF_OUT"/>
                <Port Location="XS1_PORT_1D"  Name="PORT_I2S_DAC0"/>
                <Port Location="XS1_PORT_1E"  Name="PORT_MCLK_IN"/>
                <Port Location="XS1_PORT_1F"  Name="PORT_MIDI_IN"/>
                <port Location="XS1_PORT_1H"  Name="PORT_I2S_DAC1"/>
                <Port Location="XS1_PORT_1I"  Name="PORT_I2S_LRCLK"/>
                <Port Location="XS1_PORT_1K"  Name="PORT_I2S_ADC0"/>
                <Port Location="XS1_PORT_1L"  Name="PORT_I2S_ADC1"/>
                <Port Location="XS1_PORT_8D"  Name="PORT_MIDI_OUT"/>
            </Tile>
        </Node>
        <Node Id="1" InPackageId="1" Type="periph:XS1-SU" Reference="usb_tile" Oscillator="24MHz">
        </Node>
      </Nodes>
      <Links>
        <Link Encoding="5wire">
          <LinkEndpoint NodeId="0" Link="8" Delays="52clk,52clk"/>
          <LinkEndpoint NodeId="1" Link="XL0" Delays="1clk,1clk"/>
        </Link>
      </Links>
    </Package>
  </Packages>
  <Nodes>
    <Node Id="2" Type="device:" RoutingId="0x8000">
      <Service Id="0" Proto="xscope_host_data(chanend c);">
        <Chanend Identifier="c" end="3"/>
      </Service>
    </Node>
  </Nodes>
  <Links>
    <Link Encoding="2wire" Delays="5clk" Flags="XSCOPE">
      <LinkEndpoint NodeId="0" Link="XL0"/>
      <LinkEndpoint NodeId="2" Chanend="1"/>
    </Link>
  </Links>
  <ExternalDevices>
    <Device NodeId="0" Tile="0" Class="SQIFlash" Name="bootFlash" Type="S25FL116K">
      <Attribute Name="PORT_SQI_CS" Value="PORT_SQI_CS"/>
      <Attribute Name="PORT_SQI_SCLK"   Value="PORT_SQI_SCLK"/>
      <Attribute Name="PORT_SQI_SIO"  Value="PORT_SQI_SIO"/>
    </Device>
  </ExternalDevices>
  <JTAGChain>
    <JTAGDevice NodeId="0"/>
  </JTAGChain>
</Network>
and I have also modified the makefile to use the new .xn file and the new xud_x200 architecture instead of the old xud_u.

Code: Select all

# The TARGET variable determines what target system the application is 
# compiled for. It either refers to an XN file in the source directories
# or a valid argument for the --target option when compiling.

TARGET = SLICEKIT-XU216.xn
APP_NAME =

# The flags passed to xcc when building the application
BUILD_FLAGS     = -DFLASH_MAX_UPGRADE_SIZE=64*1024 -fcomment-asm -Xmapper --map -Xmapper MAPFILE -Wall -O3 -report -lflash -fsubword-select -save-temps -g -fxscope -DXSCOPE -DSDA_HIGH=2 -DSCL_HIGH=1 -DXUD_ON_U_SERIES=1

# Test build configs (Note these make use of the defaults in customdefines.h)

# Audio Class 2, Input, Output, No MIDI, SPDIF
XCC_FLAGS_2ioxs = $(BUILD_FLAGS) 
INCLUDE_ONLY_IN_2ioxs = 

# The USED_MODULES variable lists other module used by the application. These
# modules will extend the SOURCE_DIRS, INCLUDE_DIRS and LIB_DIRS variables. 
# Modules are expected to be in the directory above the BASE_DIR directory.
USED_MODULES = module_usb_shared module_xud module_usb_audio module_spdif_tx module_spdif_rx module_usb_midi module_dfu module_i2c_single_port module_usb_device

MODULE_LIBRARIES = xud_x200

#=============================================================================
# The following part of the Makefile includes the common build infrastructure
# for compiling XMOS applications. You should not need to edit below here.

XMOS_MAKE_PATH ?= ../..
include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common
after all this I am getting the following error:

xrun: First stage multi-node boot failed, please check XN file and Xmos link connectivity

Any help if appreciated,
Ilie


User avatar
Ross
XCore Expert
Posts: 962
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

-DXUD_ON_U_SERIES=1

This looks incorrect, but I'm perry sure that's not causing the issue.
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

Does a simple blinky or hello world application run with your modified xn file?
Unchyu2
Member++
Posts: 29
Joined: Tue Jun 17, 2014 11:40 am

Post by Unchyu2 »

Hello,

1. So I have imported application note: AN10018_flashing_leds

2. I have added the same .xn file: SLICEKIT-XU216.xn

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
  <Type>Board</Type>
  <Name>sliceKIT Core Board (XU216)</Name>
  <Declarations>
    <Declaration>tileref tile[2]</Declaration>
    <Declaration>tileref usb_tile</Declaration>
  </Declarations>
  <Packages>
    <Package id="0" Type="XS2-UnA-512-FB236">
      <Nodes>
        <Node Id="0" InPackageId="0" Type="XS2-L16A-512" OscillatorSrc="1" SystemFrequency="500MHz">
          <Boot>
            <Source Location="bootFlash"/>
          </Boot>
          <Tile Number="0" Reference="tile[0]">
            <Port Location="XS1_PORT_1B" Name="PORT_SQI_CS"/>
            <Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK"/>
            <Port Location="XS1_PORT_4B" Name="PORT_SQI_SIO"/>
            <!-- XUD Ports -->
            <Port Location="XS1_PORT_1H"  Name="PORT_USB_TX_READYIN"/>
            <Port Location="XS1_PORT_1J"  Name="PORT_USB_CLK"/>
            <Port Location="XS1_PORT_1K"  Name="PORT_USB_TX_READYOUT"/>
            <Port Location="XS1_PORT_1M"  Name="PORT_USB_RX_READY"/>
            <Port Location="XS1_PORT_1N"  Name="PORT_USB_FLAG0"/>
            <Port Location="XS1_PORT_1O"  Name="PORT_USB_FLAG1"/>
            <Port Location="XS1_PORT_1P"  Name="PORT_USB_FLAG2"/>
            <Port Location="XS1_PORT_8B"  Name="PORT_USB_TXD"/>
            <Port Location="XS1_PORT_8C"  Name="PORT_USB_RXD"/>
            <!-- Audio Ports -->
            <Port Location="XS1_PORT_16B"  Name="PORT_MCLK_COUNT"/>
            <Port Location="XS1_PORT_1F"  Name="PORT_MCLK_IN2"/>
          </Tile>
        <Tile Number="0" Reference="tile[1]">
                <Port Location="XS1_PORT_1A"  Name="PORT_I2S_BCLK"/>
                <Port Location="XS1_PORT_1M"  Name="PORT_SPDIF_OUT"/>
                <Port Location="XS1_PORT_1D"  Name="PORT_I2S_DAC0"/>
                <Port Location="XS1_PORT_1E"  Name="PORT_MCLK_IN"/>
                <Port Location="XS1_PORT_1F"  Name="PORT_MIDI_IN"/>
                <port Location="XS1_PORT_1H"  Name="PORT_I2S_DAC1"/>
                <Port Location="XS1_PORT_1I"  Name="PORT_I2S_LRCLK"/>
                <Port Location="XS1_PORT_1K"  Name="PORT_I2S_ADC0"/>
                <Port Location="XS1_PORT_1L"  Name="PORT_I2S_ADC1"/>
                <Port Location="XS1_PORT_8D"  Name="PORT_MIDI_OUT"/>
            </Tile>
        </Node>
        <Node Id="1" InPackageId="1" Type="periph:XS1-SU" Reference="usb_tile" Oscillator="24MHz">
        </Node>
      </Nodes>
      <Links>
        <Link Encoding="5wire">
          <LinkEndpoint NodeId="0" Link="8" Delays="52clk,52clk"/>
          <LinkEndpoint NodeId="1" Link="XL0" Delays="1clk,1clk"/>
        </Link>
      </Links>
    </Package>
  </Packages>
  <Nodes>
    <Node Id="2" Type="device:" RoutingId="0x8000">
      <Service Id="0" Proto="xscope_host_data(chanend c);">
        <Chanend Identifier="c" end="3"/>
      </Service>
    </Node>
  </Nodes>
  <Links>
    <Link Encoding="2wire" Delays="5clk" Flags="XSCOPE">
      <LinkEndpoint NodeId="0" Link="XL0"/>
      <LinkEndpoint NodeId="2" Chanend="1"/>
    </Link>
  </Links>
  <ExternalDevices>
    <Device NodeId="0" Tile="0" Class="SQIFlash" Name="bootFlash" Type="S25FL116K">
      <Attribute Name="PORT_SQI_CS" Value="PORT_SQI_CS"/>
      <Attribute Name="PORT_SQI_SCLK"   Value="PORT_SQI_SCLK"/>
      <Attribute Name="PORT_SQI_SIO"  Value="PORT_SQI_SIO"/>
    </Device>
  </ExternalDevices>
  <JTAGChain>
    <JTAGDevice NodeId="0"/>
  </JTAGChain>
</Network>
3. modified Makefile to target this .xn file

Code: Select all

# The TARGET variable determines what target system the application is
# compiled for. It either refers to an XN file in the source directories
# or a valid argument for the --target option when compiling.

TARGET = SLICEKIT-XU216.xn

# The APP_NAME variable determines the name of the final .xe file. It should
# not include the .xe postfix. If left blank the name will default to
# the project name

APP_NAME = 

# The flags passed to xcc when building the application
# You can also set the following to override flags for a particular language:
#
#    XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
#
# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
# xcc for the final link (mapping) stage.

XCC_FLAGS = -O2 -g

# The USED_MODULES variable lists other build module used by the application.

USED_MODULES =

#=============================================================================
# The following part of the Makefile includes the common build infrastructure
# for compiling XMOS applications. You should not need to edit below here.

XMOS_MAKE_PATH ?= ../..
include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common
4. and added tile configuration to flashing_leds.xc

Code: Select all

// Copyright (c) 2016, XMOS Ltd, All rights reserved
/**
 A flashing LEDs example
 -----------------------
**/

#include <syscall.h>
#include <platform.h>
#include <xs1.h>
#include <timer.h>

/**
The simplest flashing LED program loops forever alternating between
driving a port high and driving it low. The '<:' operator drives a
value on a port. In between outputs you can make the task pause with
the 'delay_milliseconds' function. There are several 'delay_'
functions defined in 'timer.h'.
**/


void flashing_led_task1(port p, int delay_in_ms) {
  while (1) {
    p <: 0;
    delay_milliseconds(delay_in_ms);
    p <: 1;
    delay_milliseconds(delay_in_ms);
  }
}

/**
The simple example above will block the logical core while waiting
between port outputs. This is quite inefficient. To allow other
computation to occur in between outputs you need to use timer events.
This requires declaring a variable of 'timer' type and then using a
'select' statement which reacts to events on this timer.
**/


[[combinable]]
void flashing_led_task2(port p, int delay_in_ms) {
  timer tmr;
  unsigned t;
  // Convert delay from ms to 100Mhz timer ticks
  const int delay_ticks = delay_in_ms * 100000;
  // The value we are going to output
  unsigned val = 0;

  // read the initial timer value
  tmr :> t;
  while (1) {
    select {
    // This case will event when the timer moves past (t + delay_ticks) i.e
    // delay_ticks after when we took the timestamp t
    case tmr when timerafter(t + delay_ticks) :> void:
      p <: val;
      val = ~val;
      // set up the next event
      t += delay_ticks;
      break;
    }
  }
}

/**
Note that this function has been marked as '[[combinable]]'. This
means it can share a logical core with other combinable functions that
will handle other events in between the port outputs of this flashing
LED task.
**/


on tile[1] :port p = XS1_PORT_1A;
on tile[1] :port q = XS1_PORT_1B;
int main() {
  par {
      on tile[1] : flashing_led_task1(p, 200);
      on tile[1] : flashing_led_task2(q, 300);
  }
  return 0;
}
But I still get the same message:

xrun: First stage multi-node boot failed, please check XN file and Xmos link connectivity
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

This quite odd... the message

Code: Select all

xrun: First stage multi-node boot failed, please check XN file and Xmos link connectivity
really means is that the bootloader has tried to distribute the individual programs to each node (across links to the other node which should be in boot from link mode) and it has failed. One reason for this is a difference between the link description in the XN file against actual hardware (although you are using the correct XN) or another reason could be that the target system has booted from flash already and the "bootee" is already running a user program and not listening.

So try erasing the flash perhaps..

Code: Select all

xflash --erase-all --target SLICEKIT-XU216 
Have you had *anything* successfully running on the board yet?

Presumably this gets you an available device?

Code: Select all

xrun -l 
Unchyu2
Member++
Posts: 29
Joined: Tue Jun 17, 2014 11:40 am

Post by Unchyu2 »

Have you had *anything* successfully running on the board yet?
Nope, I have just received the board after about 5 weeks of waiting because DigiKey didn't have it on stock.
xrun -l
returns:

Code: Select all

Available XMOS Devices
----------------------

  ID    Name                    Adapter ID      Devices
  --    ----                    ----------      -------
  0     XMOS XTAG-2             CLChiYxb        O[0]
and
xflash --erase-all --target SLICEKIT-XU216
executes but doesn't return anything.

I tried to run my code after running the erase flash command but I get the same error.

PS. this is my first time using the command line, until now I have successfully worked on other projects using xTimeComposer (currently on 14.2.4).
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

OK - that (sucessful running of the tools command .... nothing printed is "good news, all was well" ) suggests that the tools xn file (referenced by --target SLICEKIT-XU216) is fine and works for your board. You definitely have an empty flash now.

So, it means your xn file is the source of the problem.

Looking at it more closely,

Code: Select all

        <Tile Number="0" Reference="tile[1]">
could be an issue. It should be Tile Number = "1" to be unique.

Does that fix it?
Unchyu2
Member++
Posts: 29
Joined: Tue Jun 17, 2014 11:40 am

Post by Unchyu2 »

Yes, thank you, that solved the problem.
I was able to see the PWM signal generated by the application.

Now I am trying to make USB Audio work so, I have taken the suggestion that Ross made earlier and changed -DXUD_ON_U_SERIES=1 to -DXUD_SERIES_SUPPORT=4

I have also changed the routing for the I2C ports in audiohw.xc to reflect the XA-SK-AUDIO slice pin mapings for tile 1:
from

Code: Select all

on tile[1] : out port p_gpio = XS1_PORT_32A;

on tile[1] : struct r_i2c r_i2c = {XS1_PORT_4E};
to

Code: Select all

on tile[1] : out port p_gpio = XS1_PORT_4E;

on tile[1] : struct r_i2c r_i2c = {XS1_PORT_4F};
The code compiles and executes correctly,
I can see a good 3.08MHz clock signal on X1D00 (I2S Bit Clock), witch is exactly 64*48kHz (the default Sampling Frequency)
And I can also confirm that the Audio Core is running good also because I have added a printintln() function inside it and it continuously prints debug messages.

The problem is that the device is not recognized as a audio interface neither by a PC running Windows 10 and having the latest version of TUSB Audio Driver installed, nor by a MAC.

Any suggestion is appreciated,
Ilie
Unchyu2
Member++
Posts: 29
Joined: Tue Jun 17, 2014 11:40 am

Post by Unchyu2 »

I have discovered that the board outputs 5V on USB_VBUS line (measured on pins B14 and B15 of the USB slot connector ), with and without the USB slice connected to it.

It still has the same behavior, even after a complete bard restart and without anything flashed.

Is that how it supposed to be? From what I know it shouldn't.
Post Reply