Xinyuan-LilyGO / T-Deck

302 stars 54 forks source link

SD card is not working #30

Closed laulin closed 2 months ago

laulin commented 6 months ago

Hello !

I read the pinout from utilities.h and I write a micropython code to mount the SD card :

from machine import SPI, Pin
from sdcard import SDCard
import os
import hw

power_en = Pin(hw.PERI_POWERON, mode=Pin.OUT, value=1)

clk = Pin(hw.SPI_SCK, mode=Pin.OUT, value=0) # pin 40
mosi = Pin(hw.SPI_MOSI, mode=Pin.OUT, value=0) # pin 41
miso = Pin(hw.SPI_MISO, mode=Pin.IN) # pin 38
cs_sd = Pin(hw.SDCARD_CS, mode=Pin.OUT, value=1) # pin 39

spi = SPI(1, baudrate=int(hw.SPI_SPEED), sck=clk, mosi=mosi, miso=miso)

try:
    print("SDcard")
    sd = SDCard(spi, cs_sd)
    print("Sdcard mounted")
    os.mount(sd, '/sd')
except Exception as e:
    print(str(e))

I always got "OSError: no SD card". The SPI works since I can use the TFT display and I check on the schematic that ESP_SD_CS is on IO39 (real pin : 32).

Do you have any idea ?

contractorwolf commented 5 months ago

I am having this same issue, cut my code back to barebones but it only says that is doesnt see the sd card. no damage to the card reader or card. Card is brand new and FAT32 formatted.

lewisxhe commented 5 months ago

Refer to the Arduino initialization code, you need to turn on POWERON and disable the CS of other SPI devices. https://github.com/Xinyuan-LilyGO/T-Deck/blob/36841457bf1c4f9a6e88c9de2199f6ff132885a5/examples/UnitTest/UnitTest.ino#L941

github-actions[bot] commented 2 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 2 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.