//========================================================================
//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;
}
=================================================
于是在注册表中加入
================================================
^-^==
哈哈,终于可以自动mount了,且也不用格式化了