Skip to content

Commit 6bdef28

Browse files
authoredAug 30, 2023
Doc update: Troubleshooting + SD libs (#8241)
* Updated preferences.rst * Added into FAQ info about SPIFFS failed mount * Updated troubleshooting * Moved SPIFFS paragraph from FAQ to troubleshooting * Minor updates * Updated troubleshooting * Updated SD README files and example comments * Updated troubleshooting with SD issue * Added note about S3 pins * Updated SDMMC test setPins calls + added definition for default pins * Updated SD_MMC comments * Added pin table to SD_MMC readme * Updated table in SD_SPI * Updated based on comments * Update io_mux.rst * Update README.md
1 parent 057eac6 commit 6bdef28

File tree

8 files changed

+303
-50
lines changed

8 files changed

+303
-50
lines changed
 

‎docs/source/faq.rst

+1-18
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,4 @@ Note that modifying ``sdkconfig`` or ``sdkconfig.h`` files found in the arduino-
1414
How to compile libs with different debug level?
1515
-----------------------------------------------
1616

17-
The short answer is ``esp32-arduino-lib-builder/configs/defconfig.common:44``. A guide explaining the process can be found here <guides/core_debug>
18-
19-
SPIFFS mount failed
20-
-------------------
21-
When you come across and error like this:
22-
23-
.. code-block:: shell
24-
25-
E (588) SPIFFS: mount failed, -10025
26-
[E][SPIFFS.cpp:47] begin(): Mounting SPIFFS failed! Error: -1
27-
28-
Try enforcing format on fail in your code by adding ``true`` in the ``begin`` method such as this:
29-
30-
.. code-block:: c++
31-
32-
SPIFFS.begin(true);
33-
34-
See the method prototype for reference: ``bool begin(bool formatOnFail=false, const char * basePath="/spiffs", uint8_t maxOpenFiles=10, const char * partitionLabel=NULL);``
17+
The short answer is ``esp32-arduino-lib-builder/configs/defconfig.common:44``. A guide explaining the process can be found here <guides/core_debug>

‎docs/source/troubleshooting.rst

+132-12
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Solution
3333
To avoid this error, you can install the ``python-is-python3`` package to create the symbolic links.
3434

3535
.. code-block:: bash
36-
36+
3737
sudo apt install python-is-python3
3838
3939
If you are not using Ubuntu, you can check if you have the Python correctly installed or the presence of the symbolic links/environment variables.
@@ -44,7 +44,7 @@ Flashing
4444
Why is my board not flashing/uploading when I try to upload my sketch?
4545
**********************************************************************
4646

47-
To be able to upload the sketch via serial interface, the ESP32 must be in the download mode. The download mode allows you to upload the sketch over the serial port and to get into it, you need to keep the **GPIO0** in LOW while a resetting (**EN** pin) cycle.
47+
To be able to upload the sketch via the serial interface, the ESP32 must be in the download mode. The download mode allows you to upload the sketch over the serial port, and to get into it, you need to keep the **GPIO0** in LOW while resetting (**EN** pin) the cycle.
4848
If you are trying to upload a new sketch and your board is not responding, there are some possible reasons.
4949

5050
Possible fatal error message from the Arduino IDE:
@@ -54,23 +54,26 @@ Possible fatal error message from the Arduino IDE:
5454
Solution
5555
^^^^^^^^
5656

57-
Here are some steps that you can try to:
57+
Here are some steps that you can try:
5858

59-
* Check your USB cable and try a new one.
60-
* Change the USB port.
59+
* Check your USB cable and try a new one (some cables are only for charging and there is no data connection).
60+
* Change the USB port - prefer direct connection to the computer and avoid USB hubs. Some USB ports may share the power source with other ports used, for example, for charging a phone.
6161
* Check your power supply.
62+
* Make sure that nothing is connected to pins labeled **TX** and **RX**. Please refer to the pin layout table - some TX and RX pins may not be labeled on the dev board.
6263
* In some instances, you must keep **GPIO0** LOW during the uploading process via the serial interface.
63-
* Hold down the **“BOOT”** button in your ESP32 board while uploading/flashing.
64+
* Hold down the **“BOOT”** button on your ESP32 board while uploading/flashing.
65+
* Solder a **10uF** capacitor in parallel with **RST** and **GND**.
66+
* If you are using external power connected to pins, it is easy to confuse pins **CMD** (which is usually next to the 5V pin) and **GND**.
6467

65-
In some development boards, you can try adding the reset delay circuit, as described in the *Power-on Sequence* section on the `ESP32 Hardware Design Guidelines <https://www.espressif.com/sites/default/files/documentation/esp32_hardware_design_guidelines_en.pdf>`_ in order to get into the download mode automatically.
68+
In some development boards, you can try adding the reset delay circuit, as described in the *Power-on Sequence* section on the `ESP32 Hardware Design Guidelines <https://www.espressif.com/sites/default/files/documentation/esp32_hardware_design_guidelines_en.pdf>`_ to get into the download mode automatically.
6669

6770
Hardware
6871
--------
6972

7073
Why is my computer not detecting my board?
71-
**************************************************
74+
******************************************
7275

73-
If your board is not being detected after connecting to the USB, you can try to:
76+
If your board is not being detected after connecting to the USB, you can try the following:
7477

7578
Solution
7679
^^^^^^^^
@@ -87,8 +90,8 @@ Wi-Fi
8790
Why does the board not connect to WEP/WPA-"encrypted" Wi-Fi?
8891
************************************************************
8992

90-
Please note that WEP/WPA has significant security vulnerabilities and its use is strongly discouraged.
91-
The support may therefore be removed in the future. Please migrate to WPA2 or newer.
93+
Please note that WEP/WPA has significant security vulnerabilities, and its use is strongly discouraged.
94+
The support may, therefore, be removed in the future. Please migrate to WPA2 or newer.
9295

9396
Solution
9497
^^^^^^^^
@@ -104,7 +107,7 @@ Nevertheless, it may be necessary to connect to insecure networks. To do this, t
104107
Why does the board not connect to WPA3-encrypted Wi-Fi?
105108
*******************************************************
106109

107-
WPA3 support is resource intensive and may not be compiled into the used SDK.
110+
WPA3 support is resource-intensive and may not be compiled into the used SDK.
108111

109112
Solution
110113
^^^^^^^^
@@ -119,3 +122,120 @@ Sample code to check SDK WPA3 support at compile time:
119122
#ifndef CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE
120123
#warning "No WPA3 support."
121124
#endif
125+
126+
SPIFFS mount failed
127+
-------------------
128+
When you come across an error like this:
129+
130+
.. code-block:: shell
131+
132+
E (588) SPIFFS: mount failed, -10025
133+
[E][SPIFFS.cpp:47] begin(): Mounting SPIFFS failed! Error: -1
134+
135+
Try enforcing format on fail in your code by adding ``true`` in the ``begin`` method such as this:
136+
137+
.. code-block:: c++
138+
139+
SPIFFS.begin(true);
140+
141+
See the method prototype for reference: ``bool begin(bool formatOnFail=false, const char * basePath="/spiffs", uint8_t maxOpenFiles=10, const char * partitionLabel=NULL);``
142+
143+
SD card mount fail
144+
------------------
145+
Even though you made sure that the pins are correctly connected, and not using restricted pins, you may still get an error such as this:
146+
147+
.. code-block:: shell
148+
149+
[ 1065][E][sd_diskio.cpp:807] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
150+
151+
Most of the problems originate from a poor connection caused by prototyping cables/wires, and one of the best solutions is to **solder all the connections** or use good quality connectors.
152+
153+
Note that with SD_MMC lib all the data pins need to be pulled up with an external 10k to 3.3V. This applies especially to card's D3 which needs to be pulled up even when using 1-bit line connection and the D3 is not used.
154+
155+
If you want to try the software approach before soldering, try manually specifying SPI pins, like this:
156+
157+
.. code-block:: c++
158+
159+
int SD_CS_PIN = 19;
160+
SPI.begin(18, 36, 26, SD_CS_PIN);
161+
SPI.setDataMode(SPI_MODE0);
162+
SD.begin(SD_CS_PIN);
163+
164+
165+
ESP32-S3 is rebooting even with a bare minimum sketch
166+
*****************************************************
167+
Some ESP32-S3 boards are equipped with Quad SPI (QSPI) or Octal SPI (OPI) PSRAM. If you upload such a board with default settings for ESP32-S3, it will result in rebooting with a message similar to this:
168+
169+
https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-guides/flash_psram_config.html
170+
171+
.. code-block:: bash
172+
173+
E (124) esp_core_dump_flash: Core dump flash config is corrupted! CRC=0x7bd5c66f instead of 0x0
174+
Rebooting...
175+
⸮⸮⸮ESP-ROM:esp32s3-20210327
176+
Build:Mar 27 2021
177+
rst:0xc (RTC_SW_CPU_RST),boot:0x18 (SPI_FAST_FLASH_BOOT)
178+
Saved PC:0x40376af0
179+
SPIWP:0xee
180+
Octal Flash Mode Enabled
181+
For OPI Flash, Use Default Flash Boot Mode
182+
mode:SLOW_RD, clock div:1
183+
load:0x3fce3808,len:0x44c
184+
load:0x403c9700,len:0xbec
185+
load:0x403cc700,len:0x2920
186+
entry 0x403c98d8
187+
188+
assert failed: do_core_init startup.c:326 (flash_ret == ESP_OK)
189+
190+
191+
To fix the issue, you will need to find out the precise module you are using and set **PSRAM** in the Arduino IDE Tools according to the following table.
192+
193+
How to determine the module version:
194+
------------------------------------
195+
196+
* First determine if you have a `WROOM-1 <https://www.espressif.com/sites/default/files/documentation/esp32-s3-wroom-1_wroom-1u_datasheet_en.pdf>`_ or `WROOM-2 <https://www.espressif.com/sites/default/files/documentation/esp32-s3-wroom-2_datasheet_en.pdf>`_ module - this is written on the module shielding almost at the top, right under the ESP logo and company name (Espresif) right after the ESP32-S3 - for example ESP32-S3-WROOM-2.
197+
* Then locate the version code on left bottom corner on the module shielding. The markings are very small and it might be really difficult to read with naked eyes - try using a camera with careful lighting.
198+
199+
With this knowledge find your module in the table and note what is written in the **PSRAM** column.
200+
201+
- If the results is empty (-) you don't need to change anything
202+
- For QSPI go to Tools > PSRAM > QSPI PSRAM
203+
- For OPI go to Tools > PSRAM > OPI PSRAM
204+
205+
Note that WROOM-2 has always OPI.
206+
207+
+---------+--------+------------+-------+
208+
| Module | Code | Flash Mode | PSRAM |
209+
+=========+========+============+=======+
210+
| WROOM-1 | N4 | QSPI | - |
211+
+---------+--------+------------+-------+
212+
| WROOM-1 | N8 | QSPI | - |
213+
+---------+--------+------------+-------+
214+
| WROOM-1 | N16 | QSPI | - |
215+
+---------+--------+------------+-------+
216+
| WROOM-1 | H4 | QSPI | - |
217+
+---------+--------+------------+-------+
218+
| WROOM-1 | N4R2 | QSPI | QSPI |
219+
+---------+--------+------------+-------+
220+
| WROOM-1 | N8R2 | QSPI | QSPI |
221+
+---------+--------+------------+-------+
222+
| WROOM-1 | N16R2 | QSPI | QSPI |
223+
+---------+--------+------------+-------+
224+
| WROOM-1 | N4R8 | QSPI | OPI |
225+
+---------+--------+------------+-------+
226+
| WROOM-1 | N8R8 | QSPI | OPI |
227+
+---------+--------+------------+-------+
228+
| WROOM-1 | N16R8 | QSPI | OPI |
229+
+---------+--------+------------+-------+
230+
| WROOM-2 | N16R8V | OPI | OPI |
231+
+---------+--------+------------+-------+
232+
| WROOM-2 | N16R8V | OPI | OPI |
233+
+---------+--------+------------+-------+
234+
| WROOM-2 | N32R8V | OPI | OPI |
235+
+---------+--------+------------+-------+
236+
237+
238+
Further Help
239+
------------
240+
241+
If you encounter any other issues or need further assistance, please consult the `ESP32 Arduino Core <https://github.com/espressif/arduino-esp32>`_ documentation or seek help from the `ESP32 community forums <https://esp32.com>`_.

‎docs/source/tutorials/cdc_dfu_flash.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ESP32-S3 CDC and DFU
2323

2424
It's important that your board includes the USB connector attached to the embedded USB from the SoC. If your board doesn't have the USB connector, you can attach an external one to the USB pins.
2525

26-
These instructions it will only work on the supported devices with the embedded USB peripheral. This tutorial will not work if you are using an external USB-to-serial converter like FTDI, CP2102, CH340, etc.
26+
These instructions will only work on the supported devices with the embedded USB peripheral. This tutorial will not work if you are using an external USB-to-serial converter like FTDI, CP210x, CH340, etc.
2727

2828
For a complete reference to the Arduino IDE tools menu, please see the `Tools Menus <../guides/tools_menu.html>`_ reference guide.
2929

‎docs/source/tutorials/io_mux.rst

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ To use this functionality, we must be aware of some precautions:
3535
* Some of the GPIOs are **INPUT** only.
3636
* Some peripherals have output signals and must be used on GPIO's capable to be configured as **OUTPUT**.
3737
* Some peripherals, mostly the high speed ones, ADC, DAC, Touch, and JTAG use dedicated GPIOs pins.
38+
* Some pins are used to connect flash memory on the module - this prevents them from any other use - if a peripheral is routed to one of these pins the device will not be able to boot.
3839

3940
.. warning::
4041
Before assigning the peripheral pins in your design, double check if the pins you're using are appropriate.

‎libraries/SD/README.md

+28-18
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,52 @@
1-
21
# SD library
32

4-
This library provides the integration of ESP32 and SD (Secure Digital) cards without additional modules.
5-
3+
This library provides the integration of ESP32 and SD (Secure Digital) and MMC (Multi Media Card) cards without additional modules. This library is using SPI to interface with the cards. Please note that SPI mode is slower than the intended SD or MMC mode, however, provides more flexibility as the SPI module is available on all ESP SoCs and can be routed to any GPIO through GPIO matrix.
64

75
## Sample wiring diagram:
86

7+
![Connections](http://i.imgur.com/4CoXOuR.png)
98

10-
![SD card pins](http://i.imgur.com/4CoXOuR.png)
11-
12-
For others SD formats:
13-
9+
For other SD formats:
1410

1511
![Other SD card formats](https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/MMC-SD-miniSD-microSD-Color-Numbers-Names.gif/330px-MMC-SD-miniSD-microSD-Color-Numbers-Names.gif)
1612

17-
1813
Image source: [Wikipedia](https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/MMC-SD-miniSD-microSD-Color-Numbers-Names.gif/330px-MMC-SD-miniSD-microSD-Color-Numbers-Names.gif)
1914

20-
```diff
21-
- Warning: Some ESP32 modules have different pinouts!
22-
```
15+
> **Warning**
16+
Some ESP32 modules have different pin outs!
2317

18+
## Default SPI pins:
19+
Note that SPI pins can be configured by using `SPI.begin(sck, miso, mosi, cs);` alternatively, you can change only the CS pin with `SD.begin(CSpin)`
2420

21+
+--------------+---------+-------+----------+----------+----------+
22+
| SPI Pin Name | ESP8266 | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 |
23+
+==============+=========+=======+==========+==========+==========+
24+
| CS (SS) | GPIO15 | GPIO5 | GPIO5 | GPIO13 | GPIO13 |
25+
+--------------+---------+-------+----------+----------+----------+
26+
| DI (MOSI) | GPIO13 | GPIO23| GPIO24 | GPIO14 | GPIO14 |
27+
+--------------+---------+-------+----------+----------+----------+
28+
| DO (MISO) | GPIO12 | GPIO19| GPIO25 | GPIO15 | GPIO15 |
29+
+--------------+---------+-------+----------+----------+----------+
30+
| SCK (SCLK) | GPIO14 | GPIO18| GPIO19 | GPIO16 | GPIO16 |
31+
+--------------+---------+-------+----------+----------+----------+
2532

2633
## FAQ:
2734

28-
**Do I need any additional modules, like Arduino SD module?**
35+
**Do I need any additional modules**, like **the **Arduino**** SD module**?**
2936

3037
No, just wire your SD card directly to ESP32.
3138

39+
Tip: If you are using a microSD card and have a spare adapter to full-sized SD, you can solder Dupont pins on the adapter.
3240

3341

3442
**What is the difference between SD and SD_MMC libraries?**
3543

3644
SD runs on SPI, and SD_MMC uses the SDMMC hardware bus on the ESP32.
37-
38-
39-
40-
**Can I change the CS pin?**
41-
42-
Yes, just use: `SD.begin(CSpin)`
45+
The SPI uses 4 communication pins + 2 power connections and operates on up to 80MHz. The SPI option offers flexibility on pin connection because the data connections can be routed through GPIO matrix to any data pin.
46+
SD-SPI speed is approximately half of the SD-MMC even when used on 1-bit line.
47+
You can read more about SD SPI in the [documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/sdspi_host.html)
48+
49+
SD_MMC is supported only by ESP32 and ESP32-S3 and can be connected only to dedicated pins. SD_MMC allows to use of 1, 4 or 8 data pins + 2 additional communication pins and 2 power pins. The data pins need to be pulled up externally.
50+
You can read more about SD_MMC in the [documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/sdmmc_host.html)
51+
1-bit: SD_MMC_ speed is approximately two-times faster than SPI mode
52+
4-bit: SD_MMC speed is approximately three-times faster than SPI mode.

‎libraries/SD_MMC/README.md

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# SD_MMC library
2+
3+
This library provides the integration of ESP32 and ESP32-S3 with SD (Secure Digital) and MMC (Multi Media Card) cards using a built-in SDMMC module.
4+
5+
Please note that SD_MMC is only available for ESP32 and ESP32-S3. For other SoCs please use the SD library based on SPI.
6+
7+
## Wiring:
8+
9+
![SD cards pins](https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/MMC-SD-miniSD-microSD-Color-Numbers-Names.gif/330px-MMC-SD-miniSD-microSD-Color-Numbers-Names.gif)
10+
11+
Image source: [Wikipedia](https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/MMC-SD-miniSD-microSD-Color-Numbers-Names.gif/330px-MMC-SD-miniSD-microSD-Color-Numbers-Names.gif)
12+
13+
![SD and MMC pins](https://upload.wikimedia.org/wikipedia/commons/f/ff/15-04-29-MMC-Karte-dscf4734-e.jpg)
14+
15+
Image source: [Wikipedia](https://commons.wikimedia.org/wiki/File:15-04-29-MMC-Karte-dscf4734-e.jpg)
16+
17+
pin number (refer to the picture) | micro SD - SD mode | micro SD - SPI mode | mini SD - SD mode | mini SD - SPI mode | SD - SD mode | SD - SPI mode | MMC (MMC3) - MMC mode | MMC (MMC3) - SPI mode | MMCplus / MMCmobile (MMC4) - MMC mode | MMCplus / MMCmobile (MMC4) - SPI mode
18+
----------------------------------|--------------------|---------------------|-------------------|--------------------|--------------|---------------|-----------------------|-----------------------|---------------------------------------|
19+
1 | D2 | not used | D3 | CS | D3 | CS | RES | CS | D3 | CS
20+
2 | D3 | CS | CMD | DI | CMD | DI | CMD | DI | CMD | DI
21+
3 | CMD | DI | VSS1 (GND) | VSS1 (GND) | VSS1 (GND) | VSS1 (GND) | VSS1 (GND) | VSS1 (GND) | VSS1 (GND) | VSS1 (GND)
22+
4 | VDD (3.3V) | VDD (3.3V) | VDD (3.3V) | VDD (3.3V) | VDD (3.3V) | VDD (3.3V) | VDD (3.3V) | VDD (3.3V) | VDD (3.3V) | VDD (3.3V)
23+
5 | CLK | SCLK | CLK | SCLK | CLK | SCLK | CLK | SCLK | CLK | SCLK
24+
6 | VSS (GND) | VSS (GND) | VSS2 (GND) | VSS2 (GND) | VSS2 (GND) | VSS2 (GND) | VSS2 (GND) | VSS2 (GND) | VSS2 (GND) | VSS2 (GND)
25+
7 | D0 | DO | D0 | DO | D0 | DO | DAT | DO | D0 | DO
26+
8 | D1 | not used | D1 | not used | D1 | not used | - | - | D1 | not used
27+
9 | - | - | D2 | not used | D2 | not used | - | - | D2 | not used
28+
10 | - | - | For future use | For future use | - | - | - | - | D3 | not used
29+
11 | - | - | For future use | For future use | - | - | - | - | D4 | not used
30+
12 | - | - | - | - | - | - | - | - | D5 | not used
31+
13 | - | - | - | - | - | - | - | - | D6 | not used
32+
33+
### Pin assignments for ESP32
34+
35+
On ESP32, SD_MMC peripheral is connected to specific GPIO pins and cannot be changed (rerouted). Please see the table below for the pin connections.
36+
37+
When using an ESP-WROVER-KIT board, this example runs without any extra modifications required. Only an SD card needs to be inserted into the slot.
38+
39+
ESP32 pin | SD card pin | Notes
40+
--------------|-------------|------------
41+
GPIO14 (MTMS) | CLK | 10k pullup in SD mode
42+
GPIO15 (MTDO) | CMD | 10k pullup in SD mode
43+
GPIO2 | D0 | 10k pullup in SD mode, pull low to go into download mode (see Note about GPIO2 below!)
44+
GPIO4 | D1 | not used in 1-line SD mode; 10k pullup in 4-line SD mode
45+
GPIO12 (MTDI) | D2 | not used in 1-line SD mode; 10k pullup in 4-line SD mode (see Note about GPIO12 below!)
46+
GPIO13 (MTCK) | D3 | not used in 1-line SD mode, but card's D3 pin must have a 10k pullup
47+
48+
49+
### Pin assignments for ESP32-S3
50+
51+
On ESP32-S3, SDMMC peripheral is connected to GPIO pins using GPIO matrix. This allows arbitrary GPIOs to be used to connect an SD card or MMC. The GPIOs can be configured with the following commands:
52+
```
53+
setPins(int clk, int cmd, int d0))
54+
setPins(int clk, int cmd, int d0, int d1, int d2, int d3))
55+
```
56+
57+
The table below lists the default pin assignments.
58+
59+
When using an ESP32-S3-USB-OTG board, this example runs without any extra modifications required. Only an SD card needs to be inserted into the slot.
60+
61+
ESP32-S3 pin | SD card pin | Notes
62+
--------------|-------------|------------
63+
GPIO36 | CLK | 10k pullup
64+
GPIO35 | CMD | 10k pullup
65+
GPIO37 | D0 | 10k pullup
66+
GPIO38 | D1 | not used in 1-line SD mode; 10k pullup in 4-line mode
67+
GPIO33 | D2 | not used in 1-line SD mode; 10k pullup in 4-line mode
68+
GPIO34 | D3 | not used in 1-line SD mode, but card's D3 pin must have a 10k pullup
69+
70+
Warning: ESP32-S3-WROOM-2 is using most of the default GPIOs (33-37) to interface with on-board OPI flash. If the SD_MMC is initialized with default pins it will result in rebooting loop - please reassign the pins elsewhere using the mentioned command `setPins`.
71+
72+
> **Note:** ESP32-S3-DevKitC-1 v1.1 does NOT have GPIOs 33 and 34 broken out, so it will be necessary to change at least the pin for D2 and D3.
73+
74+
### 4-line and 1-line SD modes
75+
76+
By default, this library uses 4-bit line mode, utilizing 6 pins: CLK, CMD, D0 - D3 and 2 power lines (3.3V and GND). It is possible to use 1-bit line mode (CLK, CMD, D0, 3.3V, GND) by passing the second argument `mode1bit==true`:
77+
```
78+
SD_MMC.begin("/sdcard", true);
79+
```
80+
81+
> **Note:** Even if card's D3 line is not connected to the ESP chip, it still has to be pulled up, otherwise the card will go into SPI protocol mode.
82+
83+
### Note about GPIO2 (ESP32 only)
84+
85+
GPIO2 pin is used as a bootstrapping pin, and should be low to enter UART download mode. One way to do this is to connect GPIO0 and GPIO2 using a jumper, and then the auto-reset circuit on most development boards will pull GPIO2 low along with GPIO0, when entering download mode.
86+
87+
- Some boards have pulldown and/or LED on GPIO2. LED is usually ok, but pulldown will interfere with D0 signals and must be removed. Check the schematic of your development board for anything connected to GPIO2.
88+
89+
### Note about GPIO12 (ESP32 only)
90+
91+
GPIO12 is used as a bootstrapping pin to select output voltage of an internal regulator which powers the flash chip (VDD_SDIO). This pin has an internal pulldown so if left unconnected it will read low at reset (selecting default 3.3V operation). When adding a pullup to this pin for SD card operation, consider the following:
92+
93+
## FAQ:
94+
95+
#### Do I need any additional modules, like the Arduino SD module?
96+
97+
No, just wire your SD card directly to ESP32.
98+
99+
Tip: If you are using a microSD card and have a spare adapter to full-sized SD, you can solder Dupont pins on the adapter.
100+
101+
102+
#### What is the difference between SD and SD_MMC libraries?
103+
104+
SD runs on SPI, and SD_MMC uses the SDMMC hardware bus on the ESP32.
105+
The SPI uses 4 communication pins + 2 power connections and operates on up to 80MHz. The SPI option offers flexibility on pin connection because the data connections can be routed through GPIO matrix to any data pin.
106+
SD-SPI speed is approximately half of the SD-MMC even when used on 1-bit line.
107+
You can read more about SD SPI in the [documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/sdspi_host.html)
108+
109+
SD_MMC is supported only by ESP32 and ESP32-S3 and can be connected only to dedicated pins. SD_MMC allows to use of 1, 4 or 8 data pins + 2 additional communication pins and 2 power pins. The data pins need to be pulled up externally.
110+
You can read more about SD_MMC in the [documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/sdmmc_host.html)
111+
1-bit: SD_MMC_ speed is approximately two-times faster than SPI mode
112+
4-bit: SD_MMC speed is approximately three-times faster than SPI mode.

‎libraries/SD_MMC/examples/SDMMC_Test/SDMMC_Test.ino

+27
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,27 @@
1111
* VSS GND
1212
* D0 2 (add 1K pull up after flashing)
1313
* D1 4
14+
*
15+
* For more info see file README.md in this library or on URL:
16+
* https://github.com/espressif/arduino-esp32/tree/master/libraries/SD_MMC
1417
*/
1518

1619
#include "FS.h"
1720
#include "SD_MMC.h"
1821

22+
// Default pins for ESP-S3
23+
// Warning: ESP32-S3-WROOM-2 is using most of the default GPIOs (33-37) to interface with on-board OPI flash.
24+
// If the SD_MMC is initialized with default pins it will result in rebooting loop - please
25+
// reassign the pins elsewhere using the mentioned command `setPins`.
26+
// Note: ESP32-S3-WROOM-1 does not have GPIO 33 and 34 broken out.
27+
// Note: if it's ok to use default pins, you do not need to call the setPins
28+
int clk = 36;
29+
int cmd = 35;
30+
int d0 = 37;
31+
int d1 = 38;
32+
int d2 = 33;
33+
int d3 = 39; // GPIO 34 is not broken-out on ESP32-S3-DevKitC-1 v1.1
34+
1935
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
2036
Serial.printf("Listing directory: %s\n", dirname);
2137

@@ -172,6 +188,17 @@ void testFileIO(fs::FS &fs, const char * path){
172188

173189
void setup(){
174190
Serial.begin(115200);
191+
/*
192+
// If you want to change the pin assigment on ESP32-S3 uncomment this block and the appropriate
193+
// line depending if you want to use 1-bit or 4-bit line.
194+
// Please note that ESP32 does not allow pin change and will always fail.
195+
//if(! setPins(clk, cmd, d0)){
196+
//if(! setPins(clk, cmd, d0, d1, d2, d3)){
197+
Serial.println("Pin change failed!");
198+
return;
199+
}
200+
*/
201+
175202
if(!SD_MMC.begin()){
176203
Serial.println("Card Mount Failed");
177204
return;

‎libraries/SD_MMC/src/SD_MMC.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ bool SDMMCFS::begin(const char * mountpoint, bool mode1bit, bool format_if_mount
9393
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
9494
#ifdef SOC_SDMMC_USE_GPIO_MATRIX
9595
// SoC supports SDMMC pin configuration via GPIO matrix.
96-
// Chech that the pins have been set either in the constructor or setPins function.
96+
// Check that the pins have been set either in the constructor or setPins function.
9797
if (_pin_cmd == -1 || _pin_clk == -1 || _pin_d0 == -1
9898
|| (!mode1bit && (_pin_d1 == -1 || _pin_d2 == -1 || _pin_d3 == -1))) {
9999
log_e("SDMMCFS: some SD pins are not set");

0 commit comments

Comments
 (0)
Please sign in to comment.