星空网 > 软件开发 > 操作系统

TFFS格式化到创建成功过程

True FFS内核编程

1、格式化FLASH

即使FLASH没有和块设备驱动绑定,也可对其进行格式化。

tffsDevFormat (int tffsDriveNo, int formatArg);

typedef struct

{

  tffsFormatParams formatParams;

  unsigned formatFlags;

} tffsDevFormatParams;

2、创建Boot Image区域
2.1 创建Boot Image区域

创建Boot Image区域,通过在格式化flash,使TFFS段从某个偏移的位置开始。

tffsFormatParams

typedef struct {

  long int bootImageLen; //保留给Boot Image空间大小

  unsigned percentUse;

  unsigned noOfSpareUnits;

  unsigned long vmAddressingLimit;

  int (*progressCallback)(int totalUnitsToFormat, int totalUnitsFormattedSoFar);

  char * volumeLabel;

  unsigned noOfFATcopies;

  unsigned embeddedCISlength;

  char * embeddedCIS;

} tffsFormatParams;

STATUS sysTffsFormat (void)

{

  STATUS status;

  tffsDevFormatParams params =

  {

#define HALF_FORMAT /* lower 0.5MB for bootimage, upper 1.5MB for TFFS */

#ifdef HALF_FORMAT

  {0x80000l, 99, 1, 0x10000l, NULL, {0,0,0,0}, NULL, 2, 0, NULL},

  #else

  {0x000000l, 99, 1, 0x10000l, NULL, {0,0,0,0}, NULL, 2, 0, NULL},

  #endif /* HALF_FORMAT */

  FTL_FORMAT_IF_NEEDED

};

  /* we assume that the drive number 0 is RFA */

  status = tffsDevFormat (0, (int)&params);

  return (status);

}

2.2 写Boot Image到FLASH

采用函数tffsBootImagePut()实现,该函数依赖tffsRawio(),所以不能在TFFS卷装载以后使用。

TffsBootImagePut()能直接操作FLASH的任何区域。

函数定义:

STATUS tffsBootImagePut

(

  int driveNo, /* TFFS drive number */

  int offset, /* offset in the flash chip/card */

  char * filename /* binary format of the bootimage */

)

3 mounting the driver

函数usrTffsConfig()把dosFile文件系统加载到TFFS Flash驱动上。

STATUS usrTffsConfig

(

  int drive, /* drive number of TFFS */

  int removable, /* 0 for nonremovable flash media */

  char * fileName /* mount point */

)

STATUS usrTffsConfig ( int drive, int removable, char * fileName )

{

int dosFsCacheSizeDefault = 128 * 1024 ;

CBIO_DEV_ID pCbio;

BLK_DEV * pBlkDev;

char devName [BOOT_FILE_LEN];

if ((UINT)drive >= noOfDrives) {

printErr ("drive is out of range (0-%d)./n", noOfDrives - 1);

return (ERROR);

}

/* create a block device spanning entire disk (non-distructive!) */

if ((pBlkDev = tffsDevCreate (drive, removable)) == NULL) {

printErr ("tffsDevCreate failed./n");

return (ERROR);

}

/* split off boot device from boot file */

devSplit (fileName, devName);

 

 

/* initialize the block device as a dosFs device named */

/* Create e.g. 128 Kbytes disk cache */

if ( (pCbio = dcacheDevCreate( (CBIO_DEV_ID) pBlkDev, NULL,

 

 

dosFsCacheSizeDefault, devName)) == NULL )

return (ERROR);

if (dosFsDevCreate (devName, pCbio, 0, NONE) != OK)

return (ERROR);

return (OK);

}

4 TFFS SHELL命令

格式化flash,但保留Boot Image区域。

-> sysTffsFormat

加载RFA medium做为驱动0

-> usrTffsConfig 0,0,"/RFA/"

 

转自:http://m.blog.csdn.net/blog/da895/6033647

 




原标题:TFFS格式化到创建成功过程

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流