adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
Other
4.11k stars 1.22k forks source link

ESP32 Sunton board - Noise on USB Serial at startup causes occasional board freeze #9104

Closed RetiredWizard closed 7 months ago

RetiredWizard commented 7 months ago

CircuitPython version

Adafruit CircuitPython 9.0.0-14-gc035ade1fd on 2024-03-27; sunton_esp32_2432S028 with ESP32

Code/REPL

No Code.py

or

import sys
a = ""
while a != 'q':
    a=sys.stdin.read(1)

Behavior

When the board powers up with no code.py running, random characters frequently appear as input to the REPL, I believe if the core reads the uart device for console input at the "press any key to enter REPL" prompt and encounters a non-utf8 character it sometimes hangs the device and requires a hard reset to recover.

When I run a code.py file that executes a sys.stdin.read(1) command the board doesn't freeze but the code.py program will occasionally crash with a Unicode error:

(81136)/>Traceback (most recent call last):
  File "code.py", line 5, in <module>
  File "PyDOS.py", line 1260, in <module>
  File "PyDOS.py", line 510, in PyDOS
  File "/lib/pydos_ui.py", line 593, in input
UnicodeError: 

The code.py issue is easy enough to work around by using a try/except block but when there's no code.py file the occasional hangs can be a pain.

Description

The root of this problem is most likely a hardware issue, however I think I've seen similar issues on other uart based console boards and I'm wondering if it's worth throwing a minor change into the core to ease the user experience on devices with this issue.

Additional information

No response

RetiredWizard commented 7 months ago

probably the same issue as #8890

RetiredWizard commented 7 months ago

After some testing I don't think this is the same issue as #8890. My best guess at this point is that this is caused by a startup issue with the board design. If there's no code.py running to catch and discard the noise it can be annoying to start the board with the UART connected to a host, as it may take several boot attempts, but if code.py is running, it can easily discard the noise.

I'm going to close this as it seems to be hardware related as well as the associated PR #9105.