The esp8266 and SD Cards

espusb1espusb2Recently I’ve been using the esp8266 with SD cards in order to develop the small board shown above and to the right. It hosts a CH340g USB interface, small buck converter to supply 3.3v to the esp8266 and an SD card slot.

The esp8266 is pretty thin, and doesn’t really give the information necessary to get up and running, so it took some research and hacking around to get everything working.

A lot of this was motivated by this forum thread which provided that it was possible to get SD cards working on the esp8266 using the SPI interface. SD cards generally use a more complex protocol and multiple data lines, but they can fall back to SPI mode (albeit with reduced performance).

The Arduino esp8266 support pack also has done great work, and after configuring a chip select pin, the SD card library supplied there pretty much just works.

I wanted to use the native esp8266 SDK without the Arduino environment. This took some hacking, but so far I’ve extracted the SD card library and have it up and running using a native SPI driver, the main issue was enabling (the again undocumented) duplex mode of the esp8266 SPI interface. If you’d like a copy of this code ping me.

One final note, some documents refer to “SD Card” boot mode. That would be really cool, to be able to load your firmware directly from an SD Card. Unfortunately it’s a bit of a misnomer. “SD Card” mode actually refers to SDIO mode. We don’t really hear much about SDIO anymore, but you used to be able to buy these funky Wifi cards which plugged into SD card slots. Other peripherals, like cameras were available too. You can read more about it on the wikipedia page.

The esp8266 supports an SDIO boot mode. My guess is that this is a hang over from its heritage as a general purpose Wifi interface chip. Some people have used this functionality to enable firmware loading over SPI. It’s neat, but unfortunately doesn’t mean you can boot from a standard flash SD card.

PLUG: I’m now selling the esp8266 SD card board above on my shop. My hope is to eventually progress this toward a consumer product which runs an access point and provides basic collaboration tools.