Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usb.c freezes the CPU when there is no one listening #89

Closed
anacierdem opened this issue Nov 8, 2022 · 1 comment
Closed

usb.c freezes the CPU when there is no one listening #89

anacierdem opened this issue Nov 8, 2022 · 1 comment
Labels
Enhancement New feature or request Implemented This has been fixed but not yet published/pushed USB Library This is related to the USB library (usb.c)

Comments

@anacierdem
Copy link
Contributor

Without the following timeout, the busy function is waiting indefinitely when the serial listener is hung up or not started at all.

static void usb_everdrive_usbbusy() 
{
    u32 timeout = 0;
    u32 val __attribute__((aligned(8)));
    do
    {
        usb_everdrive_readreg(ED_REG_USBCFG, &val);
        if (timeout++ != 8192)
            continue;
        usb_everdrive_writereg(ED_REG_USBCFG, ED_USBMODE_RDNOP);
    } while ((val & ED_USBSTAT_ACT) != 0);
}

I am not sure if it is possible to stop listening with the original UNF executable (I presume it is the -d flag?) but it should happen if you are logging something say every frame and you terminate the process on computer side. Previously the above fix was removed with #85 as it was causing issues for the original SDK. The fix still exists in libdragon.

An important difference between the two implementation is that, libdragon does not have threading yet so that might be causing something to break. Maybe having two different implementations for libdragon behind a define guard is an acceptable solution until the root cause is found?

@buu342 buu342 added Enhancement New feature or request USB Library This is related to the USB library (usb.c) labels Mar 13, 2023
buu342 added a commit that referenced this issue Mar 26, 2023
@buu342 buu342 added the Implemented This has been fixed but not yet published/pushed label Mar 26, 2023
buu342 added a commit that referenced this issue Mar 26, 2023
@buu342
Copy link
Owner

buu342 commented Mar 26, 2023

Fixed in b716f17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Implemented This has been fixed but not yet published/pushed USB Library This is related to the USB library (usb.c)
Projects
None yet
Development

No branches or pull requests

2 participants