<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">This is a 4-line design. </div><div dir="ltr"><br>Here is the relevant output from make monitor. There is indeed a complaint about pull-ups. <br><div><div><br></div><div>=======================================================</div><div>===== Test using SD Card in SPI mode              =====</div><div>===== SD Card uses the same gpio's as TFT display =====</div><div>=======================================================</div><div><br></div><div>I (52) SDCard test: Initializing SD card</div><div>I (56) SDCard test: Using SPI peripheral</div><div>I (62) gpio: GPIO[19]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 </div><div>E (112) sdmmc_sd: sdmmc_init_sd_if_cond: send_if_cond (1) returned 0x108</div><div>I (112) gpio: GPIO[23]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 </div><div>I (118) gpio: GPIO[25]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 </div><div>I (127) gpio: GPIO[26]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 </div><div>E (136) SDCard test: Failed to initialize the card (264). Make sure SD card lines have pull-up resistors in place.</div></div><div><br>Now, checking the hardware:<br><br>This is a Hackerboxes kit #20. The SD Card is on a TFT display. The particular TFT display is this one:<br><a href="https://www.amazon.com/gp/product/B01CZL6QIQ/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&psc=1">https://www.amazon.com/gp/product/B01CZL6QIQ/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&psc=1</a><br><br>There are resistors on the TFT display in the expected places and there is 3.3v on the SD card SPI pins when the board is powered up. <br><br>Looking at this board's schematic, the wrong pins were assigned for SPI access to the SD Card. <br><br>The schematic is located in Step 4 in this website: <br><a href="https://www.instructables.com/id/HackerBoxes-0020-Summer-Camp/">https://www.instructables.com/id/HackerBoxes-0020-Summer-Camp/</a><br><br>So, I updated the SD SPI to match the schematic. Unfortunately, same errors. <br><br><div>=======================================================</div><div>===== Test using SD Card in SPI mode              =====</div><div>===== SD Card uses the same gpio's as TFT display =====</div><div>=======================================================</div><div><br></div><div>I (52) SDCard test: Initializing SD card</div><div>I (56) SDCard test: Using SPI peripheral</div><div>I (62) gpio: GPIO[17]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 </div><div>E (112) sdmmc_sd: sdmmc_init_sd_if_cond: send_if_cond (1) returned 0x108</div><div>I (112) gpio: GPIO[16]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 </div><div>I (118) gpio: GPIO[4]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 </div><div>I (127) gpio: GPIO[0]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 </div><div>E (136) SDCard test: Failed to initialize the card (264). Make sure SD card lines have pull-up resistors in place.</div><div><br></div><div><br></div><div>Removing the card completely? Same errors. Hmmm.<br><br><div>=======================================================</div><div>===== Test using SD Card in SPI mode              =====</div><div>===== SD Card uses the same gpio's as TFT display =====</div><div>=======================================================</div><div><br></div><div>I (52) SDCard test: Initializing SD card</div><div>I (56) SDCard test: Using SPI peripheral</div><div>I (62) gpio: GPIO[17]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 </div><div>E (112) sdmmc_sd: sdmmc_init_sd_if_cond: send_if_cond (1) returned 0x108</div><div>I (112) gpio: GPIO[16]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 </div><div>I (118) gpio: GPIO[4]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 </div><div>I (127) gpio: GPIO[0]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 </div><div>E (136) SDCard test: Failed to initialize the card (264). Make sure SD card lines have pull-up resistors in place.</div></div><div><br></div><div><br></div><div>Next, I scrounged around to see if I missed anything super obvious.</div><br>In a community-provided repository for Hackerboxes #20 (<a href="https://github.com/lmarty/Hackerboxes20" target="_blank">https://github.com/lmarty/Hackerboxes20</a>), I found this:<br>"<br><div>IF THE SD ISN'T WORKING...</div><div><br></div><div>try holding down the flash button on the dev kit board as you boot</div><div>If that fixes it... Pop your TFT board off the project PCB and flip it over. There are two small pads labled "j1" on the back, solder them together."</div><br><br></div><div>But Hackerboxes replied with this:<br><br>"From what I understand, shorting J1 on the LCD module bypasses the voltage regulator that converts the incoming 5V to the 3.3V needed by the LCD. J1 is intended to be shorted if you are providing 3.3V to the module to begin with. Shorting J1 is probably not a great idea if the supply to the module is 5V."</div><div><br></div><div>So I postponed that idea as just too janky. <br></div><div><br><br><br>But it has to be something simple I'm doing wrong. </div><div><br></div><div><br><br>Here's the code from tft_demo.c (from esp-idf examples directory) that sources the errors.<br><br><br><div>    // Use settings defined above to initialize SD card and mount FAT filesystem.</div><div>    // Note: esp_vfs_fat_sdmmc_mount is an all-in-one convenience function.</div><div>    // Please check its source code and implement error recovery when developing</div><div>    // production applications.</div><div>    sdmmc_card_t* card;</div><div>    esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);</div><div><br></div><div>    if (ret != ESP_OK) {</div><div>        if (ret == ESP_FAIL) {</div><div>            ESP_LOGE(TAG, "Failed to mount filesystem. "</div><div>                "If you want the card to be formatted, set format_if_mount_failed = true.");</div><div>        } else {</div><div>            ESP_LOGE(TAG, "Failed to initialize the card (%d). "</div><div>                "Make sure SD card lines have pull-up resistors in place.", ret);</div><div>        }</div><div>        return;</div><div>    }</div></div><div><br></div><div><br></div><div><br></div><div>OK so we failed to initialize the card, so climbing back into esp_vfs_fat_sdmmc_mount() is the next step, just like it says to do in the comments. <br><br>So I went and looked for it and I think I found it in <br>/esp/esp-idf/components/fatfs/src/esp_vfs_fat.h</div><div>/esp/esp-idf/components/fatfs/src/vfs_fat_sdmmc.c<br></div><div><br></div><div><div>And that's where I'm at as of right this minute. <br><br>More soon, pausing for any good advice anyone has from here on the list on what to check next (in addition to digging through the library code). <br><br>Steve Conklin asked if we had an SPI decoder. I think we might. <br><br>-mdt</div></div><div><br></div><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, May 4, 2019 at 9:53 AM Michelle Thompson <<a href="mailto:mountain.michelle@gmail.com" target="_blank">mountain.michelle@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">This question is mainly for Wally, but posting here for anyone else that has experience with integrating SD cards into a project!</div><div dir="auto"><br></div><div dir="auto">I’m getting some errors with the example code from ESP-idf. </div><div dir="auto"><br></div><div dir="auto">Any best practices I should learn about?</div><div dir="auto"><br></div><div dir="auto">Like with many HTs and modern radios, mass storage for us will be very useful. </div><div dir="auto"><br></div><div dir="auto">-mdt</div>-- <br><div dir="ltr" class="gmail-m_733098936201215211gmail-m_-4157823662050055049gmail-m_60603635539270823gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr">-Michelle W5NYV<br><br><div dir="ltr">"Potestatem obscuri lateris nescis."<br></div><div><br></div></div></div></div></div></div></div></div>
</blockquote></div>