Thursday, 7 December 2017

Toubleshooting: ampy "could not enter raw repl" error


When using ampy tool, nothing works!

ampy --port /dev/ttyUSB0 get boot.py

>>> 
Traceback (most recent call last):
  File "/usr/local/bin/ampy", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/ampy/cli.py", line 96, in get
    contents = board_files.get(remote_file)
  File "/usr/local/lib/python2.7/dist-packages/ampy/files.py", line 68, in get
    self._pyboard.enter_raw_repl()
  File "/usr/local/lib/python2.7/dist-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

On the NodeMCU side it prints:
...
>>>
>raw REPL; CTRL-B to exit >

The reason is because the serial port is busy. So after I closed the REPL python terminal and called ampy again, every thing works perfectly. 


ref:
http://forums.openmv.io/viewtopic.php?t=298

3 comments:

  1. The only thing that worked for me was changing the file "pyboard.py" in Python_path / Lib / site-packages /
    (for Python3, first change the extension to the adafruit_ampy-X.X.X-py.X.X file from .egg to .zip and unzip, edit the file and then change the extension again).
    In the "pyboard.py" file, you have to add a pause in the definition of the "enter_raw_repl" function, after the line
    self.serial.write (b '\ r \ x03 \ x03')
    add
    time.sleep (. 5)

    It worked for me in Windows10 with a wemos_oled_18650_battery board

    I am sorry for my bad english

    ReplyDelete
    Replies
    1. less time works too
      try time.sleep(.2) or even less

      Delete