基于全志A20 android4.2平台如何支持三个SD卡

来源:互联网 发布:淘宝纯银首饰 编辑:程序博客网 时间:2024/05/22 00:26


 

         做过android平台的同仁大多都知道android原生态只支持了一个sd卡,默认的挂载点也就是/mnt/sdcard,所以在应用中使用getExternalStorageDirectory()得到的都是/mnt/sdcard,通常会symlink 到/sdcard目录。做过全志平台的童鞋也知道全志android SDK支持2sd卡,通常是一个内置的,一个外置的,内置的一般是从nand上或者emmc上的用户数据区,因为现在的nandemmc容量都比较大,存放android程序、cachebackupdownload等之外,还有大量的空间剩余,因此这部分大多都会做成一个sd卡来使用,通常挂载到/mnt/sdcard上;外置的是挂载在/mnt/extsd节点上。但是,如何在全志平台上使用三个sd卡呢?即再增加一个外置的SD卡支持。

      为了多支持一个SD卡,我们有以下基本需要做:

      1、          在系统配置文件里,打开对应的SD卡驱动支持,设置好检测方式,如果是gpio方式的要配置好gpio引脚;笔者测试过,如果两个外置的SD卡,都使用gpio polling的方式,系统只识别一个SD卡,笔者把两个SD卡一个配置成gpio polling,另外一个配置成了GPIO IRQ中断模式;

[plain] view plaincopyprint?
  1. [mmc0_para]  
  2. sdc_used            = 1  
  3. sdc_detmode         = 2  
  4. sdc_buswidth        = 4  
  5. sdc_clk             = port:PF02<2><1><2><default>  
  6. sdc_cmd             = port:PF03<2><1><2><default>  
  7. sdc_d0              = port:PF01<2><1><2><default>  
  8. sdc_d1              = port:PF00<2><1><2><default>  
  9. sdc_d2              = port:PF05<2><1><2><default>  
  10. sdc_d3              = port:PF04<2><1><2><default>  
  11. sdc_det             = port:PH3<6><1><default><default>  
  12. sdc_use_wp          = 0  
  13. sdc_wp              =  
  14. sdc_isio            = 0  
  15. sdc_regulator       = "none"  
  16.   
  17. [mmc1_para]  
  18. sdc_used            = 1  
  19. sdc_detmode         = 1  
  20. sdc_buswidth        = 4  
  21. sdc_clk             = port:PH23<5><1><2><default>  
  22. sdc_cmd             = port:PH22<5><1><2><default>  
  23. sdc_d0                   = port:PH24<5><1><2><default>  
  24. sdc_d1                   = port:PH25<5><1><2><default>  
  25. sdc_d2                   = port:PH26<5><1><2><default>  
  26. sdc_d3                   = port:PH27<5><1><2><default>  
  27. sdc_det                  = port:PH2<0><1><default><default>  
  28. sdc_use_wp          = 0  
  29. sdc_wp              =  
  30. sdc_isio            = 0  
  31. sdc_regulator       = "none"  

     2、          vold.fstab里,需要修改一下,如下:

[plain] view plaincopyprint?
  1. ## Vold 2.0 fstab for HTC Passion  
  2. #  
  3. ## - San Mehat (san@android.com)  
  4. ##   
  5. #######################  
  6. ## Regular device mount  
  7. ##  
  8. ## Format: dev_mount <label> <mount_point> <part> <sysfs_path1...>   
  9. ## label        - Label for the volume  
  10. ## mount_point  - Where the volume will be mounted  
  11. ## part         - Partition # (1 based), or 'auto' for first usable partition.  
  12. ## <sysfs_path> - List of sysfs paths to source devices  
  13. ######################  
  14.   
  15. # Mounts the first usable partition of the specified device  
  16. #/devices/platform/awsmc.3/mmc_host for sdio  
  17. dev_mount   sdcard  /mnt/sdcard auto    /devices/virtual/block/nandk    /devices/platform/sunxi-mmc.2/mmc_host  
  18. dev_mount   extsd   /mnt/extsd  auto    /devices/platform/sunxi-mmc.1/mmc_host  
  19. dev_mount   extsd2  /mnt/extsd2 auto    /devices/platform/sunxi-mmc.0/mmc_host  
  20. dev_mount   usbhost1    /mnt/usbhost1   auto    /devices/platform/sw-ehci.1 /devices/platform/sw_hcd_host0  /devices/platform/sw-ohci.1  

这三个SD卡挂载点都是可以随便交换的;

