Mounting SD Card on ESP-WROOM-32 using SD/MMC hardware.

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
UmFqYXQ
Posts: 5
Joined: Sat May 16, 2020 7:22 am

Mounting SD Card on ESP-WROOM-32 using SD/MMC hardware.

Post by UmFqYXQ » Sat May 16, 2020 4:00 pm

Hello all.
I have successfully mounted SD card using the SPI interface but I am unable to do the same using SD/MMC on ESP-WROOM-32. I am on Windows 10 using ESPlorer IDE and I am new to MicroPython.

Connections:-
Image

Output:-
Image

Please help me in solving this issue.
Thank you.

shaoziyang
Posts: 319
Joined: Sun Apr 17, 2016 1:55 pm

Re: Mounting SD Card on ESP-WROOM-32 using SD/MMC hardware.

Post by shaoziyang » Sun May 17, 2020 1:11 am

Please make sure the hardware connection is correct firest.

http://docs.micropython.org/en/latest/l ... DCard.html

User avatar
UmFqYXQ
Posts: 5
Joined: Sat May 16, 2020 7:22 am

Re: Mounting SD Card on ESP-WROOM-32 using SD/MMC hardware.

Post by UmFqYXQ » Sun May 17, 2020 2:19 am

shaoziyang wrote:
Sun May 17, 2020 1:11 am
Please make sure the hardware connection is correct firest.

http://docs.micropython.org/en/latest/l ... DCard.html
Yes, all the connections are correct. Actually I have made and prepared the table of connection as per http://docs.micropython.org/en/latest/l ... html#esp32 .

User avatar
UmFqYXQ
Posts: 5
Joined: Sat May 16, 2020 7:22 am

Re: Mounting SD Card on ESP-WROOM-32 using SD/MMC hardware.

Post by UmFqYXQ » Sun May 17, 2020 8:33 am

I have succeed in mounting a SD card on esp-wroom-32.

According to this https://github.com/espressif/esp-idf/issues/227 post all the GPIOs (i.e. 2, 4, 12, 13 and 15) should be pulled up in the software.

Take a look at the results:-

