sd_pullup_requirements.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. SD Pull-up Requirements
  2. =======================
  3. 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.
  4. 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.
  5. 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.
  6. .. todo::
  7. Add a diagram of the Bus lines and pullups
  8. This document has the following structure:
  9. - `Overview of compatibility`_ between the default pull states on pins of Espressif's products and the states required by the SD bus
  10. - `Solutions`_ - ideas on how to resolve compatibility issues
  11. - `Related information`_ - other relevant information
  12. .. _compatibility_overview_espressif_hw_sdio:
  13. Overview of Compatibility
  14. -------------------------
  15. 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.
  16. Systems on a Chip (SoCs)
  17. ^^^^^^^^^^^^^^^^^^^^^^^^
  18. .. only:: esp32
  19. - ESP32 (except for D2WD versions, see `ESP32 datasheet <https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf>`_):
  20. - :ref:`sd_pull-up_no_pull-ups`
  21. - :ref:`strapping_conflicts_dat2` for models with 3.3 V flash chip
  22. - ESP32-D2WD:
  23. - :ref:`sd_pull-up_no_pull-ups`
  24. - :ref:`no_pull-up_on_gpio12`
  25. .. only:: esp32s2
  26. .. note::
  27. No chips listed for ESP32-S2 yet.
  28. Systems in Packages (SIP)
  29. ^^^^^^^^^^^^^^^^^^^^^^^^^
  30. .. only:: esp32
  31. - ESP32-PICO-D4:
  32. - :ref:`sd_pull-up_no_pull-ups`
  33. - :ref:`strapping_conflicts_dat2`
  34. .. only:: esp32s2
  35. .. note::
  36. No chips listed for ESP32-S2 yet.
  37. Modules
  38. ^^^^^^^
  39. .. only:: esp32
  40. - ESP32-WROOM-32 Series, including ESP32-WROOM-32, ESP32-WROOM-32D, ESP32-WROOM-32U, and ESP32-SOLO-1
  41. - :ref:`sd_pull-up_no_pull-ups`
  42. - :ref:`strapping_conflicts_dat2`
  43. - ESP32-WROVER Series, including ESP32-WROVER and ESP32-WROVER-I
  44. - :ref:`sd_pull-up_no_pull-ups`
  45. - ESP32-WROVER-B Series, including ESP32-WROVER-B and ESP32-WROVER-IB
  46. - :ref:`sd_pull-up_no_pull-ups`
  47. - :ref:`strapping_conflicts_dat2`
  48. .. only:: esp32s2
  49. .. note::
  50. No chips listed for ESP32-S2 yet.
  51. .. _sdio_dev_kits:
  52. Development Boards
  53. ^^^^^^^^^^^^^^^^^^
  54. .. only:: esp32
  55. - ESP32-PICO-KIT, including PICO-KIT v4.1, v4.0, and v3
  56. - :ref:`sd_pull-up_no_pull-ups`
  57. - :ref:`strapping_conflicts_dat2`
  58. - :ref:`gpio2_strapping_pin`
  59. - ESP32-DevKitC, including ESP32-DevKitC v4 and v2
  60. - :ref:`sd_pull-up_no_pull-ups`
  61. - :ref:`strapping_conflicts_dat2`
  62. - :ref:`gpio2_strapping_pin`
  63. - ESP-WROVER-KIT
  64. - Required pull-ups are provided
  65. - :ref:`pull-up_conflicts_on_gpio13` (v4.1, v3, v2, and v1)
  66. - :ref:`strapping_conflicts_dat2` (v4.1, v2, and v1)
  67. - :ref:`gpio2_strapping_pin` (v2, v1)
  68. You can determine the version of your ESP23-WROVER-KIT by checking which module is mounted on it:
  69. - ESP32-WROVER-B on v4.1
  70. - ESP32-WROVER on v3
  71. - ESP32-WROOM-32 on v1 and v2
  72. - ESP32-LyraTD-MSC
  73. - Required pull-ups are provided
  74. - :ref:`strapping_conflicts_dat2`
  75. - ESP32-LyraT
  76. - Required pull-ups are provided
  77. - :ref:`pull-up_conflicts_on_gpio13`
  78. .. only:: esp32s2
  79. .. note::
  80. No chips listed for ESP32-S2 yet.
  81. Non-Espressif Hosts
  82. ^^^^^^^^^^^^^^^^^^^
  83. Please make sure that your SDIO host provides necessary pull-ups for all SD bus signals.
  84. Solutions
  85. ---------
  86. .. _sd_pull-up_no_pull-ups:
  87. No Pull-ups
  88. ^^^^^^^^^^^
  89. If you use a development board without pull-ups, you can do the following:
  90. - 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`.
  91. - Attach external pull-ups by connecting each pin which requires a pull-up to VDD via a 10 kOhm resistor.
  92. .. _pull-up_conflicts_on_gpio13:
  93. Pull-up Conflicts on GPIO13
  94. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  95. If DAT3 of your device is not properly pulled up, you have the following options:
  96. - Use 1-bit SD mode and tie the device's DAT3 to VDD
  97. - Use SPI mode
  98. - Perform one of the following actions on the GPIO13 pin:
  99. - Remove the pull-down resistors
  100. - Attach a pull-up resistor of less than 5 kOhm (2 kOhm suggested)
  101. - Pull it up or drive it high either by using the host or with 3.3 V on VDD in 1-bit SD mode
  102. .. _strapping_conflicts_dat2:
  103. Conflicts Between Bootstrap and SDIO on DAT2
  104. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  105. There is a conflict between the boot strapping requirements of the ESP32 and the SDIO protocol. For details, see :ref:`mtdi_strapping_pin`.
  106. To resolve the conflict, you have the following options:
  107. 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.
  108. .. warning::
  109. 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.
  110. If you are sure that you need to irreversibly burn eFuses, go to your ESP-IDF directory and run the following command:
  111. .. code-block:: bash
  112. components/esptool_py/esptool/espefuse.py set_flash_voltage 3.3V
  113. 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:
  114. .. code-block:: bash
  115. espefuse.py v2.6
  116. Connecting....
  117. Enable internal flash voltage regulator (VDD_SDIO) to 3.3 V.
  118. The following eFuses are burned: XPD_SDIO_FORCE, XPD_SDIO_REG, XPD_SDIO_TIEH.
  119. This is an irreversible operation.
  120. Type 'BURN' (all capitals) to continue.
  121. BURN
  122. VDD_SDIO setting complete.
  123. To check the status of the eFuses, run::
  124. ``components/esptool_py/esptool/espefuse.py summary``
  125. If running from an automated flashing script, ``espefuse.py`` has an option ``--do-not-confirm``.
  126. For more details, see the `{IDF_TARGET_NAME} Technical Reference Manual <{IDF_TARGET_TRM_EN_URL}>`_ (PDF).
  127. 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:
  128. - Leave the host's DAT2 floating and directly connect the slave's DAT2 to VDD.
  129. - 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.
  130. .. _no_pull-up_on_gpio12:
  131. No Pull-up on GPIO12
  132. ^^^^^^^^^^^^^^^^^^^^
  133. Your module is compatible with the SDIO protocol. Just connect GPIO12 to VDD via a 10 kOhm resistor.
  134. .. _gpio2_strapping_pin:
  135. Download Mode Not Working (minor issue)
  136. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  137. 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.
  138. There are the following solutions:
  139. - 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.
  140. - 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.
  141. - **LEDs** would not affect operation in most cases.
  142. - **Pull-down resistors** can interfere with DAT0 signals and must be removed.
  143. 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.
  144. .. _related_info_sdio:
  145. Related Information
  146. -------------------
  147. .. _mtdi_strapping_pin:
  148. MTDI Strapping Pin
  149. ^^^^^^^^^^^^^^^^^^
  150. 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.
  151. .. only:: esp32
  152. 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.
  153. When adding a pull-up to this pin for SD card operation, consider the following:
  154. - For boards that do not use the internal regulator (VDD_SDIO) to power flash, GPIO12 can be pulled high.
  155. - 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.
  156. - 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`.
  157. Internal Pull-ups and Strapping Requirements
  158. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  159. 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.
  160. 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.
  161. The following abbreviations are used in the table:
  162. - **WPU**: Weak pull-up inside the SoC
  163. - **WPD**: Weak pull-down inside the SoC
  164. - **PU**: Pull-up inside Espressif modules but outside the SoC
  165. .. list-table:: Default pull-up and pull-down states of the CMD and DATA pins
  166. :widths: 25 25 25 25
  167. :header-rows: 1
  168. * - GPIO number
  169. - Pin Name
  170. - Startup State
  171. - Strapping Requirement
  172. * - **15**
  173. - CMD
  174. - WPU
  175. -
  176. * - **2**
  177. - DAT0
  178. - WPD
  179. - Low for Download mode
  180. * - **4**
  181. - DAT1
  182. - WPD
  183. -
  184. * - **12**
  185. - DAT2
  186. - PU for 1.8 V flash; WPD for 3.3 V flash
  187. - High for 1.8 V flash; Low for 3.3 V flash
  188. * - **13**
  189. - DAT3
  190. - WPU
  191. -