04-06-2018, 12:44 PM (This post was last modified: 04-06-2018, 12:52 PM by lobo.)
if you don't set → MicroPython → SD Card configuration → SD Card mode in menuconfig to 1-line mode (default is 4-line mode), you must run uos.sdconfig() before the first uos.mountsd().
BTW, there is still a small bug preventing the High-speed sdcards to to run at 50 MHz (in SD modes).
I have fixed it, the repository will be updated later today.
04-06-2018, 01:12 PM (This post was last modified: 04-06-2018, 01:32 PM by OutoftheBOTS.)
I have set SD to 1_LINE in menuconfig.
But look at this if I run sdconfig(uos.SDMODE_1LINE) before mountsd() then it doesn't work.
But if I run it in this order mountsd() then sdconfig(uos.SDMODE_1LINE) then mountsd() it will work
See these 2 examples
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()
E (38801) sdmmc_req: handle_idle_state_events unhandled: 00000004 00000000
E (38802) sdmmc_cmd: sdmmc_card_init: send_op_cond (1) returned 0x107
E (38805) vfs_native: Failed to initialize SDcard (263).
Traceback (most recent call last):
File "", line 1, in
OSError: [Errno 5] EIO
>>>
and now this 1
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()
E (23220) sdmmc_cmd: sdmmc_card_init: send_scr (2) returned 0xffffffff
E (23221) 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()
---------------------
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
>>>
I just flashed your prebuilt esp32_psram_all firmware and can only get SPI mode to work, 1_LINE doesn't work no matter what I try
I've tried all possible combination, and with sdcard mode set to 1-line in menuconfig, I never have an error with mountsd(), with or without sdconfig() before it.
If it is not related to some hardware issue, I can't explain it (for now).
Ok I seemed to have found what the problem was. It definitely has to do with the pull-ups. I made 2 BOB myself and put pull-ups on 1 but not on the other.
What I found the BOB without pull-ups will work fine in SPI mode but won't work in SD mode either 1_LINE or 4_LINE but the board with pull-ups works for everything.
So 1 of the advantages os SPI mode is it doesn't need pull-ups so this makes it easier to use these pins as multipurpose pins for both GPIO and SPI
(04-07-2018, 01:31 AM)OutoftheBOTS Wrote: Ok I seemed to have found what the problem was. It definitely has to do with the pull-ups. I made 2 BOB myself and put pull-ups on 1 but not on the other.
What I found the BOB without pull-ups will work fine in SPI mode but won't work in SD mode either 1_LINE or 4_LINE but the board with pull-ups works for everything.
So 1 of the advantages os SPI mode is it doesn't need pull-ups so this makes it easier to use these pins as multipurpose pins for both GPIO and SPI
04-10-2018, 04:14 AM (This post was last modified: 04-10-2018, 04:38 AM by cwt.)
@OutoftheBOTS
I have almost the same board (TTGO-T8 V1.3) and having the same problem. However, I can't use your method (mount -> config -> mount) to mount my SD card. My situation is like this:
1. if I put the SD card in builtin slot *before* power on or press the reset button, the SD card can only operate in SPI mode.
2. if I put the SD card *after* the board is power on or just remove and put it back again while the board is power on, *sometimes* the SD card can operate in 1-Line SD mode.
The schematic of V1.1 board showing that the pin 2, 13, 14, 15 are already pull up, and it also show that SD DAT1 and DAT3 are not connected. So we will be able to use only SPI and 1-Line SD mode, but I don't know why SD mode is really unstable. I have to remove and put it in so many times before it can operate in SD mode.
However, if I change my SD card to the old one (not SDHC/SDXC) it can operate in both SPI and SD mode without any problem even put it in before power on or reset.
Update: TTGO does not post schematic for V1.3 board on their web yet, so I use my meter and found that there is no R pull up on my board for pin 2, 13, 14, 15. So I think my board might be difference.
04-10-2018, 08:56 AM (This post was last modified: 04-10-2018, 09:00 AM by OutoftheBOTS.)
There seems to be a number fo version of the TTGO board that I have (there all similar but not the same). So far everyone has reported they don't have pull-upsd on the SD card lines and ESP32 pin4 and pin 12 isn't connected to the SD adapter.
You can see the C library needs external pullups and doesn't use the internal pullups on the ESP32 for 1_LINE or 4_LINE mode but does make use of the ESP32 internal pull ups for SPI mode.
You can also see the Ardunio library doesn't need external pullups and uses the ESP32 internal ones in its driver.
My Lolin32 pro came with Micro-Python installed on it and with external pull-ups but my TTGO came with Ardunio boot loader and blinky sketch installed on it and without any external pullups.
So it seems depending if the board is designed for C/Micropython or designed for Ardunio to if it has external pullups or not.
Here's the work around that I found works for me every time on my TTGO in 1_LINE mode, simply set the needed pins as input pullup before mounting the SD card
Quote:MicroPython ESP32_LoBo_v3.2.4 - 2018-04-06 on Out of the BOTS with ESP32
Type "help()" for more information.
>>> from machine import Pin
>>> pin14 = Pin(14, Pin.IN, Pin.PULL_UP)
>>> pin15 = Pin(15, Pin.IN, Pin.PULL_UP)
>>> pin2 = Pin(2, Pin.IN, Pin.PULL_UP)
>>> pin13 = Pin(13, Pin.IN, Pin.PULL_UP)
>>> import uos
>>> 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
04-10-2018, 09:26 AM (This post was last modified: 04-10-2018, 09:33 AM by lobo.)
As I've mentioned in some of the earlier posts, all needed pull-ups for all modes are set before initializing sd card.
Look at the source file.
All SD card pins not used in specific mode (not configured by the driver) should have external pull-up provided by the user and should not be connected to ESP32.
Arduino library uses SPI for SD card acces, and the spi driver is, I think, different than the standard esp-idf one.
04-10-2018, 10:53 AM (This post was last modified: 04-10-2018, 11:08 AM by OutoftheBOTS.)
@lobo
Yes your source code sets the pins to pullup so this makes the results that I get very strange.
If I try to mount without setting the pins to pull up first it gets an error see the test that I just ran
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 (33573) sdmmc_req: handle_idle_state_events unhandled: 00000004 00000000
E (33574) sdmmc_cmd: sdmmc_card_init: send_op_cond (1) returned 0x107
E (33577) vfs_native: Failed to initialize SDcard (263).
Traceback (most recent call last):
File "", line 1, in
OSError: [Errno 5] EIO
>>>
But If I cycle the power then set the pins to pullup it works fine see
Quote:MicroPython ESP32_LoBo_v3.2.4 - 2018-04-06 on Out of the BOTS with ESP32
Type "help()" for more information.
>>> from machine import Pin
>>> pin14 = Pin(14, Pin.IN, Pin.PULL_UP)
>>> pin15 = Pin(15, Pin.IN, Pin.PULL_UP)
>>> pin2 = Pin(2, Pin.IN, Pin.PULL_UP)
>>> pin13 = Pin(13, Pin.IN, Pin.PULL_UP)
>>> import uos
>>> 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
>>>
Ok now be genital with me as I may now ask some dumb questions as I know nothing about the underlying C code for the ESP23
The difference I see between your code for SPI and 1_LINE is
All of your workarounds are not working on my TTGO-T8 V1.3 board. I'm using SPI now as it can survive hard reset and power cycling at the cost of half speed of external RAM (40MHz).