• 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

  • 相关阅读:
    Android 禁用以及捕捉home键
    android中正确导入第三方jar包
    使用SharedPreferences进行数据存储
    tomcat不安全因素
    spring边边角角
    宏定义
    C++变量对比java变量所占内存
    结构指针的分析
    对结构使用指针
    什么是程序文件?
  • 原文地址:https://www.cnblogs.com/gongxing/p/4943181.html
Copyright © 2020-2023  润新知