TFFS format to the creation successful process
True FFS kernel programming 1. Formatting FLASH can be formatted even if FLASH is not bound to a block device driver.
tffsDevFormat (int tffsDriveNo, int formatArg);typedef struct{ tffsFormatParams formatParams; unsigned formatFlags;} tffsDevFormatParams;
2. Create Boot Image region 2.1 create Boot Image region, and enable the TFFS segment to start from a certain offset by formatting flash.
Struct {long int bootImageLen; // the size of the Boot Image to be retained. unsigned percentUse; unsigned noOfSpareUnits; unsigned long vmAddressingLimit; int (* progressCallback ); char * volumeLabel; unsigned noOfFATcopies; unsigned embeddedCISlength; char * embeddedCIS;} tffsFormatParams; STATUS effecffsformat (void) {STATUS status STATUS; tffsDevFormatParams params ={# define HALF_FORMAT/* lower 0.5 MB for bootimage, upper 1.5 MB for TFFS */# ifdef HALF_FORMAT {0x80000l, 99, 1, 0x0000l, NULL, {0, 0, 0, 0}, NULL, 2, 0, NULL}, # else {0x000000l, 99, 1, 0x0000l, NULL, {0, 0, 0}, NULL, 2, 0, NULL }, # endif/* HALF_FORMAT */FTL_FORMAT_IF_NEEDED};/* we assume that the drive number 0 is RF */status = tffsDevFormat (0, (int) & params ); return (status );}
2.2 write Boot Image to FLASH using the function tffsBootImagePut (). This function depends on tffsRawio (), so it cannot be used after the TFFS volume is loaded. TffsBootImagePut () can directly operate any area of FLASH. Function Definition:
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 function usrTffsConfig () loads the dosFile File System to the TFFS Flash drive.
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 Command Format flash, but keep the Boot Image area. -> Using ffsformat to load fadmedium as the drive 0-> usrTffsConfig, "/TPD /"