Nandflash 驱动移植
在飞凌提供的BSP中,Nandflash采用的是FMD+PDD的结构,PDD主要是应对上层的接口,这里我们不需要修改,直接修改FMD就好。(至于在网上看到很多人说这个结构理论上不支持MLC的Nandflash,这个暂且不说).
FMD部分的驱动源码在 C:\WINCE600\PLATFORM\SMDK6410\src\common\nandflash\FMD\ 这个目录下边。
FMD的目录结构:
nand.s
cfnand.h
fmd_LB.h(实际并没用到)
fmd_SB.h(实际并没用到)
nand.h
fmd.cpp
sources
makefile
先看sources文件:
[cpp]
!if 0
Copyright (c) Microsoft Corporation. All rights reserved.
!endif
!if 0
Use of this sample source code is subject to the terms of the Microsoft
license agreement under which you licensed this sample source code. If
you did not accept the terms of the license agreement, you are not
authorized to use this sample source code. For the terms of the license,
please see the license agreement between you and Microsoft or, if applicable,
see the LICENSE.RTF on your install media or the root of your tools installation.
THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
!endif
!IF 0
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
!ENDIF
TARGETNAME=nandflash_lib11
TARGETTYPE=LIBRARY
RELEASETYPE=PLATFORM
SYNCHRONIZE_BLOCK=1
WINCEOEM=1
WINCECPU=1
NOMIPS16CODE=1
ADEFINES=-pd "_TGTCPU SETS \"$(_TGTCPU)\"" $(ADEFINES)
LDEFINES=-subsystem:native /DEBUG /DEBUGTYPE:CV /FIXED:NO
INCLUDES=$(INCLUDES)
SOURCES=\
fmd.cpp
ARM_SOURCES=\
nand.s
这个代码是飞凌提供的,且看这一句 TARGETNAME=nandflash_lib11,经查实,FMD+PDD使用的是FMD产生的nandflash_lib.lib库文件,而不是nandflash_lib11.lib文件,这也说明飞凌在这方面留了一手,并没有直接提供可用的源码,而是给了一个lib库给我们。
在这里,我们需要把 TARGETNAME=nandflash_lib11 修改为 TARGETNAME=nandflash_lib
cfnand.h文件:
[cpp]
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 2001 Microsoft Corporation
Module Name: S3C6410.H
Abstract: FLASH Media Driver Inte易做图ce Samsung S3C6410 CPU with NAND Flash
controller.
Environment: As noted, this media driver works on behalf of the FAL to directly
access the underlying FLASH hardware. Consquently, this module
needs to be linked with FLASHFAL.LIB to produce the device driver
named FLASHDRV.DLL.
-----------------------------------------------------------------------------*/
#ifndef _S3C6410_CFNAND_H
#define _S3C6410_CFNAND_H
#include "FMD_LB.h"
#include "FMD_SB.h"
#include "nand.h"
#define BW_X08 (0)
#define BW_X16 (1)
#define BW_X32 (2)
#define MAX_SECTORS_PER_PAGE (8)
/*****************************************************************************/
/* S3C6410 Nand Flash Internal Data Structure Definition */
/*****************************************************************************/
typedef struct
{
UINT16 nMID; /* Manufacturer ID */
UINT16 nDID; /* Device ID */
UINT16 nNumOfBlks; /* Number of Blocks */
UINT16 nPgsPerBlk; /* Number of Pages per block */
UINT16 nSctsPerPg; /* Number of Sectors per page */
UINT16 nNumOfPlanes; /* Number of Planes */
UINT16 nBlksInRsv; /* The Number of Blocks in Reservior for Bad Blocks */
UINT8 nBadPos; /* BadBlock Information Poisition*/
UINT8 nLsnPos; /* LSN Position */
UINT8 nECCPos; /* ECC Policy : HW_ECC, SW_ECC */
UINT16 nBWidth; /* Nand Organization X8 or X16 */
UINT16 nTrTime; /* Typical Read Op Time */
&nb
补充:软件开发 , C++ ,