Running uPyEasy from a SD Card

Moderators: Voyager, BertB, grovkillen, Stuntteam, LisaM

Post Reply
Message
Author
LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Running uPyEasy from a SD Card

#1 Post by LisaM » 04 Apr 2018, 10:57

Cheered to early... :(
It is using the standard Loboris firmware for the ESP32-WROVER, like a Lolin32 Pro, which has both an SD Card and 4MB of PsRam (url: https://github.com/loboris/MicroPython_ ... _psram_all). Then put all of the modules code and the upyeasy code (in the SD root dir upyeasy) on the SD Card.

Next put this in the boot.py:

Code: Select all

import uos,os
uos.sdconfig(uos.SDMODE_SPI, clk=14, mosi=15, miso=2, cs=13)
os.mountsd()
import upyeasy
upyeasy.main()
Since you now have 2MB of heap, there's plenty of room left to load all of the modules. But...
There's a bug on Loboris, meaning you'll have to change line 235 of the file uasyncio/__init__.py to:

Code: Select all

ai = _socket.getaddrinfo(host, port)
Then put the next code on line 239:

Code: Select all

s.settimeout(10000)
Then reboot, and the following appear in the log:

Code: Select all

Internal FS (SPIFFS): Mounted on partition 'internalfs' [size: 1048576; Flash address: 0x200000]
----------------
Filesystem size: 956416 B
           Used: 14848 B
           Free: 941568 B
----------------
D (278) intr_alloc: Connected src 31 to int 9 (cpu 1)
---------------------
 Mode: SPI
 Name: NCard
 Type: SDHC/SDXC
Speed: default speed (25 MHz)
 Size: 15180 MB
  CSD: ver=1, sector_size=512, capacity=31088640 read_bl_len=9
  SCR: sd_spec=2, bus_width=5

loaded sink log
loaded sink console
loaded sink syslog
1970-01-01T00:26:53.005 [debug] uPyEasy: Init: Init constructor
1970-01-01T00:26:53.005 [debug] uPyEasy: Init: Entering init
1970-01-01 00:26:53 [debug] uPyEasy: Init: Create directory config
1970-01-01 00:26:54 [debug] uPyEasy: Init: Create directory plugins
1970-01-01 00:26:54 [debug] uPyEasy: Init: Create directory protocols
1970-01-01 00:26:54 [debug] uPyEasy: Init: Create directory scripts
1970-01-01 00:26:54 [debug] uPyEasy: Init: Create directory rules
1970-01-01 00:26:54 [debug] uPyEasy: Init: config Table
1970-01-01 00:26:55 [debug] uPyEasy: Init: network Table
1970-01-01 00:26:55 [debug] uPyEasy: Init: protocol Table
1970-01-01 00:26:55 [debug] uPyEasy: Init: controller Table
1970-01-01 00:26:55 [debug] uPyEasy: Init: hardware Table
1970-01-01 00:26:55 [debug] uPyEasy: Init: dxpin Table
1970-01-01 00:26:56 [debug] uPyEasy: Init: dxmap Table
1970-01-01 00:26:56 [debug] uPyEasy: Init: plugin Table
1970-01-01 00:26:56 [debug] uPyEasy: Init: pluginstore Table
1970-01-01 00:26:56 [debug] uPyEasy: Init: device Table
1970-01-01 00:26:56 [debug] uPyEasy: Init: service Table
1970-01-01 00:26:57 [debug] uPyEasy: Init: notification Table
1970-01-01 00:26:57 [debug] uPyEasy: Init: advanced Table
1970-01-01 00:26:57 [debug] uPyEasy: Init: script Table
1970-01-01 00:26:57 [debug] uPyEasy: Init: rule Table
1970-01-01 00:26:58 [debug] uPyEasy: Hal: Init
1970-01-01 00:26:59 [debug] uPyEasy: Hal: init, network record present
1970-01-01 00:26:59 [debug] uPyEasy: Hal: esp32
I (21346) phy: phy_version: 383.0, 79a622c, Jan 30 2018, 15:38:06, 0, 0
1970-01-01 00:27:02 [debug] uPyEasy: Hal: esp32, ip: 192.168.178.109
1970-01-01 00:27:02 [debug] uPyEasy: Hal: nic present
1970-01-01 00:27:02 [debug] uPyEasy: Protocols: Load
1970-01-01 00:27:02 [debug] uPyEasy: Protocols: Init protocol records
1970-01-01 00:27:03 [debug] uPyEasy: Protocols: Load protocol domoticz_mqtt
1970-01-01 00:27:05 [debug] uPyEasy: Protocols: Create protocol Record: domoticz_mqtt
1970-01-01 00:27:05 [debug] uPyEasy: Protocols: Load protocol domoticz_http
1970-01-01 00:27:06 [debug] uPyEasy: Protocols: Create protocol Record: domoticz_http
1970-01-01 00:27:06 [debug] uPyEasy: Plugins: Load
1970-01-01 00:27:06 [debug] uPyEasy: Plugins: init plugin records
1970-01-01 00:27:07 [debug] uPyEasy: Plugins: Register frozen plugin switch
1970-01-01 00:27:09 [debug] uPyEasy: Plugin: switch contruction
1970-01-01 00:27:09 [debug] uPyEasy: Plugins: Create frozen plugin Record: switch
1970-01-01 00:27:09 [debug] uPyEasy: Plugins: Register frozen plugin bme280
1970-01-01 00:27:11 [debug] uPyEasy: Plugins: Create frozen plugin Record: bme280
1970-01-01 00:27:11 [debug] uPyEasy: Plugins: Register frozen plugin test
1970-01-01 00:27:11 [debug] uPyEasy: Plugins: Create frozen plugin Record: test
1970-01-01 00:27:12 [debug] uPyEasy: Plugins: Register frozen plugin ds18
1970-01-01 00:27:13 [debug] uPyEasy: Plugin: ds18 contruction
1970-01-01 00:27:14 [debug] uPyEasy: Plugins: Create frozen plugin Record: ds18
1970-01-01 00:27:14 [debug] uPyEasy: Init: Init devices
1970-01-01 00:27:14 [debug] uPyEasy: Scripts: Load
1970-01-01 00:27:14 [debug] uPyEasy: Scripts: Init
1970-01-01 00:27:14 [debug] uPyEasy: Plugins: GetQueue
1970-01-01 00:27:15 [debug] uPyEasy: Scripts: init scripts records
1970-01-01 00:27:15 [debug] uPyEasy: Scripts: init rules records
1970-01-01 00:27:16 [debug] uPyEasy: Utils: Sys hostname
1970-01-01 00:27:16 [debug] uPyEasy: Utils: uPyEasy Name
Set syslog hostname 0.0.0.0
reloaded sink syslog
1970-01-01 00:27:17 [debug] uPyEasy-uPyEasy: Hal: Entering SetTime
1970-01-01 00:27:17 [debug] uPyEasy-uPyEasy: Hal: Entering GetNtpTime
1970-01-01 00:27:17 [debug] uPyEasy-uPyEasy: Hal: network Table
1970-01-01 00:27:17 [debug] uPyEasy-uPyEasy: Hal: Using NTP Hostname: pool.ntp.org
1970-01-01 00:27:17 [debug] uPyEasy-uPyEasy: Hal: TimeZome offset: 60
1970-01-01 00:27:18 [debug] uPyEasy-uPyEasy: Hal: Received UTC NTP Time: 576168798
1970-01-01 00:27:18 [debug] uPyEasy-uPyEasy: Hal: Timezone corrected NTP Time: 576172398
1970-01-01 00:27:18 [debug] uPyEasy-uPyEasy: Hal: DST corrected NTP Time: 576172398
1970-01-01 00:27:18 [debug] uPyEasy-uPyEasy: Hal: Received NTP Time: 576172398
1970-01-01 00:27:19 [debug] uPyEasy-uPyEasy: Hal: StartTime: 576172398
1970-01-01 00:27:19 [debug] uPyEasy-uPyEasy: Set time: 1970-01-01T00:27:19
1970-01-01 00:27:30 [debug] uPyEasy-uPyEasy: Main: Pre-loading home page
1970-01-01 00:27:31 [debug] uPyEasy-uPyEasy: Hal: get_ip_address esp32, ip: 192.168.178.109
1970-01-01 00:27:31 [debug] uPyEasy-uPyEasy: Main: Schedule async loops
1970-01-01 00:27:31 [debug] uPyEasy-uPyEasy: Main: uPyEasy Main Async Loop
1970-01-01 00:27:32 [debug] uPyEasy-uPyEasy: Plugins: Async processing plugins
1970-01-01 00:27:32 [debug] uPyEasy-uPyEasy: Protocols: Async processing protocols
1970-01-01 00:27:33 [debug] uPyEasy-uPyEasy: Scripts: Async processing scripts/rules
The nasty part? It then hangs and doesn't response anymore... :oops:

I've have filed this bug for it: https://github.com/loboris/MicroPython_ ... issues/119

AndrewJ
Normal user
Posts: 229
Joined: 14 Feb 2017, 12:38

Re: Running uPyEasy from a SD Card!

#2 Post by AndrewJ » 04 Apr 2018, 14:34

Very nice!! :D :D
I'll give it a try on a TTGO T8 ESP32 board which arrived recently, which has an SD card slot.

(I do/did have a Lolin32 Pro, which also has SD, but it seems to have died.... :cry: )

Cheers
Andrew

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Running uPyEasy from a SD Card!

#3 Post by LisaM » 04 Apr 2018, 15:28

AndrewJ wrote: 04 Apr 2018, 14:34 Very nice!! :D :D
I'll give it a try on a TTGO T8 ESP32 board which arrived recently, which has an SD card slot.

(I do/did have a Lolin32 Pro, which also has SD, but it seems to have died.... :cry: )

Cheers
Andrew
In that case, you'll need to adjust the parameters:

Code: Select all

spi = machine.SPI(1, baudrate=10000000, polarity=0, phase=0, sck=machine.Pin(14), miso=machine.Pin(2), mosi=machine.Pin(15))
sd = sdcard.SDCard(spi, machine.Pin(13))
For the Lolin32 pro, the connections listed above are:
sdcard lolin32 pro.png
sdcard lolin32 pro.png (21.99 KiB) Viewed 10763 times
So you'll need to take a look at your ESP32 SD Card to see on which pins miso, mosin, sck and cs are. CS is used in the secode code line.

AndrewJ
Normal user
Posts: 229
Joined: 14 Feb 2017, 12:38

Re: Running uPyEasy from a SD Card!

#4 Post by AndrewJ » 04 Apr 2018, 16:37

Hi Lisa,
Thanks for the tip - it should avoid a quantity of hair-pulling! :)
Andrew

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Running uPyEasy from a SD Card!

#5 Post by LisaM » 04 Apr 2018, 17:10

AndrewJ wrote: 04 Apr 2018, 16:37 Hi Lisa,
Thanks for the tip - it should avoid a quantity of hair-pulling! :)
Andrew
Sorry Andrew, i have run into a wall. See first page.
You can still mount the SD however and use it using the uPyEasy firmware version, with the uPyEasy firmware version it's not possible to run uPyEasy from the SD card.

