Communication stuck if connecting to one UART only
alessandrodn opened this issue · 9 comments
First of all, kudos for the project.
I have a device exposing two UARTS and I connect both the serials to the PICO.
I noticed that if I open a serial session (I use screen
on macOS) to one UART only (either one of the two), the communication stuck after few bytes exchanged.
If I open the connection to the second UART, while the first one is frozen, the connection is resumed on both.
Please see attached screen recording.
Screen.Recording.2024-02-04.at.15.50.09.mov
Did you try updating the pico SDK to HEAD? It includes lots of fixes, probably might fix it for you.
It's one of the first things I do when I run into problems.
I was also able to recreate the same problem here on Linux, but there's specific conditions to trip the problem.
The communication packets have actually started, then stopped from the PC side...
...while there is a data flood on either or both channels from the UARTs.
This is caused by two bugs.
Basically the code spins waiting to unblock, which will never happen until the host catches up, it never will. Basically it gets stuck because...
...the silly read ISRs that end up in an endless loop.
This is because the data incoming from the UART is not discarded if the buffer is full, thus, the IRQ is never cleared.
The fix is to remove the infinite loop by dropping the UART data on the floor.
Try this version and let me know if it works.
My changes are as follows:
UART0_TX 0
UART0_RX 1
UART0_LED_TX 19
UART0_LED_RX 18
UART1_TX 4
UART1_RX 5
UART1_LED_TX 17
UART1_LED_RX 16
It is also possible to send breaks with this firmware.
Try this version and let me know if it works. My changes are as follows:
UART0_TX 0 UART0_RX 1 UART0_LED_TX 19 UART0_LED_RX 18 UART1_TX 4 UART1_RX 5 UART1_LED_TX 17 UART1_LED_RX 16
It is also possible to send breaks with this firmware.
@xxxajk it would help a lot if you could provide the modified source code with the fixes.
Done.
https://github.com/xxxajk/pico-uart-bridge
If it is a fix for enough people, I'll do a pull request to here, although there's not a lot of activity here...
Done.
Thanks!
If it is a fix for enough people, I'll do a pull request to here, although there's not a lot of activity here...
Yes, please, open a new PR with this
Are you OK with the different pin setup?