XUF208 usb audio. Suspend after host PC reboot

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
User avatar
maxssau
Member
Posts: 8
Joined: Mon Mar 18, 2019 8:35 am
Location: Russia, Samara

XUF208 usb audio. Suspend after host PC reboot

Postby maxssau » Fri Mar 29, 2019 2:31 pm

Hello!

XUF208 MCU, last USB audio SDK(6.15).

OS: Windows 10 x64, Ubuntu 18 x64.

I have a problem:

after reboot host PC, usb device suspend with error. if hardware reset usb device, it work good.

Code: Select all

tile[0] core[5]  (Suspended: Signal 'ET_ILLEGAL_RESOURCE' received. Description: Resource exception.)   
   3 XUD_Manager()  0x00046188   
   2 _Susb_audio_core_0.task.XUD_Manager.0() main.xc:325 0x00041ee5   
   1 __start_core()  0x00047610   

stack trace:

#0  0x00046188 in XUD_Manager ()
#1  0x00041ee5 in _Susb_audio_core_0.task.XUD_Manager.0 (frame=<value optimized out>) at C:/Projects/UI-01_sw1_hw1/module_usb_audio/main.xc:325
#2  0x00047610 in __start_core ()


part of main.xc

325:   XUD_Manager(c_xud_out, ENDPOINT_COUNT_OUT, c_xud_in, ENDPOINT_COUNT_IN,
                        c_sof, epTypeTableOut, epTypeTableIn, p_usb_rst,
                        clk, 1, XUD_SPEED_HS, XUD_PWR_CFG);


I try XSCOPE disable.

How fix it?
User avatar
mon2
XCore Legend
Posts: 1358
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Sat Mar 30, 2019 5:11 am

User avatar
maxssau
Member
Posts: 8
Joined: Mon Mar 18, 2019 8:35 am
Location: Russia, Samara

Postby maxssau » Thu Apr 04, 2019 8:42 am

solution:

1. add to XN file:

Code: Select all

   <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="4,4" Flags="XSCOPE">
   <LinkEndpoint NodeId="0" Link="XL0"/>
   <LinkEndpoint NodeId="2" Chanend="1"/>
   </Link>
   </Links>


2. Ubuntu Usb core have bug, need disable autosuspend:

Code: Select all

root terminal:
echo -1 > /sys/bus/usb/devices/3-2/power/autosuspend
User avatar
mon2
XCore Legend
Posts: 1358
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Thu Apr 04, 2019 4:39 pm

Thank you for your resolution post.
User avatar
maxssau
Member
Posts: 8
Joined: Mon Mar 18, 2019 8:35 am
Location: Russia, Samara

Postby maxssau » Wed Apr 17, 2019 3:10 pm

addition to the solution:

add 2 files:

xuduser.c

Code: Select all

#include <platform.h>
#include <xs1_su.h>
#include "devicedefines.h"
#include "hostactive.h"
#include "audiostream.h"

#if 1
#include <hwtimer.h>
#include "interrupt.h"
hwtimer_t g_rebootTimer;


#pragma select handler
void HandleRebootTimeout(timer t)
{
    unsigned pll_ctrl_val;

    /* Reset device */
    read_sswitch_reg(get_local_tile_id(), 6, pll_ctrl_val);
    pll_ctrl_val &= 0x7FFFFFFF;
    write_sswitch_reg_no_ack(get_local_tile_id(), 6, pll_ctrl_val);
    while(1);
}

#define REBOOT_TIMEOUT 20000000

void XUD_UserSuspend(void)
{
    unsigned time;

    UserAudioStreamStop();
    UserHostActive(0);

    DISABLE_INTERRUPTS();

    asm volatile("setc res[%0], %1"::"r"(g_rebootTimer),"r"(XS1_SETC_COND_NONE));
    g_rebootTimer :> time;
    time += REBOOT_TIMEOUT;

    asm volatile("setd res[%0], %1"::"r"(g_rebootTimer),"r"(time));
    asm volatile("setc res[%0], %1"::"r"(g_rebootTimer),"r"(XS1_SETC_COND_AFTER));

    set_interrupt_handler(HandleRebootTimeout, 1, g_rebootTimer, 0)
}

void XUD_UserResume(void)
{
    unsigned config;

    /* Clear the reboot interrupt */
    DISABLE_INTERRUPTS();
    asm("edu res[%0]"::"r"(g_rebootTimer));

    asm("ldw %0, dp[g_currentConfig]" : "=r" (config):);

    if(config == 1)
    {
        UserHostActive(1);
    }
}

#endif


interrupt.c

Code: Select all

#if 1

#include <interrupt.h>

register_interrupt_handler(HandleRebootTimeout, 1, 200)

#endif


this not work with attached XTAG.

Who is online

Users browsing this forum: No registered users and 0 guests