Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MicroPython for ESP32 with psRAM support

License

NotificationsYou must be signed in to change notification settings

loboris/MicroPython_ESP32_psRAM_LoBo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

with support for 4MB of psRAM


This repository can be used to build MicroPython for ESP32 boards/modules withpsRAM as well as for ESP32 boards/moduleswithout psRAM.

Building onLinux,MacOSandWindows (includingLinux Subsystem on Windows 10)is supported.

MicroPython works great on ESP32, but the most serious issue is still (as on most other MicroPython boards) limited amount of free memory.
This repository contains all the tools and sources necessary tobuild working MicroPython firmware which can fully use the advantages of4MB (or more) ofpsRAM.
It ishuge difference between MicroPython running withless than 100KB of free memory and running with4MB of free memory.


ESP32 can use externalSPIRAM (psRAM) to expand available RAM up to 16MB.

Currently, there are several modules & development boards which incorporates4MB of psRAM:


Wiki pages with detailed documentation specific to thisMicroPython port are available.

Some examples can be found inmodules_examples directory.


This repository contains all the tools and sources necessary tobuild working MicroPython firmware which can fully use the advantages of4MB (or more) ofpsRAM

It ishuge difference between MicroPython running withless than 100KB of free memory and running with4MB of free memory.


The MicroPython firmware is built as esp-idf component

This means the regular esp-idfmenuconfig system can be used for configuration. Besides the ESP32 configuration itself, many MicroPython options can also be configured viamenuconfig.

This way many features not available in standard ESP32 MicroPython are enabled, like unicore/dualcore, all Flash speed/mode options etc. No manualsdkconfig.h editing and tweaking is necessary.