Code: Select all

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4844
load:0x40078000,len:9656
load:0x40080400,len:6216
entry 0x400806f0
[0;32mI (457) cpu_start: Pro cpu up.[0m
[0;32mI (457) cpu_start: Application information:[0m
[0;32mI (457) cpu_start: Compile time:     Dec 20 2019 07:50:41[0m
[0;32mI (461) cpu_start: ELF file SHA256:  0000000000000000...[0m
[0;32mI (467) cpu_start: ESP-IDF:          v3.3[0m
[0;32mI (471) cpu_start: Starting app cpu, entry point is 0x40083600[0m
[0;32mI (0) cpu_start: App cpu up.[0m
[0;32mI (482) heap_init: Initializing. RAM available for dynamic allocation:[0m
[0;32mI (489) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM[0m
[0;32mI (495) heap_init: At 3FFBA488 len 00025B78 (150 KiB): DRAM[0m
[0;32mI (501) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM[0m
[0;32mI (507) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m
[0;32mI (514) heap_init: At 40092D6C len 0000D294 (52 KiB): IRAM[0m
[0;32mI (520) cpu_start: Pro cpu start user code[0m
[0;32mI (203) cpu_start: Chip Revision: 1[0m
[0;33mW (203) cpu_start: Chip revision is higher than the one configured in menuconfig. Suggest to upgrade it.[0m
[0;32mI (207) cpu_start: Starting scheduler on PRO CPU.[0m
[0;32mI (0) cpu_start: Starting scheduler on APP CPU.[0m
MicroPython v1.12 on 2019-12-20; ESP32 module with ESP32
Type "help()" for more information.
>>> 
import uos
import uos
>>> 
import machine
import machine
>>> 
pins = [2, 4, 12, 13, 15]
pins = [2, 4, 12, 13, 15]
>>> 
for pin in pins:
for pin in pins:
...     
 machine.Pin(pin).init(-1, machine.Pin.PULL_UP)
 machine.Pin(pin).init(-1, machine.Pin.PULL_UP)
...     


...     


... 


>>> 
uos.mount(machine.SDCard(width=4), '/sd')
uos.mount(machine.SDCard(width=4), '/sd')
[0;32mI (22180) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 [0m
[0;31mE (22210) sdmmc_sd: sdmmc_init_sd_scr: send_scr (1) returned 0x109[0m
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: 16
>>> 
#No pull-up was connected to GPIO 12.
#No pull-up was connected to GPIO 12.
>>> ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4844
load:0x40078000,len:9656
load:0x40080400,len:6216
entry 0x400806f0
[0;32mI (457) cpu_start: Pro cpu up.[0m
[0;32mI (457) cpu_start: Application information:[0m
[0;32mI (457) cpu_start: Compile time:     Dec 20 2019 07:50:41[0m
[0;32mI (461) cpu_start: ELF file SHA256:  0000000000000000...[0m
[0;32mI (467) cpu_start: ESP-IDF:          v3.3[0m
[0;32mI (471) cpu_start: Starting app cpu, entry point is 0x40083600[0m
[0;32mI (0) cpu_start: App cpu up.[0m
[0;32mI (482) heap_init: Initializing. RAM available for dynamic allocation:[0m
[0;32mI (489) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM[0m
[0;32mI (495) heap_init: At 3FFBA488 len 00025B78 (150 KiB): DRAM[0m
[0;32mI (501) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM[0m
[0;32mI (507) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m
[0;32mI (514) heap_init: At 40092D6C len 0000D294 (52 KiB): IRAM[0m
[0;32mI (520) cpu_start: Pro cpu start user code[0m
[0;32mI (203) cpu_start: Chip Revision: 1[0m
[0;33mW (203) cpu_start: Chip revision is higher than the one configured in menuconfig. Suggest to upgrade it.[0m
[0;32mI (207) cpu_start: Starting scheduler on PRO CPU.[0m
[0;32mI (0) cpu_start: Starting scheduler on APP CPU.[0m
MicroPython v1.12 on 2019-12-20; ESP32 module with ESP32
Type "help()" for more information.
>>> 
#This time I have conected a 10k pull-up to GPIO 12
#This time I have conected a 10k pull-up to GPIO 12
>>> 
import uos
import uos
>>> 
import machine
import machine
>>> 
pins = [2, 4, 12, 13, 15]
pins = [2, 4, 12, 13, 15]
>>> 
for pin in pins:
for pin in pins:
...     
 machine.Pin(pin).init(-1, machine.Pin.PULL_UP)
 machine.Pin(pin).init(-1, machine.Pin.PULL_UP)
...     


...     


... 


>>> 
uos.mount(machine.SDCard(width=4), '/sd')
uos.mount(machine.SDCard(width=4), '/sd')
[0;32mI (68130) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 [0m
>>> 
uos.listdir()
uos.listdir()
['sd', 'boot.py']
>>> 
uos.listdir('/sd')
uos.listdir('/sd')
['System Volume Information', 'test.txt']
>>> 
with open('/sd/test.txt') as txt:
with open('/sd/test.txt') as txt:
...     
text = txt.read()
text = txt.read()
...     


...     


... 


>>> 
print(text)
print(text)
Hello, World!
>>>
Can anyone please tell why this is happening.
Is the BLUE_LED connected to GPIO 2 has to do anything with this?

Please consider any spelling/grammatical mistakes.
Thank you.

User avatar
UmFqYXQ
Posts: 5
Joined: Sat May 16, 2020 7:22 am

Re: Mounting SD Card on ESP-WROOM-32 using SD/MMC hardware.

Post by UmFqYXQ » Sun May 17, 2020 8:50 am

One more thing to tell:
Even if I execute the following code I can successfully mount an SD card.

Code: Select all

import uos
import machine
machine.Pin(2).init(-1, machine.Pin.PULL_UP)	# with 10k pull-up connected to GPIO 2.
uos.mount(machine.SDCard(width=4), '/sd')
One more thing to ask:
Why this code worked without pulling up other GPIO pins?
Is all this related to the BLUE_LED connected to GPIO 2 or there is any other reason?

Please guide me I'm a bit confused.
Thank you.

shaoziyang
Posts: 319
Joined: Sun Apr 17, 2016 1:55 pm

My pyESP32 board

Post by shaoziyang » Mon May 18, 2020 12:41 am

My ESP32 board, with microSD slot.

pyESP32-01.jpg
pyESP32-01.jpg (97.31 KiB) Viewed 146 times

pyESP32-02.jpg
pyESP32-02.jpg (103.03 KiB) Viewed 146 times

User avatar
UmFqYXQ
Posts: 5
Joined: Sat May 16, 2020 7:22 am

Re: Mounting SD Card on ESP-WROOM-32 using SD/MMC hardware.

Post by UmFqYXQ » Mon May 18, 2020 3:54 am

I don't have a ESP32 with a built in µSD card slot on it, rather I have a ESP like this one:-
Image
and the ESP has a WROOM chip on it as seen in this picture.

shaoziyang
Posts: 319
Joined: Sun Apr 17, 2016 1:55 pm

Re: Mounting SD Card on ESP-WROOM-32 using SD/MMC hardware.

Post by shaoziyang » Mon May 18, 2020 6:41 am

pyESP32 is make by myself, use ESP32-WROVER with 4M psram.
  • USB type-c interface
  • USB power and charge
  • High efficiency DC/DC power supply
  • on board USB/TTL converter
  • one click upgrade firmware
  • microSD slot
  • low cost
  • open hardware
不带ESP32.jpg
不带ESP32.jpg (105.03 KiB) Viewed 127 times

Post Reply