AU平台SD0无法自动安装的解决方法

 

//========================================================================
//TITLE:
//    AU平台SD0无法自动安装的解决方法

//AUTHOR:
//    soloman

//DATE:
//    Saturday  28-02-2012

//Environment: WCE6.0+AU1380
//    NONE
//========================================================================

如上图所示,加入了SD卡的驱动后,SD1可以找到盘符,而SD0却找不到,但在控制面板的Storage Manager中可以看到SD0。

把BSP编为DEBUG后,打印信息如下

StoreDisk_t::MountStore: Opened the store "DSK1:" hStore=0xD7C792A0

FSDMGR!StoreDisk_t::MountStore: Geometry: NumSec=15097856 BytesPerSec=512 FreeSec=0 BiggestCreatable=0

终于找到了源码:E:\WINCE600\PRIVATE\WINCEOS\COREOS\STORAGE\FSDMGR\storedisk.cpp (注释部分是我加进去的)

DWORD StoreDisk_t::MountStore(HANDLE hStore, BOOL bMount)
{
    DWORD dwError = ERROR_GEN_FAILURE;
    BOOL bFormat = FALSE;

    // We have a handle to this store.
    m_hStore = hStore;

 DEBUGMSG(ZONE_INIT, (L"^^^^^^FSDMGR!StoreDisk_t::+MountStore:bMount = %d\r\n",
  bMount));
    if(ERROR_SUCCESS == (dwError = OpenDisk())) {
        if (GetStoreSettings()) {
            m_pPartDriver = new PartitionDriver_t();
            if (!m_pPartDriver) {
                return ERROR_OUTOFMEMORY;
            }
            if (ERROR_SUCCESS == (dwError = m_pPartDriver->LoadPartitionDriver(m_szPartDriver)))
   {
    DEBUGMSG(ZONE_INIT, (L"^^^^^^FSDMGR!StoreDisk_t::MountStore:LoadPartitionDriver success\r\n"));
#ifdef UNDER_CE
                dwError = m_pPartDriver->OpenStore( m_hDisk, &m_dwStoreId );
#else
                // Pass the store handle rather than the disk handle to the partition driver
                // so it will trap back into STG_DeviceIoControl when calling DeviceIoControl.
                dwError = m_pPartDriver->OpenStore( m_hStore, &m_dwStoreId );
#endif
                if (ERROR_DEVICE_NOT_PARTITIONED == dwError)
    {
     DEBUGMSG(ZONE_INIT, (L"^^^^^^FSDMGR!StoreDisk_t::MountStore:OpenStore not_partitioned\r\n"));
                    if (m_dwStoreId)
                        m_pPartDriver->CloseStore( m_dwStoreId);
                    delete m_pPartDriver;
                    VERIFY( SUCCEEDED(::StringCchCopyW ( m_szPartDriver, MAX_PATH, L"")));
                    m_pPartDriver = new PartitionDriver_t();
                    if (!m_pPartDriver) {
                        return ERROR_OUTOFMEMORY;
                    }
                    dwError = m_pPartDriver->LoadPartitionDriver(m_szPartDriver);
                    if (ERROR_SUCCESS == dwError)
     {
                        dwError = m_pPartDriver->OpenStore( m_hDisk, &m_dwStoreId );
                    }
                }
                if (ERROR_SUCCESS == dwError)
    {
                    // Activity Timer Setup
                    if ((STORE_FLAG_ACTIVITYTIMER & m_dwFlags) && wcslen( m_szActivityName))
     {
                        m_hActivityEvent = CreateEvent( NULL, FALSE, FALSE, m_szActivityName);
                        // there is really nothing we can do if event creation fails
                        DEBUGCHK(m_hActivityEvent);
                    }
                    DEBUGMSG(ZONE_INIT, (L"FSDMGR!StoreDisk_t::MountStore: Opened the store \"%s\" hStore=0x%08X\r\n",
                        m_szDeviceName, m_dwStoreId)); --------------------------------------------------------------------------------------------------.//打印信息
                    m_si.cbSize = sizeof(PD_STOREINFO);
                    m_pPartDriver->GetStoreInfo( m_dwStoreId, &m_si);
                    DEBUGMSG(ZONE_INIT, (L"FSDMGR!StoreDisk_t::MountStore: Geometry: NumSec=%ld BytesPerSec=%ld FreeSec=%ld BiggestCreatable=%ld\r\n",
                        (DWORD)m_si.snNumSectors, (DWORD)m_si.dwBytesPerSector, (DWORD)m_si.snFreeSectors,
                        (DWORD)m_si.snBiggestPartCreatable)); ----------------------------------------------------------------------------------------// 打印信息
                    if (ERROR_SUCCESS != m_pPartDriver->IsStoreFormatted(m_dwStoreId))          //在第一次启动时,SD卡是还没格式化
                  {
                         DEBUGMSG(ZONE_INIT, (L"^^^^^^FSDMGR!StoreDisk_t:: IsStoreFormatted failed\r\n"));
                        if (m_dwFlags & STORE_ATTRIBUTE_AUTOFORMAT)                                          // "AutoFormat"=dword:1决定

                      {
                            // TODO: Check for failure
       DEBUGMSG(ZONE_INIT, (L"^^^^^^FSDMGR!StoreDisk_t:: is autoformat\r\n"));
                            m_pPartDriver->FormatStore(m_dwStoreId);
                            m_pPartDriver->GetStoreInfo( m_dwStoreId, &m_si);
                        }
                    }
                    if (ERROR_SUCCESS == m_pPartDriver->IsStoreFormatted(m_dwStoreId))
     {
      DEBUGMSG(ZONE_INIT, (L"^^^^^^FSDMGR!StoreDisk_t:: try again\r\n"));
      // Retry again if we formatted it
                        GetPartitionCount();
                        if (!m_dwPartCount)
      {
                            if (m_dwFlags & STORE_ATTRIBUTE_AUTOPART)                 // "AutoPart"=dword:1决定
       {
        DEBUGMSG(ZONE_INIT, (L"^^^^^^FSDMGR!StoreDisk_t:: autopart\r\n"));
                                PD_STOREINFO si;
                                si.cbSize = sizeof(PD_STOREINFO);
                                m_pPartDriver->GetStoreInfo(m_dwStoreId, &si);
                                if ( (ERROR_SUCCESS == m_pPartDriver->CreatePartition(m_dwStoreId, L"PART00", 0, si.snBiggestPartCreatable, TRUE)) &&
                                     (ERROR_SUCCESS == m_pPartDriver->FormatPartition(m_dwStoreId, L"PART00", 0, TRUE)))
        {
                                        m_pPartDriver->GetStoreInfo( m_dwStoreId, &m_si);
                                        DEBUGMSG( 1, (L"FSDMGR!StoreDisk_t::MountStore: Geometry: NumSec=%ld BytesPerSec=%ld FreeSec=%ld BiggestCreatable=%ld\r\n",
                                            (DWORD)m_si.snNumSectors, (DWORD)m_si.dwBytesPerSector,
                                            (DWORD)m_si.snFreeSectors, (DWORD)m_si.snBiggestPartCreatable));
                                        m_dwPartCount = 1;
                                        bFormat = TRUE;
                                }
                            }
                        }
                        LoadExistingPartitions(bMount, bFormat);
                    }
                    m_dwFlags |= STORE_FLAG_MOUNTED;
                    if (m_pBlockDevice) {
                        m_pBlockDevice->AdvertiseInterface(m_szDeviceName, TRUE);
                    }
                }
            }
        }
    }
    return dwError;
}

=================================================

于是在注册表中加入

; 这样SD0就能自动格式化和自动安装了
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles]
"AutoPart"=dword:1
    "AutoFormat"=dword:1

 

 

================================================

^-^==

哈哈,终于可以自动mount了,且也不用格式化了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值