2440/2416/6410/S5PV210之wince+android系统驱动开发者

等待新发生的事情

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

2440 6.0BSP移植过程之nand flash驱动

//-----------------------------------------------------------------------------------------------------------

// 作者:wogoyixikexie@gliet

//论坛账号:gooogleman (经常在CSDN出没)

// 版权:桂林电子科技大学一系科协wogoyixikexie@gliet

// 平台:wince5.0 2440 5.0 BSP

// 发布日期:2009年6月18日

// 最后修改:

// 注意事项:未经作者同意,不得在转载的时候擅自修改、删除文章的任何部分

//-----------------------------------------------------------------------------------------------------------


作者:wogoyixikexie@gliet(注意转载请标明原创作者)

下面是nand flash驱动, 我想配置成TFAT格式,但是启动的时候产生了异常,wince6.0 顺利启动了系统,可是flash盘符没有出现。
; HIVE BOOT SECTION
IF BSP_NONANDFS !
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\SMFLASH]
    ;"DefaultFileSystem"="BINFS"
 "DefaultFileSystem"="FATFS"
    "AutoPart"=dword:1
    "AutoMount"=dword:1
 "AutoFormat"=dword:1           ;because didn't use eboot
    "PartitionDriver"="mspart.dll"
    "Name"="Microsoft Flash Disk"
    "Folder"="NandFlash"
    "BootPhase"=dword:0
 "Flags"=dword:1000             ; copy from yl2440 5.0BSP

; Keep FATFS from trying to shadow \Windows
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\SMFLASH\FATFS]
    "Flags"=dword:14
    "FormatTfat"=dword:1
    "CheckForFormat"=dword:1
 ;---copy from yl2440 5.0BSP
    ;"FriendlyName"="FAT FileSystem"
 ;"Dll"="fatfsd.dll"
 ;"Flags"=dword:00280014
 ;"Paging"=dword:1
 ;"CacheSize"=dword:0
 ;"EnableCacheWarm"=dword:0
 ;"EnableCache"=dword:1
 ;"MountFlags"=dword:2
   
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\SMFLASH]
    "Prefix"="DSK"
    "Dll"="smflash.dll"
    "Index"=dword:1
    "Order"=dword:0
    "Profile"="SMFLASH"
    "IClass"="{A4E7EDDA-E575-4252-9D6B-4195D48BB865}"


[HKEY_LOCAL_MACHINE\System\StorageManager\FATFS]
    "Flags"=dword:00000014  ;FATFS_TFAT_ALWAYS|FATFS_FORCE_TFAT
     "MountFlags"=dword:0
    
[HKEY_LOCAL_MACHINE\System\StorageManager\AutoLoad\SMFLASH]
    "DriverPath"="Drivers\\BuiltIn\\SMFLASH"
    "LoadFlags"=dword:1      ;load synchronously
    ;"LoadFlags"=dword:1
    ;"BootPhase"=dword:0
 "MountFlags"=dword:11
 "BootPhase"=dword:1
 "Flags"=dword:1000

ENDIF ; BSP_NONANDFS
; END HIVE BOOT SECTION

启动时候的异常
Windows CE Kernel for ARM (Thumb Enabled) Built on Nov 24 2008 at 14:58:01
DCache: 8 sets, 64 ways, 32 line size, 16384 size
ICache: 8 sets, 64 ways, 32 line size, 16384 size
Exception 'Prefetch Abort' (3): Thread-Id=005c0002(pth=98ccb264), Proc-Id=00400002(pprc=809b8308) 'NK.EXE', VM-active=00400002(pprc=809b8308) 'NK.EXE'
PC=00000000(???+0x00000000) RA=c0662ad0(smflash.dll+0x00002ad0) SP=d00bf0f8, BVA=00000000
Exception 'Raised Exception' (-1): Thread-Id=005c0002(pth=98ccb264), Proc-Id=00400002(pprc=809b8308) 'NK.EXE', VM-active=00400002(pprc=809b8308) 'NK.EXE'
PC=c0038ddc(k.coredll.dll+0x00018ddc) RA=802384c8(kernel.dll+0x000064c8) SP=d00be974, BVA=ffffffff

什么原因造成的呢? 这个真的很难判断。

后来找到了驱动开发网zhengshijie牛人给的答案
我想你肯定会遇到这个问题,
最终系统生成,下载运行,产生异常,指示是smflash.dll->falmain.cpp
FMD.pInit((LPTSTR)dwContext,NULL,NULL)
查看falmain.cpp代码,知道它要调用GetFMDInterface()
FMD_OEMIoControl (IOCTL_FMD_GET_INTERFACE, NULL, 0, (PBYTE)&FMD, sizeof(FMDInterface), NULL)
即要求我的fmd.cpp->FMD_OEMIoControl提供对IOCTL_FMD_GET_INTERFACE的处理,
修改fmd.cpp
BOOL FMD_OEMIoControl(DWORD dwIoControlCode, PBYTE pInBuf, DWORD nInBufSize, PBYTE pOutBuf, DWORD nOutBufSize, PDWORD pBytesReturned)
{
    switch(dwIoControlCode)
    {
    case IOCTL_FMD_GET_INTERFACE:
    {
        if (!pOutBuf || nOutBufSize < sizeof(FMDInterface))
        {
            DEBUGMSG(1, (TEXT("FMD_OEMIoControl: IOCTL_FMD_GET_INTERFACE bad parameter(s).\r\n")));
            return(FALSE);
        }   

        PFMDInterface pInterface = (PFMDInterface)pOutBuf;
        pInterface->cbSize = sizeof(FMDInterface);
        pInterface->pInit = FMD_Init;
        pInterface->pDeInit = FMD_Deinit;
        pInterface->pGetInfo = FMD_GetInfo;       
        pInterface->pGetInfoEx = NULL;//FMD_GetInfoEx;
        pInterface->pGetBlockStatus = FMD_GetBlockStatus;   
        pInterface->pSetBlockStatus = FMD_SetBlockStatus;
        pInterface->pReadSector = FMD_ReadSector;
        pInterface->pWriteSector = FMD_WriteSector;
        pInterface->pEraseBlock = FMD_EraseBlock;
        pInterface->pPowerUp = FMD_PowerUp;
        pInterface->pPowerDown = FMD_PowerDown;
        pInterface->pGetPhysSectorAddr = NULL;           

        break;
    }
    default:
        break;
        }
    return(TRUE);
}
通过看wince600/private/winceos/drivers/msflash/src/falmain.cpp->
DSK_Init()->GetFMDInterface(pDevice);
    FMD_OEMIoControl (IOCTL_FMD_GET_INTERFACE, NULL, 0, (PBYTE)&FMD, sizeof(FMDInterface), NULL)
要么实现IOCTL_FMD_GET_INTERFACE的操作,要么FMD_OEMIoControl()函数返回FALSE;
试试先。

哈哈,果然可以了!
Windows CE Kernel for ARM (Thumb Enabled) Built on Nov 24 2008 at 14:58:01
DCache: 8 sets, 64 ways, 32 line size, 16384 size
ICache: 8 sets, 64 ways, 32 line size, 16384 size
FMD: ReadID (Mfg=ec, Dev=dc)
FMD_Init: finished successful
IsBlockBad(C9E): TRUE
IsBlockBad(C9E): TRUE
HW_USBClocks::D0
s3c2440disp: display instance '<NULL>', num monitors 1

posted on 2010-11-05 10:14  gooogleman  阅读(338)  评论(0编辑  收藏  举报