Failure to mount SPI SD-card on ESP32-S3 #9946
-
I am unable to get a SD card mounted on ESP32-S3. Is there still some unsolved issue with SPI SD cards on ESP32-S3? Or have I just not understood what are the correct parameters required by the Our hardware details are:
This should be the very basic way to connect the SD card over SPI. If I have understood correctly, according to https://docs.micropython.org/en/latest/library/machine.SDCard.html, the basic commands to mount the SD should be: import machine
import os
# Connect to the SD card over the SPI
sd = machine.SDCard(slot=SLOTNUM)
# Mount SD to the file system
os.mount(sd, "/sd")
# Show files present on the SD
print(str(os.listdir('/sd'))) The machine.SDCard instructions about ESP32 tell that "slots 2 and 3 use the SPI ports", but I have tried all slots [0,1,2,3] and none of them work. I have also tried to assign the pins Here are the error messages with my various trials: sd = machine.SDCard(slot=0)
# --> OSError: (-259, 'ESP_ERR_INVALID_STATE')
sd = machine.SDCard(slot=1)
# --> OSError: (-259, 'ESP_ERR_INVALID_STATE')
sd = machine.SDCard(slot=2)
# --> OSError: (-258, 'ESP_ERR_INVALID_ARG')
sd = machine.SDCard(slot=3)
# --> No error, but os.mount --> OSError: 16
sd = machine.SDCard(sck=machine.Pin(36), mosi=machine.Pin(35), miso=machine.Pin(37), cs=machine.Pin(7))
# --> OSError: (-259, 'ESP_ERR_INVALID_STATE')
sd = machine.SDCard(slot=2, sck=machine.Pin(36), mosi=machine.Pin(35), miso=machine.Pin(37), cs=machine.Pin(7))
# --> OSError: (-258, 'ESP_ERR_INVALID_ARG')
sd = machine.SDCard(slot=2, width=1, sck=machine.Pin(36), mosi=machine.Pin(35), miso=machine.Pin(37), cs=machine.Pin(7))
# --> OSError: (-258, 'ESP_ERR_INVALID_ARG')
sd = machine.SDCard(slot=3, sck=machine.Pin(36), mosi=machine.Pin(35), miso=machine.Pin(37), cs=machine.Pin(7))
# --> No error, but os.mount --> OSError: 16 What parameters I should put to the Or is this still somehow related to the earlier ESP32 SD-issues reported in #8217 and #8514 . The issue 8217 is apparently solved by @TGiles1998 with "> Solved: create a timeout and continue to os.mount() until connects", but I have no idea how to do that in my script. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I believe this is still a bug or issue with ESP32-S3 hardware/port. Our solution was to switch to Teensy4.1 in which the SD works like a charm. |
Beta Was this translation helpful? Give feedback.
I believe this is still a bug or issue with ESP32-S3 hardware/port. Our solution was to switch to Teensy4.1 in which the SD works like a charm.