CF card file system based on S3C2410

Publisher:幸福自在Latest update time:2018-03-22 Source: eefocusKeywords:S3C2410 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

    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.

17.jpg
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.

18.jpg
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
19.jpg
 
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


Keywords:S3C2410 Reference address:CF card file system based on S3C2410

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

Development and implementation principle of embedded Linux network driver
    introduction   As people's enthusiasm for open source software grows, Linux, as a powerful and stable open source operating system, is increasingly favored by thousands of computer experts and enthusiasts. In the embedded field, Linux can be solidified in a memory chip or microcontroller with a capacity of only t
[Microcontroller]
Development and implementation principle of embedded Linux network driver
Embedded wireless smart home control device
introduction With the rapid development of science and technology, residential intelligence is a new revolution in human housing. Families in modern society are pursuing the diversified information and safe, comfortable and convenient living environment brought by home intelligence, and a more relaxed, orderly and e
[Microcontroller]
Embedded wireless smart home control device
Design and research of radio station network control system based on ARM9
1. Introduction In today's information age, as people's requirements for system performance and cost control continue to increase, embedded systems have gained more and more favor with their excellent cost-effectiveness and unique convenience. Radio stations have evolved from traditional analog to digital,
[Microcontroller]
s3c2410 watchdog
1. What is watchdog? Watchdog, in Chinese, is called "watchdog", and its full name is watchdog timer. From the literal meaning, we can know that it is actually a timer. However, it is different from the timers we usually come into contact with in terms of function. Ordinary timers generally play the role of timekeepi
[Microcontroller]
Bare Metal Series - DMA Work
The advantage of DMA is that it does not require CPU intervention when transmitting data, which can greatly improve the CPU's working efficiency. DMA is very important in large-capacity data transmission, such as image data transmission, SD card data transmission, USB data transmission and so on. S3C2410 has four
[Microcontroller]
Design of GPRS module based on S3C2410
  An embedded system is a combination of computer hardware and software with specific functions or purposes, or a special computer system that is installed in another device and controls the device. The biggest feature of an embedded system is that it is purposeful and targeted, that is, the development of each embedd
[Microcontroller]
Design of GPRS module based on S3C2410
Method and implementation of remote parameter measurement based on embedded system
Introduction: At present, embedded systems are developing very rapidly, and the development of various applications based on ARM processors is in full swing. This is mainly due to the high cost performance and short development cycle of embedded systems, and they can be implemented in a variety of application systems.
[Microcontroller]
Method and implementation of remote parameter measurement based on embedded system
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号