Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SD card SPI vs 1LINE
#1
I have a TTGO dev board and I can get the SD adapter to work in SPI mode but it throws an error if I try to use 1LINE mode


Quote:MicroPython ESP32_LoBo_v3.1.28 - 2018-03-29 on ESP32 board with ESP32
Type "help()" for more information.
>>> import uos
>>> uos.sdconfig(uos.SDMODE_1LINE, clk=14, mosi=15, miso=2, cs=13)
>>> uos.mountsd(True)
E (33552) sdmmc_req: handle_idle_state_events unhandled: 00000004 00000000
E (33553) sdmmc_cmd: sdmmc_card_init: send_op_cond (1) returned 0x107
E (33556) vfs_native: Failed to initialize SDcard (263).
Traceback (most recent call last):
  File "", line 1, in
OSError: [Errno 5] EIO
>>>

The exact same code except for changing uos.SDMODE_1LINE to uos.SDMODE_SPI works fine.

Considering the SPI works doesn't this means the 1_LINE mode should also work as it uses the same pins??

I tried rebuilding the firmware with 1_LINE selected in the menuconfig but this didn't make any difference


The TTGO dev board doesn't have pull ups on the SD card lines rather relys on the building ones on the ESP32 chip. The TTGO also doesn't have pin 4 or 12 connected to the SD adapter so it can't use 4_LINE mode.
Reply
#2
Did you read https://github.com/loboris/MicroPython_E...ile-system ?

When you cant change wiring you only can use SPI-mode i guess.

Or try:

uos.sdconfig(uos.SDMODE_1LINE)
Reply
#3
Bug 
(04-05-2018, 10:09 PM)OutoftheBOTS Wrote: I have a TTGO dev board and I can get the SD adapter to work in SPI mode but it throws an error if I try to use 1LINE mode

There was a bug  preventing configuring SD Card for 1-line SD mode.
It is fixed now and the repository is updated.

Thank you for reporting this. I'm sory for the bug, it was a stupid copy-paste error.

BTW, you don't need to give mosi,miso,clk and cs arguments when selecting 1-line or 4-line mode. Only the mode argument is needed:
uos.sdconfig(uos.SDMODE_1LINE) or uos.sdconfig(uos.SDMODE_4LINE)
Reply
#4
@lobo

What's the difference between SPI and 1_LINE. SPI. In SPI mode I will have the advantage that I can reuse the MOSI, MISO and SCK lines for other SPI devices just with a different CS line.

Why would someone choose to use 1_LINE mode?? is it faster than SPI???
Reply
#5
I just did a git pull then rebuild the firmware but got same response


Quote:MicroPython ESP32_LoBo_v3.2.4 - 2018-04-06 on Out of the BOTS with ESP32
Type "help()" for more information.
>>> import uos
>>> uos.sdconfig(uos.SDMODE_1LINE)
>>> uos.mountsd(True)
E (78554) sdmmc_req: handle_idle_state_events unhandled: 00000004 00000000
E (78555) sdmmc_cmd: sdmmc_card_init: send_op_cond (1) returned 0x107
E (78558) vfs_native: Failed to initialize SDcard (263).
Traceback (most recent call last):
  File "", line 1, in
OSError: [Errno 5] EIO
>>>
Reply
#6
Have you removed the power from SD Card after it was initiated in SPI mode ?
Once the sdcard is configured for SPI mode it cannot be configured for SD mode without the power cycle.
I have tested with simple sdcard adapter (made from usd->sd adapter) with 10K pull-up resistors on all sdcard pins.

