简体   繁体   中英

How do I control an sd card reader using spidev

I've got a Samsung RF711 Core i7 laptop running Debian Wheezy with an integrated usb Multi Flash Reader, but this question could apply to any system with an sd card reader on an usb port. Here's what lsusb says

Bus 004 Device 004: ID 058f:6366 Alcor Micro Corp. Multi Flash Reader

I want to use an old sd card and solder some wires onto it to allow it to communicate with a PIC via SPI when I plug it into the sd card port.

I'm aware that the sd card voltages are 3.3v and that a voltage level converter would be needed to interface with a 5v SPI device.

I compiled a custom kernel to produce the spidev kernel module, now what? I know it's something to do with udev rules, usb_modeswitch? but I can't see the wood for the trees.

Ideally the solution would be a program, let's call it sdcard-spi. When the program starts it flips the drivers and creates an spidev device in /dev. When it quits it restores the slot functionality to be able to read sdcards once more. It could be a daemon process - starting it converts the slot, stopping it converts the slot back to being an sd card reader.

It seems like something the writers of spidev could easily do, as sd cards are initially probed in SPI mode.

Just to be clear, I want to open the sd card reader in SPI mode, so no card is detected and I can do SPI communication using an spidev device node, say /dev/spidev.0.

You cannot do this by writing a linux driver.

You would have to rewrite the firmware of the card reader. There's a synchronous serial interface inside the card reader, but the interface between card reader and Linux computer is not a general purpose serial interface, but a USB mass-storage device.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM