← index #8002PR #10041
Likely Duplicate · medium · value 1.926
QUERY · ISSUE

ESP32, Mac Os, Enter raw repl failes

openby fanselauopened 2021-11-17updated 2021-11-29
port-esp32

Hi there,

I was using the micropython 1.17 firmware on an ESP32 and was trying to load a file into memory with the pyboard.py tool. I was doing the same thing on a Linux machine (where the serial port was /dev/tty.USB0) but for some reason the same fails on Mac OS (serial port /dev/tty.usbserial-0001) with the following error:
b'\x9a\x82\xc2\x82\xa2\x82\x82bb\x95\xb9\xe94292\r\nentry 0x400806b0\r\nMicroPython v1.17 on 2021-09-02; ESP32 module with ESP32\r\nType "help()" for more information.\r\n>>> ' Traceback (most recent call last): File "/Users/luca/mambaforge/bin/mpremote", line 8, in <module> sys.exit(main()) File "/Users/luca/mambaforge/lib/python3.9/site-packages/mpremote/main.py", line 414, in main pyb.enter_raw_repl() File "/Users/luca/mambaforge/lib/python3.9/site-packages/mpremote/pyboard.py", line 340, in enter_raw_repl raise PyboardError("could not enter raw repl") mpremote.pyboard.PyboardError: could not enter raw repl

Looking at the pyboard file, it suggest that the activation of the "raw repl" mode is unsuccessful, which is weird since i can use "mpremote connect /dev/tty.usbserial-0001" to get into the normal repl and the use Ctrl-B to access the raw repl mode.

On further investigation it seems like the write does not actually reach or gets interpreted by the microcontroller.

Thanks in advance for any recommendation or resources that might be useful to fix this issue

CANDIDATE · PULL REQUEST

wait for >>> when attempting to enter_raw_repl

closedby BrianPughopened 2022-11-21updated 2025-01-16
tools

On some boards (notably esp32), pyboard.py hangs when attempting to enter raw repl mode. As outlined in this thread and this PR, @roaldarbol and I have resolved this issue. Basically, the issue/solution is this:

  1. After pressing ctrl+c twice, some boards take a while to respond (up to ~2 or ~3 seconds).
  2. Attempting to enter raw repl during this time will result in the command being ignored.
  3. To detect the board responding, the new change is to wait until the >>> prompt is sent from device.
  4. If the device is already in raw repl mode, the >>> prompt will not be sent. To mitigate this, we will attempt to exit raw repl mode. If not in raw repl mode, this will do nothing.
  5. Once the >>> prompt is reached, we know the device is ready for more commands and we can set the device in raw repl mode.

This should also mitigate the issue in some other very old issues. This change is working well in Belay, but I didn't really test this exact PR for micropython.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied