Mounting sd card
Posted: Thu May 26, 2016 10:49 pm
I would like to read and write files from an sd card. Currently I'm using a microsd connector ripped from an old device (connected to a custom esp-12 breakout board) but the goal is to mount a connector on a new custom pcb eventually.
I have gotten sdcard.py from micropython/drivers/sdcard to work by changing the spi syntax to the current one and adding some more waiting/retry loops to work with my specific card.
I'm not sure how to mount the card to the filesystem though. I thought I could just look at the code for the pyboard but the moduos.c files seem to be organized quite differently. Simply doing
doesn't seem to work, writing to the sd directory writes to the flash and calling e.g. "sdfs.listdir()" just gives the files on the flash. I couldn't figure out why though, I got a bit lost in the code (there is a hardcoded "MP_STATE_PORT(fs_user_mount)[0]" in moduos.py but that shouldn't affect the methods on sdfs).
I would appreciate any tips.
The goal would be to load the python code (main.py) from the flash on the esp-12 and read/write data files on the sd card.
I have gotten sdcard.py from micropython/drivers/sdcard to work by changing the spi syntax to the current one and adding some more waiting/retry loops to work with my specific card.
I'm not sure how to mount the card to the filesystem though. I thought I could just look at the code for the pyboard but the moduos.c files seem to be organized quite differently. Simply doing
Code: Select all
card=SDCard(spi,cs)
sdfs=os.Vfsfat(card, "/sd")
I would appreciate any tips.
The goal would be to load the python code (main.py) from the flash on the esp-12 and read/write data files on the sd card.