sd_pullup_requirements.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. SD Pull-up Requirements
  2. =======================
  3. .. only:: esp32c3
  4. .. warning::
  5. This document is not updated for ESP32-C3 yet.
  6. Espressif hardware products are designed for multiple use cases which may require different pull states on pins. For this reason, the pull state of particular pins on certain products will need to be adjusted to provide the pull-ups required in the SD bus.
  7. SD pull-up requirements apply to cases where {IDF_TARGET_NAME} uses the SPI controller to communicate with SD cards. When an SD card is operating in SPI mode or 1-bit SD mode, the CMD and DATA (DAT0 - DAT3) lines of the SD bus must be pulled up by 10 kOhm resistors. Slaves should also have pull-ups on all above-mentioned lines (regardless of whether these lines are connected to the host) in order to prevent SD cards from entering a wrong state.
  8. By default, the MTDI bootstrapping pin is incompatible with the DAT2 line pull-up if the flash voltage is 3.3 V. For more information, see :ref:`mtdi_strapping_pin` below.
  9. .. todo::
  10. Add a diagram of the Bus lines and pullups
  11. This document has the following structure:
  12. - `Overview of compatibility`_ between the default pull states on pins of Espressif's products and the states required by the SD bus
  13. - `Solutions`_ - ideas on how to resolve compatibility issues
  14. - `Related information`_ - other relevant information
  15. .. _compatibility_overview_espressif_hw_sdio:
  16. Overview of Compatibility
  17. -------------------------
  18. This section provides an overview of compatibility issues that might occur when using SDIO (secure digital input output). Since the SD bus needs to be connected to pull-ups, these issues should be resolved regardless of whether they are related to master (host) or slave (device). Each issue has links to its respective solution. A solution for a host and device may differ.
  19. Systems on a Chip (SoCs)
  20. ^^^^^^^^^^^^^^^^^^^^^^^^
  21. .. only:: esp32
  22. - ESP32 (except for D2WD versions, see `ESP32 datasheet <https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf>`_):
  23. - :ref:`sd_pull-up_no_pull-ups`
  24. - :ref:`strapping_conflicts_dat2` for models with 3.3 V flash chip
  25. - ESP32-D2WD:
  26. - :ref:`sd_pull-up_no_pull-ups`
  27. - :ref:`no_pull-up_on_gpio12`
  28. .. only:: esp32s2
  29. .. note::
  30. No chips listed for ESP32-S2 yet.
  31. Systems in Packages (SIP)
  32. ^^^^^^^^^^^^^^^^^^^^^^^^^
  33. .. only:: esp32
  34. - ESP32-PICO-D4:
  35. - :ref:`sd_pull-up_no_pull-ups`
  36. - :ref:`strapping_conflicts_dat2`
  37. .. only:: esp32s2
  38. .. note::
  39. No chips listed for ESP32-S2 yet.
  40. Modules
  41. ^^^^^^^
  42. .. only:: esp32
  43. - ESP32-WROOM-32 Series, including ESP32-WROOM-32, ESP32-WROOM-32D, ESP32-WROOM-32U, and ESP32-SOLO-1
  44. - :ref:`sd_pull-up_no_pull-ups`
  45. - :ref:`strapping_conflicts_dat2`
  46. - ESP32-WROVER Series, including ESP32-WROVER and ESP32-WROVER-I
  47. - :ref:`sd_pull-up_no_pull-ups`
  48. - ESP32-WROVER-B Series, including ESP32-WROVER-B and ESP32-WROVER-IB
  49. - :ref:`sd_pull-up_no_pull-ups`
  50. - :ref:`strapping_conflicts_dat2`
  51. .. only:: esp32s2
  52. .. note::
  53. No chips listed for ESP32-S2 yet.
  54. .. _sdio_dev_kits:
  55. Development Boards
  56. ^^^^^^^^^^^^^^^^^^
  57. .. only:: esp32
  58. - ESP32-PICO-KIT, including PICO-KIT v4.1, v4.0, and v3
  59. - :ref:`sd_pull-up_no_pull-ups`
  60. - :ref:`strapping_conflicts_dat2`
  61. - :ref:`gpio2_strapping_pin`
  62. - ESP32-DevKitC, including ESP32-DevKitC v4 and v2
  63. - :ref:`sd_pull-up_no_pull-ups`
  64. - :ref:`strapping_conflicts_dat2`
  65. - :ref:`gpio2_strapping_pin`
  66. - ESP-WROVER-KIT
  67. - Required pull-ups are provided
  68. - :ref:`pull-up_conflicts_on_gpio13` (v4.1, v3, v2, and v1)
  69. - :ref:`strapping_conflicts_dat2` (v4.1, v2, and v1)
  70. - :ref:`gpio2_strapping_pin` (v2, v1)
  71. You can determine the version of your ESP23-WROVER-KIT by checking which module is mounted on it:
  72. - ESP32-WROVER-B on v4.1
  73. - ESP32-WROVER on v3
  74. - ESP32-WROOM-32 on v1 and v2
  75. - ESP32-LyraTD-MSC
  76. - Required pull-ups are provided
  77. - :ref:`strapping_conflicts_dat2`
  78. - ESP32-LyraT
  79. - Required pull-ups are provided
  80. - :ref:`pull-up_conflicts_on_gpio13`
  81. .. only:: esp32s2
  82. .. note::
  83. No chips listed for ESP32-S2 yet.
  84. Non-Espressif Hosts
  85. ^^^^^^^^^^^^^^^^^^^
  86. Please make sure that your SDIO host provides necessary pull-ups for all SD bus signals.
  87. Solutions
  88. ---------
  89. .. _sd_pull-up_no_pull-ups:
  90. No Pull-ups
  91. ^^^^^^^^^^^
  92. If you use a development board without pull-ups, you can do the following:
  93. - If your host and slave device are on seperate boards, replace one of them with a board that has pull-ups. For the list of Espressif's development boards with pull-ups, go to :ref:`sdio_dev_kits`.
  94. - Attach external pull-ups by connecting each pin which requires a pull-up to VDD via a 10 kOhm resistor.
  95. .. _pull-up_conflicts_on_gpio13:
  96. Pull-up Conflicts on GPIO13
  97. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  98. If DAT3 of your device is not properly pulled up, you have the following options:
  99. - Use 1-bit SD mode and tie the device's DAT3 to VDD
  100. - Use SPI mode
  101. - Perform one of the following actions on the GPIO13 pin:
  102. - Remove the pull-down resistors
  103. - Attach a pull-up resistor of less than 5 kOhm (2 kOhm suggested)
  104. - Pull it up or drive it high either by using the host or with 3.3 V on VDD in 1-bit SD mode
  105. .. _strapping_conflicts_dat2:
  106. Conflicts Between Bootstrap and SDIO on DAT2
  107. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  108. There is a conflict between the boot strapping requirements of the ESP32 and the SDIO protocol. For details, see :ref:`mtdi_strapping_pin`.
  109. To resolve the conflict, you have the following options:
  110. 1. (Recommended) Burn the flash voltage selection eFuses. This will permanently configure the internal regulator's output voltage to 3.3 V, and GPIO12 will not be used as a bootstrapping pin. After that, connect a pull-up resistor to GPIO12.
  111. .. warning::
  112. Burning eFuses is irreversible! The issue list above might be out of date, so please make sure that the module you are burning has a 3.3 V flash chip by checking the information on http://www.espressif.com/. If you burn the 3.3 V eFuses on a module with a 1.8 V flash chip, the module will stop functioning.
  113. If you are sure that you need to irreversibly burn eFuses, go to your ESP-IDF directory and run the following command:
  114. .. code-block:: bash
  115. components/esptool_py/esptool/espefuse.py set_flash_voltage 3.3V
  116. This command will burn the `XPD_SDIO_TIEH`, `XPD_SDIO_FORCE`, and `XPD_SDIO_REG` eFuses. After all the three eFuses are burned to value 1, the internal VDD_SDIO flash voltage regulator will be permanently set to 3.3 V. You will see the following log if the burning succeeds:
  117. .. code-block:: bash
  118. espefuse.py v2.6
  119. Connecting....
  120. Enable internal flash voltage regulator (VDD_SDIO) to 3.3 V.
  121. The following eFuses are burned: XPD_SDIO_FORCE, XPD_SDIO_REG, XPD_SDIO_TIEH.
  122. This is an irreversible operation.
  123. Type 'BURN' (all capitals) to continue.
  124. BURN
  125. VDD_SDIO setting complete.
  126. To check the status of the eFuses, run::
  127. ``components/esptool_py/esptool/espefuse.py summary``
  128. If running from an automated flashing script, ``espefuse.py`` has an option ``--do-not-confirm``.
  129. For more details, see *{IDF_TARGET_NAME} Technical Reference Manual* [`PDF <{IDF_TARGET_TRM_EN_URL}#efuse>`__].
  130. 2. **If using 1-bit SD mode or SPI mode**, disconnect the DAT2 pin and make sure it is pulled high. For this, do one the following:
  131. - Leave the host's DAT2 floating and directly connect the slave's DAT2 to VDD.
  132. - For a slave device, build a firmware with the option ``SDIO_SLAVE_FLAG_DAT2_DISABLED`` and re-flash your device. This option will help avoid slave detecting on the DAT2 line. Note that 4-bit SD mode will no longer be supported by the standard Card Common Control Register (CCCR); however, the host will not be aware of that. The use of 4-bit SD mode will have to be disabled on the host's side.
  133. .. _no_pull-up_on_gpio12:
  134. No Pull-up on GPIO12
  135. ^^^^^^^^^^^^^^^^^^^^
  136. Your module is compatible with the SDIO protocol. Just connect GPIO12 to VDD via a 10 kOhm resistor.
  137. .. _gpio2_strapping_pin:
  138. Download Mode Not Working (minor issue)
  139. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  140. When the GPIO2 pin is pulled high in accordance with the SD pull-up requirements, you cannot enter Download mode because GPIO2 is a bootstrapping pin which in this case must be pulled low.
  141. There are the following solutions:
  142. - For boards that require shorting the GPIO0 and GPIO2 pins with a jumper, put the jumper in place, and the auto-reset circuit will pull GPIO2 low along with GPIO0 before entering Download mode.
  143. - For boards with components attached to their GPIO2 pin (such as pull-down resistors and/or LEDs), check the schematic of your development board for anything connected to GPIO2.
  144. - **LEDs** would not affect operation in most cases.
  145. - **Pull-down resistors** can interfere with DAT0 signals and must be removed.
  146. If the above solutions do not work for you, please determine if it is the host or slave device that has pull-ups affecting their GPIO2, then locate these pull-ups and remove them.
  147. .. _related_info_sdio:
  148. Related Information
  149. -------------------
  150. .. _mtdi_strapping_pin:
  151. MTDI Strapping Pin
  152. ^^^^^^^^^^^^^^^^^^
  153. MTDI (GPIO12) is used as a bootstrapping pin to select the output voltage of an internal regulator (VDD_SDIO) which powers the flash chip. This pin has an internal pull-down, so, if left unconnected, it will read low at startup, which will lead to selecting the default 3.3 V operation.
  154. .. only:: esp32
  155. All ESP32-WROVER modules, excluding ESP32-WROVER-B, use 1.8 V flash and have internal pull-ups on GPIO12. Other modules that use 3.3 V flash have no pull-ups on the GPIO12 pin, and this pin is slightly pulled down internally.
  156. When adding a pull-up to this pin for SD card operation, consider the following:
  157. - For boards that do not use the internal regulator (VDD_SDIO) to power flash, GPIO12 can be pulled high.
  158. - For boards using 1.8 V flash chips, GPIO12 needs to be pulled high at reset. This is fully compatible with the SD card operation.
  159. - On boards using the internal regulator and a 3.3 V flash chip, GPIO12 must be pulled low at reset. This is incompatible with the SD card operation. For reference information on compatibility of Espressif's boards with the SD card operation, see :ref:`compatibility_overview_espressif_hw_sdio`.
  160. Internal Pull-ups and Strapping Requirements
  161. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  162. Using external resistors is always preferable. However, Espressif's products have internal weak pull-up and pull-down resistors which can be enabled and used instead of external ones. Please keep in mind that this solution cannot guarantee reliable SDIO communication.
  163. With that said, the information about these internal pull-ups and strapping requirements can still be useful. Espressif hardware products have different weak internal pull-ups / pull-downs connected to CMD and DATA pins. The table below shows the default pull-up and pull-down states of the CMD and DATA pins.
  164. The following abbreviations are used in the table:
  165. - **WPU**: Weak pull-up inside the SoC
  166. - **WPD**: Weak pull-down inside the SoC
  167. - **PU**: Pull-up inside Espressif modules but outside the SoC
  168. .. list-table:: Default pull-up and pull-down states of the CMD and DATA pins
  169. :widths: 25 25 25 25
  170. :header-rows: 1
  171. * - GPIO number
  172. - Pin Name
  173. - Startup State
  174. - Strapping Requirement
  175. * - **15**
  176. - CMD
  177. - WPU
  178. -
  179. * - **2**
  180. - DAT0
  181. - WPD
  182. - Low for Download mode
  183. * - **4**
  184. - DAT1
  185. - WPD
  186. -
  187. * - **12**
  188. - DAT2
  189. - PU for 1.8 V flash; WPD for 3.3 V flash
  190. - High for 1.8 V flash; Low for 3.3 V flash
  191. * - **13**
  192. - DAT3
  193. - WPU
  194. -