Published:2011/8/3 21:32:00 Author:Phyllis From:SeekIC
for removable mass storage devices
By Mark Schultz
Till now USB has been available only on personal computers, leaving large, untapped potential in the area of embedded systems. New embedded host controllers from Cypress herald a new era.
An embedded system is defined as hardware and firmware — either stand-alone or part of a larger system — usually with some sort of operating system. The operating system can be Windows CE, VxWorks or a more simple system consisting of ‘home made’ code. Using the above definition, it can be said that any electronic device that has a processor has the potential to be an embedded USB host.
Designs that incorporate a USB Host controller have a distinct advantage over traditional designs in the sense that they can now host any type of USB device. The obvious advantage here is that storage space for a design can be dynamically added or removed at any time. Consider the case of an MP-3 player that contains a USB Host. MP-3 files can be easily downloaded via a USB flash drive or any other media that includes USB support. Many other types of applications should be able to realize similar performance with the addition of a Host USB solution, such as the ability to perform field upgrades or download critical data to a non-networked system. Existing solutions for expansion of embedded systems usually involve a laptop or some other type of portable computing device connected to the embedded system via a serial cable. Although this is a simple and effective solution, it requires the extra PC and additional cabling. Additionally, there could be problems associated with the use of legacy ports.
Typically, a PC is a USB host. Anything else containing USB is a peripheral. As an example, take the case of a digital camera. A digital camera has traditionally been a USB peripheral. To print an image to a USB based printer, a PC is first used to upload the images from the camera to the PC and then to download them to a printer. If the digital camera had USB host capabilities, it could download the images directly to the printer.
Of course, such functionality comes with a price. A USB Host is responsible for a number of tasks including enumeration of devices, task scheduling and bandwidth allocation. Fortunately, there will be a code framework that will handle these tasks for us.
This article will outline some of the basics required for interfacing a USB Host controller to a removable mass storage device. A short primer on the use of SCSI commands and how they relate to file systems will be presented as well as a quick overview of the FAT file system. This will be followed by a design example.
Mass storage basics
Communication via the USB interface uses SCSI commands embedded inside a UFI Packet. A file system is a logical structure used to track various parameters of the storage media.
FAT File System
This design will support the File Allocation Table (FAT) type of file system. In the FAT file system, there is a table that contains a number corresponding to each section or cluster on the disk. It will be necessary to use the File Allocation table to locate the individual clusters within a file since they may not all be contiguous. There are other types of file systems such as NTFS (NT File System) and UFS (Unix File System) that will not be supported by this design.
Our file system will be logically represented by a data structure called a volume. A volume contains information about the location of the File Allocation Table (FAT), roof directory, and a data area that is subdivided into sectors and clusters.
All mass storage devices contain a boot record. Aside from containing code that can be used for bootstrapping the device, this area also contains other useful information about the device that can be used to fill in the volume information. There is also a partition record for each useable partition on the device. We will use this later on as well.
The basic outline of the file system is shown in Figure 1. There are a number of distinct areas on a mass storage device beside just the directory and data area. The partition information begins at offset 1BE^ of the first physical sector on the drive. After this sector, there are a number of reserved sectors, followed by the actual file allocation table. The FAT operates on groups of sectors called clusters. The FAT contains information about the physical clusters on the drive such as whether they are available to be written to and where the next cluster in the file is located. There are actually two copies of the FAT per drive for redundancy purposes. The root directory is 51 2 entries long in a FAT16 system with each entry occupying 32 bytes. Thus the total root directory takes up 32 sectors.
After that is the data area containing files and subdirectories. The start of the data area is said to be at cluster number 2, although in reality it is actually more than 512 sectors from the beginning of the drive. Table 1 shows the volume information for one particular USB flash device: The beginning of the actual data is 235JJ sectors from the beginning of the drive. The area before this contains the partition record, boot record, two copies of the FAT, and the root directory. This information will be used later on to locate files on the drive.
Reprinted Url Of This Article: http://www.seekic.com/blog/project_solutions/2011/08/03/USB_EMBEDDED_HOST_CONTROLLER__(1).html
Print this Page | Comments | Reading(770)
Author:Ecco Reading(33516)
Author:Ecco Reading(3534)
Author:Ecco Reading(3250)
Author:Ecco Reading(3816)
Author:Ecco Reading(5341)
Author:Ecco Reading(3318)
Author:Ecco Reading(3474)
Author:Ecco Reading(3620)
Author:Ecco Reading(4017)
Author:Ecco Reading(3819)
Author:Ecco Reading(3760)
Author:Ecco Reading(3790)
Author:Ecco Reading(6103)
Author:Ecco Reading(3778)
Author:Ecco Reading(4587)