New version of rshell with better startup for ESP8266 and ESP32

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

New version of rshell with better startup for ESP8266 and ESP32

Post by dhylands » Thu Mar 28, 2019 8:57 pm

I just release version 0.0.21 of rshell.

It turns out that some ESP8266 and EPS32 boards reset when you open the serial port, and the verbage printed out at startup was confusing rshell trying to get a REPL prompt.

rshell now send a Control-C followed by RETURN several times while waiting for the >>> from MicroPython to show up.

None of my boards reset when opening the serial port, so I simulated it by tweaking the RTS and DTR lines immediately after opening the serial port.

I'd love for somebody who previously had issues; typically hanging at the 'Testing if ubinascii.unhexlify exists ...' would test this version.

Some people worked around this by adding a delay in pyboard.py.

Thanks

cefn
Posts: 230
Joined: Tue Aug 09, 2016 10:58 am

Re: New version of rshell with better startup for ESP8266 and ESP32

Post by cefn » Sat Mar 30, 2019 11:47 am

My suspicion is that some serial drivers send the reset on connect, as it only seems to affect some OS. Linux is unaffected by this behaviour. Mac OS is affected by the behaviour. Can't remember for Windows.

It's a real pain since if there is a main.py I am used to interactively killing the micropython script to make e.g. ampy put work (which relies on a responsive console to do file upload). Unfortunately ampy put then makes a connection, which restarts the board, which triggers main.py and makes the console unresponsive again.

If rshell is intelligently handling this, I'll probably switch vanguard put to use rshell instead...
https://github.com/vgkits/vanguard-cli/ ... __.py#L210

I already wrap rshell elsewhere and it's a dependency already so people don't have to install it.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: New version of rshell with better startup for ESP8266 and ESP32

Post by kevinkk525 » Sat Mar 30, 2019 1:53 pm

For me the OS didn't make a difference and it seems to be hardware dependent. The one esp32 "doit esp32 devkit" does reset on connect, the other devices I have don't.

However the latest version fixes the problem and works great.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

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

Re: New version of rshell with better startup for ESP8266 and ESP32

Post by pythoncoder » Mon Apr 01, 2019 10:08 am

This is a big improvement. There is still a minor issue with ESP32 if you exit rshell and then attempt to reconnect: it either fails to connect or hangs trying to do so. I'm using an Espressif ESP32-DEVKITC with ESP-WROOM-32.

The workround is simple: press the reset button before attempting to reconnect.

Code: Select all

$ rsusb
Using buffer-size of 30
Connecting to /dev/ttyUSB0 (buffer-size 30)...
Trying to connect to REPL ....................Unable to connect to REPL
Welcome to rshell. Use Control-D (or the exit command) to exit rshell.

No MicroPython boards connected - use the connect command to add one
I use the following to connect to ESPx

Code: Select all

alias rsusb='rshell -p /dev/ttyUSB0 --editor nano --buffer-size=30 -a'
Peter Hinch
Index to my micropython libraries.

bortunac
Posts: 1
Joined: Sat Jan 18, 2020 12:36 am

Re: New version of rshell with better startup for ESP8266 and ESP32

Post by bortunac » Sat Jan 18, 2020 1:22 am

Thank you ! WAW!!
Great tool that opens the gate from IDE editing to esp flash.
I wil try this path
windows + NETBEANS editing esp32/ directory on remote (raspberry-pi + esp32 on /dev/ttyUSB0)
INCRON watching esp32/ and run push.sh
rshell -p /dev/ttyUSB0 | (wait ???) rsync esp32/ /pyboard | exit

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: New version of rshell with better startup for ESP8266 and ESP32

Post by davef » Wed Aug 19, 2020 1:36 am

When I run rshell on my ESP32 I get:

Code: Select all

> rshell
Welocome to rshell. Use Control-D to exit.
/home/dave
From the docs it appears you should end up at:

Code: Select all

.../micropython/rshell>
When I re-install rshell it appears to be in:

Code: Select all

Requirement already satisfied: rshell in /usr/local/lib/python3.7/dist-packages (0.0.28)
Do I make a link to it or have I messed up the install?

Thanks,
Dave

kinno
Posts: 32
Joined: Mon Oct 21, 2019 2:06 pm

Re: New version of rshell with better startup for ESP8266 and ESP32

Post by kinno » Wed Aug 19, 2020 11:05 am

Really great release! Some of my esp-32s were affected by this. I will report back once I test it out.

Thanks again.

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

Re: New version of rshell with better startup for ESP8266 and ESP32

Post by pythoncoder » Wed Aug 19, 2020 12:20 pm

@davef There is nothing wrong with your installation: the rshell prompt shows the current directory wherever that may be.
Peter Hinch
Index to my micropython libraries.

User avatar
jcw
Posts: 37
Joined: Sat Dec 21, 2019 12:08 pm
Location: CET/CEST

Re: New version of rshell with better startup for ESP8266 and ESP32

Post by jcw » Wed Aug 19, 2020 5:18 pm

On macOS, I think the default is to have DTR inactive until the port is opened. If that is used by the ESP, then that might explain the reset-on-open behaviour.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: New version of rshell with better startup for ESP8266 and ESP32

Post by davef » Wed Aug 19, 2020 10:48 pm

jcw,
I assume that remark is for someone else.

Peter,
This is what happens when I run rshell:

Code: Select all

dave@dave-AOD255E:~$ sudo rshell -p /dev/ttyUSB0 --editor nano --buffer-size=30 -a
Using buffer-size of 30
Connecting to /dev/ttyUSB0 (buffer-size 30)...
Trying to connect to REPL  connected
Testing if ubinascii.unhexlify exists ... Y
Retrieving root directories ... /batt_voltage_values/ /boot.py/ /datalog.csv/ /myLogger.py/ /umail.py/ /webrepl_cfg.py/
Setting time ... Aug 20, 2020 10:43:07
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 2000
Welcome to rshell. Use Control-D (or the exit command) to exit rshell.
/home/dave>
but when I do:

Code: Select all

 ls -l /
I get the root directory of the host computer. There is no /sd or /flash on my ESP32. The ESP32 has webrepl running and it is configured as an AP, is one of those conditions a problem?

rshell appears to find my files but I can't!

Update:
I found it in /pyboard

Thanks,
Dave

Post Reply