Skip to content

🪲[BUG] pio_usb_host_frame() hangs #197

@dikdom

Description

@dikdom

RP2350B, C SDK 2.2.0, the included tinyUSB lib is 0.18. I use Pico PIO USB v0.7.2 (latest, afaik)

Describe the bug you encountered:
I'm connecting an USB HID (mouse) dongle to my MCU and that core stops working. After some investigation it turned out that usb_host_frame() -> pio_usb_bus_usb_transfer() blocks at this point:

while (*pc < PIO_USB_TX_ENCODED_DATA_COMP) {
continue;
}

...

What did you expect to happen instead?
When I plug an USB device the enumeration should pass and the mouse should send its events as callbacks.
...

What actually happened in your case?
It stops working.

...

Additional information
A dummy program having exactly the same configuration works as expected on the same rig. In fact at that case the built-in peripheral is used as a device for sending debug messages to the serial console of my IDE.

The pio_usb host is initialized with .skip_alarm_pool=true , so I'm calling the
pio_usb_host_frame(); and tuh_task(); methods in every 1ms, from a main loop.
I have 1 PIO in use, and I allocated the 2nd one for the pio_usb.
I configured in tusb_config.h the following
#define CFG_TUSB_OS OPT_OS_NONE
so there is no locks and mutexes are used, causing no interrupts are disabled. That is essential in my case.
tuh_init(1); returns with OK (true);
To be honest I have no idea what could be the difference with my dummy project. A little help here would be appreciated...

UPDATE#1:
if I skip configuring the GPIO interrupts on that core causing no GPIO interrupts arrive, then the core doesn't freeze. So.
What is required for the one-thread execution of the pio-usb? One thread can execute all the tasks but those cannot be interrupted?
Reproduced in my dummy project: set up a repeating timer that sleeps for 200us and is executed at every ms:
add_repeating_timer_ms(-1, timer_task_dummy, NULL, &rt_data);
In that case the programs hangs on a dongle connect.
If I relax the timing as
add_repeating_timer_ms(1, timer_task_dummy, NULL, &rt_data);
then the code runs properly. Still, this is my dummy test code.
Does it mean that there are code snippets in pio_usb that requires undisturbed 500-1000us timewindow?


Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions