码迷,mamicode.com
首页 > 其他好文 > 详细

TFFS格式化到创建成功过程

时间:2015-11-06 18:06:12      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:

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格式化到创建成功过程

标签:

原文地址:http://www.cnblogs.com/gongxing/p/4943181.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!