Hi,
So I've been using Adafruit's "ampy" tool to put main.py file into the nodeMCU and it works great. But I noticed this same issue with pyboard.py where if I used the command line from micropython with a serial terminal (teraterm vt in my case) then I always had to run ampy TWICE to get it to work again. After it worked, it would work every time until I ever opened the command line serially again.
I get this same error case that you're getting with pyboard.py where it can't open REPL mode. Here is the traceback:
Traceback (most recent call last):
File "c:\users\celtofj\appdata\local\programs\python\python36-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\celtofj\appdata\local\programs\python\python36-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\celtofj\AppData\Local\Programs\Python\Python36-32\Scripts\ampy.exe\__main__.py", line 9, in <module>
File "c:\users\celtofj\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "c:\users\celtofj\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 697, in main
rv = self.invoke(ctx)
File "c:\users\celtofj\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\celtofj\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\celtofj\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 535, in invoke
return callback(*args, **kwargs)
File "c:\users\celtofj\appdata\local\programs\python\python36-32\lib\site-packages\ampy\cli.py", line 208, in put
board_files.put(remote, infile.read())
File "c:\users\celtofj\appdata\local\programs\python\python36-32\lib\site-packages\ampy\files.py", line 129, in put
self._pyboard.enter_raw_repl()
File "c:\users\celtofj\appdata\local\programs\python\python36-32\lib\site-packages\ampy\pyboard.py", line 184, in enter_raw_repl
raise PyboardError('could not enter raw repl')
ampy.pyboard.PyboardError: could not enter raw repl
And so I thought maybe I could just update pyboard.py to "try" twice at the control A sending? But that didn't work. Any thoughts? Where is this pyboard.com file and is there a way to fix that to try twice if needed? Do I have to recompile something then?
Code: Select all
self.serial.write(b'\r\x01') # ctrl-A: enter raw REPL
data = self.read_until(1, b'raw REPL; CTRL-B to exit\r\n>')
if not data.endswith(b'raw REPL; CTRL-B to exit\r\n>'):
# try one more Control A
self.serial.write(b'\r\x01') # ctrl-A: enter raw REPL
data = self.read_until(1, b'raw REPL; CTRL-B to exit\r\n>')
if not data.endswith(b'raw REPL; CTRL-B to exit\r\n>'):
print(data)
raise PyboardError('could not enter raw repl'