introduction
This article refers to the address: http://
Currently, car players basically use CD players, MD players, and tape players. Since such players have some mechanical transmission components inside, and are installed in the specific environment of the automobile, the sound quality is often affected by mechanical transmission or sounding or twisting of the optical head and the magnetic head.
Flash memory is gradually used in mobile electronic products such as mobile phones, PDAs and digital cameras because it has many advantages such as large storage capacity, no loss of power-down data, small size, and multiple erasability. . As a storage for storing data and applications, it can move and exchange large amounts of data easily and quickly.
Based on the above two points, an in-vehicle MP3 system was designed. The system uses Flash as the external memory and is composed of all solid-state devices. It does not play skipping or twisting during playback, and the sound quality is also very good. Because the flash memory may have damaged unit in the application process, affecting the performance of the car MP3 player, this paper designs a file system for the physical characteristics of the flash memory itself, based on the file name or the data content in the flash memory. Storage management of file numbers and application of transparent corruption management. The system optimizes storage speed and storage space and improves the reliability of the car MP3 playback system.
1 Flash memory features
The Flash is internally divided into a plurality of storage unit blocks, and each storage unit block is composed of a plurality of pages. A memory cell block is the smallest unit that can be erased, and a page is the smallest unit of data written.
The flash memory reads data similarly to a general memory, and can perform random reading, and the reading speed is also fast. The write operation of the flash memory is different from that of the general memory. The write operation of the flash must first be erased by the memory block (write 0xff to the memory cell block to be erased), and then written in the page order. Since the flash memory erase takes a long time, the flash memory write time mainly lies in the erase operation inside the flash memory and the like.
The first block of Flash memory must be a valid block, while other blocks may be bad blocks before use or become invalid blocks during use. The determination of the internal bad block by the flash memory is determined according to whether or not the sixth Cloumn content in the third area in each unit storage block is 0xff. Although the contents of the flash memory have bad blocks, since the internal structure of each block is independent of each other, the bad block does not affect the operation of the effective block by the system as long as the state is recognized.
2 Flash file system design
This paper designs a Flash storage management system based on Flash storage to physically manage Flash. On the basis of the Flash storage management system, a FAT file system is established to manage the file operations. The Flash storage management system and the FAT file system form the Flash file system. The file system fully supports the functions of the general file system such as file name management and automatic damage management; at the same time, the design of the special application environment of the car MP3 player system improves the reliability of the file system even under severe conditions. It will not affect the sound quality. The specific structure of the Flash file system is shown in Figure 1.
2.1 Flash storage management system
The operation of the flash memory is in units of blocks, and the FAT file system is based on disk operations in units of sectors (usually 512 bytes/sector). Therefore, this paper designs a special Flash storage management system to solve the contradiction between the physical properties of Flash in block units and the file system interface in sector, so that the physical address of Flash and the logical address of FAT operation Can correspond to each other. At the same time, due to other features of Flash, the Flash storage management system also achieves the work of erasing the number of erasing and bad block management between blocks.
(1) Mapping of physical addresses to logical addresses
In order to establish a good mapping relationship between the physical address of the Flash and the logical address of the FAT operation, the storage space of the Flash is logically redefined. Combined with the characteristics of Flash, each memory cell block is internally divided into several physical sectors, and each physical sector is composed of 512 bytes + 16 bytes = 528 bytes. The 512 bytes of the Main Area are valid data spaces, and the 16 bytes of the Spare Area are used to store other information.
From the above definition, the correspondence between the physical sector of the Flash and the absolute address can be determined:
Absolute address = Flash base address + physical sector number × 528
After the mapping between the physical address and the logical address is established, the operation of the audio file by the in-vehicle system can be well converted into the programming or erasing operation of the system direct flash. For example, in the system to perform the ReadFile () operation, it can be implemented according to its corresponding relationship by executing the sectorread () operation in the Flash storage management system.
(2) Reliability design
Since the in-vehicle system is powered by a car, when the car is in an unbalanced environment, it may be abnormally powered off due to bumpy broadcast systems, so it is very important to improve the reliability of the car MP3 player system. In this paper, the reliability of the playback system is improved by defining 16 bytes of the Spare Area as the logical sector number, the current state of the sector, bad block information, and the like. The specific definition of Spare Area is as follows:
Logical sector number Sector current status Bad block information Reserved byte
1st to 3rd bytes 4th to 5th bytes 6th byte 7th to 16th bytes
As can be seen from the above definition, the 4th to 5th bytes of the Spare Area are used to store the current state of the sector. In this way, during the flash write operation, if the power is suddenly turned off, the power-down data recovery can be performed according to this state. There are three types of current sectors in the system: sector is empty (0xfff), sector data is useless (0x0000), and sector data is valid (0x00ff). After this definition, the system can save the current state in time when the Flash write operation terminates abnormally, so that the next time the system is turned on, it can determine the problems in the previous system and deal with them accordingly.
(3) Bad block management
Because there are bad blocks inside Flash, the Flash storage management system needs to perform bad block management on Flash. The management of bad blocks in this paper is divided into the following two cases:
1 initial bad block processing. Flash memory may have bad blocks before use, and these bad blocks are randomly distributed. Therefore, the Flash file management system first creates a bad block table before the system performs the read and write operations, then performs an initial scan of the flash memory to find the bad block, and marks the bad block as unavailable, and adds it to the bad block table.
2 bad block processing during operation. When an error occurs during erasing or programming, the Flash file management system re-copyes the data of other pages in the block to a new empty block, and then marks the block as a bad block and adds it to the bad block table. In this process, since the contents of the flash memory cell block are changed due to the erasing or programming operation of the flash, the flash file management system does not wipe the block after the memory cell block of the flash memory is found to be a bad block. In addition to or programming operations, to avoid clearing the bad block flag data, the block is marked as a bad block and added to the bad block table.
After the above-mentioned bad block management is performed by the Flash file management system, the bad block unit is completely transparent to the user application. This greatly facilitates the use of the user and also achieves the purpose of the car MP3 player system.
(4) Balanced erasing times
Since Flash has a certain service life, the number of erasable times is generally 10 to 1 million times, so as the number of uses increases, some units gradually become unstable or fail. Therefore, it is necessary to avoid frequently operating the same block address, so as to avoid causing partial damage of the local unit. At the same time, since the erasing operation takes more time, the erasing operation should be reduced, and the erasing frequency should be balanced as much as possible. To this end, this paper designed the Flash update algorithm and wear level detection algorithm.
The Flash update algorithm directly writes the data to be updated in the Flash into an empty block, which reduces the frequent erasure of the block due to the characteristics of the Flash first erase and write, and also improves the use efficiency of the Flash. Speed ​​up the operation. The wear level detection algorithm must perform a bad block scan on the Flash before writing to the Flash to ensure that data is not written to the bad block and the data is lost. This design is also to improve the reliability of the car MP3 playback system.
2.2 FAT design
Based on the Flash file management system, the FAT file system is also established to manage file operations. The FAT file system is divided into the following four parts:
(1) Guide area of ​​FAT
This boot area stores the information needed for the code and the most important file system information. This information includes the type, capacity, and number of clusters of Flash memory; how many sectors each cluster contains, the number of FAT tables, the number of reserved sectors, the first cluster number of the root directory and the number of root directory entries, version information, etc. . The boot sector is generated when the Flash is formatted.
(2) FAT file allocation table
It is very important that the file allocation table stores the storage space family chain occupied by the file and the occupied and free space of the flash memory. In order to prevent file loss caused by file allocation table corruption, two identical file allocation tables FAT1 and FAT2 are saved in the system to improve its security. In the operation of the file system, the program sequentially modifies the two backups of the FAT table structure to ensure that a complete set of file allocation tables is always stored on the flash memory.
The principle of accessing the FAT table by the system is as follows: When accessing a file, the directory entry of the file is first found from the directory to be read, and the first cluster number is read therefrom. Then, the directory entry for the file is found in the directory, and the first cluster number is read from it. Then find the cluster chain starting from the first cluster number in the FAT. The cluster number on the cluster chain is the sector number chain occupied by the file in the logical sector, so that the data can be read and written.
(3) FAT root directory area
The FAT root directory area is a fixed size area immediately following the FAT table. This article will use the 32 sectors immediately following the FAT area as the root directory area, and can store 512 directory entries. Each directory entry records the file name, file attribute, file size, date and time when the file was created, and the first cluster number of the file in the data area, that is, the entry of the file in the FAT table.
(4) FAT data area
The data content of the file exists in the data area. The storage space of the file system for the data area is divided and managed by clusters. In this system, 1Cluster=32sector is defined. A file always occupies several whole clusters, and the remaining space of the last cluster used by the file is no longer used.
As can be seen from Figure 1, the FAT file system provides basic functions such as formatting of files, opening, deleting, closing, and reading, writing, and searching of files. After the operation of the file is managed by the Flash file system, the car playback system can implement a series of functions such as selecting a song, adding a deleted song, downloading a song, and adjusting the volume.
3 applications
Through this design, the storage performance of Flash has been greatly improved, and the reliability of the system is also very good. Even in the worst working conditions where the Flash write operation is abnormally terminated, the data will not be lost, and the system file will be damaged without damaging the very important file allocation table structure. Therefore, the Flash file system designed in this paper can be very Good for applications in car MP3 playback systems.
Hengstar designed item Industrial Stretched Bar series LCD Display customized for different display resolutions, it is especially for industrial application, provide high quality image, the structure solid, rugged 15mm Aluminum front frame,3mm Aluminum chassis, strengthen the organic board protection, can be easily mounted touch screen, tempered glass display surface box, avoid dust, waterproof, avoid vibration.
bar lcd display,stretched monitor,stretched bar lcd monitor,stretched lcd display,Ultra Stretch Display,Ultra-Stretch Digital Signage
Shenzhen Hengstar Technology Co., Ltd. , https://www.angeltondal.com