MicroPython on ESP32 with SPIRAM support

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: MicroPython on ESP32 with SPIRAM support

Post by dhylands » Mon Jan 15, 2018 6:05 am

Does os.listdir('/') show the sd directory? If not, rshell won't see it.

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

Re: MicroPython on ESP32 with SPIRAM support

Post by pythoncoder » Mon Jan 15, 2018 8:08 am

Isn't there a need to mount the drive before rshell starts? I'd try mounting the drive in main.py.
Peter Hinch
Index to my micropython libraries.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: MicroPython on ESP32 with SPIRAM support

Post by OutoftheBOTS_ » Mon Jan 15, 2018 11:14 am

I haven't used the SD card with Rshell but did use the SD card in 4 pin mode with FPT transfer not a problem.

os.list() will list the the contents of the SD directory when it is my active directory.

If your using loboris firmware then rshell is a bit obsolete as this firmware allows telent and FTP.

You can get a repl terminal over a telent session on putty and can transfer/edit files over ftp much faster then over serial.

slzatz
Posts: 92
Joined: Mon Feb 09, 2015 1:09 am

Re: rshell and sd card

Post by slzatz » Mon Jan 15, 2018 2:40 pm

Thanks for the responses. It seems very odd although I am sure it's something absolutely obvious that I am missing. I am mounting the sd card in boot.py although I've tried main.py as well. I have run rshell in debug mode and when it does remote_eval of os.listdir("/") all that returns is /flash whereas os.listdir("/") done directly from the micropython repl shows both /flash and /sd. I am not sure how that can happen since rshell's remote_eval is just running os.listdir("/") in raw repl I assume but that's what I am finding.

Here's an rshell session where rshell doesn't see /sd but when I enter repl from rshell, there it is ...

Code: Select all

(rshell) slzatz@slz-t470s:~/rshell$ rshell -p /dev/ttyUSB0
Connecting to /dev/ttyUSB0 ...
Welcome to rshell. Use Control-D to exit.
/home/slzatz/rshell> ls /flash
boot.py          iot_esp32_tft.py settings.py     
config.py        main.py          test            
/home/slzatz/rshell> ls /sd
Cannot access '/sd': No such file or directory
/home/slzatz/rshell> repl
Entering REPL. Use Control-X to exit.
>
MicroPython ESP32_LoBo_v3.1.3 - 2017-01-13 on ESP32 board with ESP32
Type "help()" for more information.
>>> 
>>> uos.listdir("/")
['flash', 'sd']
>>> 

ttmetro
Posts: 104
Joined: Mon Jul 31, 2017 12:44 am

Re: MicroPython on ESP32 with SPIRAM support

Post by ttmetro » Mon Jan 15, 2018 3:50 pm

What does rshell’s boards command return?
Bernhard Boser

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

Re: MicroPython on ESP32 with SPIRAM support

Post by Roberthh » Mon Jan 15, 2018 5:53 pm

That does not work for me either. The problem is more, that the mounting state is not properly cleared on a soft reset (Ctrl-D). If you add the mount statement in your main.py and perform a hard reset, the device is mounted. If you the do a soft reset, the sd is in a zombie mode. It cannot be mounted (message: device is already mounted), and it cannot be unmounted. Similar the pycom port.
I do not know how rshell internally works, whether it issues a soft reset and how it performs the repl, but opening the latter definitely does not cause main.py to be run.

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

Re: MicroPython on ESP32 with SPIRAM support

Post by dhylands » Mon Jan 15, 2018 6:08 pm

Each command that rshell executes on the device essentially goes through pyboard.py which does a soft-reset of the device and goes into raw-repl mode. Something like doing an ls command requires a bunch of commands to be executed.

I think that main.py isn't executed when doing that (at least that's how it works on the pyboard).

rshell does an initial query to determine the "roots" (/flash and /sd) and this is probably insufficient to deal with dynamically mounted devices.

slzatz
Posts: 92
Joined: Mon Feb 09, 2015 1:09 am

Re: rshell and sd card

Post by slzatz » Mon Jan 15, 2018 6:20 pm

If I mount the sd in boot.py and do a hard reset, I can make some progress. Rshell does know that /sd exists but can't access it when issuing an ls command but can cd into the directory -- it just can't do anything once there. Here is the rshell output:

Code: Select all

(rshell) slzatz@slz-t470s:~/rshell$ rshell -p /dev/ttyUSB0 
Connecting to /dev/ttyUSB0 ...
Welcome to rshell. Use Control-D to exit.
/home/slzatz/rshell> boards
pyboard @ /dev/ttyUSB0 connected Dirs: /flash /sd /pyboard/flash /pyboard/sd
/home/slzatz/rshell> ls /sd
Cannot access '/sd': No such file or directory
/home/slzatz/rshell> cd /sd
/sd> ls
Cannot access '/sd': No such file or directory
/sd> ls /flash
boot.py          iot_esp32_tft.py settings.py     
config.py        main.py          test            
As was suggested, it may be time to telnet (or ssh - I think the @loboris port supports that too) into the board -- I haven't tried that yet.

loboris
Posts: 344
Joined: Fri Oct 02, 2015 6:19 pm

Re: MicroPython on ESP32 with SPIRAM support

Post by loboris » Mon Jan 15, 2018 6:53 pm

I'm not using rshell, but I'll try to fix this issue in a next couple of days.

loboris
Posts: 344
Joined: Fri Oct 02, 2015 6:19 pm

Re: MicroPython on ESP32 with SPIRAM support

Post by loboris » Tue Jan 16, 2018 12:54 am

There was a bug in unmounting/mounting sdcard on soft reset. It is fixed now and update commited to the repository.

To acces the sdcard from rshell put in boot.py:

Code: Select all

import uos
uos.mountsd()
At the moment, main.py is not executed when the raw repl is requested on soft reset (which is the case with rshell).

SDCard can now be accessed from rshell without problem.

Post Reply