The FunKey game console uses the SD Card both as its boot device and its only storage device, so a good operation of this interface is absolutely mandatory.
The Allwinner V3s provides 2x 4-bit MMC / SD Card / SDIO interfaces. In the FunKey, only interface #0 is used.
If you look on the Web, you will find many contradictory SD Card interface designs, with a combination of pull-up / pull-down resistors, ESD devices and power supply filtering, with all pins wired or not, such that it is very difficult to know what is really required. To better understand the situation, we need to go back to the specifications.
The SD Card physical interface is provided in the “SD specifications, part 1, Physical Layer Specification version 2.00, May 9, 2006”, for which a simplified version is available here.
The MMC phyiscal interface can be found in the “Multi Media Card System Specification version 4.3, JESD84-A43, November 2007”, available here (registration required).
But a good summary of the requirements is given in the “AN10911 SD(HC)-memory card and MMC Interface conditioning” application note from NXP, from which this schematic is taken:
Note: This schematic does not include details concerning card-supply and typical power-supply decoupling capacitors.
Write Protect (WP)
A write protect mechanical switch is provided in the full-size SD Card, but not in the mini or micro SD Card form factor. As we plan to use a micro SD Card only, it is not used for the FunKey, along with its pull-up resistor and ESD protection.
Card Detection (CD)
As the SD Card is required to boot the FunKey, is always inserted and opening the device is requried for its removal, we don’t need the optional card detect mechanical switch feature (even if the chosen connector provides it) and its related pull-up resistor and ESD protection.
The SD Card specification provides another mean to detect the card using a card built-in pull-up resistor on its DAT3 signal, that can be later disconnected during normal operation using he SET_CLR_CARD_DETECT (ACMD42) command. In order to correctly detect if the card is inserted, a high value external pull-down resistor (> 270 kohms) is required to drive the detect signal low when no card is inserted, while the card built-in 10-50 kohms resistor will drive this signal high when inserted.
However, this feature is not compatible with MMC cards, so its usage should be avoided and the mechanical detection is preferred.
Both the SD Card and MMC specifications require not to leave the interface signals floating, except for the CLK signal, where a pull resistor would cause significant signal distortion because of the required high speed and short rise/fall times. OTOH, it is recommended to add a series resistor on this CLK signal as close as possible to the clock source (the CPU) to avoid ringing, as we already discussed it in the log about the CPU.
Hopefully, the Allwinner V3s CPU provides internal pull-up resistors for all these signals, so we don’t have to add external pull-up resistors. These resistors are given with a typical value of 100 kohms (50 min, 150 max). Unfortunately, the CMD signal for MMC card features an open-drain output mode, and its value should be undercut (down to 4.7 kohms) to guarantee a sufficiently short rise time in this mode.
The FunKey SD Card interface schematic is the following:
Even if in the FunKey device the SD Card and its connector are not accessible without opening the enclosure, there may be some situations where the user may decide to do so. We thus attach an ESD protection TVS diode (D16, D17, D18, D25, D26, D27, D28) on each signal to avoid any ESD hazard.
As discussed above, a single pull-up resistor R10 is used on the CMD signal for MMC compatibility.
The micro SD Card connector built-in card detection switch is not used, since the card must always be inserted for the FunKey to boot, and the corresponding pins are thus connected to GND.
The SD Card power supply is done through an RC low-pass filter to provide a soft-start operation, as the card built-in large bulk capacitor on its power rail may collapse the supply voltage when initially powered up.