SPI vs 1-line SD mode:
  • some cards doesn't work in SPI mode, all works in SD mode
  • In SPI mode sdcard can run only at 20 MHz (Default Speed, 25 Mb/s). 
    In 1-line mode sdcard can run at 40 MHz (High Speed, 50 Mb/s, if the card supports that speed)
  • 1-line SD mode does not need CS, so if different pins are used for sdcard and other SPI devices, one extra pin is needed in SPI mode (M5Stack was designed that way, which does not make much sense)
  • There are some issues when using sdcard and other spi devices with same mosi,miso,sck (and even with different ones).
    The sdcard SPI and other SPI devices must be on the separate SPI bus (HSPI, VSPI), if psRAM is used, it cannot run at 80MHz (VSPI is in that case used by psRAM) 
    In some usage cases, like using SPI display and sdcard in SPI mode, some operations (like drawing the image from sdcard) can be much slower. 
    It is impossible to read from sdcard and write to the display at the same time, which is possible if 1-line SD mode is used. 
    Some of these issues may be solved in the future.


Attached Files Thumbnail(s)
   
Reply
#7
I just tried fresh firmware on fresh power up using my external SD card adapter with the pull-ups on it and I got same result. It is strange that it will work fine in SPI mode for both my built in SD adapter and my external adapter but neither will work in 1_LINE mode


Quote:MicroPython ESP32_LoBo_v3.2.4 - 2018-04-06 on Out of the BOTS with ESP32
Type "help()" for more information.
>>> import uos
>>> uos.sdconfig(uos.SDMODE_1LINE)
>>> uos.mountsd(True)
E (38894) sdmmc_req: handle_idle_state_events unhandled: 00000004 00000000
E (38895) sdmmc_cmd: sdmmc_card_init: send_op_cond (1) returned 0x107
E (38898) vfs_native: Failed to initialize SDcard (263).
Traceback (most recent call last):
  File "", line 1, in
OSError: [Errno 5] EIO
>>>

You did update your repository with your latest bug fix for SD 1_LINE as I get exact same result as before the bug fix
Reply
#8
This is strange.
I have tested git pull in my test directory which had a version before the bug fix.
I have also tested git clone to the new directory.
Both works!
I have also tested the prebuilt firmware, it works.

Have you run ./BUILD clean before building/flashing ?
Reply
#9
Im using newest Firmware too but now have the problem that my sd-card only get inited each second (re)boot Huh

Using SPI mode and my sdcard get mounted by boot.py

=> http://raspberrypi.roxxs.org/FILES/esp32_sdcard.mp4
Reply
#10
I have just drawn up a Micro SD card BOB with all the pins broken out and needed pull-ups so that I can test all modes (SPI, 1_LINE, 4_LINE).

I will fire up my laser cutter tomorrow morning and make it up as it is night here in Australia and my family is sleeping.

   

Quote:Have you run ./BUILD clean before building/flashing ?

I went 1 better than that and totally removed the whole MicroPython_ESP32_paRAM_LoBo directory tree then downloaded it again before rebuilding.

Now I have found a way to make it work. If I try to mount it without specifying 1_LINE mode then specify 1_LINE then try to mount it a second time then it works.


Quote:MicroPython ESP32_LoBo_v3.2.4 - 2018-04-06 on Out of the BOTS with ESP32
Type "help()" for more information.
>>> import uos
>>> uos.mountsd(True)
E (25965) sdmmc_cmd: sdmmc_card_init: send_scr (2) returned 0xffffffff
E (25965) vfs_native: Failed to mount filesystem on SDcard.
Traceback (most recent call last):
  File "", line 1, in
OSError: [Errno 5] EIO
>>> uos.sdconfig(uos.SDMODE_1LINE)
>>> uos.mountsd(True)
---------------------
 Mode:  SD (1bit)
 Name: SD16G
 Type: SDHC/SDXC
Speed: default speed (25 MHz)
 Size: 14784 MB
  CSD: ver=1, sector_size=512, capacity=30277632 read_bl_len=9
  SCR: sd_spec=2, bus_width=5

>>>
Even the builtin SD card adaptor without pull-ups will work if I use this order

Could it possibly be conflicting with something else that I have enabled in menuconfig??
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)