Background technology
The Nandflash storage is a kind of of flash storage, and it provides cheap effective solution for the realization of solid-state large-capacity storage.The Nandflash storer has the advantages such as capacity is larger, and rewriting speed is fast, is applicable to the storage of mass data, thereby has obtained using more and more widely at a lot of electronic products.Although there is the situation that produces bad piece in dispatch from the factory bad piece and the use in Nandflash, along with the introducing that bad piece is replaced and bad piece is skipped mechanism, and the yaffs file system is for the Nandflash design in serviceable life, so that these do not become problem.
In the prior art, the programming of Nandflash is mainly undertaken by following two kinds of methods, the first is to adopt first the software that provides in advance that the data that need programming are generated image file, re-use fever writes the image file programming in Nandflash, thereby finish the programming of production, if adopt this mode, for file system a plurality of subregions are arranged, and just can only make when all bad piece being arranged in each subregion and damage the piece mechanism of replacing, damage piece and skip mechanism and can not make, service efficiency is had certain impact.The second is after adopting the software approach upgrading, to take off Nandflash with hardware means, obtains data wherein, and this method is poor efficiency not only, and can not guarantee successfully.
Summary of the invention
Method of the present invention is the problems referred to above that exist in order to solve prior art, has proposed a kind of Nandflash programming method.
Technical scheme of the present invention is: a kind of Nandflash programming method specifically comprises the steps:
S1. start motherboard, boot and start-up routine are upgraded to Nandflash;
S2. start-up system, and after start-up system, finish the upgrading of file system;
S3. calculate the size of each subregion after the upgrading, according to each partition size that calculates, extract respectively each partition image file;
S4. use fever writes, finish the programming of Nandflash.
Further, the described fever writes of step S4 is supported subregion programming image file.
Further, the described fever writes of step S4 finds to point out when there is bad piece the boot section Nandflash chip unavailable in the programming process.
Further, the described fever writes of step S4 finds to point out when there is bad piece in the bad block table district Nandflash chip unavailable in the programming process.
The invention has the beneficial effects as follows: method of the present invention adopts Software-only method, easy to use, be not subjected to the restriction of Bad Block Management mechanism, have high-level efficiency and high reliability, solve the direct programming image file of Nandflash to the restriction of Bad Block Management mechanism and the drawback that adopts hardware means to exist, can realize easily the generation of image file and the programming of Nandflash simultaneously.
Embodiment
The present invention is described further below in conjunction with the drawings and specific embodiments.
As shown in Figure 1, in the method for the present invention, need to use the fever writes of main frame, motherboard and customization, main frame is connected Serial Port Line and connects with netting twine with motherboard, the boot on the main frame, start-up routine and file system are upgraded on the motherboard, finish the upgrading to motherboard; Then the data on the motherboard are extracted into image file, with fever writes Nandflash are carried out programming.
Specific implementation process comprises the steps: as shown in Figure 2
A. start motherboard, boot and start-up routine are upgraded to Nandflash; Here can use the device start motherboards such as SD card.
B. start-up system, and after start-up system, finish the upgrading of file system; Here can use SD card start-up system, or pass through the mode start-up system of nfs carry.
C. calculate the size of each subregion after the upgrading, according to each partition size that calculates, extract respectively each partition image file;
D. use fever writes, finish the programming of Nandflash.
In Fig. 2, after motherboard and main frame connect, by device start motherboards such as SD cards, by network boot and start-up routine are passed on the motherboard from main frame, finish the upgrading of boot and start-up routine; Start-up system on the partitions of file carry of motherboard, passes to file system on the motherboard by network, finishes the upgrading of file system; Check the partition information after the upgrading, calculate each partition size, according to the partition size of calculating, extract the image file of each subregion.During extraction, if judge have bad piece to exist, the size of extracting is increased the shared storage size of bad piece number, re-start extraction; The image file that extraction is finished is that available fever writes is carried out programming to Nandflash.
Wherein, the customization of fever writes requires: support subregion programming image file; Can identify bad piece of boot section, in the programming process, find to point out when there is bad piece the boot section Nandflash chip unavailable; Can identify bad piece of bad block table district, in the programming process, find bad block table district (last 4 pieces of chip) when bad piece is arranged, prompting Nandflash chip is unavailable.
In Fig. 3, this is the partition scheme of commonly using, and can increase subregion according to the design needs.Because the boot section is used for system's rear Bootstrap Commissioning Program that powers on, so this subregion must exist, and the position fixes, but section post take up space needn't be too large.The bad block table district is used for the bad piece of register system, so this subregion must exist, and the position fixes, and its size is generally 4 pieces.
System partitioning commonly used has comprised the boot district, start-up routine district, file system area, bad block table district.The boot district only need distribute the space of a piece to meet the demands; Start-up routine district take up space is decided according to start-up routine size, will be for it keep certain redundancy when subregion, in case the usefulness when in the subregion bad piece being arranged, redundancy is made as about 20% of start-up routine size; File system area is maximum in all subregions, and it wants files all in the saved system, and reserves enough spaces for system's operation, and therefore, this subregion is got larger as much as possible; The bad block table district is used for recording the bad piece of whole Nandflash chip, the space of using 2 pieces just can, reserve 2 pieces more and be used alternatingly to increase reliability.
From above-mentioned analysis and description, method of the present invention adopts Software-only method, easy to use, be not subjected to the restriction of Bad Block Management mechanism, have high-level efficiency and high reliability, solve the direct programming image file of Nandflash to the restriction of Bad Block Management mechanism and the drawback that adopts hardware means to exist, can realize easily the generation of image file and the programming of Nandflash simultaneously.
Those of ordinary skill in the art will appreciate that embodiment described here is in order to help reader understanding's principle of the present invention, should to be understood to that protection scope of the present invention is not limited to such special statement and embodiment.Those of ordinary skill in the art can make various other various concrete distortion and combinations that do not break away from essence of the present invention according to these technology enlightenments disclosed by the invention, and these distortion and combination are still in protection scope of the present invention.