<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Any electronics guys out there can help out with SD CARD? It is frustrating as hell. The last part of the hardware puzzle. Once we solve this, we can hit the button to start making these. China and I have been struggling with this for the last month, with little progress.</div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">We are just following the standard Espressif schematics for this. Here is Espressif’s master document on it:</div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><a href="https://github.com/espressif/esp-idf/tree/master/examples/storage/sd_card" class="">https://github.com/espressif/esp-idf/tree/master/examples/storage/sd_card</a></div></blockquote><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Our circuit has been built for 4 wire SD mode, using the standard pins and pullups (as documented by Espressif). Result is that it is unreliable. Fails to mount 90% of SD CARDS, and those that do mount fail and corrupt data when writing lots of data out.</div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">The core problem (we think) is that the GPIO2 and GPIO12 pins used for SD CARD are also required to be at specific values during boot (to select different boot modes). Espressif suggest to work around this using the transistor logic they have for controlling boot mode pins using the USB-to-serial converter and DTR + RTS async control pins.</div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">We want 4-wire, but let’s start with a simple 1-wire diagram on a breadboard (as per Espressif instructions):</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><table style="box-sizing: border-box; border-spacing: 0px; border-collapse: collapse; margin-top: 0px; margin-bottom: 16px; display: block; width: 888px; overflow: auto; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class=""><thead style="box-sizing: border-box;" class=""><tr style="box-sizing: border-box; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(198, 203, 209);" class=""><th style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">ESP32 pin</th><th style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">SD card pin</th><th style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">SPI pin</th><th style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">Notes</th></tr></thead><tbody style="box-sizing: border-box;" class=""><tr style="box-sizing: border-box; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(198, 203, 209);" class=""><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class=""><b class="">GPIO14</b> (MTMS)</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class=""><b class="">CLK</b></td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">SCK</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class=""><b class="">10k pullup</b> in SD mode</td></tr><tr style="box-sizing: border-box; background-color: rgb(246, 248, 250); border-top-width: 1px; border-top-style: solid; border-top-color: rgb(198, 203, 209);" class=""><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class=""><b class="">GPIO15</b> (MTDO)</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class=""><b class="">CMD</b></td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">MOSI</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class=""><b class="">10k pullup</b>, both in SD and SPI modes</td></tr><tr style="box-sizing: border-box; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(198, 203, 209);" class=""><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class=""><b class="">GPIO2</b></td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class=""><b class="">D0</b></td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">MISO</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class=""><b class="">10k pullup in SD mode, pull low to go into download mode (see note below!)</b></td></tr><tr style="box-sizing: border-box; background-color: rgb(246, 248, 250); border-top-width: 1px; border-top-style: solid; border-top-color: rgb(198, 203, 209);" class=""><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">GPIO4</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">D1</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">N/C</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">not used in 1-line SD mode; 10k pullup in 4-line SD mode</td></tr><tr style="box-sizing: border-box; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(198, 203, 209);" class=""><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">GPIO12 (MTDI)</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">D2</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">N/C</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">not used in 1-line SD mode; 10k pullup in 4-line SD mode (see note below!)</td></tr><tr style="box-sizing: border-box; background-color: rgb(246, 248, 250); border-top-width: 1px; border-top-style: solid; border-top-color: rgb(198, 203, 209);" class=""><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">GPIO13 (MTCK)</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class=""><b class="">D3</b></td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">CS</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">not used in 1-line SD mode, but card's D3 pin must have a <b class="">10k pullup</b></td></tr><tr style="box-sizing: border-box; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(198, 203, 209);" class=""><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">N/C</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">CD</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class=""></td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">optional, not used in the example</td></tr><tr style="box-sizing: border-box; background-color: rgb(246, 248, 250); border-top-width: 1px; border-top-style: solid; border-top-color: rgb(198, 203, 209);" class=""><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">N/C</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">WP</td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class=""></td><td style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(223, 226, 229);" class="">optional, not used in the example</td></tr></tbody></table><br class=""></div><div class="">Also:</div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#24292e" face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol" size="3" class="">Connect GPIO0 and GPIO2 using a jumper (so transistors drive GPIO2 and GPIO0 low when entering download mode (10K pullup otherwise)</font></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#24292e" face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol" size="3" class="">3.3V connect to SDCARD</font></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#24292e" face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol" size="3" class="">GND connect to SDCARD</font></span></div></blockquote><div class=""><br class=""></div><div class="">We have a variety of ESP32 development modules to try this with. Espressif said that the original DEVKIT C had a problem with the boot pin control lines and transistor logic (but never said what exactly that problem was).</div><div class=""><br class=""></div><div class="">With original (old) ESP32 DEVKIT C, I can’t get it to work reliably at all. Sometimes ok. Sometimes not. With OVMS test code (that writes a lot of data), it never works.</div><div class=""><br class=""></div><div class="">With our OVMS boards, all versions, I can’t get it to work reliably at all. Sometimes ok. Sometimes not. With OVMS test code (that writes a lot of data), it never works.</div><div class=""><br class=""></div><div class="">I don’t think it ever worked. Just before our test was so simple that it didn’t show the problem.</div><div class=""><br class=""></div><div class="">So, I just purchased one of these:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><a href="https://www.banggood.com/ESP32-Development-Board-WiFiBluetooth-Ultra-Low-Power-Consumption-Dual-Cores-ESP-32-ESP-32S-Board-p-1109512.html" class="">https://www.banggood.com/ESP32-Development-Board-WiFiBluetooth-Ultra-Low-Power-Consumption-Dual-Cores-ESP-32-ESP-32S-Board-p-1109512.html</a></div><div class=""><br class=""></div><div class=""><h1 itemprop="name" class="" style="padding: 0px; margin: 0px; font-size: 16px; line-height: 1.5; color: rgb(51, 51, 51); font-family: Arial; background-color: rgb(249, 249, 249);">Geekcreit® ESP32 Development Board WiFi+Bluetooth Ultra Low Power Consumption Dual Cores ESP-32 ESP-32S Board</h1><div class=""><br class=""></div></div><div class="">(Very similar to DEVKIT C, but more modern)</div></blockquote><div class=""><br class=""></div><div class="">It works 100%. Although after flashing it cannot boot (waiting for download) - need to disconnect GPIO0 - GPIO2 link, reset, then reconnect GPIO0-GPIO2 link. Then perfect.</div><div class=""><br class=""></div><div class="">I think our problem is related to that transistor auto-flash reset circuitry. GPIO2 is the line for data transfer, so if problem will cause data corruption and unreliable (like we are seeing).</div><div class=""><br class=""></div><div class="">Espressif SD CARD notes here:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><a href="https://github.com/espressif/esp-idf/tree/master/examples/storage/sd_card" class="">https://github.com/espressif/esp-idf/tree/master/examples/storage/sd_card</a></div></blockquote><div class=""><br class=""></div><div class="">Schematic for Geekcreit board is here:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><a href="https://www.dropbox.com/s/jefwxxtufgwg0ex/esp32_Schematic%20Prints.pdf?dl=0" class="">https://www.dropbox.com/s/jefwxxtufgwg0ex/esp32_Schematic%20Prints.pdf?dl=0</a></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><br class=""></div><div class=""><img apple-inline="no" id="4E2D82B1-4476-444B-88B7-D83B3A446755" class="" src="cid:BB1BAF91-49B9-4C9D-98C7-EBFE25961A95"></div></blockquote><div class=""><br class=""></div><div class="">Schematic for latest version of Espressif DEVKIT C board is here:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font class=""><a href="http://espressif.com/sites/default/files/documentation/esp32_hardware_design_guidelines_en.pdf" class="">http://espressif.com/sites/default/files/documentation/esp32_hardware_design_guidelines_en.pdf</a></font></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><br class=""></div><div class=""><img apple-inline="no" id="BBC315E0-571C-4E8D-BE53-9E3691A57028" class="" src="cid:B877B268-3D5B-4387-A8C4-2FF4A2B5145D"></div></blockquote><div class=""><br class=""></div><div class="">The original DEVKIT C (v1) had 1K resistors on that circuit. This is the version I have.</div><div class=""><br class=""></div><div class="">The Geekcreit has 10K resistors on that circuit.</div><div class=""><br class=""></div><div class="">OVMS has 10K resistors on that circuit.</div><div class=""><br class=""></div><div class="">The latest DEVKIT C (v3) has 12K resistors on that circuit.</div><div class=""><br class=""></div><div class="">DEVKIT C v1 schematic is here: <a href="http://dl.espressif.com/dl/schematics/ESP32-DevKitJ-v1_sch.pdf" class="">http://dl.espressif.com/dl/schematics/ESP32-DevKitJ-v1_sch.pdf</a></div><div class="">DEVKIT C v2 schematic is here: <a href="http://dl.espressif.com/dl/schematics/ESP-WROVER-KIT_SCH-2.pdf" class="">http://dl.espressif.com/dl/schematics/ESP-WROVER-KIT_SCH-2.pdf</a></div><div class=""><br class=""></div><div class="">The latest Espressif ROVER KIT development board schematic is here:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><a href="https://dl.espressif.com/dl/schematics/ESP-WROVER-KIT_SCH-3.pdf" class="">https://dl.espressif.com/dl/schematics/ESP-WROVER-KIT_SCH-3.pdf</a></div><div class=""><br class=""></div><div class=""><img apple-inline="no" id="64166452-92B5-40EE-89B9-96028BCD323A" class="" src="cid:A0B71647-071F-42E7-840C-852F37074F8C"></div><div class=""><br class=""></div><div class=""><img apple-inline="no" id="AC7C45FD-1C5D-4AC6-BF5E-AC8F90283B7C" class="" src="cid:B881A4D2-1904-4E9A-A0F3-7C744DF25F66"></div></blockquote><div class=""><br class=""></div><div class="">Note that they are now using 100K resistors, and a separate transistor on IO0 (to allow it to be independently controlled after boot).</div><div class=""><br class=""></div><div class="">I am reasonably certain our SD CARD problem concerns the GPIO0-GPIO2 link.</div><div class=""><br class=""></div><div class="">Can you look at these, and see if you can find the difference? Apart from resistor sizes (which Espressif keep messing around with), I can’t see the practical difference.</div><div class=""><br class=""></div><div class="">Regards, Mark.</div></div></body></html>