MicroPython on ESP32 with SPIRAM support

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
ClockToshi
Posts: 5
Joined: Thu Nov 16, 2017 9:25 pm

Re: MicroPython on ESP32 with SPIRAM support

Post by ClockToshi » Thu Nov 16, 2017 11:23 pm

@loboris it worked

thank you. I will spend a bit of time playing with it :D

ClockToshi
Posts: 5
Joined: Thu Nov 16, 2017 9:25 pm

Re: MicroPython on ESP32 with SPIRAM support

Post by ClockToshi » Fri Nov 17, 2017 12:34 am

by the way, i found a difference, not sure if important, micropython-esp32 master you can do both import uhashlib and import hashlib. In your repo only the latter works.

Not a problem but I was surprised because your repo is up to date

ClockToshi
Posts: 5
Joined: Thu Nov 16, 2017 9:25 pm

Re: MicroPython on ESP32 with SPIRAM support

Post by ClockToshi » Fri Nov 17, 2017 12:51 am

Another difference I found with code working on micropython-esp32 (same device)

Code: Select all


from machine import Pin
pin = Pin(39, Pin.IN, Pin.PULL_DOWN)  # <- fails here 
 
#pin.init(pin.IN)
#pin.irq(trigger=Pin.IRQ_FALLING, handler=lambda x: print(x))   


Traceback (most recent call last):
  File "main.py", line 2, in <module>
ValueError: pins 34~39 do not have pull-up or pull-down circuitry

and if I comment the buttons code out, it then fails with

Code: Select all


from machine import Pin, SPI
spi = SPI(                                                                      
    -1,                                                                         
    baudrate=1200000,                                                           
    miso=Pin(19),                                             
    mosi=Pin(23),                                             
    sck=Pin(18)  

Traceback (most recent call last):
  File "main.py", line 2, in <module>
OSError: error initializing spi

I'm sorry I'm a noob :(

ClockToshi
Posts: 5
Joined: Thu Nov 16, 2017 9:25 pm

Re: MicroPython on ESP32 with SPIRAM support

Post by ClockToshi » Fri Nov 17, 2017 1:48 am

Some small update:

after disabling what doesn't work (display, buttons, see previous comments). i tested a bit the performance of my code using your micropython repository vs vanilla micropython-esp32 repository and things are nice!

For my code I get 20%+ more performance on your repository. I also tried the threading library and I was hoping it used both cores but looks like it doesn't.

Is there any 'advanced' way to use both cores with micropython other than writing some C module? the code i have is actually faster without using threads right now (and shares no state or locks)

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

Re: MicroPython on ESP32 with SPIRAM support

Post by loboris » Fri Nov 17, 2017 9:02 am

@ClockToshi

GPIOs 34-39 are input-only and do not have internal pull-up or pull-down circuitry, so this error is improvement over master MicroPython-ESP32.

This port uses only hardware SPI, you can only select SPI.HSPI (1) ir SPI.VSPI(2) as spi ID.

AFAIK, uhashlib does not exist in master MicroPithon-ESP32 port.

Some of the internal task/servers are running on the different core than main MPy task. Most of the wifi stack runs on different core, so there should be an improvement when running on both cores. I'm working on enabling MicroPython threads to run on different core and some other improvements related to dual core usage, but I don'e expect to push them before the end of this year.

What exactly does not work in display ?

ruf
Posts: 1
Joined: Tue Nov 21, 2017 7:02 am

Re: MicroPython on ESP32 with SPIRAM support

Post by ruf » Tue Nov 21, 2017 7:22 am

loboris,

I am building and testing it on HELTEC WIFI KIT 32( no SPI-RAM, with SSD1366 oled). it works well. The embedded telnetd and ftpd are very useful. thanks for your great work :)

there are some issues:

if I enable bluetooth in menuconfig, i got CPU halt.

I set timezone to CST-8 in menuconfig, rebuild and flash, after rtc.ntp_sync(), time.gmtime() returns correct, but time.localtime() returns wrong time. It should be +0800 but i got -0800 time.

machine.Timer() not work yet. hoping your new commits will fix it 8-)

sometime, while threads is exiting, run '_thread.list()' cause core crash.

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

Re: MicroPython on ESP32 with SPIRAM support

Post by devnull » Wed Nov 22, 2017 1:51 pm

Anybody know how to access the built-in hall sensor ?

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

Re: MicroPython on ESP32 with SPIRAM support

Post by loboris » Wed Nov 22, 2017 2:38 pm

ruf wrote:
Tue Nov 21, 2017 7:22 am
if I enable bluetooth in menuconfig, i got CPU halt.

I set timezone to CST-8 in menuconfig, rebuild and flash, after rtc.ntp_sync(), time.gmtime() returns correct, but time.localtime() returns wrong time. It should be +0800 but i got -0800 time.

machine.Timer() not work yet. hoping your new commits will fix it 8-)

sometime, while threads is exiting, run '_thread.list()' cause core crash.
Bluetooth does not work, BT module will be (temporarily) removed from build in next commit.

I've tested with timezone set to CST-8 in menuconfig, and the time is returned correctly:

Code: Select all

>>> time.gmtime()
(2017, 11, 22, 14, 36, 14, 4, 326)
>>> time.localtime()
(2017, 11, 22, 22, 36, 21, 4, 326)
>>> 
>>> time.strftime("%c",time.gmtime())
'Wed Nov 22 14:50:13 2017'
>>> time.strftime("%c",time.localtime())
'Wed Nov 22 22:50:16 2017'
>>> 
machine.Timer now works correctly (and many featureas are added), it will be commited this week.

Please, test the _thread.list issue after nex commit.
Last edited by loboris on Wed Nov 22, 2017 2:50 pm, edited 2 times in total.

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

Re: MicroPython on ESP32 with SPIRAM support

Post by loboris » Wed Nov 22, 2017 2:40 pm

devnull wrote:
Wed Nov 22, 2017 1:51 pm
Anybody know how to access the built-in hall sensor ?
Reading the built-in hall sensor is now included in ADC Module. The update will be committed this week.

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

Re: MicroPython on ESP32 with SPIRAM support

Post by devnull » Thu Nov 23, 2017 10:13 am

Wondering why is the reset reason RTC WDT reset when a hard reset is performed ??

Code: Select all

FreeRTOS running on BOTH CORES, MicroPython task started on App Core.

 Reset reason: RTC WDT reset
    uPY stack: 19456 bytes
     uPY heap: 80000/6752/73248 bytes

MicroPython ESP32_LoBo_v2.0.8 - 2017-11-04 on ESP32 board with ESP32
Type "help()" for more information.

Post Reply