1 Introduction
With the rapid development of computer application technology, mobile storage devices have been widely used. CF (Com PAC t Flash) card was born in 1994 with its design concept of capturing, saving, transmitting data and other audio and video information. It is the earliest flash memory card. Due to its low price, small size, large storage capacity and high speed, CF card is widely used in digital cameras, PDAs and notebook computers and other instruments and equipment that need high-speed sampling, real-time data recording, and then transfer the data to the computer for analysis and processing.
Since the information stored in the CF card needs to be readable from the PC, a standard format must be used to organize the data. The usual method is to embed a file system in the CF card. At present, there are many commercial embedded operating systems on the market that can support file systems, but these operating systems generally have high hardware requirements, are expensive, and take up a certain amount of additional storage space. Due to cost and other restrictions, embedded operating systems are rarely used, so it is necessary to develop a standard file system that does not rely on commercial operating systems. This article introduces the CF card file system based on S3C2410 implemented in the FAT32 format.
2 CF Card Introduction
The CF memory card has a built-in single-chip controller and flash memory module, and the connector is a 25-pin double-row female socket with a dot pitch of 50 mil (1.27 mm). The internal structure module diagram of the CF card is shown in Figure 1.
Figure 1 CF memory card module diagram
The main controller is connected to the CF card through a 50-pin connector. The connector is a male plug with 25 pins (1.27mm) per row.
There are three ways to access CF cards: PC Card Memory mode, PC Card I/O mode, and True IDE mode. PC Card mode is compatible with the PCMCIA standard. True IDE mode is compatible with the ATA standard.
3 S3C2410 and CF card interface design
This system uses ARM's 32-bit embedded microprocessor S3C2410. ARM series embedded microprocessors, with their outstanding advantages such as low power consumption and high performance, have firmly ranked first in the world in 32-bit embedded applications and have become synonymous with high-performance and low-power embedded processors. The ARM core is now the core of the embedded SoC system chip and is also the direction of development of modern embedded systems.
The hardware connection relationship between S3C2410 and CF card is shown in Figure 2. Three modes can be realized by changing the internal logic relationship of CPLD. Since in True IDE mode, the CF card and the host communicate with the least signal, the hardware interface is the simplest, and the software is easy to implement, this design adopts True IDE mode.
Figure 2 Hardware connection diagram between S3C2410 and CF card
In True IDE mode, some signals have special meanings and must be set using the unique True IDE mode settings, as shown in Table 1 True IDE mode I/O decoding :
Table 1 True IDE mode I/O decoding
nCE1 is the chip select signal of the task file register, which is valid at low level; nCE2 is the chip select signal of the alternate status register and the device control register, which is also valid at low level. Because the alternate status register and the device control register are rarely used in actual operation, the operation of the CF card is actually the operation of the task file register. Therefore, nCE1=0 and nCE2=1 are generally set. When the host operates the CF card, the system only uses the address bus A2~A0 to select one of the 8 registers that make up the task file register. In Table 1, when nCE1=0, the corresponding 8 registers are collectively referred to as the task file register.
It should be noted that in True IDE mode, nOE is not a read enable signal, but an enable signal for the True IDE mode of the CF card. When the CF card is powered on, if nOE (PIN9) is "0", the CF card automatically enters the True IDE mode; if nOE="1", it enters the PC Card mode. When the power is always on, hot-plugging the CF card will reconfigure it from the original True IDE mode to the PC Card mode. Therefore, during the hot-plugging process, in order to make the CF card work in the True IDE mode, it is necessary to ground the nOE signal while the CF card is powered on. Implementation method: Set nOE to 0 in the CPLD. In True IDE mode, nWE is not used as a write enable signal, but should be grounded by the host. Processing method: Set it to 1 only in the CPLD.
Another point to note is that the Reset signal is valid at low level in True IDE mode, but valid at high level in other modes. Connect the Reset signal to the system reset signal nReset of S3C2410.
4 System software composition
At present, under the management of PC DOS/Windows, FAT12, FAT16 and FAT32 file systems are widely used.
FAT12 is generally used for floppy disks, while FAT16 and FAT32 are used for hard disks. This system uses the FAT32 file system.
A volume of the FAT file system consists of four basic zones, which are arranged in the following order in the volume:
0——reserved area (boot area);
1——FAT area;
2——root directory area (the floating FDT table exists in FAT32);
3——file and directory data area.
The first important data structure in the FAT volume is BPB (BIOS Parameter BLOCk), which is located in the first sector of the reserved area of the volume. The BPB parameter block records the partition's start sector, end sector, file storage format, hard disk media descriptor, root directory size, FAT number, allocation unit size and other important parameters. The file allocation table FAT, starting from logical sector 1, is a table used by the file management system to allocate disk physical space to each file. The FAT file allocation table consists of a set of table identifiers and cluster mappings. An identical mirror copy is continuously stored in the main FAT table. The entire purpose of FAT is to track files. The specific description requires the description of the usage of each storage unit (cluster) in the entire disk partition, the cluster storage of file data (continuous or fragmented), and the description of the tree-type directory structure. FAT is actually a mapping table of all cluster usage in a volume. Each file and directory corresponds to several items in the table and is indexed in the directory. After FAT is the root directory, which records useful information of all files on the entire disk, where each file occupies 32 bytes, including file name, file attributes, file modification time, file length, etc. The root directory is followed by the data area, which is used to store collected data and other information.
The process of reading and writing files on a CF card is as follows: CF card reading and writing is based on sectors, each sector is 512 bytes, and one or more continuous sectors can be read and written each time. When reading and writing a CF card, the sector count, sector number, low cylinder, high cylinder, and select card/head register are written to the sector location that the CF card needs to access. There are two write modes: CHS (Cylinder/Head/Sector) mode and LBA (Log IC al Block Address) mode. The mode is determined by setting the 6th bit LBA of the select card/head register: if LBA=0, it is CHS mode; if LBA=1, it is LBA mode. This design uses LBA addressing to access CF card data.
When S3C2410 reads sector data from a CF card, it first writes the corresponding data to the sector count, sector number, low cylinder, high cylinder, and card/head selection registers to specify the sector to be read or written; then it writes 20H to the command register, reads the status word as 58H, and then reads the data; finally, it reads the status word of the command register. If it is 50H, it means there is no error, and the CF card enters standby mode.
The command for S3C2410 to write data to the specified sector of the CF card is 30H. The operation is similar to reading data, except that after writing the data, the process cannot be completed until the data in the CF card is stable and enters the idle state.
By writing the command ECH to the CF card, a sector can be read, which contains some parameter information of the CF card, such as capacity, default number of cylinders, default number of heads, number of bytes per sector, number of sectors per track and total number of sectors on the CF card, etc., so as to determine whether the CF card needs to be formatted. The formatted CF card has the FAT file system structure.
When the FAT32 file system works on a CF card, it first initializes the file system; then creates a directory; then reads/writes a file; then deletes the file and directory; and finally closes the file system.
//Initialize the file system
DiskInit(); //Initialize the logical disk information management module
AddFi LED river(CFCammand); //Load the CF card underlying driver
FileInit(); //Initialize the file pointer system
//Create a directory
ChangeDrive("a:"); //Change the current logical disk
MakeDir("dir2.dir"); //Create a directory
ChangDir("a:\dir2"); //Change the current directory
//Read/write a file
FHandle = FileOpen("a.txt",w"); //Open the file in the specified way
If (FHandle != Not_Open_FILE)
{
FileSeek(FHandle,0,SEEK_END); //Move the file read/write position
FileWrite(S,6, FHandle); //Write the file
FileClose(FHandle); //Close the specified file
}
FHandle = FileOpen("a.txt",r");
If (FHandle != Not_Open_FILE)
{
FileSeek(FHandle,0,SEEK_END);
FileRead(buf,6, FHandle2);
FileClose(FHandle);
} //Delete this file, directory, and finally close the file system
RemoveFile(S); //Delete the file
ChangeDir("a:\"); //Change the current directory
RemoveDir("dir2"); //Delete the directory
RemoveFi LED river(GetDrive("a")); //GetDrive("a") - Get the logical drive number of the specified directory
// RemoveFileDriver - Delete an underlying driver
5 Conclusion
According to the FAT32 file format, the basic file system functions based on the CF card are realized in the S3C2410 application system, such as reading, writing, creating, deleting and copying files, creating, opening and deleting subdirectories and returning to the parent directory, etc., and can exchange information with other systems that support FAT32. The system can easily expand the storage capacity, and the power consumption is low, which meets the requirements of long-term large-scale data storage. The stored files are compatible with the widely used Windows operating system, which is more convenient for data acquisition and playback analysis in high-speed sampling and other occasions. The system has strong scalability and can be easily applied to various industrial sites and small portable embedded systems. It is more flexible and stable in data acquisition and storage, and is free from the limitations of the operating system.
The innovation of this paper is to introduce a standard CF card file system based on S3C2410 that is independent of commercial operating systems and implemented in FAT32 format, so that the information stored in the CF card can be read from a PC.
References
[1] Li Hao, Wang Yueke, Zhou Rui, Pan Zhongming. Typical application of CF card in large-capacity data storage system [J]. Microcomputer Information, 2005, 11-1: 66-68.
[2] Mao Xiaoyan. Implementation of CF card file system based on 8051 [J]. Automation Instrumentation, 2003, 24 (6): 23-37.
[3] Yao Fangjun. Design of embedded Com PAC t Flash card interface [J]. Computer Application Research, 2003, (6): 225-227.
[4] Tian Ze. Embedded System Development and Application Tutorial [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 2005.3
Previous article:Design of power distribution control module based on LPC2119 microprocessor
Next article:Analysis of the differences between ARM and MCU
Recommended ReadingLatest update time:2024-11-16 14:55
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Understanding wireless communication technology
- Infineon Tmall flagship store offers huge discounts Part 1 - Limited cashback on a first-come, first-served basis, Double 11 special promotion!
- Good evening, experts.
- You may need oscilloscope information urgently, especially analog ones. You can get the information here.
- XMC4800 Review (Part 2) - Unboxing and Lighting
- Share the use of Allegro Color command with everyone
- Comparison of technical indicators between N76E003AT20 and STM8S003F3P6
- CCS variable observer problem
- [NXP Rapid IoT Review] Rapid IoT Studio Simple Programming Step 4 Add Bluetooth RGB Light Control
- EEWORLD University - What is Dynamic Multi-Protocol Manager (DMM)?