Operating the hard disk FAT32 File System Based on the Blackfin Processor

Source: Internet
Author: User
Tags what file system ide hard drive

Operating the hard disk FAT32 File System Based on the Blackfin Processor
[Date:] Source: Electronic Technology Application Author: Zhou binjing [Font:Large Medium Small]

 

Blackfin Processor is a new embedded processor designed to meet the computing requirements and power consumption constraints of embedded audio, video and communication applications. When Blackfin is used for audio and video processing, the storage and management of large data volumes of media data becomes a key issue. The most common solution for processing large-capacity data storage is the IDE hard disk. For file management, the FAT32 file system has high performance in the management of large-capacity file partitions, and can be identified in most operating systems, so it has high compatibility. Therefore, the IDE hard drive and FAT32 file system can be used as an ideal solution for managing large-capacity file storage in embedded systems. This article mainly describes the hardware and software implementation of this solution based on the Blackfin533 processor. The hardware part is the IDE interface expansion board designed based on the ADSP-BF533 EZKIT Lite evaluation board; the software part includes the IDE interface driver developed based on the Expansion board and VisualDSP ++ IDDE and FAT32 file system operating functions.
1. Principle of IDE Hard Drive
1.1 addressing of IDE Hard Disks

The storage structure 1 of the hard disk is shown in.

Its basic storage unit is called a Sector. There are two important components of a hard disk: Head and Cylinder. They constitute the addressing space of the hard disk. Their addresses are called physical addresses. Obviously, the physical address addressing method is not intuitive enough. Most hard disks now support another addressing method. The address is called the logical address (LBA), which sequentially numbers the sectors, you do not have to consider parameters such as C, H, and S. The Conversion Relationship Between LBA and C, H, and S is as follows:
= NH × NS × C + NS × H + S-1;
C = (LBA div NS) div NH;
H = (LBA div NS) mod NH;
S = (LBA mod NS) + 1
NH indicates the number of cores for each cylinder, NS indicates the number of slices for each track, and C indicates the number of cylinders [1].
1.2 Hard Drive boot Principle
The boot principle of Hard Disk partitioning 2 is shown in.

The first sector (0 cylinder, 0 head, 1 sector) of the hard disk is called the primary Boot Sector-MBR (Master Boot Record ). In MBR, the main content is the guiding code and the primary partition table. The primary Partition Table has only four Partition Table items. They can be used to describe partitions directly or [2] by extending the partition table.
This Bootstrap organization is completely unrelated to the file system. In each partition, you can install any file system as needed. But what file system should be used for recording in the response Partition Table item.
2 FAT32 File System Overview [2] [4]
2.1 FAT file system

The FAT (File Allocation Table) File system was released by Microsoft from the end of 1970s to the beginning of 1980s, supported by Microsoft's MS-DOS operating system. In the development process, three versions of FAT12, FAT16, and FAT32 emerged. The FAT12 file system was replaced by FAT16 for a long time due to some fatal disadvantages, FAT16 and FAT32 are still widely used. Table 1 compares the three file systems.

The principle of the FAT file system can be simply described as to map a bucket to a table in blocks, so as to flexibly control the bucket. Each block in a bucket is called a cluster, and the ing table of a bucket is called a FAT table. One obvious difference between the three FAT file systems is that the number of digits used by a cluster is different in the FAT table, which is 12, 16, and 32. File storage does not need to be continuous, but files can be linked together in the form of a linked list in the FAT table, as shown in 3.

Because the FAT file system currently supports most operating systems and is easy to implement, it is an ideal embedded system large-capacity storage file management solution.
2.2 FAT32 File System
As the efficiency of the FAT16 file system in the management of large-capacity partitions decreases sharply, the FAT32 file system solves this problem well. Therefore, FAT32 is an ideal file system for the management of large partitions.

The structure of the FAT32 file system continues the basic structure of the FAT file system, as shown in figure 4, which consists of the following three parts:
(1) DBR (Dos Boot Record), including jump command, vendor logo, OS version number, BPB (Bios Parameter Block), extension BPB, Boot program and terminator;
(2) FAT table: The ing table of the actual data storage space. FAT1 and FAT2 are exactly the same, and the latter is used as the backup of the former;
(3) actual data storage space, compared with FAT16, slave Cluster 2 does not have a dedicated root directory space, but treats the root directory as a special file. The starting cluster is 2.
2.3 FAT32 File System File Management
All files except the root directory (subdirectories also exist as special files) correspond to a set of data as file descriptions, which are called file directory items. All files and sub-directories in each directory are stored in the corresponding bucket. Each file directory item contains 32 bytes, it mainly includes file names, file attributes, file size, file storage location, and a series of time descriptions. By associating the file paths, file directory items, and FAT tables, you can fully grasp the storage of a file on the hard disk. Figure 5 shows an example to locate all the content of a file through the following steps:
(1) Find the cluster (a) in the directory where the file is located through the path ).
(2) Compare the file name in the space (c) corresponding to the directory and find the file directory item (d) corresponding to the file ).
(3) determine the starting cluster and file size of the file through the file directory items.
(4) determine the file storage space (e) Based on the cluster chain (B) in the FAT table ).

3 IDE Hard Disk Interface Design
3.1 ADSP-BF533 EZKIT Lite Evaluation Board Introduction [5]