Code: Select all

import machine, os, sdcard
spi = machine.SPI(1, baudrate=10000000, polarity=0, phase=0, sck=machine.Pin(14), miso=machine.Pin(2), mosi=machine.Pin(15))
sd = sdcard.SDCard(spi, machine.Pin(13))
vfs = os.VfsFat(sd)
os.mount(vfs, "/sd")
If you then run the command os.listdir() the sd directory will be visible.

AndrewJ
Normal user
Posts: 229
Joined: 14 Feb 2017, 12:38

Re: Running uPyEasy from a SD Card!

#6 Post by AndrewJ » 04 Apr 2018, 19:09

LisaM wrote: 04 Apr 2018, 17:10
AndrewJ wrote: 04 Apr 2018, 16:37 Hi Lisa,
Thanks for the tip - it should avoid a quantity of hair-pulling! :)
Andrew
Sorry Andrew, i have run into a wall. See first page.
You can still mount the SD however and use it using the uPyEasy firmware version, with the uPyEasy firmware version it's not possible to run uPyEasy from the SD card.

Code: Select all

import machine, os, sdcard
spi = machine.SPI(1, baudrate=10000000, polarity=0, phase=0, sck=machine.Pin(14), miso=machine.Pin(2), mosi=machine.Pin(15))
sd = sdcard.SDCard(spi, machine.Pin(13))
vfs = os.VfsFat(sd)
os.mount(vfs, "/sd")
If you then run the command os.listdir() the sd directory will be visible.
Oh, that's a real shame. :( Still, there's a lot of potential there, when the issue is resolved.
I haven't yet experimented with the SD card in the TTGO, I'll see what happens with it.
Andrew

Drum
Normal user
Posts: 300
Joined: 07 Feb 2016, 11:56

Re: Running uPyEasy from a SD Card

#7 Post by Drum » 09 Apr 2018, 11:31

Having the extra storage still opens a lot of very cool possibilities, especially for displaying information in stored templates, almost endless functional menus on touch displays....

Maybe it is possible to put some larger parts of the firmware, like more complex plugins on the SD Card or boot from internal memory and run from SD.

Even without a larger firmware, it still opens the possibility for much more advanced inexpensive wireless touchscreen controllers and displays.


I really have to work on my programming skills.....

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Running uPyEasy from a SD Card

#8 Post by LisaM » 09 Apr 2018, 23:10

PYcom also has an ESP32 micropython version for their ESP32's, i'll order one to see if that's working as planned. I was going to order the NB-IoT ESP32 version from them anyway...

Cheers,

Lisa

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest