ESP32, Mac Os, Enter raw repl failes
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
tools/pyboard: Split Ctrl-C into two separate steps with small delay
This makes pyboard.py successfully enter raw-repl on an ESP32 board.
Without the split the running program won't always successfully abort and thus entering raw-repl fails.
I'm not completely sure, if this also depends on the actual program that is running on the device and whether this also happens on a real pyboard.
So for reference, here's the program running on the device which triggers the behaviour for me:
from machine import Pin
from time import sleep
import micropython
p = Pin(0, Pin.OUT)
#@micropython.native
def func():
for _ in range(1000):
p.value(not p.value())
while 1:
func()
This change has not been tested on an actual pyboard, because I don't have one.