Accessing SD cards
Accessing SD cards
I'm wondering about the ways to access an SD card. I know that currently the MicroPython port for ESP8266 doesn't support mounting two filesystems at the same time, but I wonder if we could unmount the internal filesystem and mount the one on the SD card in its place? What other pieces would be then missing to get this working?
Re: Accessing SD cards
Which module are you using which supports an SD card?
None of mine obviously do.
None of mine obviously do.
Re: Accessing SD cards
You simply connect an SD card with SPI. There are shields both for the Adafruit HUZZAH Feather (https://www.adafruit.com/products/2922) and for the WeMos D1 Mini (http://www.wemos.cc/Products/micro_sd_shield.html). Also many TFT displays modules include an SD card socket, because it's common to need them for storing the graphics -- those can be used too.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Accessing SD cards
I wonder where in the developers' roadmap mounting more filesystems is placed. It would be great to have this feature. I came unstuck with this when I tried porting my ferroelectric RAM driver.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Accessing SD cards
ACK ... and picture completes together with DB module. (viewtopic.php?f=16&t=2043)pythoncoder wrote:It would be great to have this feature
Re: Accessing SD cards
Does it use the same SPI pins as the built-in SPI flash on the modules (e.g. ESP-12) ?
Is there some chip-select line or something?
Is there some chip-select line or something?
Re: Accessing SD cards
No, you need to use the second SPI or the software SPI. There is a chip select pin on the flash SPI, but using it together with running your program from flash is a bit tricky.
Re: Accessing SD cards
My ever so nearly working SPIFFS code gets around the second file system problem by defining its own open method.
Once you have the filehandle it works as you'd expect. So for the time being one would use the existing (and now smaller) FAT filesystem for Python code and SPIFFS for data and logfiles.
Jon
Once you have the filehandle it works as you'd expect. So for the time being one would use the existing (and now smaller) FAT filesystem for Python code and SPIFFS for data and logfiles.
Jon
Re: Accessing SD cards
So, to answer my own question, yes, it is possible. I just did it.
First, you need to comment out the mounting of the filesystem in the modules/_boot.py
Then you need to import the sdcard code (from https://bitbucket.org/thesheep/micropyt ... /sdcard.py) and run the esp8266_mount function from it.
Then you can use the sd card as your storage.
First, you need to comment out the mounting of the filesystem in the modules/_boot.py
Then you need to import the sdcard code (from https://bitbucket.org/thesheep/micropyt ... /sdcard.py) and run the esp8266_mount function from it.
Then you can use the sd card as your storage.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact: