OpenVINOTM,给你看得见的未来!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » TFFS for DiskOnChip 2000 / VxWorks(老站转)

共1条 1/1 1 跳转至

TFFS for DiskOnChip 2000 / VxWorks(老站转)

菜鸟
2002-06-01 00:33:00    评分
TrueFFS(R) for M-Systems DiskOnChip 2000 / VxWorks(R). -------------------------------------------------------- 1. The object module FLITE2.O contains the True Flash File System (R) driver for VxWorks(R) operating system. This library supports M-Systems' DiskOnChip 2000. This object module should be added to your linking process either statically or dynamically. One possible way to this is to copy FLITE2.O to Tornado/target/lib directory and add it to existing VxWorks I80486 object library: ar386 -cru libI80486gnuvx.a flite2.o 2. To use the driver two routines must be called by user program: - tffsDrv() to initialize the driver. Before using the driver, it must be initialized by calling this routine exactly once. Normally, it is called from usrRoot. - tffsDevCreate() to create device. Before a flash device can be used, it must be created by issuing tffsDevCreate() call. This routine takes two parameters: flash_drive_number - usually zero (i.e. first flash drive) removable_media_flag - must be zero (i.e. non-removable) Once the device has been created, it must be associated with a name and a file system (dosFs). This is accomplished using the file system's device initialization routine e.g., dosFsDevInit(). The tffsDevCreate() call returns a pointer to a block device structure (BLK_DEV). This structure contains fields that describe the physical properties of a disk device and specify the addresses of routines within the driver. The BLK_DEV structure address must be passed to the file system (dosFs) via the file system's device initialization routine. Only then is a name and file system associated with the device, making it available for use. The following example shows how to create the device named "TFFSDEV0" representing DiskOnChip 2000. step 1: Initialize the TFFS driver. tffsDrv(); step 2: Create block flash device. BLK_DEV *pBlkDev0 = tffsDevCreate (0,0);, step 3: Assigned the name "TFFSDEV0" to newly created device and associate it for use with dosFs. DOS_VOL_DESC *pVolDesc0 = dosFsDevInit ("TFFSDEV0:", pBlkDev0, NULL); 3. To format the flash disk with DOS FAT format use tffsDevFormat() routine. The following example shows how to do this: #include "fldrvvxw.h" /* format request packet sent to tffsDevFormat() routine */ static tffsDevFormatParams formatInfo = TFFS_STD_FORMAT_PARAMS; /* kind of format, FLDRVVXW.H contains additional information */ /* about formatting parameters */ formatInfo.formatFlags = FTL_FORMAT; /* optional user defined function for format progress reporting; */ /* if none set this field to NULL */ formatInfo.formatParams.progressCallback = formatProgress; /* format call, tffsDriveNo is 0 */ int formatResult = tffsDevFormat(0, (int) (&formatInfo)); The above mentioned formatProgress() routine may look something like this: static int formatProgress(int unitsToErase, int unitsErasedSoFar) { printf("Formatting in progress: %%%ld complete\r", (long) unitsErasedSoFar * 100 / unitsToErase); return OK; } 4. The file FLDRVVXW.H contains tffsDrv(), tffsDevCreate() and tffsDevFormat() functions prototypes and formatting parameter definitions. 5. Booting VxWorks from DiskOnChip 2000. You will need the following files: - DFORMAT utility from M-Systems standard utility set for DOS - DOC105.EXB file (or whatever .EXB file is available from M-Systems standard utility set for DOS) - VXSYS standard VxWorks utility - VxWorks bootimage file (BOOTROM.SYS) Here is a procedure for booting VxWorks from DiskOnChip 2000: step 1. Boot MS-DOS on the target board step 2. Use DFORMAT to re-format DiskOnChip 2000: DFORMAT /WIN=xxxx /S=DOC105.EXB /FIRST /Y /WIN=xxxx specifies DiskOnChip 2000 memory window segment, for example /WIN=D000 step 3. Boot MS-DOS on the target board and check that DiskOnChip 2000 has installed itself at drive letter C: dir C: step 4. Run WindRiver's utility VXSYS: VXSYS C: to copy VxWorks boot sector to the DiskOnChip 2000. step 5. Copy your BOOTROM.SYS to the root directory of DiskOnChip 2000. Now DiskOnChip 2000 is ready to boot VxWorks. There are three basic VxWorks boot scenarios supported by DiskOnChip 2000 which are briefly described below: A. Network boot. In this case DiskOnChip 2000-resident bootfile BOOTROM.SYS acts as a secondary program loader and uses network connection to bring the application from the remote host. This scenario is usually used on application development stage for cross debugging of applications of any size. B. One step standalone boot. In this case DiskOnChip 2000-resident bootfile BOOTROM.SYS includes the application itself. This scenario is used for small applications which could fit entirely in 640K of low memory. C. Two steps standalone boot. In this case DiskOnChip 2000-resident bootfile BOOTROM.SYS acts as a secondary program loader which loads the application from the DiskOnChip 2000. This scenario is used for middle and large size applications. Boot scenarios 'A' and 'B' are supported by DiskOnChip 2000 in straightforward fashion, there is no need to do any changes in VxWorks boot code. Boot scenario 'C' requires some minimal changes to be done to the following VxWorks files: - BSP configuration .H file (i.e. /target/config/pc486/config.h in case of pc486 BSP) - /target/config/all/bootConfig.c - /target/config/all/usrConfig.c Here is a precise list of changes needed by boot scenario 'C'. You could simply copy code sections below to the specified places in VxWorks files. 5.1. BSP configuration .H file (i.e. target/config/pc486/config.h in case of pc486 BSP). Please add the following line: #define INCLUDE_TFFS /* M-SYSTEMS TFFS */ 5.2. BSP configuration .H file (i.e. target/config/pc486/config.h in case of pc486 BSP). Please change #define DEFAULT_BOOT_LINE as follows: #define DEFAULT_BOOT_LINE \ "tffs=0,0(0,0)host:/tffs0/vxWorks h=90.0.0.3 e=90.0.0.50 u=target" 5.3. File /target/config/all/bootConfig.c Code section under #define INCLUDE_TFFS must be added just before the routine usrInit() as shown below: #ifdef INCLUDE_TFFS #ifdef __cplusplus extern "C" { #endif #ifndef _ASMLANGUAGE #include "blkIo.h" #if defined(__STDC__) || defined(__cplusplus) extern STATUS tffsDrv (void); extern BLK_DEV * tffsDevCreate (int tffsDriveNo, int removableMediaFlag); #else /* __STDC__ */ extern STATUS tffsDrv (); extern BLK_DEV * tffsDevCreate (); #endif /* __STDC__ */ #endif /* _ASMLANGUAGE */ #ifdef __cplusplus } #endif /* forward declarations */ #ifdef __STDC__ void devSplit (char *fullFileName, char *devName); #else void devSplit (); #endif /* __STDC__ */ extern unsigned noOfDrives; STATUS usrTffsConfig ( int drive, /* drive number of TFFS */ int removable, /* 0 - nonremovable flash media */ char * fileName /* mount point */ ) { BLK_DEV * pBootDev; char bootDir [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 ((pBootDev = tffsDevCreate (drive, removable)) == NULL) { printErr ("tffsDevCreate failed.\n"); return (ERROR); } /* split off boot device from boot file */ devSplit (fileName, bootDir); /* initialize the boot block device as a dosFs device named */ if (dosFsDevInit (bootDir, pBootDev, NULL) == NULL) { printErr ("dosFsDevInit failed.\n"); return (ERROR); } return (OK); } LOCAL STATUS tffsLoad ( int drive, /* TFFS drive number (0 - (noOfDrives-1)) */ int removable, /* 0 - nonremovable flash media */ char * fileName, /* file name to download */ FUNCPTR * pEntry ) { int fd; if (tffsDrv () != OK) { printErr ("Could not initialize.\n"); return (ERROR); } printf ("Attaching to TFFS... "); dosFsInit (NUM_DOSFS_FILES); /* initialize DOS-FS */ if (usrTffsConfig (drive, removable, fileName) == ERROR) { printErr ("usrTffsConfig failed.\n"); return (ERROR); } printErr ("done.\n"); /* load the boot file */ printErr ("Loading %s...", fileName); if ((fd = open (fileName, O_RDONLY, 0)) == ERROR) { printErr ("\nCannot open \"%s\".\n", fileName); return (ERROR); } if (bootLoadModule (fd, pEntry) != OK) goto tffsLoadErr; close (fd); return (OK); tffsLoadErr: printErr ("\nerror loading file: status = 0x%x.\n", errnoGet ()); close (fd); return (ERROR); } #endif /* INCLUDE_TFFS */ 5.4. File /target/config/all/bootConfig.c Code section under #define INCLUDE_TFFS must be added to helpMsg[] in the routine bootHelp() as shown below: #ifdef INCLUDE_FD "boot device: fd=drive,fdType file name: /fd0/vxWorks","", #endif /* INCLUDE_FD */ #ifdef INCLUDE_IDE "boot device: ide=drive,configType file name: /ide0/vxWorks","", #endif /* INCLUDE_IDE */ #ifdef INCLUDE_ATA "boot device: ata=ctrl,drive file name: /ata0/vxWorks","", #endif /* INCLUDE_ATA */ #ifdef INCLUDE_PCMCIA "boot device: pcmcia=sock file name: /pcmcia0/vxWorks","", #endif /* INCLUDE_PCMCIA */ #ifdef INCLUDE_TFFS "boot device: tffs=drive,removable file name: /tffs0/vxWorks","", #endif /* INCLUDE_TFFS */ "Boot flags:", "", 5.5. File /target/config/all/bootConfig.c. Code section under #define INCLUDE_TFFS must be added to routine bootHelp() as shown below: #ifdef INCLUDE_FD printf (" fd"); #endif /* INCLUDE_FD */ #ifdef INCLUDE_IDE printf (" ide"); #endif /* INCLUDE_IDE */ #ifdef INCLUDE_ATA printf (" ata"); #endif /* INCLUDE_ATA */ #ifdef INCLUDE_TFFS */ printf (" tffs"); #endif /* INCLUDE_TFFS */ printf ("\n"); } 5.6. File /target/config/all/bootConfig.c. Code section under #define INCLUDE_TFFS must be added to routine bootLoad() as shown below: #ifdef INCLUDE_FD if (strncmp (params.bootDev, "fd", 2) == 0) { int type = 0; int drive = 0; if (strlen (params.bootDev) == 2) return (ERROR); else sscanf (params.bootDev, "%*2s%*c%d%*c%d", &drive, &type); if (fdLoad (drive, type, params.bootFile, pEntry) != OK) { printErr ("\nError loading file: errno = 0x%x.\n", errno); return (ERROR); } return (OK); } #endif /* INCLUDE_FD */ #ifdef INCLUDE_IDE if (strncmp (params.bootDev, "ide", 3) == 0) { int type = 0; int drive = 0; if (strlen (params.bootDev) == 3) return (ERROR); else sscanf (params.bootDev, "%*3s%*c%d%*c%d", &drive, &type); if (ideLoad (drive, type, params.bootFile, pEntry) != OK) { printErr ("\nError loading file: errno = 0x%x.\n", errno); return (ERROR); } return (OK); } #endif /* INCLUDE_IDE */ #ifdef INCLUDE_ATA if (strncmp (params.bootDev, "ata", 3) == 0) { int ctrl = 0; int drive = 0; if (strlen (params.bootDev) == 3) return (ERROR); else sscanf (params.bootDev, "%*3s%*c%d%*c%d", &ctrl, &drive); if (ataLoad (ctrl, drive, params.bootFile, pEntry) != OK) { printErr ("\nError loading file: errno = 0x%x.\n", errno); return (ERROR); } return (OK); } #endif /* INCLUDE_ATA */ #ifdef INCLUDE_PCMCIA pcmciaInit (); /* init PCMCIA Lib */ if (strncmp (params.bootDev, "pcmcia", 6) == 0) { int sock = NONE; if (strlen (params.bootDev) == 6) return (ERROR); else sscanf (params.bootDev, "%*6s%*c%d", &sock); if (pcmciaLoad (sock, params.bootFile, pEntry) == OK) return (OK); /* fall through if the PC card is not a block device. * let's try to boot it from an ethernet device. */ } #endif /* INCLUDE_PCMCIA */ #ifdef INCLUDE_TFFS if (strncmp (params.bootDev, "tffs", 4) == 0) { int drive = 0; int removable = 0; if (strlen (params.bootDev) == 4) return (ERROR); else sscanf (params.bootDev, "%*4s%*c%d%*c%d", &drive, &removable); if (tffsLoad (drive, removable, params.bootFile, pEntry) != OK) { printErr ("\nError loading file: errno = 0x%x.\n", errno); return (ERROR); } return (OK); } #endif /* INCLUDE_TFFS */ 5.7. File /target/config/all/bootConfig.c. Please add #define INCLUDE_TFFS as shown below: #if (defined (INCLUDE_SCSI_BOOT) || defined (INCLUDE_FD) || \ defined (INCLUDE_IDE) || defined (INCLUDE_ATA) || \ defined (INCLUDE_TFFS)) 5.8. File /target/config/all/usrConfig.c Code section under #define INCLUDE_TFFS must be added just before the routine usrRoot() as shown below: #ifdef INCLUDE_TFFS #ifdef __cplusplus extern "C" { #endif #ifndef _ASMLANGUAGE #if defined(__STDC__) || defined(__cplusplus) extern STATUS tffsDrv (void); #else /* __STDC__ */ extern STATUS tffsDrv (); #endif /* __STDC__ */ #endif /* _ASMLANGUAGE */ #ifdef __cplusplus } #endif 5.9. File /target/config/all/usrConfig.c Code section under #define INCLUDE_TFFS must be added to the routine usrRoot() as shown below: #ifdef INCLUDE_FD fdDrv (FD_INT_VEC, FD_INT_LVL); /* initialize floppy disk driver */ #endif /* INCLUDE_FD */ #ifdef INCLUDE_IDE ideDrv (IDE_INT_VEC, IDE_INT_LVL, IDE_CONFIG); /* init IDE disk driver */ #endif /* INCLUDE_IDE */ #ifdef INCLUDE_ATA { /* initialize hard disk driver */ IMPORT ATA_RESOURCE ataResources[]; ATA_RESOURCE *pAtaResource; for (ix = 0; ix < ATA_MAX_CTRLS; ix++) { pAtaResource = &ataResources[ix]; if (pAtaResource->ctrlType == IDE_LOCAL) ataDrv (ix, pAtaResource->drives, pAtaResource->intVector, pAtaResource->intLevel, pAtaResource->configType, pAtaResource->semTimeout, pAtaResource->wdgTimeout); } } #ifdef INCLUDE_SHOW_ROUTINES ataShowInit (); /* install ATA/IDE show routine */ #endif /* INCLUDE_SHOW_ROUTINES */ #endif /* INCLUDE_ATA */ #ifdef INCLUDE_LPT { IMPORT LPT_RESOURCE lptResources[]; lptDrv (LPT_CHANNELS, &lptResources[0]); /* init LPT parallel driver */ } #endif /* INCLUDE_LPT */ #ifdef INCLUDE_PCMCIA #ifdef INCLUDE_SHOW_ROUTINES pcmciaShowInit (); /* install PCMCIA show routines */ #endif /* INCLUDE_SHOW_ROUTINES */ pcmciaInit (); /* init PCMCIA Lib */ #endif /* INCLUDE_PCMCIA */ #ifdef INCLUDE_TFFS tffsDrv (); #endif /* INCLUDE_TFFS */ #ifdef INCLUDE_FORMATTED_IO fioLibInit (); /* initialize formatted I/O */ #endif /* INCLUDE_FORMATTED_IO */



关键词: DiskOnChip     VxWorks     老站转     ta    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]