loboris / MicroPython_ESP32_psRAM_LoBo

MicroPython for ESP32 with psRAM support
Other
825 stars 341 forks source link

SD Mode = SPI Issue #192

Open bdespatis opened 6 years ago

bdespatis commented 6 years ago

Hi,

I found a problem with my electric engineer Gregory. We can't use our SD card in SPI Mode with the new firmware. Last April, I had no issues and it was working great (same line of code)

>>> import os, uos
>>> uos.sdconfig(uos.SDMODE_SPI,clk=27,mosi=26,miso=5,cs=18)
>>> os.mountsd()
---------------------
 Mode: SPI
 Name: SA04G
 Type: SDHC/SDXC
Speed: default speed (25 MHz)
 Size: 3796 MB
  CSD: ver=1, sector_size=512, capacity=7774208 read_bl_len=9
  SCR: sd_spec=2, bus_width=5

Now it looks like this :

>>> import os
>>> import uos
>>> uos.sdconfig(uos.SDMODE_SPI,clk=27, mosi=26,miso=5,cs=18)
>>> os.mountsd()
E (65592) sdmmc_cmd: sdmmc_card_init: send_scr (2) returned 0x107
E (65594) vfs_native: Failed to initialize SDcard (263).
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 5] EIO
bdespatis commented 6 years ago

I tested SDMODE_1Line and SDMODE_4Line, they work great. without pin pull up statement before.

Still wondering why SPI is no longer working since April Updates ...

luciengaitskell commented 6 years ago

Any plan on addressing this in a future update? It's the main reason I haven't been able to implement this port, as I can't mount using an existing SD driver

luciengaitskell commented 6 years ago

Just found this post on the forum: https://loboris.eu/forum/showthread.php?tid=216 I'll look out that commit in the future

loboris commented 6 years ago

There were some updated to SDCard handling in the latest update. uos.sdconfig() Wiki is updated. You can try to set a lower spi speed if the default one does not work. For example Adafruit Feather wing requires the spi speed to be set to 16 MHz.