Friday, November 5, 2010

SD Card Boot Sequence on Android Platform

When you are porting Android, one important feature to check is SD card mount.

Needless to say this feature is needed for many functions to operate in correctly.

Couple of such examples are Bluetooth OPP and FTP profiles.

SD card boot up sequence is as follows :

mmc/sd driver recognises the inserted card, makes device object for every partitions

with unique combination of MAJOR:MINOR numbers and generate uevent.

uevent comes to user-level via kernel socket NETLINK_KOBJECT_UEVENT.

vold handles this uevent in uevent.c::handle_block_event().

vold reads boot sector to determine, how many partitions remains on storage.

If all partitions are found, vold will start "mount" procedure.

If mount is successfully finished, vold sends "volume_mounted:/sdcard" to

com.android.server.MountListener.

com.android.server.MountListener dispatches message to

com.android.server.MountService by handleEvent() method.

com.android.server.MountService provides to framework the logical interpretation of

vold actions such as update icon notification and forwards command from user to vold.

So, in our case MountService::notifyMediaMounted() will generate

Intent.ACTION_MEDIA_MOUNTED.

This intent will start com.android.providers.media.MediaScanner which will start

searching the media content and makes the database. Parallely

com.android.settings.deviceinfo.Memory will update memory status.

Some important files to remember for SD card boot sequence are mmc.c,

ums.c vold.c, voldmgr.c, uevent.c. These files will be useful in debugging SD card

boot up sequence. The configuration file of SD card is vold.conf and is present in

/etc.

1 comment:

  1. Do you know of a way to get the SDcard to mount before the actual launcher loads, on Android? It seems that alot of times the launcher will load before the sdcard does.

    ReplyDelete