Home |
The ISO 9660 File System Structure The exFAT File System Structure RTFiles-32 in Embedded Applications MTD Drivers RTFMtdCFI2_x |
MTD Drivers RTFMtdCFI2_xThe RTFMtdCFI2_... MTD drivers for the linear flash disk driver RTFDrvFlash supports flash chips with the following characteristics:
1, 2, or 4 8-bit flash chips can be operated in parallel to form an 8, 16, or 32 bit wide flash bank. 1 or 2 16-bit flash chips can be operated in parallel to form a 16 or 32 bit wide flash bank. Any number of contiguous, identical flash banks can be used by each driver to form flash disks of arbitrary size. The following table shows which driver handles which flash bank configuration.
All five drivers share the same data type RTFMtdCFI2Data for their device data: typedef struct { const char * RegionName; // Name of memory entity DWORD ReservedBlocks; // Erase blocks not to use DWORD EraseTimeout, // milliseconds EraseDelay; // ditto DWORD BlockSize, // size of one erase unit BlocksPerBank, // erase units per bank BankSize, // address space of one bank BankOffset, // offset of usable flash within bank ... } RTFMtdCFI2Data; All fields may be initialized to zero for the driver's default behavior. RTFMtdCFI2Data.RegionName can be set to the name of a Nothing entity declared in the program's configuration file. If no RegionName (NULL) is specified, the name "FlashDisk" is assumed. The drivers determine the address and number of banks from the "FlashDisk" Nothing entity. RTFMtdCFI2Data.ReservedBlocks is the number of erase blocks at the end of the flash disk which shall not be used. Such reserved blocks can be used as a boot device. However, no code can be executed from such a boot device while the flash disk is being written to. RTFMtdCFI2Data.EraseTimeout and RTFMtdCFI2Data.EraseDelay specify after how many milliseconds the driver should abort a block erase operation, or respectively wait until the block erase status is polled. If zero is specified, RTFMtdCFI2Data.EraseTimeout is set to the value found in the CFI data structure (typically 10-15 seconds). The default value for RTFMtdCFI2Data.EraseDelay is half of the typical erase time given in the CFI data (typically 0.5 seconds). If values RTFMtdCFI2Data.BlockSize, RTFMtdCFI2Data.BlocksPerBank, RTFMtdCFI2Data.BankSize, and RTFMtdCFI2Data.BankOffset are all zero, the driver will determine these values from the CFI data published by the flash chips. This only works with chips which accurately publish all of their regions in ascending address space order in their CFI data. If the driver finds flash chips with erase block regions of varying block sizes, only the erase block region with the largest number of blocks is used. For flash chips with inappropriate CFI data, the application must supply all of these fields. RTFMtdCFI2Data.BlockSize specifies the size in bytes of one erase unit. For example, if 2 8-bit flash chips are used in parallel to form a 16-bit flash bank, and each has an erase unit size of 64k, this value must be set to 128k. RTFMtdCFI2Data.BlocksPerBank specifies the number of erase units in each bank available for the flash disk. RTFMtdCFI2Data.ReservedBlocks should not be subtracted. This value specifies the physical properties of the flash region used. RTFMtdCFI2Data.BankSize specifies the size in bytes of a complete bank. This value is used to calculate the address of the second, third, etc bank. RTFMtdCFI2Data.BankOffset is the offset in bytes from a bank's start address where the flash memory available to the flash disk begins. ExampleThe AMD Élan SC520 Evaluation Board is equipped with eight AM29LV017D flash chips (2MBits, 8 bits wide each), which satisfy the characteristics specified above. The chips are organized in two banks with four chips in each 32-bit wide bank. The AM29LV017D publishes accurate CFI data, so the driver can determine the flash topology automatically. The SC520 demos initialize these two flash banks to reside at addresses 30000000h and 30800000h in configuration file Sc520ini.cfg. The hardware declaration configuration file Sc520.cfg declares a region for the flash memory: Region Flash 1G-256M 16M Device The FlashDemo program's configuration file locates the required Nothing entity named "FlashDisk" into this flash region: Locate Nothing FlashDisk Flash.Start Flash.Size The RTFiles-32 device list must include the linear flash disk driver, which in turn must reference a suitable MTD. This configuration requires the RTFMtdCFI2_32 MTD driver: #include <Rtfiles.h> // Custom RTFiles-32 Device List // We want a single flash disk device configured as a hard disk. // The Eval Board uses 4 chips 8 bits wide each to implement a 32-bit // wide device, so we use the RTFMtdCFI2_32 MTD driver. // MTD data static RTFMtdCFI2Data MTDData = {0}; // Flash driver data, links to MTD driver static RTFDrvFlashData FlashDisk = { &RTFMtdCFI2_32, &MTDData }; // Device List, pulls in flash driver RTFDevice RTFDeviceList[] = { { RTF_DEVICE_FDISK, 0, 0, &RTFDrvFlash, &FlashDisk }, { 0 } }; The complete FlashDemo example can be executed on the AMD Élan SC520 Evaluation Board and is included with RTFiles-32. ExampleA single Am29LV320DT flash chip in 16-bit mode is to be used as a flash disk. The Am29LV320DT has 32 megabits = 4 megabytes including a boot sector of 64k at the end of its address space. In its CFI data, the Am29LV320DT advertises one region of 8 erase blocks with 8k each followed by 63 erase blocks with 64k each. Unfortunately, the actual order of these two regions is not as given in the CFI data, so the flash topology has to be specified manually: #include <Rtfiles.h> // Custom RTFiles-32 Device List // We want a single flash disk device configured as a hard disk. // We have one 16-bit flash device with 63 blocks, 64k each. // The boot sector is not used. // MTD data static RTFMtdCFI2Data MTDData = { "MyFlashDisk", // RegionName, see config file below 0, // ReservedBlocks, use all blocks given in BlocksPerBank 0, // EraseTimeout, read from CFI data 0, // EraseDelay, read from CFI data 64*1024, // BlockSize, 64k per erase block 63, // BlocksPerBank, can't use the boot sector 64*64*1024, // BankSize, 4M, next bank starts here 0}; // BankOffset, first block is at offset zero in bank // Flash driver data, links to MTD driver static RTFDrvFlashData FlashDisk = { &RTFMtdCFI2_16_16, &MTDData }; // Device List, pulls in flash driver RTFDevice RTFDeviceList[] = { { RTF_DEVICE_FDISK, 0, 0, &RTFDrvFlash, &FlashDisk }, { 0 } }; In the configuration file(s), we would need: #define FLASH_ADDR <address of flash memory> Region Flash FLASH_ADDR 4M Device Locate Nothing MyFlashDisk Flash.Start Flash.Size
|