MicroPython on ESP32 with SPIRAM support

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
loboris
Posts: 317
Joined: Fri Oct 02, 2015 6:19 pm

Re: MicroPython on ESP-WROVER with 4MB of psRAM

Post by loboris » Sun Jul 23, 2017 3:26 pm

ESP-WROVER-KIT is designed with with esp32 module footprint for ESP-WROVER (which has psRAM) or ESP-WROOM-32 module (without psRAM).
Adafruit offers only ESP-WROVER-KIT with ESP-WROOM-32.
AnalogLamb and Olimex have ESP-WROVER-KIT with ESP-WROVER.

Only SD card can be used in CD card connector. ESD protection diodes are recommended on every connector which can be touched by hand. It doesn't make much sense on such a bord with all MCU IO pins exposed. The design was probably copied from some other device.

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

Re: MicroPython on ESP-WROVER with 4MB of psRAM

Post by pythoncoder » Mon Jul 24, 2017 5:44 am

Thanks for the clarification.

As for uncritical "cut'n'paste" hardware design, words fail me ;)
Peter Hinch

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

Re: MicroPython on ESP-WROVER with 4MB of psRAM

Post by loboris » Mon Jul 24, 2017 3:40 pm

:!: Update:
  • Added native ESP32 VFS support, MicroPython's FatFS VFS is not used (it can still be selected via menuconfig).
    It is now very simple to work with files from C modules using standard file functions.
    Thanks to SHA2017 Badge Team https://github.com/SHA2017-badge/micropython-esp32 for initial support.
  • New MicroPython configuration options added to menuconfig
  • Xtensa toolchain and eps-idf directories (for both standard & psRAM build) added to make the build process even easier
Coming next: spiffs support for internal Flash filesystem.

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

Re: MicroPython on ESP-WROVER with 4MB of psRAM

Post by loboris » Wed Jul 26, 2017 12:25 pm

:!: Update:
  • Added support for SPIFFS filesystem on internal spi Flash
  • SPIFFS or FatFS can be selected via menuconfig
  • SFPIFFS fs image file can be prepared on host and flashed to ESP32
  • File systems functions updated, improved, some bugfixes
  • MicroPython sources updated
  • BUILD.sh script updated with new options
See GitHub repository for more info.
You can also visit this Espressif forum topic for more detailes.
Last edited by loboris on Thu Jul 27, 2017 7:15 pm, edited 1 time in total.

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

Re: MicroPython on ESP-WROVER with 4MB of psRAM

Post by loboris » Thu Jul 27, 2017 7:13 pm

:!: Update:
  • Added support for connecting sd card in SPI mode
  • works only with master esp-idf, psRAM esp-idf branch does not have the necessary support yet
  • main advantage (the only one?) of connecting sd card in SPI mode is that the card can be attached to any ESP32 pins
  • Sd card working mode (SD-1-line, SD-4-line, SPI) can be selected via menuconfig
  • sdcard module initialization syntax is changed:

    Code: Select all

    import sdcard
    sd = sdcard.SDCard([chdir_to_sd_root])
    If the optional boolean parameter is True the working directory will be changed to sdcard root
  • umount method is added

    Code: Select all

    >>> uos.listdir('/')
    ['flash']
    >>> sd = sdcard.SDCard()
    ---------------------
     Mode:  SD (4bit)
     Name: SL08G
     Type: SDHC/SDXC
    Speed: default speed (25 MHz)
     Size: 7580 MB
      CSD: ver=1, sector_size=512, capacity=15523840 read_bl_len=9
      SCR: sd_spec=2, bus_width=5
    
    >>> uos.listdir('/')
    ['flash', 'sd']
    >>> sd.umount()
    >>> uos.listdir('/')
    ['flash']
    
See GitHub repository for more info.
You can also visit this Espressif forum topic for more detailes.

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

Re: MicroPython on ESP-WROVER with 4MB of psRAM

Post by loboris » Fri Jul 28, 2017 2:34 pm

:!: Update:
  • Added ymodem module
  • Send or receive files to/from host via same uart on which REPL runs
  • Text or binary files (like images, encoded data, ...) of any size can be sent or received reliably
  • Terminal emulator with support for ymodem protocol must be used (like minicom on Linux or TeraTerm, ExtraPuTTY on Windows)

Code: Select all

>>> import ymodem, uos
>>>
>>> ymodem.recv('image1.bmp')

