Page 1 of 1

sdcard doesn't work with SoftSPI

Posted: Mon Jan 18, 2021 7:14 pm
by FakirMaker
Hello today i have built the latest firmware with my custom modules and upload my esp32, however the regular sd card module started not to work. When i tried to use it as it was tomorrow i got an error :
Warning: SPI(-1, ...) is deprecated, use SoftSPI(...) instead
and i used

Code: Select all

import machine
import sys
from machine import SoftSPI,Pin
import sdcard
import uos
spi =SoftSPI(baudrate=1000000,polarity=1,phase=0,sck=Pin(18),mosi=Pin(5),miso=Pin(19))
sd = sdcard.SDCard(spi,Pin(23))
uos.mount(sd,"/sd")
i got this error
File "sd.py", line 8, in <module>
which means

Code: Select all

sd = sdcard.SDCard(spi,Pin(23))
cannot initialize.
Is it about the SoftSPI or sdcard module?

thanks

Re: sdcard doesn't work with SoftSPI

Posted: Mon Jan 18, 2021 8:08 pm
by Roberthh
It may also be of SD cards. Micropyton is a little bit picky about SD card. They have to be formatted with a single FAT32 partition. Brand new SD cards are sometimes formatted differently. I had good experience with Samsung, Transcend and Sandisk cards in sizes of 8, 16, and 32 GB. And try to a) insert the card first, then b) push reset, then c) attempt to mount it, at least for initial testing.

Re: sdcard doesn't work with SoftSPI

Posted: Tue Jan 19, 2021 9:47 pm
by FakirMaker
Roberthh wrote:
Mon Jan 18, 2021 8:08 pm
It may also be of SD cards. Micropyton is a little bit picky about SD card. They have to be formatted with a single FAT32 partition. Brand new SD cards are sometimes formatted differently. I had good experience with Samsung, Transcend and Sandisk cards in sizes of 8, 16, and 32 GB. And try to a) insert the card first, then b) push reset, then c) attempt to mount it, at least for initial testing.
Thanks for reply Robert, the problem is caused by my board's design. Some genius people created a disaster. They confused my hardware pins and also added a led to pin 5 :) I finally solved the problem by myself in case somebody using TTGO T2 board with onboard SD card socket and SSD1331 display faces this problem in the future just use:

Code: Select all

spi =SPI(1,baudrate=500000,polarity=0,phase=0,sck=Pin(18),mosi=Pin(5),miso=Pin(19))
sd = sdcard.SDCard(spi,Pin(23))