Features

  • MicroPython core based on latest build frommain Micropython repository
  • added changes needed to build for ESP32 with psRAM
  • Default configuration has2MB of MicroPython heap,20KB of MicroPython stack,~200KB of free DRAM heap for C modules and functions
  • MicroPython can be built inunicore (FreeRTOS & MicroPython task running only on the first ESP32 core, ordualcore configuration (MicroPython task running on ESP32App core)
  • ESP32 Flash can be configured in any mode,QIO,QOUT,DIO,DOUT
  • BUILD.sh script is provided to makebuilding MicroPython firmware aseasy as possible
  • Internal Fat filesystem is built with esp-idfwear leveling driver, so there is less danger of damaging the flash with frequent writes.
  • SPIFFS filesystem is supported and can be used instead of FatFS in SPI Flash. Configurable viamenuconfig
  • Flexible automatic and/or manual filesystem configuration
  • sdcard support is included which uses esp-idfsdmmc driver and can work inSD mode (1-bit and4-bit) or inSPI mode (sd card can be connected to any pins). For imformation on how to connect sdcard see the documentation.
  • Filestimestamp is correctly set to system time both on internal fat filesysten and on sdcard
  • Native ESP32 VFS support for spi Flash & sdcard filesystems.
  • RTC Class is added to machine module, including methods for synchronization of system time tontp server,deepsleep,wakeup from deepsleepon external pin level, ...
  • Time zone can be configured viamenuconfig and is used when syncronizing time from NTP server
  • Built-inymodem module for fast transfer of text/binary files to/from host
  • Some additional frozen modules are added, likepye editor,urequests,functools,logging, ...
  • Btree module included, can be Enabled/Disabled viamenuconfig
  • _threads module greatly improved, inter-threadnotifications andmessaging included
  • Neopixel module using ESP32RMT peripheral with many new features
  • DHT module implemented using ESP32 RMT peripheral
  • 1-wire module implemented using ESP32 RMT peripheral
  • i2c module uses ESP32 hardware i2c driver
  • spi module uses ESP32 hardware spi driver
  • adc module improved, new functions added
  • pwm module, ESP32 hardware based
  • timer module improved, new timer types and features
  • curl module added, many client protocols including FTP and eMAIL
  • ssh module added with sftp/scp support andexec function to execute program on server
  • display module added with full support for spi TFT displays
  • mqtt module added, implemented in C, runs in separate task
  • mDNS module added, implemented in C, runs in separate task
  • telnet module added, connect toREPL via WiFi using telnet protocol
  • ftp server module added, runs as separate ESP32 task
  • GSM/PPPoS support, connect to the Internet via GSM module
  • OTA Update supported, various partitions layouts
  • Eclipse project files included. To include it into Eclipse goto File->Import->Existing Projects into Workspace->Select root directory->[selectMicroPython_BUILD directory]->Finish.Rebuild index.

How to Build


Detailed instructions onMicroPython building process are available in theWiki.


Using file systems

Detailed information about using MicroPython file systems are available in theWiki.


Some examples

Using new machine methods and RTC:

importmachinertc=machine.RTC()rtc.init((2017,6,12,14,35,20))rtc.now()rtc.ntp_sync(server="<ntp_server>" [,update_period=])# <ntp_server> can be empty string, then the default server is used ("pool.ntp.org")rtc.synced()# returns True if time synchronized to NTP serverrtc.wake_on_ext0(Pin,level)rtc.wake_on_ext1(Pin,level)# wake up from deepsleep on pin levelmachine.deepsleep(10000)ESP32:DEEPSLEEP# ...# ...Resetreason:Deepsleepwake-upWakeupsource:RTCwake-upuPYstack:19456bytesuPYheap:3073664/5664/3068000bytes (inSPIRAMusingmalloc)MicroPythonESP32_LoBo_v3.1.0-2017-01-03onESP32boardwithESP32Type"help()"formoreinformation.machine.wake_reason()# returns tuple with reset & wakeup reasonsmachine.wake_description()# returns tuple with strings describing reset & wakeup reasons

Using sdcard module:

importuosuos.mountsd()uos.listdir('/sd')

Working directory can be changed to root of the sd card automatically on mount:

>>>importuos>>>uos.mountsd(True)---------------------Mode:SD (4bit)Name:NCardType:SDHC/SDXCSpeed:defaultspeed (25MHz)Size:15079MBCSD:ver=1,sector_size=512,capacity=30881792read_bl_len=9SCR:sd_spec=2,bus_width=5>>>uos.listdir()['overlays','bcm2708-rpi-0-w.dtb', ......>>>

Tested onESP-WROVER-KIT v3Tested on


Example terminal session

I (0) cpu_start: App cpu up.I (1569) spiram: SPI SRAM memory test OKI (1570) heap_init: Initializing. RAM available for dynamic allocation:D (1570) heap_init: New heap initialised at 0x3ffae6e0I (1575) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAMD (1581) heap_init: New heap initialised at 0x3ffc1a00I (1586) heap_init: At 3FFC1A00 len 0001E600 (121 KiB): DRAMI (1593) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAMI (1599) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAMD (1606) heap_init: New heap initialised at 0x4009d70cI (1611) heap_init: At 4009D70C len 000028F4 (10 KiB): IRAMI (1617) cpu_start: Pro cpu start user codeI (1622) spiram: Adding pool of 4096K of external SPI memory to heap allocatorI (1630) spiram: Reserving pool of 32K of internal memory for DMA/internal allocationsD (1646) clk: RTC_SLOW_CLK calibration value: 3305242D (89) intr_alloc: Connected src 46 to int 2 (cpu 0)D (90) intr_alloc: Connected src 57 to int 3 (cpu 0)D (90) intr_alloc: Connected src 24 to int 9 (cpu 0)I (95) cpu_start: Starting scheduler on PRO CPU.D (0) intr_alloc: Connected src 25 to int 2 (cpu 1)I (4) cpu_start: Starting scheduler on APP CPU.D (119) heap_init: New heap initialised at 0x3ffe0440D (125) heap_init: New heap initialised at 0x3ffe4350D (130) intr_alloc: Connected src 16 to int 12 (cpu 0)D (145) nvs: nvs_flash_init_custom partition=nvs start=9 count=4D (178) intr_alloc: Connected src 34 to int 3 (cpu 1)D (187) intr_alloc: Connected src 22 to int 4 (cpu 1)Internal FS (SPIFFS): Mounted on partition 'internalfs' [size: 1048576; Flash address: 0x2D0000]----------------Filesystem size: 956416 B           Used: 512 B           Free: 955904 B----------------FreeRTOS running on BOTH CORES, MicroPython task running on both cores.Running from partition at 10000, type 10 [MicroPython_1]. Reset reason: Power on reset    uPY stack: 19456 bytes     uPY heap: 3073664/5664/3068000 bytes (in SPIRAM using malloc)MicroPython ESP32_LoBo_v3.1.0 - 2017-01-03 on ESP32 board with ESP32Type "help()" for more information.>>> >>> import micropython, machine>>> >>> micropython.mem_info()stack: 752 out of 19456GC: total: 3073664, used: 5904, free: 3067760 No. of 1-blocks: 19, 2-blocks: 7, max blk sz: 325, max free sz: 191725>>> >>> machine.heap_info()Heap outside of MicroPython heap:---------------------------------              Free: 239920         Allocated: 52328      Minimum free: 233100      Total blocks: 85Largest free block: 113804  Allocated blocks: 79       Free blocks: 6SPIRAM info:------------              Free: 1048532         Allocated: 3145728      Minimum free: 1048532      Total blocks: 2Largest free block: 1048532  Allocated blocks: 1       Free blocks: 1>>>

About

MicroPython for ESP32 with psRAM support

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp