Accessing SD cards

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Accessing SD cards

Post by deshipu » Thu Sep 01, 2016 8:06 am

The sdcard driver included in MicroPython's tree now works both on PyBoard and on the ESP8266. See the example on how to use it. https://github.com/micropython/micropyt ... /sdcard.py

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

Re: Accessing SD cards

Post by pythoncoder » Thu Sep 01, 2016 8:59 am

Excellent! That is seriously useful :D
Peter Hinch
Index to my micropython libraries.

ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

Re: Accessing SD cards

Post by ajie_dirgantara » Fri Sep 09, 2016 3:05 am

[quote="deshipu"]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.[/quote]

Hi,

where is this modules/_boot.py located?

Thanks,

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: Accessing SD cards

Post by platforma » Fri Sep 09, 2016 2:31 pm

ajie_dirgantara wrote: where is this modules/_boot.py located?
It's located in https://github.com/micropython/micropyt ... 66/modules.
Is it necessary to prevent the filesystem mount at boot with the micropython's sdcard.py driver? You should be able to just use the driver without the need to modify the _boot.py file.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Accessing SD cards

Post by deshipu » Fri Sep 09, 2016 3:11 pm

Yes, it's no longer necessary to edit your _boot.py, you as you can now unmount the filesystem.

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

Re: Accessing SD cards

Post by pythoncoder » Fri Sep 09, 2016 4:34 pm

Is it in the roadmap to support multiple mounted filesystems as per the Pyboard?
Peter Hinch
Index to my micropython libraries.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Accessing SD cards

Post by deshipu » Fri Sep 09, 2016 7:43 pm

As far as I know that's the plan eventually, but some considerable cleanup of the related code needs to happen first, see https://github.com/micropython/micropython/pull/2140 for some discussion.

bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Re: Accessing SD cards

Post by bitninja » Fri Sep 16, 2016 9:15 pm

Hi! Thanks for all the great info. I have been able to use the module to successfully read the SD card from my Wemos D1 Mini SD Card shield.

All I really had to change was to use machine.SPI(1) instead of machine.SPI(0) and then I was able to remount to the SD card.

I had a couple of questions though...

1) How do I change the mount back to the original file system (SPIFFS I guess?). and

2) To what extent does the sdcard.py support Long File Names? I see them is my directory listing, so can I open them and manipulate them as normal?

Thanks!

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Accessing SD cards

Post by deshipu » Fri Sep 16, 2016 9:33 pm

You can see how your _boot.py mounts the internal filesystem on startup: https://github.com/micropython/micropyt ... t.py#L4-L8 and do the same thing.

As for your second question, I honestly have no idea.

bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Re: Accessing SD cards

Post by bitninja » Sat Sep 17, 2016 1:23 am

[quote="deshipu"]You can see how your _boot.py mounts the internal filesystem on startup.[/quote]

I'm sorry, where would I find _boot.py?

I'm new to Python as well, so it may be something basic I am missing.

:)

Post Reply