This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM3517 - How to auto mount/unmount sd-card in android?

Other Parts Discussed in Thread: AM3517

Hi, I'm not good at English.

I am using TI_Android_GingerBread_2_3_4Sources android stack for am3517 based custom board. 

1) Insert SD-CARD
2) Booting custom board.
==> SD-CARD mounted at /part-1  (/mnt/sdcard is same directory? I can't understand..., Anyway It's OK.)

# mount
rootfs / rootfs rw 0 0 192.168.0.3:/home/skyzeal/targetfs-android / nfs rw,relatime,vers=3,rsize=1024,wsize=1024,namlen=255,hard,nolock, proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.3,mountvers=3,mountproto=tcp,local_lock=all,addr=192.16 8.0.3 0 0
tmpfs /dev tmpfs rw,relatime,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0 /dev/block/mmcblk0p1 /part-1 vfat rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso 8859-1,shortname=mixed,errors=remount-ro 0 0
/dev/block/vold/179:1 /mnt/sdcard vfat rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,cod epage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
/dev/block/vold/179:1 /mnt/secure/asec vfat rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=002 2,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0 tmpfs /mnt/sdcard/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0

 

1. When I remove SD-CARD from custom board after boot, SD-CARD not unmounted.
  1.1) Insert SD-CARD
  1.2) Booting Custom board.
  1.3) Remove SD-CARD  ==> Not unmounted. I want to unmount automatically. not unsing input command(unmount) via serial.

2. Booting SD-CARD after remove SD-CARD, and insert SD-CARD after boot ==> SD-CARD not mounted.
  2.1) Remove SD-CARD
  2.2) Booting Custom board
  2.3) Insert SD-CARD ==> Not mounted. I want to mount automatically. not unsing input command(mount) via serial.

How to mount/unmount sd-card automatically in android ?

 

 

  • Kim,

    Can you check the kernel logs when the card is inserted and removed? Is kernel able to detect the card insertion/removal? 

  • Hi, Thomas
    Thank you for your advice. My custom board MMC1_D5(SD Card detect) pin was short-circuit.
    So, Now kernel can detect SD Card insertion or removal


    Here is my sequence.

    SD Card Insertion -> Android Setting -> Storage -> Mount SD Card  // Mounted. OK
    Android Setting -> Storage -> Unmount SD Card -> SD Card Removal //OK.
    SD Card Insertion -> Android Setting -> Storage -> Mount SD Card -> SD Card Removal

    ==> Now Storage settings menu didn't updated (Mount SD card or Unmount SD card - ListView didn't updated - disabled.)
    Could you advice for this case ?

    Here is kernel log when I remove SD card and insert SD card.

    # mmc_sd_detect(mmc0): Unable to re-detect card (-110)
    mmc0: card aaaa removed
    FAT: Directory bread(block 5914) failed
    FAT: Directory bread(block 5915) failed
    FAT: Directory bread(block 5916) failed
    .......
    FAT: Directory bread(block 5917) failed
    FAT: Directory bread(block 5918) failed

    # mmc0: mmc_rescan: trying to init card at 400000 Hz
    mmc0: new high speed SD card at address aaaa
    mmcblk0: mmc0:aaaa SD02G 1.84 GiB (ro)
    mmcblk0: p1 p2 p3

  • Kim,

    Is kernel able to detect card removal properly? If so, the driver should be checking for the card whether its inserted or not before issuing a command. Can you check this again? If possible, can you attach complete logs? 

    I'm not really sure why the Android framework is not handling detection properly. 

  • Hi, Thomas.

    Here is Kernel log and logcat log. (sd-card insertion and removal)

    1665.log.zip

  • Kim,

    Basically card insertion is handled by the kernel properly and removal is not detected properly. Can you insert a print inside the kernel's card detection/removal interrupt handler and see the output? If possible can you share the code, so that it will be easier to debug. 

  • Hi, Thomas,
    Thanks you for your reply.

    Now, SD-Card mount/unmount works well automatically.
    I checked my custom board agian, and chaned kernel configuration and init.rc, vold.fstab file.

    1. Kernel configuraiton
      1.1) Device Drivers  ---> MMC/SD/SDIO card support  --->
            ==> deselect: [ ]   Assume MMC/SD cards are non-removable (DANGEROUS) 
            ==> select:     [*]   Enable paranoid SD card initialization (EXPERIMENTAL)
    2. init.rc
       2.1) comment part-3
            ==> #    mkdir /part-3 
                   #    mount vfat /dev/block/mmcblk0p3 /part-3/

    3. system/etc/vold.fstab
       3.1) changed mtd3 to mtd1 (I need only 1 partion SD card)
           ==> dev_mount sdcard /mnt/sdcard 1 /devices/platform/mmci-omap-hs.0/mmc_host/mmc0
      

  • Hai Kim

    Are you familiar in linux kim?I am also had that same automount issue in my custom board that is derived from Beagleboard xm.

    Currently i'm using Linux OS for my board.In my external mmc card i had that issue.

    I use card detect pin for that mmc card to connect the PMIC's GPIO via pull-up resistor.

    I'm waiting for ur reply. Thanks

  • Hi Jae-Hyun Kim,

    Thank you for posting the clear solution after you have solved your issue.

    Regards,

    Naresh