-
I have 2 of these boards, with ESP32-S3 WROOM-1 modules and an epaper 4.7" screen. It has a 'TF card' slot, which I would like to use from the micropython port. From the schema, it seems like the slot is wired to use SPI and the board overview pic shows the GPIOs labelled like SPI. So, I tried to mount the card like this:
-> Exception:
Some googling led me to #4722 which implied I should try lower frequency, and also explicilty set pull_ups... sd.info() gives me a timeout:
I looked at the code in machine_sdcard.c, and I see that the default 'slot' of 1 is for SD/MMC protocol, if I want to use SPi I need to set slot to 2 or 3 (for SPI2/3 on an ESP32-S3)
->exception
I can find no combination of parameters that lets me select slot 2 or 3 -> always this INVALID_ARG error. Has anyone got the SD card on the T5-PLUS to work from micropython?? Thanks.... |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 6 replies
-
You can refer to this issue |
Beta Was this translation helpful? Give feedback.
-
A view months ago, I spent a lot of time to get SD Cards to work. Those that are present on the module as well as external ones connected via SPI. I also used an ESP32 module and I had the same strange behavior as you. Also, I could only ever mount cards once. After a umount() it didn't work anymore. I always had to do a reset. The solution was the use of the module machine.SoftSPI anstand machine.SPI. I then created a SoftSDCard class which uses the SoftSPI class. With this I can mount and unmount cards as often as I want. Note: I created the /sd folder in the root directory manually.
|
Beta Was this translation helpful? Give feedback.
-
Finally back to this project... but still stuck on this:
spi creation ok, but then fails as no 'sdcard' module in the build... -> try with machine.SDCard
No, spi not an argument for the builtin machine.SDCard Need to search for the sdcard module that can take a spi instance... |
Beta Was this translation helpful? Give feedback.
-
By copying in the sdcard.py from micropython/micropython-lib/micropython/drivers/storage/sdcard.py, and using the SDCard class from there, I finally got it to work with SoftSPI:
It also works with machine.SPI using SPI instance 2:
Doing the mount again, it was ok... Not sure why.... |
Beta Was this translation helpful? Give feedback.
-
It works. The firmware I am using is https://github.com/lbuque/micropython-builder. You can find the compiled firmware in the github action. import machine
import os
sd = machine.SDCard(slot=3, sck=11, miso=16, mosi=15, cs=42)
sd.info()
os.mount(sd, "/sd")
os.listdir('/sd') |
Beta Was this translation helpful? Give feedback.
By copying in the sdcard.py from micropython/micropython-lib/micropython/drivers/storage/sdcard.py, and using the SDCard class from there, I finally got it to work with SoftSPI:
It also works with machine.SPI using SPI instance 2:
spi = SPI(2, baudrate=400000, sck=Pin(11,Pin.IN,Pin.PULL_UP), miso=Pin(16,Pin.IN,Pin.PULL_UP), mosi=Pin(15,Pin.IN,Pin.PULL_UP))
but the first attempt at mount gave me: