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 hangs if receiving UART stream over 10kB/s #53

Open
MrJake222 opened this issue May 12, 2024 · 2 comments
Open

USB hangs if receiving UART stream over 10kB/s #53

MrJake222 opened this issue May 12, 2024 · 2 comments

Comments

@MrJake222
Copy link

I don't know the details yet, but it spams error -71 in dmesg. Will investigate with picoprobe later.

@MrJake222
Copy link
Author

The bug is related to UART incoming characters interrupts flushing the input while the mutex is locked by some other function (particularly by another flush).

Stacktrace screenshot from when the adapter becomes unresponsive:

image

MrJake222 added a commit to MrJake222/pico-ice-sdk that referenced this issue May 13, 2024
this implements rudimentary fifo for uart1 only
tud_cdc_n_write_char aquires mutex and it's not recommended in ISRs (can deadlock for example, is long)
fifo has two sets of variables, index and total, read and written. This is to limit race conditions.
Each set is accessed only in one context.

Fixes tinyvision-ai-inc#53
@josuah
Copy link
Collaborator

josuah commented Jul 9, 2024

Thank you for tracing this down! Indeed, since the OSAL calls a mutex through the RP2040, this cannot be used in IRQ.
I will discuss on the draft pull request.

josuah pushed a commit that referenced this issue Jul 16, 2024
this implements rudimentary fifo for uart1 only
tud_cdc_n_write_char aquires mutex and it's not recommended in ISRs (can deadlock for example, is long)
fifo has two sets of variables, index and total, read and written. This is to limit race conditions.
Each set is accessed only in one context.

Fixes #53
josuah pushed a commit that referenced this issue Jul 21, 2024
This implements rudimentary fifo for uart1 only
tud_cdc_n_write_char aquires mutex and it's not recommended in ISRs (can deadlock for example, is long)
fifo has two sets of variables, index and total, read and written. This is to limit race conditions.
Each set is accessed only in one context.

Fixes #53
MrJake222 added a commit to MrJake222/pico-ice-sdk that referenced this issue Oct 30, 2024
Now on UART0 too. Speeds up UART0 by 16%.

Only in Rx direction. I've tested another case of bidir buffering
but it actually slowed things down by 25%.
MrJake222 added a commit to MrJake222/pico-ice-sdk that referenced this issue Nov 6, 2024
Now on UART0 too. Speeds up UART0 by 16%.

Only in Rx direction. I've tested another case of bidir buffering
but it actually slowed things down by 25%.
josuah pushed a commit that referenced this issue Nov 12, 2024
Now on UART0 too. Speeds up UART0 by 16%.

Only in Rx direction. I've tested another case of bidir buffering
but it actually slowed things down by 25%.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants