Question

Some phones carry a SD card and can read/write files on it. If the phone is connected to a computer and placed in mass storage mode, the computer can also read/write files on the SD card as if it's a USB drive. So my question is, how can the computer access a peripheral that belongs to another device (the phone)?

To my understanding, there should be a physical switch in the phone that routes the data buses of the SD card to either the bus of the phone or the micro-USB port? Then there's also a driver that controls this switch? If so, where's such driver (in Android OS or iOS for examples)? If not, what's the mechanism to share this SD card?

Note that I'm not talking about MTP, but the mass storage class. I know that the phone and computer may not be able to access the SD card simultaneously - probably one at a time, depending on the status of USB connection. I'm interested in the mechanism to control/switch the access/connection to the SD card from two hosts.

Comments: The similar mechanism may be found in a mp3 player: when it's plugged into the computer, we can add/remove musics. The mp3 player cannot play musics until it's unplugged from the computer - at least mine is like this. Android OS should do the same but I can't find the related source codes.

Was it helpful?

Solution

To my understanding, there should be a physical switch

No, the switch is in the software.

what's the mechanism to share this SD card?

A piece of the software does the umount of the sdcard and connects it as a USB Mass storage device to the PC - like a card reader would do.

The Linux kernel itself contains a driver that works as a USB mass storage device, but I don't know whether Android actually uses this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top