problems entering raw repl (needs 2 Ctrl-A's?)

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
gojimmypi
Posts: 36
Joined: Wed Mar 02, 2016 8:01 pm
Contact:

problems entering raw repl (needs 2 Ctrl-A's?)

Post by gojimmypi » Mon Apr 18, 2016 11:49 pm

Greetings,

Apologies in advance if this is a newbie question... but I'm been having problems with the /micropython/tools/pyboard.py tool (it won't connect). After a long delay, I get a message:

Code: Select all

could not enter raw repl
I looked at the source and it apparently has not changed in months. It previously worked for me, leading me to believe the problem is on the ESP8266 receiving side.
https://github.com/micropython/micropyt ... rd.py#L180

Code: Select all

180         self.serial.write(b'\r\x01') # ctrl-A: enter raw REPL 
181         data = self.read_until(1, b'raw REPL; CTRL-B to exit\r\n>') 
182         if not data.endswith(b'raw REPL; CTRL-B to exit\r\n>'): 
183             print(data) 
184             raise PyboardError('could not enter raw repl') 
It looks like a simple matter of sending two bytes - a Carriage Return and Ctrl-A should start the raw repl. When I try it interactively (using minicom) - a single Ctrl-A does nothing. However entering Ctrl-A twice... (found that accidentallty)... now that gets the raw repl mode prompt.

Code: Select all

>>>
raw REPL; CTRL-B to exit
>
MicroPython v1.7-107-g8dcce92-dirty on 2016-04-18; ESP module with ESP8266
Type "help()" for more information.
>>>
Compiled fresh today with version:

Code: Select all

xtensa-lx106-elf-cc (crosstool-NG 1.20.0) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
And sure enough... editing my local pyboard.com to send 2 consecutive Ctrl-A's instead of one does result in the pyboard.py apparently working properly.

There are no other apparent serial problems. I've tried this from both Debian and Raspberry Pi.

Anyone else see this? Thanks

User avatar
Roberthh
Posts: 1744
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: problems entering raw repl (needs 2 Ctrl-A's?)

Post by Roberthh » Tue Apr 19, 2016 5:32 am

What you see is related to minicom. Ctrl-A is its command character starting commands for minocom. To get a Ctrl-A to the connected device, you have to enter Ctrl-A twice. That's intentional and not related to the ESP8266 at all. More useful inofrmation can be found on minicom's man page.

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: problems entering raw repl (needs 2 Ctrl-A's?)

Post by platforma » Sun Apr 24, 2016 3:35 pm

Just thought I'd mention that similar similar forks of minicom like picocom or tinyserial inherit the command sequence and work exactly the same way!

eradicatore
Posts: 49
Joined: Thu Apr 20, 2017 9:19 pm

Re: problems entering raw repl (needs 2 Ctrl-A's?)

Post by eradicatore » Sat Apr 29, 2017 2:24 pm

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'
 

User avatar
dhylands
Posts: 3247
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: problems entering raw repl (needs 2 Ctrl-A's?)

Post by dhylands » Sat Apr 29, 2017 6:32 pm

Are you exiting out of the terminal program before trying to use pyboard.py.

pyboard.py can be found in the tools directory:
https://github.com/micropython/micropyt ... pyboard.py

eradicatore
Posts: 49
Joined: Thu Apr 20, 2017 9:19 pm

Re: problems entering raw repl (needs 2 Ctrl-A's?)

Post by eradicatore » Wed May 03, 2017 2:03 am

Yes, I get a different error (COM12 in use) if I don't exit out of the terminal. And note I'm not using pyboard.py directly. I am using "ampy" from Adafruit which seems like the built off of other open source stuff. The command line is

ampy put main.py

User avatar
devnull
Posts: 401
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: problems entering raw repl (needs 2 Ctrl-A's?)

Post by devnull » Thu May 04, 2017 1:23 am

I have problems with ampy and the 8285, where the repl takes longer to output it's info and a delay is needed to wait for this:

viewtopic.php?f=16&t=3217#p19117

Not sure if it also fixes your problem ?

eradicatore
Posts: 49
Joined: Thu Apr 20, 2017 9:19 pm

Re: problems entering raw repl (needs 2 Ctrl-A's?)

Post by eradicatore » Fri May 05, 2017 3:23 am

I'll have to check that out. But just from the description it doesn't seem to me it would be something like this. My setup works 100% on the second try to ampy. I've even noticed that if I start ampy, and abort it after a few seconds then the second one passes 100%. So I don't have to wait for ampy to fail normally which usually takes a good 15-20 seconds.

eradicatore
Posts: 49
Joined: Thu Apr 20, 2017 9:19 pm

Re: problems entering raw repl (needs 2 Ctrl-A's?)

Post by eradicatore » Sun Jun 18, 2017 2:10 pm

Just a quick update, not sure if you've ever tried uPyLoader but if not it's WAY better than ampy.

viewtopic.php?f=16&t=2245

User avatar
pythoncoder
Posts: 3724
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: problems entering raw repl (needs 2 Ctrl-A's?)

Post by pythoncoder » Mon Jun 19, 2017 7:30 am

Or use the excellent rshell https://github.com/dhylands/rshell.
Peter Hinch

Post Reply