sdcard doesn't work with SoftSPI

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
FakirMaker
Posts: 5
Joined: Mon Jan 18, 2021 7:06 pm

sdcard doesn't work with SoftSPI

Post by FakirMaker » Mon Jan 18, 2021 7:14 pm

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

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: sdcard doesn't work with SoftSPI

Post by Roberthh » 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.

FakirMaker
Posts: 5
Joined: Mon Jan 18, 2021 7:06 pm

Re: sdcard doesn't work with SoftSPI

Post by FakirMaker » Tue Jan 19, 2021 9:47 pm

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))

Post Reply