3、          如果完成了上面两步,extsd2对应的SD卡热插拔是可以自动挂载,如果是开机启动前就在sd卡槽里面的话,就不会自动识别,因此我们得明确告诉系统storage配置,配置在storage_list.xml文件中,如下:

[html] view plaincopyprint?
  1.          <storage android:mountPoint="/mnt/extsd"  
  2.   
  3.              android:storageDescription="extsd"  
  4.   
  5.              android:primary="false"  
  6.   
  7.              android:removable="true"  
  8.   
  9.              android:emulated="false"    
  10.   
  11.              android:mtpReserve="0"   
  12.   
  13.              android:allowMassStorage="true"  
  14.   
  15.              android:maxFileSize="0"/>  
  16.    

4、          system/vold下面做一些处理,类似extsd处理,加上即可,如下:

[plain] view plaincopyprint?
  1. diff --git a/DirectVolume.cpp b/DirectVolume.cpp  
  2. index 16ac2d8..43ce612 100755  
  3. --- a/DirectVolume.cpp  
  4. +++ b/DirectVolume.cpp  
  5. @@ -346,7 +346,7 @@ void DirectVolume::handlePartitionRemoved(const char *devpath, NetlinkEvent *evt  
  6.           * Yikes, our mounted partition is going away!  
  7.           */  
  8.    
  9. -        if(!strstr(getLabel(),"usb")&&!strstr(getLabel(),"extsd")){  
  10. +        if(!strstr(getLabel(),"usb")&&!strstr(getLabel(),"extsd")&&!strstr(getLabel(),"extsd2")){  
  11.          snprintf(msg, sizeof(msg), "Volume %s %s bad removal (%d:%d)",  
  12.                   getLabel(), getMountpoint(), major, minor);  
  13.          mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeBadRemoval,  
  14. diff --git a/Volume.cpp b/Volume.cpp  
  15. old mode 100644  
  16. new mode 100755  
  17. index 23556ea..a1f059a  
  18. --- a/Volume.cpp  
  19. +++ b/Volume.cpp  
  20. @@ -864,7 +864,7 @@ int Volume::unmountVol(bool force, bool revert) {  
  21.      setState(Volume::State_Unmounting);  
  22.      usleep(1000 * 1000); // Give the framework some time to react  
  23.    
  24. -    if(getMountpoint()!=NULL&&!strstr(getMountpoint(),"usb")&&!strstr(getMountpoint(),"extsd")){  
  25. +    if(getMountpoint()!=NULL&&!strstr(getMountpoint(),"usb")&&!strstr(getMountpoint(),"extsd")&&!strstr(getMountpoint(),"extsd2")){  
  26.          /*  
  27.           * Remove the bindmount we were using to keep a reference to  
  28.           * the previously obscured directory.  

 

     完成了以上几步,三个SD卡已经可以自动识别挂载了,mount的信息如下:

[plain] view plaincopyprint?
  1. root@android:/ # mount  
  2.   
  3. rootfs / rootfs rw 0 0  
  4. tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0  
  5. devpts /dev/pts devpts rw,relatime,mode=600 0 0  
  6. proc /proc proc rw,relatime 0 0  
  7. sysfs /sys sysfs rw,relatime 0 0  
  8. debugfs /sys/kernel/debug debugfs rw,relatime 0 0  
  9. none /acct cgroup rw,relatime,cpuacct 0 0  
  10. tmpfs /mnt/secure tmpfs rw,relatime,mode=700 0 0  
  11. tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0  
  12. tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0  
  13. none /dev/cpuctl cgroup rw,relatime,cpu 0 0  
  14. /dev/block/nandd /system ext4 rw,nodev,noatime,nobarrier,data=ordered 0 0  
  15. /dev/block/nande /data ext4 rw,nosuid,nodev,noatime,journal_checksum,nobarrier,noauto_da_alloc,data=ordered 0 0  
  16. /dev/block/nandh /cache ext4 rw,nosuid,nodev,noatime,journal_checksum,nobarrier,noauto_da_alloc,data=ordered 0 0  
  17. /dev/block/vold/179:16 /mnt/extsd vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1023,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 0  
  18. /dev/block/vold/179:0 /mnt/extsd2 vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1023,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 0  
  19. /dev/block/vold/93:80 /mnt/sdcard vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 0  
  20. /dev/block/vold/93:80 /mnt/secure/asec vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 0  
  21. tmpfs /mnt/sdcard/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0  
  22. root@android:/ #   
0 0
原创粉丝点击