Receiving file, please start YModem transfer on host ...
(Press "a" to abort)
CCCC
File received, size=230456, original name: "tiger.bmp"

>>> uos.listdir()
['spiffs.info', 'lib', 'boot.py', 'yyy.txt', 'tiger240.jpg', 'tiger.jpg', 'image1.bmp']
>>> uos.stat('image1.bmp')
(32768, 0, 0, 0, 0, 0, 230456, 138, 138, 138)
>>>
>>> ymodem.send('image1.bmp')

Sending file, please start YModem receive on host ...
(Press "a" to abort)
CCC

Transfer complete, 230456 bytes sent
>>>
See GitHub repository for more info.
You can also visit this Espressif forum topic for more detailes.

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

Re: MicroPython on ESP-WROVER with 4MB of psRAM

Post by pythoncoder » Sat Jul 29, 2017 9:32 am

Is it not possible to use rshell for file transfer with the ESP32?
Peter Hinch

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

Re: MicroPython on ESP-WROVER with 4MB of psRAM

Post by loboris » Sat Jul 29, 2017 3:43 pm

pythoncoder wrote:Is it not possible to use rshell for file transfer with the ESP32?
rshell and ampy can be used, but I've had some problems transfering binary files (in fact, couldn't transfer any binary file).
I also find it far more simple to send or receive the file directly from REPL than to exit REPL, start rshell, transfer file(s), back to repl ...
It is far more simple and more reliable.
Of course, when I need to transfer more files (or large files) I'm using ftpserver module. It works very fast and I've had no problems so far.

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

Re: MicroPython on ESP-WROVER with 4MB of psRAM

Post by dhylands » Sat Jul 29, 2017 5:47 pm

rshell also has a repl command...

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

Re: MicroPython on ESP-WROVER with 4MB of psRAM

Post by loboris » Mon Jul 31, 2017 9:35 pm

:!: Update:
  • Some changes needed to build with latest esp-idf commits
  • Master esp-idf archive updated (for non-psRAM builds)
  • improvements in _thread module
    • _thread.start_new_thread() now returns thread id which can be used in some methods
    • added methods suspend(th_id), resume(th_id), stop(th_id)
    • inter-thread notifications:
      • _thread.notify(th_id) send notification to the specific thread
      • _thread.getnotification() check if a notification received from within the thread
    • threads are tested with (relatively) complex modules like uftpserver and works wery well
  • Updated uftpserver frozen module to quietly run in thread
  • other small changes and bug fixes
Thread example:

Code: Select all

>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== import machine, _thread, time
===
=== bled    = machine.Pin(4, mode=machine.Pin.OUT)
=== gled    = machine.Pin(0, mode=machine.Pin.OUT)
=== rled    = machine.Pin(2, mode=machine.Pin.OUT)
===
=== bled.value(0)
=== gled.value(0)
=== rled.value(0)
===
===
=== def rgbleds(n, x):
===     ledon = 0
===     notif_exit = 4718
===     notif_print = 2
===     while x > 0:
===         if ledon == 0:
===             bled.value(1)
===             gled.value(0)
===             rled.value(0)
===         if ledon == 1:
===             gled.value(1)
===             bled.value(0)
===             rled.value(0)
===         if ledon == 2:
===             rled.value(1)
===             bled.value(0)
===             gled.value(0)
===         ledon = ledon + 1
===         if ledon > 2:
===             ledon = 0
===         time.sleep_ms(n)
===         x = x - 1
===
===         notif = _thread.getnotification()
===         if notif == notif_exit:
===             print("[rgbleds] Exiting")
===             return
===         elif notif == notif_print:
===             print("[rgbleds] I was notified")
===         elif notif != 0:
===             print("[rgbleds] Unknown notification %u" % (notif) )
===
===
=== lth=_thread.start_new_thread(rgbleds, (333,10000))
===
>>>
>>> _thread.notify(lth,7788)
True
>>> [rgbleds] Unknown notification 7788
_thread.notify(lth,2)
True
>>> [rgbleds] I was notified

>>> import uftpserver
>>> ftpth=_thread.start_new_thread(uftpserver.ftpserver, (3600,True))
Starting ftp server. Version 1.2
>>> FTPServer address:  192.168.0.21

>>> _thread.notify(ftpth,7788)
True
>>> [ftpserver] Notification 7788 unknown

>>> _thread.notify(ftpth,7591)
True
>>> [ftpserver] Received QUIT notification, exiting
See GitHub repository for more info.

Post Reply