JackMacWindows
Posts: 2
Joined: Fri May 28, 2021 3:05 am

USB on second core - assertion failed from _hw_endpoint_xfer_sync

Fri May 28, 2021 3:24 am

I'm working on writing a small program for the Pico that uses USB keyboard input. I have a lot of code that needs to run (Lua interpreter), and to avoid unresponsiveness for the keyboard I'd like to use the second core for all I/O tasks. I've adapted the code from the host_hid example, and on startup I launch core 1 with a very simple run loop:

Code: Select all

void inputCore() {
    tusb_init();
    gpio_put(25, 0);
    unsigned char report = 0;
    while (1) {
        tuh_task();
        hid_task();
        report = !report;
        gpio_put(25, report);
    }
}
With this code, the program's able to start up, but as soon as I plug in a keyboard, an error is displayed over serial and thread 2 halts:

Code: Select all

assertion "!(buf_ctrl & USB_BUF_CTRL_FULL)" failed: file ".../pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040/rp2040_usb.c", line 191, function: _hw_endpoint_xfer_sync
If I move tusb_init() to core 0, core 1 somehow crashes while setting the GPIO - it hits an ISR for USB, but then jumps off into nowhere and eventually hits sleep_until, which causes a panic.

Does TinyUSB not support using the second core for user input? Or am I going about this the wrong way? In the future I'm going to use the second core for VGA output, and having to stuff everything on the (already overloaded) first core is going to slow my program down considerably.

My code is on GitHub: https://github.com/MCJack123/craftos-pico

JackMacWindows
Posts: 2
Joined: Fri May 28, 2021 3:05 am

Re: USB on second core - assertion failed from _hw_endpoint_xfer_sync

Fri Jun 11, 2021 3:01 am

I've tried this again using the latest SDK with TinyUSB 0.10.1 and the new example code, but I continue to get the same error. Is anyone able to help?

DarkElvenAngel
Posts: 1697
Joined: Tue Mar 20, 2018 9:53 pm

Re: USB on second core - assertion failed from _hw_endpoint_xfer_sync

Sat Jun 12, 2021 3:08 am

What kind of keyboards have you tried?

I've found it's very fussy about what keyboard you use. For example I've tried a Logitech wireless keyboard, Rii keyboard, and even the official keyboard all failed to work with the Pico. I found an old Dell keyboard and that works. Host mode seems to still be a very much work in progress.

Return to “SDK”