Blackfin533 is a MISC system microprocessor developed by Analog Devices. This kind of system is a collection of both the RISC Instruction Set and the DSP kernel. Therefore, Blackfin533 can be used as a general embedded microprocessor for development and application, as well as powerful DSP data processing capabilities.
ADSP-BF533 EZKIT Lite is an evaluation board provided by Analog Devices to facilitate the development of Blackfin533 applications. It can be debugged with a PC using a USB or PCI interface simulator, which is easy to use. The core of the evaluation board is a Blackfin533 processor with an input frequency of 27 MHz, which can be controlled by the internal PLL to work at the desired operating frequency up to 750 MHz.
The ADSP-BF533 ezkit lite evaluation board has rich on-chip resources. It has 32 m sdram (16 m × 16 bit) and 2 M Flash (K × 16 bit × 2). The ad1836 audio processing chip provides four audio inputs and six audio output ports; the adv7183 video decoding chip and adv7171 Video Encoding Chip provide three video input and video output ports respectively. In addition, the evaluation board provides UART, JTAG, button circuit, led indication, and other devices, in particular, it provides a set of fully functional extended interfaces for access from other devices. The IDE interface circuit is designed based on this set of extended interfaces.
3.2 Hardware Design
The IDE interface expansion board is designed based on the ebiu (External Bus Interface Unit) of the blackfin533 chip.
Ebiu is a common external bus interface between blackfin533 and external memory. By setting the ebiu control register, it can be connected to synchronous memory such as SDRAM, it can also be connected to asynchronous memory such as Rom, fifos, and Flash. The internal structure of ebiu is 6.

According to the atapi Protocol [3], the IDE interface scheme is designed based on ebiu, so that blackfin533 can perform operations on the hard disk through this interface, as shown in figure 7.

4 FAT32 File System Software Design
The FAT32 file system interface program is compiled and debugged in the visual DSP ++ 3.5 integrated compilation environment. The program is written in standard C language and the calling relationship is divided into five layers, as shown in table 2.

4.1 Visual DSP ++ 3.5 integrated compilation environment [6]
Visual DSP ++ 3.5 is a convenient management system developed by Analog Devices for Its DSP, the complete system includes the integrated compiling and debugging environment integrated with the visual DSP ++ kernel, the C/C ++ optimized compiler with real-time Runtime Library, assembly and linker and simulation software, and a large number program routine. Visualdsp ++ also has many useful functions that allow developers to more accurately understand the internal resource usage of a program, and more intuitively understand the efficiency of various functions in the program, in this way, the DSP program development and optimization can be conveniently conducted on the visual DSP ++ software platform.
4.2 file read/write policy optimization
The underlying driver function of the FAT32 file system determines the file read/write policy, which is the key to improving the speed of reading and writing files. Theoretically, the FAT32 file system can operate any file content in the way shown in 8. However, this operation is intended for the IDE hard disk. Therefore, you must consider the data transmission feature of the IDE hard disk.

The data transmission rate of the IDE Hard Disk can be divided into external transmission rate and internal transmission rate ). The external transfer rate refers to the data transmission rate between the cache and the Controller through the IDE interface. The internal transmission rate is also called the hard disk continuous transmission rate, which is the data transmission rate between the disk and the cache. The latter is much slower than the former, so to improve the transmission speed, we should try to read and write continuously to reduce the number of internal cache Flushing Times.
By studying the file operation process in theory, it is found that the operation on the fat table greatly affects the continuous reading and writing of the file. In actual program design, to solve this problem, on the one hand, specify a member in the data structure of the description file to record the cluster where the operation pointer of the current file is located, on the other hand, some fat tables are read into SDRAM in advance. These two operations greatly reduce the number of consecutive read/write interruptions on the hard disk. Experiments show that this scheme greatly improves the program efficiency and increases the speed by about three orders of magnitude.
4.3 Function Design
A complete set of file system library functions are the most basic functions for file operations. They should include functions such as opening, closing, reading, writing, and locating files. I have designed ten functions for external calls, including opening, closing, reading, writing, locating, searching, directory list, renaming, creating directories, and deleting files. The upper-layer library functions call the second-layer function to perform operations on these functions. The three most important functions are fnfindfile, fnreadfile, and fnwritefile.
Fnfindfile is used to find the file directory items that match the target file name under the specified directory and generate a pointer to the file, as shown in figure 9.
The fnreadfile function is a file read function. Its Parameters include the address to be read, the unit size of the data to be read, the length of the data to be read, and the file pointer of the target file, as shown in figure 10.

 

The fnWriteFile function is a file writing function. Its parameters are similar to the basic process and the Read File function. However, because the size of the written file may exceed the size of the original file, you must consider opening up new spaces and modifying File Information on the hard disk, flowchart 11 is shown.

This article introduces a solution for operating the FAT32 File System on the IDE Hard Disk Based on the Blackfin533 processor. This system is designed based on the hard disk PIO transmission mode. The maximum transmission speed of the hard disk PIO transmission mode can reach 8.3 MByte/s, and the average speed of reading files in this system can reach 6 MByte/s, this shows that the system has a high efficiency. This system can be compiled and translated into a library under Visual DSP ++ 3.5. Other programs can easily call the FAT32 file system operation functions provided in the library, implements an embedded large-capacity file storage management solution based on the Blackfin533 processor.

References
1 IDE-Hardware Reference & Information Document. http://www.repairfaq.org/filipg/LINK/F_IDE-tech.html, 1996.11.6
2 FAT file system principle (1) (2) (3) (4). http://www.sjhf.net
3 Information Technology-AT Attachment with Packet Interface Extension (ATA/ATAPI-4), T13, Revision 1998, 19 August
4 Microsoft Extensible Firmware Initiative FAT32 File System Specification (Version 1.03). Microsoft Corporation, December 6, 2000
5 ADSP-BF533 EZ-KIT Late (r) Evaluation System Manual. Analog Device Inc, 2000
6 Liu Feng. Blackfin DSP principles and system development. Beijing: Electronics Industry Press, 2004

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.