XUD_UserSuspend and XUD_UserResume not being overridden properly in sw_usb_audio_sw_v8_1_0

Discussions about USB Audio on XMOS devices
Jakub
New User
Posts: 2
Joined: Thu Aug 01, 2024 2:49 pm

XUD_UserSuspend and XUD_UserResume not being overridden properly in sw_usb_audio_sw_v8_1_0

Post by Jakub »

Hello,

I am working with the sw_usb_audio_sw_v8_1_0 framework and both XUD_UserSuspend and XUD_UserResume seem not to be overridden properly in the XUA lib.

My project highly depends on the UserHostActive function being called properly from within the XUA lib when the USB is connected and disconnected from the PC.

When the code is left untouched in the "lib_xua\lib_xua\src\core\xuduser\xuduser.c"

Code: Select all

// Copyright 2013-2023 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include "xua.h"
#if XUA_USB_EN
#include "hostactive.h"
#include "audiostream.h"

/* Implementations over-riding empty versions in lib_xud/sec/core/XUD_User.c */

void XUD_UserSuspend(void) __attribute__ ((weak));
void XUD_UserSuspend(void)
{
    UserAudioStreamStop();
    UserHostActive(0);
}

void XUD_UserResume(void) __attribute__ ((weak));
void XUD_UserResume(void)
{
    unsigned config;

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

    if(config == 1)
    {
        UserHostActive(1);
    }
}
#endif /* XUA_USB_EN*/
UserHostActive is not called properly, I have also verified it by setting two breakpoints:
Image

When I modify the code to comment out the weak attributes

Code: Select all

// Copyright 2013-2023 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include "xua.h"
#if XUA_USB_EN
#include "hostactive.h"
#include "audiostream.h"

/* Implementations over-riding empty versions in lib_xud/sec/core/XUD_User.c */

// void XUD_UserSuspend(void) __attribute__ ((weak));
void XUD_UserSuspend(void)
{
    UserAudioStreamStop();
    UserHostActive(0);
}

// void XUD_UserResume(void) __attribute__ ((weak));
void XUD_UserResume(void)
{
    unsigned config;

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

    if(config == 1)
    {
        UserHostActive(1);
    }
}
#endif /* XUA_USB_EN*/
The functions are properly overridden:
Image

The UserHostActive is then called properly whenever the USB is connected/disconnected from the PC.

Is there something I am missing or is that a bug?
You do not have the required permissions to view the files attached to this post.
User avatar
Ross
Verified
XCore Legend
Posts: 1183
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

This is a bug, they shouldn't also be weak - the ones are lib_xud are also weak and theirs no guarantee the correct one will be picked up. We've fixed for the next release.
Technical Director @ XMOS. Opinions expressed are my own
User avatar
Ross
Verified
XCore Legend
Posts: 1183
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

I should probably mention we're over hauling the suspend notification stuff so we can do more advanced actions during suspend - such as clocking down the xcore to save power.

We hope to get this released over the next couple of weeks.

Preview here: https://github.com/xmos/lib_xud/pull/441 and here: https://github.com/xmos/lib_xua/pull/471
Technical Director @ XMOS. Opinions expressed are my own