rshell fails to get esp32 serial console rshell.pyboard.PyboardError

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
ldfsilva
Posts: 3
Joined: Sun Aug 27, 2017 2:19 am

rshell fails to get esp32 serial console rshell.pyboard.PyboardError

Post by ldfsilva » Sun Aug 27, 2017 2:25 am

When attempting to get esp32 serial console it fails with the following error[1]. The same issue occurred with two different firmware versions.
Has anyone experienced such behavior before, I'm wondering weather I missing a configuration on host side or if that may be a bug with rshell and micropython ?

As follows detail:

Thanks,

Firmwares:
Downloads/esp32-20170820-v1.9.1-436-gd3ad3fdb.bin
Downloads/esp32-20170827-v1.9.1-439-g6c62e70b.bin

pi@raspberrypi:~ $ esptool.py --port /dev/ttyUSB0 flash_id
esptool.py v2.0.1
Connecting.....
Detecting chip type... ESP32
Chip is ESP32D0WDQ6 (revision 0)
Uploading stub...
Running stub...
Stub running...
Manufacturer: c8
Device: 4016
Detected flash size: 4MB
Hard resetting...
pi@raspberrypi:~ $

pi@raspberrypi:~ $ rshell --buffer-size=30 --port /dev/ttyUSB0 -d
Debug = True
Port = /dev/ttyUSB0
Baud = 115200
User = micro
Password = python
Wait = 0
nocolor = 0
Timing = 0
Quiet = 0
Buffer_size = 30
Cmd = []
Connecting to /dev/ttyUSB0 ...
----- About to send 286 bytes of code to the pyboard -----
def test_buffer():
"""Checks the micropython firmware to see if sys.stdin.buffer exists."""
import sys
try:
_ = sys.stdin.buffer
return True
except:
return False
output = test_buffer()
if output is None:
print("None")
else:
print(output)

-----
b'\r\n>CWhat? \r\n>CWhat? \r\n>\r\n>\x01'
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1185, in connect
ip_address = socket.gethostbyname(port)
socket.gaierror: [Errno -5] No address associated with hostname

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/rshell", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.5/dist-packages/rshell/command_line.py", line 4, in main
rshell.main.main()
File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 2646, in main
real_main()
File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 2608, in real_main
connect(args.port, baud=args.baud, wait=args.wait, user=args.user, password=args.password)
File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1191, in connect
connect_serial(port, baud=baud, wait=wait)
File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1215, in connect_serial
dev = DeviceSerial(port, baud, wait)
File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1435, in __init__
Device.__init__(self, pyb)
File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1261, in __init__
self.has_buffer = self.remote_eval(test_buffer)
File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1352, in remote_eval
return eval(self.remote(func, *args, **kwargs))
File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1330, in remote
self.pyb.enter_raw_repl()
File "/usr/local/lib/python3.5/dist-packages/rshell/pyboard.py", line 187, in enter_raw_repl
raise PyboardError('could not enter raw repl')
rshell.pyboard.PyboardError: could not enter raw repl
pi@raspberrypi:~ $

pi@raspberrypi:~ $ cat /etc/hosts
127.0.0.1 localhost
::1 ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

192.168.1.76 raspberrypi.local raspberrypi
pi@raspberrypi:~ $

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

Re: rshell fails to get esp32 serial console rshell.pyboard.PyboardError

Post by dhylands » Sun Aug 27, 2017 4:46 am

It looks like you have some code running which might be interfering with rshell getting the raw repl.

The first error:

Code: Select all

-----
b'\r\n>CWhat? \r\n>CWhat? \r\n>\r\n>\x01'
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1185, in connect
ip_address = socket.gethostbyname(port)
socket.gaierror: [Errno -5] No address associated with hostname
is the root cause of the problem.

If you setup f=your esp32 board so that it just goes to the REPL, does rshell behave the same?

ldfsilva
Posts: 3
Joined: Sun Aug 27, 2017 2:19 am

Re: rshell fails to get esp32 serial console rshell.pyboard.PyboardError

Post by ldfsilva » Sun Aug 27, 2017 2:53 pm

Did you mean something running on esp32 or raspberrypi that may be causing conflict? On esp32 the errors occur right after a fresh image install write_flash, so I have no specific code running. Also I tried rebooting pi board with no luck.

ldfsilva
Posts: 3
Joined: Sun Aug 27, 2017 2:19 am

Re: rshell fails to get esp32 serial console rshell.pyboard.PyboardError

Post by ldfsilva » Sun Aug 27, 2017 4:11 pm

Hi dhylands, I figured out what was the issue and it's now working as expected. I was flashing the esp32 micropython image on 0x0 address which did not work, after writing it to 0x1000 the rshell opened up just fine!

Do you believe it is worth setting a flag on esptool, so whenever a esp32 is being used the address used should be 0x1000 and do not accept 0x0 or do you believe it goes beyond its scope?

pi@raspberrypi:~ $ esptool.py --port /dev/ttyUSB0 write_flash 0x1000 Downloads/esp32-20170827-v1.9.1-439-g6c62e70b.bin
esptool.py v2.0.1
Connecting......
Detecting chip type... ESP32
Chip is ESP32D0WDQ6 (revision 0)
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 1086304 bytes to 604097...
Wrote 1086304 bytes (604097 compressed) at 0x00001000 in 55.2 seconds (effective 157.5 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting...
pi@raspberrypi:~ $ rshell --buffer-size=30 --port /dev/ttyUSB0
connecting to serial /dev/ttyUSB0
Connecting to /dev/ttyUSB0 ...
Welcome to rshell. Use Control-D to exit.
/home/pi>

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

Re: rshell fails to get esp32 serial console rshell.pyboard.PyboardError

Post by pythoncoder » Mon Aug 28, 2017 7:06 am

This caught me out too. But esptool is a vendor application and the 0x1000 offset is MicroPython specific so I think the best option is to document the procedure. I'll raise an issue suggesting this.
Peter Hinch
Index to my micropython libraries.

Post Reply