Sharing an SDCard between a GL823 and an ESP32 - Page 1
Forum section: electronics / projects

author: chrisgreening
author_rank: Newbie
timestamp: October 08, 2023, 04:30:00 pm
content: I have a project with an ESP32 and need to store video files on an SDCard.I can setup the ESP32 as a mass storage controller so the SDCard can be mounted through it to a PC - but it's limited to USB1.1 full speed which is only 12Mbits/s - so not great for transferring large video files.So, I'm thinking of having the device operate in two modes - a normal mode where the ESP32 is using the SDCard. And a mass storage mode where a GL823 is controlling the SDCard and the ESP32 doesn't touch it.It looks like I can use a USB multiplexer (e.g.https://datasheet.lcsc.com/lcsc/2304140030_Texas-Instruments-TS3USB221ERSER_C129313.pdf) to switch the USB data lines between the ESP32 and the GL823.The ESP32 would control this, so when it needs to switch into mass storage mode it will- turn off its SPI connection to the SDCard- power off the SDCard- switch the USB over to the GL823- power on the SDCard- connect the GL823 to the USB5VI'll probably include some way for the ESP32 to know when the USB is connected - to get out of mass storage mode the user will need to unplug the USB.Does this sound like it will work?My concerns are mostly around sharing the SDCard between the ESP32 and the GL823. When the GL823 is powered off it will still be connected to the SDCard so might interfere with the ESP32's signals?Are there any alternatives to the GL823 that include some kind of enable pin?

author: wraper
author_rank: Unknown
timestamp: October 08, 2023, 04:44:50 pm
content: You cannot power off GL823 while there is communication with SD card as ESD protection and MOSFET body diodes on its pins will pass voltage from its I/O to its VDD. You probably could keep it in reset state if it causes its SD interface to be in high impedance state.

author: chrisgreening
author_rank: Newbie
timestamp: October 08, 2023, 05:22:41 pm
content: Right - that makes sense.The data sheet is very quiet on what happens when the chip is being reset - I guess it’s time for some experimentation.Worst case I can get the the boards made up and remove the GL823 if it causes problems.

author: wraper
author_rank: Unknown
timestamp: October 08, 2023, 05:54:20 pm
content: As I see it from datasheet, only SD_CLK should be of concern as it's stated as output only, while others as pull-up when input. So depending on how it works in practice, you may need to disconnect this signal in some way.

author: chrisgreening
author_rank: Newbie
timestamp: October 08, 2023, 06:13:11 pm
content: Do you think something like this could be used to switch the clock between the ESP32 and the GL823?https://datasheet.lcsc.com/lcsc/1808311550_WILLSEMI-Will-Semicon-WAS3157B-6-TR_C213161.pdf

author: wraper
author_rank: Unknown
timestamp: October 08, 2023, 06:18:19 pm
content: Looks fine on a quick glance. You could create footprints for jumper resistor and this IC and mount appropriate part after testing in practice.

author: globoy
author_rank: Frequent Contributor
timestamp: October 08, 2023, 06:24:06 pm
content: It might be too late to change the ESP32 variant but the faster ESP32-S3 sports a native USB interface and the IDF supports both CDC and MSC device classes (in fact it has a composite MSC+CDC option). The MSC can work with the SD driver as well so maybe you wouldn't need the GL823 and supporting circuitry.https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/usb_device.htmlThis guy seems to have integrated the two using the Arduino ESP32 package:https://www.reddit.com/r/arduino/comments/w4o8wn/esb32s3_nand_sd_storage_usb_msc_arduino_that/But I didn't look into his work very deeply.

author: chrisgreening
author_rank: Newbie
timestamp: October 08, 2023, 06:26:49 pm
content: I've got the ESP32-S3 working in MSC mode - but it's just a bit too slow for transferring large files. The ESP32 can only do USB1.1 full speed which is just 12Mb/s.

author: chrisgreening
author_rank: Newbie
timestamp: October 08, 2023, 06:28:18 pm
content: I could use this to isolate all 4 of the SPI lines that the ESP32 uses.Jumpers to bypass it are a great idea.

author: chrisgreening
author_rank: Newbie
timestamp: October 08, 2023, 06:36:36 pm
content: Actually - this looks perfect -https://datasheet.lcsc.com/lcsc/2210281000_Diodes-Incorporated-PI3A27518ZDEX_C3001682.pdfThere are potentially 6 connections (if you ignore power and ground) from the SDCard and I could switch these between the ESP32 and the GL823. This would potentially let me run the ESP32 in SDIO mode.

author: chrisgreening
author_rank: Newbie
timestamp: February 04, 2024, 10:16:52 pm
content: Quick update on this - I ended up using a USB2244 and it was a simple as just holding it in reset mode when it's not in use. Works like a charm.