Hang when reading from UART and writing to filesystem on RPI Pico
When reading from UART and trying to write the read line to a file the board has a hard hang. I've confirmed the following code causes the issue on both an RPI Pico and a Pimorini Pico Lipo. The hang occurs anywhere from the first iteration of the loop, most often early, but can run to 10 or 20.
*Note: I'm not sure if this is the same issue as (https://github.com/micropython/micropython/issues/7204) but thought I'd raise anyway.
I've run the same code on an ESP-32 board (Firebeetle v4) with no issue. The UART is read and line written to file with no issues.
Sample code that draws the error (apologies I'm not the best coder so apologies for the quality of the code):
import os
import machine
#print sys info
print(os.uname())
f_debug = open('debug_test116.log', 'a')
f_debug.write('=======STARTED =======\n')
f_debug.flush()
#print uart info
uart = machine.UART(1, baudrate=9600, txbuf=1024, rxbuf=1024, timeout=1000, timeout_char=4 )
print(uart)
i = 0
while i < 1000:
line = uart.readline()
f_debug.write(str(line))
f_debug.flush()
print(line)
i = i + 1
print()
print("- bye -")
USB problem on RPi pico
I have an issue with rshell that seems to be caused by the USB comms.
If I issue the command cp ports/rp2/examples/* /pyboard then rshell will hang, typically on the first file.
If I add some statements in the recv_file_from_host function in rshell (this is the part that runs on the pico) that opens a UART and logs some additional information to the UART, then the copies all succeed.
I tried adding 20 msec delays each place that there was log statement, but that doesn't seem to make things work either.
Sorry I don't have a simpler test case, but I figured I'd log the issue and see if I can create a simple program which reproduces the hang/crash.
Sometimes, things hang, and sometimes the serial port is forcibly closed (I suspect that this might be a crash on the pico side).