3

I followed this thread to enable ALT-3 on GPIO 22-27 to be used with a SDIO device.

Using raspbian jessie with kernel 4.1 on a Raspi 2 I enabled the sdio-overlay in the /boot/config.txt. The systems boots normally but it seems to not find any sdio-device.

I'm not surprised that it doesn't work - it is missing the card-detect-pin.

Normally this pin is telling the host-controller that a new device has been connected and it makes the host-controller-driver enumerate the device.

Does anyone know how to simulate/enable the SD-CARD-DETECT signal when using the secondary SD(IO)-interface on the raspi?

4
  • No idea. The Pi kernel tries to read the SD card once a second to see if it is inserted or not. I suppose you will have to do something similar.
    – joan
    Commented Nov 18, 2015 at 15:05
  • That would be the SDHOST-controller which checks for a device every second. And if I'm lucky it does this even on the secondary SD-port
    – Patrick B.
    Commented Nov 18, 2015 at 15:09
  • I checked with an oscilloscope. I can see activity on CMD and CLOCK during boot-up. But nothing afterwards.
    – Patrick B.
    Commented Nov 18, 2015 at 16:05
  • @joan I think your comment could be the answer to my question.
    – Patrick B.
    Commented Nov 20, 2015 at 8:11

2 Answers 2

3

I'm looking in to your question now. This is what I found so far. It is not yet a complete answer, but it is far too long for a comment, so here it is.

The physical SD card slot on the Raspberry Pi is connected to GPIO pins 48 to 53. I dumped the status of these GPIO pins and determined that in normal use, these GPIOs are set to ALT3. The functions of these pins are completely undocumented.

The device tree overlay switches the function of these pins to ALT0, which is also undocumented. It also switches pins 22 to 27 to ALT3, which is documented as being SD1.

Now from the forum thread we read this:

SDIO is supported by the mmc (SD1) driver. In order to use SD1 for SDIO, you'll need to use SD0 (sdhost) for booting, as SD1 is currently being used for this. Phil has written a device tree overlay which does this.

Based on this we can infer that the default function ALT3 on GPIO 48-53 (card slot) connects those pins to SD1 (eMMC). ALT0 connects those pins to SD0 (sdhost). This frees up SD1 to be connected to GPIO 22-27 for SDIO purposes. Interestingly, GPIO 22-27 has an undocumented ALT0 function. Perhaps this connects those pins to SD0 (sdhost)?

Now the detect pin. According to the available schematics, card detect is on GPIO 47. This GPIO is not altered by the overlay, which means it will still presumably deliver any input to SD1, which is now controlling your SDIO card, as long as you have a microSD card inserted as well. So SD1 should still think there is a card inserted, because there is.

This raises the question of how SD0, now controlling the card slot, is able to detect the card. Since you are still able to boot, this suggests that the card detect signal is not really very important to the functioning of the system.

Further evidence for this comes from my dump. In normal use, this pin is set as an output, which means it isn't actually going to do anything. It is possible that the state may change if I eject the micro SD card. I can't really test that for obvious reasons.

A little more reading of the device trees and it turns out GPIO 47 is also the GPIO which controls the SD card activity LED, which explains why it's normally an output.

2
  • Thanks for your answer. Having no card-detect is no problem, when you have the sdhost doing some polling. Which it does not with the current delivered sdio-overlay.dtb.
    – Patrick B.
    Commented Nov 20, 2015 at 8:09
  • Right now, I'm facing another issue. The cmd and data0-lines seems to suffer from a conflict of some sort. When a transaction (the very first enumeration) is starting, there are no zeroes. Everything is stuck to 1.
    – Patrick B.
    Commented Nov 20, 2015 at 8:10
1

Here is what's missing:

SMI - Secondary Memory Interface - Extracted chapter from BCM2835 datasheet. Originally omitted from the BCM2835 peripheral spec as the SMI could not work with the 26 pin header from the old Raspberry-Pi boards. (PDF) https://lovedoc.org/secondary-memory-interface-for-the-raspberry-pi-family

Includes "When the bus is idle these pins will (all) be driven high."

RASPBERRY PI GPIO PIN ALTERNATE FUNCTIONS - Part of Raspberry Pi Projects For Dummies Cheat Sheet (BOOK) https://www.dummies.com/computers/raspberry-pi/raspberry-pi-gpio-pin-alternate-functions/

A complete list of all 5 ALT GPIO pins. Note the reserved ALT2 pinouts are the DPI ones mentioned here.

Adding a secondary sd card on Raspberry PI - There are two often talked about methods for mounting a second SD card on the Raspberry PI, these are using the SDIO controller and the SPI interface. I can confirm on kernal 4.4.y both of these methods are usable and can be enabled using the device trees. (WWW) https://ralimtek.com/raspberry_pi_secondary_sd_card/

Has a section on armv6 version chips, what is needed for new kernel, and where the devices show up (/dev/mmcblk*).

And lastly @joan comment is still true, and the way it is officially dont on RPi, poll sdcard contents 1x per second.

EDIT: You might find this useful, especially for debugging: https://github.com/Terminus-IMRC/raspi-smi-util

Confirm GPIO pin values here: https://pinout.xyz/pinout/sdio and https://pinout.xyz/pinout/spi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.