[go: up one dir, main page]

WO2014082583A1 - Method and device for generating dynamic partition information in nand flash memory - Google Patents

Method and device for generating dynamic partition information in nand flash memory Download PDF

Info

Publication number
WO2014082583A1
WO2014082583A1 PCT/CN2013/088017 CN2013088017W WO2014082583A1 WO 2014082583 A1 WO2014082583 A1 WO 2014082583A1 CN 2013088017 W CN2013088017 W CN 2013088017W WO 2014082583 A1 WO2014082583 A1 WO 2014082583A1
Authority
WO
WIPO (PCT)
Prior art keywords
partition
dynamic
blocks
original
partitions
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2013/088017
Other languages
French (fr)
Chinese (zh)
Inventor
秦绍天
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Device Co Ltd
Original Assignee
Huawei Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Device Co Ltd filed Critical Huawei Device Co Ltd
Publication of WO2014082583A1 publication Critical patent/WO2014082583A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory

Definitions

  • Embodiments of the present invention relate to the field of computers, and more particularly, to a method and apparatus for generating dynamic partition information in a Nand flash memory. Background technique
  • Nand flash memory is a storage medium capable of reading, writing and erasing. It has the advantages of large capacity, fast erasing speed and low price. It is widely used in set-top boxes, digital cameras, mobile phones, tablet computers and other electronic products. , used to store programs, parameters, media data, etc.
  • the abstract device access layer provides a system such as MTD (Memory Technology Device), which provides unified, abstract access to flash memory for the operating system. interface.
  • Partitioning is an important step in the use of MTD equipment.
  • the so-called partitioning is to divide multiple areas on the flash memory.
  • the divided areas are simply referred to as partitions.
  • Each partition has a fixed physical starting address and partition size, where the partition size is usually composed of blocks included in each partition (block).
  • the number of ) determines the size of each block as the default.
  • the starting address and number of blocks of a partition are also referred to herein as partition information. These partition information are important parameters for the system to start and run, to read data on the flash and mount the file system.
  • Nand flash memory Despite the large capacity and low price of Nand flash memory, there is an inherent defect in Nand flash memory itself: there are bad blocks at the factory, and these bad blocks are randomly distributed. Nand flash is managed in blocks. According to the experience in the art, the ratio of bad blocks to the number of blocks of the entire Nand flash memory is less than a certain value, and the fixed value is, for example, 2%. Therefore, it is likely that multiple bad blocks will appear consecutively in the same partition. It is because of this defect that it brings certain reliability problems to the use, especially for the smaller partitions that may appear in the system. For example, a partition used to store some parameter data may occupy a total of 2 to 4 blocks. When there are multiple consecutive bad blocks, The partition will not be able to write parameters properly, nor will it be able to read the parameters when the system starts up.
  • the number of blocks of partition information includes the number of reserved blocks.
  • the embodiments of the present invention provide a method and an apparatus for generating dynamic partition information in a Nand flash memory, so as to solve the problem that a large number of blocks are reserved for a partition in order to avoid the random distribution of bad blocks in the storage medium.
  • the first aspect provides a method for generating dynamic partition information in a Nand flash memory, including: parsing original partition information, where the original partition information includes a named n partitions and a number of original blocks of each partition, where n is a positive integer; According to the original block number of n partitions and the original start address of the first partition of n partitions, dynamic partition information is generated for n partitions by sequentially detecting the states of the blocks of each partition, and the dynamic partition information includes n partitions. Dynamic start address and number of dynamic blocks; store dynamic partition information to a specified area.
  • the original start address of the first partition of the n partitions is used as the dynamic start address of the first partition, and is detected from the first partition to the nth partition.
  • the dynamic start address of the i+1th partition the dynamic start address of the i th partition + the i th partition
  • the number of dynamic blocks is X block size.
  • a third possible implementation manner when detecting that the current block state is good, erasing the current block and writing data; or when detecting When the current block status is bad, the current block is skipped and no data is written.
  • the original partition information is generated before the original partition information is parsed.
  • the boot is also written in the first block of the first partition of the Nand flash memory. program.
  • a second aspect provides an apparatus for generating partition information in a Nand flash memory, including a parsing unit, a first generating unit, and a storage unit: a parsing unit, configured to parse the original partition information and send the information to the first generating unit, the original partition information
  • the number of original blocks including the named n partitions and each partition, where n is a positive integer
  • the first generating unit the number of original blocks of n partitions parsed according to the parsing unit and the first partition of n partitions
  • the original starting address by sequentially detecting the state of the blocks of each partition, generating dynamic partition information for the n partitions and transmitting to the storage unit, the dynamic partition information includes the dynamic start address and the number of dynamic blocks of the n partitions;
  • the dynamic partition information generated by the first generation unit is stored in the designated area.
  • the first generating unit includes a detecting module, a counting module, and a determining module: a detecting module, configured to use the original starting address of the first partition of the n partitions as the dynamic of the first partition The starting address, starting from the first partition until the nth partition, sequentially detecting the state of each block in the i-th partition, where n ⁇ ; when the detecting module detects that the current block state is good, the counting module will The number of good blocks is increased by 1; and when the detection module detects that the current block status is bad, the counting module adds 1 to the number of bad blocks; and when the number of good blocks > the number of original blocks of the i-th partition, the module is determined to be a good block.
  • a detecting module configured to use the original starting address of the first partition of the n partitions as the dynamic of the first partition The starting address, starting from the first partition until the nth partition, sequentially detecting the state of each block in the i-th partition, where n ⁇ ; when the detecting
  • the sum of the number and the number of bad blocks is the number of dynamic blocks of the i-th partition, and the dynamic start address of the i+1th partition is determined by the dynamic start address of the i-th partition and the number of dynamic blocks of the i-th partition.
  • the device further includes: an erasing unit and a programming unit: when the detecting module detects that the current block state is good, The erasing unit is for erasing the current block and the programming unit writes data in the current block; or when the detecting module detects that the state of the current block is bad, the erasing unit is used to skip the current block and the programming unit is The current block does not write data.
  • the apparatus further includes: a second generating unit, configured to generate the original partition before parsing the original partition information information.
  • the device further includes: a programming unit, configured to: before parsing the original partition information,
  • the boot program is written in the first block of the first partition of the Nand flash.
  • the original partition information is parsed by the foregoing technical solution, and each block in each partition is tested for good or bad, the number of blocks in each partition and the starting address are re-stated, and dynamic partition information is generated, so that the partition information can be dynamically changed, thereby saving
  • the block resource of the storage medium improves the utilization rate of the storage medium.
  • FIG. 1 is a schematic diagram of a method for generating partition information in a Nand flash memory in the prior art.
  • 2 is a schematic diagram of another method for generating partition information in a Nand flash memory in the prior art.
  • FIG. 3 is a schematic diagram of another method of generating partition information in a Nand flash memory in the prior art.
  • 4 is a schematic flow chart of a method for generating dynamic partition information in a Nand flash memory according to an embodiment of the present invention.
  • FIG. 5 is a schematic flow chart of a method for generating dynamic partition information in a Nand flash memory according to an embodiment of the present invention.
  • FIG. 6 is a schematic schematic diagram of a method for generating partition information according to an embodiment of the present invention.
  • Figure 7 is a schematic block diagram of an apparatus for generating dynamic partition information in a Nand flash memory in accordance with an embodiment of the present invention.
  • Figure 8 is a schematic block diagram of another apparatus for generating dynamic partition information in a Nand flash memory in accordance with an embodiment of the present invention.
  • Figure 9 is a schematic block diagram of another apparatus for generating dynamic partition information in a Nand flash memory in accordance with an embodiment of the present invention. detailed description
  • FIG. 1 is a schematic diagram of a method for generating partition information in a Nand flash memory in the prior art.
  • FIG. 1 illustrates four partitions, a first partition 11, a second partition 12, a third partition 13, and a fourth partition 14, respectively, for storing a boot program, a system kernel (Linux Kernel) program, and a root file system. ( Root file System ) and parameter data ( Parameters Data ).
  • Root file System parameter data
  • each partition is named by a serial number, but the partition can be named by other methods.
  • the first partition 11 can also be named as a boot partition
  • the fourth partition 14 can also be named as a parameter partition.
  • a piece of Nand flash memory consists of several blocks. The block size is the factory default.
  • the number of blocks included in one partition is simply referred to as the number of blocks.
  • one block size is 128K bytes.
  • the starting address and size of each partition are as shown in FIG. 1, which are: the starting address of the first partition 11 is 0x0, the size is 512K bytes, the number of blocks is 2; the starting address of the second partition 121 is 0x80000, The size is 4M bytes, the number of blocks is 31250; the starting address of the third partition 13 is 0x480000, the size is 40M bytes, the number of blocks is 312500; the starting address of the fourth partition 14 is 0x2C80000, and the size is 512K bytes.
  • the number of blocks is 2.
  • the starting address of the first partition is known, optionally starting from 0x0; of course, it is also possible to start from the specified address.
  • the number of blocks in a partition X block size plus the starting address is the starting address of the next partition.
  • the partition information in this article includes at least the name of the partition and the number of blocks.
  • partition information is critical to the startup and operation of the system.
  • a prior art referring to FIG. 2, does not consider the characteristics of the random distribution of bad blocks of the Nand flash memory, only according to the number of blocks actually used by the partition, and considering that the partition may be reserved to prevent bad blocks from being used during use. The number of blocks, while partitioning.
  • FIG. 2 is a schematic diagram of another method for generating partition information in a Nand flash memory in the prior art.
  • the first partition 21, the second partition 22, and the third partition 23 are shown in FIG. 2, and the second partition 22 is taken as an example for description.
  • the method of the partition does not take into account the random distribution characteristics of the bad blocks of the Nand flash memory, the defects are very obvious.
  • the partition information cannot be changed, which means that the Nand flash memory will be unusable and can only be used as a defective product. But in fact, this Nand flash memory is in compliance with the requirements, except that the bad blocks at the factory are just concentrated in the partition. Therefore, according to the prior art partition of Fig. 2, material waste is actually caused.
  • FIG. 3 Another prior art, referring to Figure 3, takes full account of the random distribution of bad blocks of Nand flash memory during partitioning. That is, when planning the partition, in addition to considering the normal data storage area, it is also necessary to reserve a certain number of blocks for each partition because of the random distribution characteristics of the bad blocks; according to the general practice in the art, the most reliable is Each partition reserves 2% of the total number of Nand flash memory. For Nand flash memory with a capacity of 512 Mbytes, at least 80 blocks need to be reserved for each partition.
  • FIG. 3 is a schematic diagram of another method of generating partition information in a Nand flash memory in the prior art.
  • the three partitions, the first partition 31 to the sixth partition 36, are schematically illustrated in Fig. 3, wherein the reserved areas included in each partition are 31A to 36A, respectively.
  • each block size is 128 Kbytes, assuming 3
  • the parameter partition itself is small, and only a small number of blocks need to be reserved. The partitioning method shown in Figure 3 causes a larger number of blocks to be wasted.
  • embodiments of the present invention provide a method and apparatus for generating dynamic partition information in a Nand flash memory, which can dynamically adjust partitions and generate new partition information.
  • FIG. 4 is a schematic flow diagram of a method 40 of generating dynamic partition information in a Nand flash memory according to an embodiment of the present invention, including the following.
  • the original partition information includes the named n partitions and each of the The number of original blocks of the partition, where n is a positive integer.
  • the raw partition information may be obtained from other devices or may be generated by the device performing the method 40. From the original partition information, it can be known that the Nand flash is divided into n partitions, the names of n partitions, and the number of original blocks included in each partition. The original starting address of the first of the n partitions is known, so the original size and original starting address of each partition can be determined by the number of original blocks included in each partition. It is necessary to extract information in the original partition information, such as the order of the partitions, the number of original blocks included in each partition, and the like.
  • the bad block of the Nand flash memory is considered to be detectable.
  • constructing a partition it is possible to check the blocks in each partition according to the original size of each partition at the time of partitioning, and actively skip the bad blocks, so that the number of good blocks in the partition can satisfy the original size of each partition.
  • dynamically adjusting the partition and generating new partition information that is, dynamic partition information.
  • the dynamic partition information needs to be stored and can be stored in the specified area.
  • the dynamic partition information will be read and data operations will be performed, including reading or running the core program, mounting the file system, and reading parameters.
  • the file system is mounted according to the partition. Therefore, the preservation of the partition information is crucial.
  • an OTP (once time program) protection may be performed.
  • the embodiment of the invention solves the problem of resource waste caused by the random distribution of bad blocks in the storage medium, and reserves more blocks for the partition to avoid the problem, and also includes the reliability caused by partitioning without considering the feature.
  • the problem is that by parsing the original partition information, performing good and bad detection for each block in each partition, re-counting the number of blocks in each partition and the starting address, and generating dynamic partition information, thereby dynamically changing the partition information, thereby saving
  • the block resource of the storage medium improves the utilization of the storage medium.
  • the method of the embodiment of the present invention may be applied in the process of producing a Nand flash memory.
  • the original partition information is first planned, and then the original partition information is transmitted to the burning machine.
  • the burning machine analyzes the original partition information, the blocks of each partition are dynamically calculated. Quantity, create new partitions in turn and erase and burn data, and store the generated new partition information as dynamic partition information in a pre-planned place, for example, can be stored in the first block of Nand flash memory In the specified area, or in the attribute area of the Nand flash memory.
  • the attribute area of the Nand flash memory is a special storage area independent of the main storage area, and is used for storing the configuration information of the Nand flash memory.
  • the user's use of the Nand flash memory for data erasing does not affect the content in the attribute area.
  • the dynamic partition information may also be stored in a Nor flash memory used in combination with the Nand flash memory.
  • Nor flash can also be read, write, and erase. It is characterized by a read speed block and good reliability, but its capacity is small, the erasing speed is slow, and it is expensive.
  • Nor flash does not have the inherently bad distribution of bad blocks in Nand flash, so the two flashes can be combined to provide users with more reliable storage.
  • the Nor flash memory can be used to store the boot program or dynamic partition information of the Nand flash memory, thereby avoiding ensuring that the first block of the Nand flash memory is a good block at the time of shipment in the art. Therefore, the bootstrap is usually also stored in the specified area of the first block.
  • the data of the Nand flash memory is used, the following method is used: first, the boot program is programmed, and then the boot program uniformly writes the data to the Nand flash memory. Then, the application process in the boot program can also use the method of the embodiment of the present invention.
  • the boot program obtains the original partition information, including but not limited to: implementing the original partition information into the boot program, or reading the original partition information through the serial port or the network, the boot program parsing the original partition information, and then reading the burned data, Dynamically calculate the number of blocks in each partition, erase and burn data to the Nand flash memory, and finally store the newly generated partition information as dynamic partition information in a pre-planned place, for example, the first to be stored in the Nand flash memory.
  • the specified area of the block it can also be stored in the attribute area of the Nand flash memory, or it can also be stored in the Nor flash memory used in conjunction with the Nand flash memory.
  • FIG. 5 is a schematic flow diagram of a method 50 of generating dynamic partition information in a Nand flash memory according to an embodiment of the present invention, including the following.
  • the original partition information defines the n partitions that need to be generated sequentially in the Nand flash, the name of each partition, and the number of blocks included in each partition.
  • n is a positive integer, i G ⁇ 1 , n ⁇ .
  • the size of each partition can be determined by the number of blocks included in each partition and the default value of the block size.
  • the original partition information may be generated by a device that implements the method of the embodiment of the present invention.
  • the raw partition information includes multiple partitions, which can be presented in the form of a partition table.
  • the information in the partition table includes: The name of each partition, which can be arbitrarily named, and the number of original blocks included in each partition.
  • the table item information of the original partition table can be abstracted as follows: typedef struct ⁇
  • S52 is an alternative to S51.
  • the original partition information may be generated by other devices, and the original partition information is implemented in the boot program by using the device in the embodiment of the present invention, or the original partition information is read from other devices through a serial port or a network.
  • the original starting address and the number of original blocks for each partition are first determined in order from the first partition.
  • the original starting address of the first partition is 0x0, assuming that 1 block size is 128K bytes and the number of original blocks is 2.
  • block-by-block detection according to the state of the block, the new one is the number of dynamic blocks, and the new dynamic start address.
  • the original starting address of the first partition is the same as the dynamic starting address.
  • the block status in each partition is detected in turn until the last partition is detected.
  • the sum of the number of good blocks and the number of bad blocks is taken as the number of dynamic blocks of the partition, and the dynamic start address and the number of dynamic blocks of the partition are used as dynamic partition information of the partition.
  • the dynamic start address of the next partition is determined by the dynamic start address of the partition and the number of dynamic blocks of the partition.
  • the dynamic partition information of all partitions is uniformly stored in a planned place, for example, may be stored in a specified area of the first block of the Nand flash memory, or may be stored in the attribute area of the Nand flash memory, or may be stored in Nand flash memory combined with Nor flash.
  • the original starting address of the first partition is the same as the dynamic starting address. According to the detection of the block status, the original block number and the dynamic block number of each partition may be the same or different; the original start address and the dynamic start address of the partition after the first partition may be the same or may be different.
  • the dynamic start address of the i+1th partition the dynamic start address of the i th partition + the dynamic block number of the i th partition X block size.
  • the entry information of the dynamic partition information can be abstracted as follows:
  • ⁇ PhyPartInforhunt Figure 6 is a schematic schematic diagram of a method of generating partition information according to an embodiment of the present invention.
  • the number of original blocks of the second partition 61 in the original partition information is 4, that is, 4 good blocks are required. If, by block state detection, it is determined that 3 bad blocks are detected before ensuring that at least 4 good blocks are included in the second partition 61, the number of dynamic blocks of the re-determined second partition is the sum of the number of good blocks and the number of bad blocks. , equal to 7.
  • the partition by acquiring and parsing the original partition information, performing good and bad detection for each block in each partition, re-counting the number of blocks in each partition and the starting address, and generating dynamic partition information, so that the partition can be dynamically changed.
  • the information saves the block resources of the storage medium and improves the utilization rate of the storage medium.
  • the system reads the partition information, performs data reading, partition mounting, and the like. Therefore, this method can be used whenever there is a need to regenerate the partition, so it is also applicable to the following cases.
  • the block of the Nand flash memory becomes a bad block after being erased multiple times and exceeds the lifetime in the subsequent use process, the number of good blocks on the partition may not be sufficient. Use this partition, making the entire system unusable.
  • the traditional static partition can be changed by using the embodiment of the present invention, which avoids the problem that the partition cannot be used when the number of bad blocks of the partition is large, or the number of reserved blocks is too large, resulting in waste of the partition.
  • the traditional static partition can be changed by using the embodiment of the present invention, which avoids the problem that the Nand flash memory cannot be used normally when the partition information is lost, or the number of reserved blocks is too large, resulting in waste of the partition.
  • the method of the embodiment of the present invention can be used to generate dynamic partition information.
  • FIG. 7 is a schematic block diagram of an apparatus 70 for generating dynamic partition information in a Nand flash memory in accordance with an embodiment of the present invention.
  • the apparatus 70 includes: a parsing unit 71, a first generating unit 72, and a storage unit 73.
  • the parsing unit 71 parses the original partition information and sends it to the first generating unit, the original partition information including the named n partitions and the number of original blocks of each of the partitions, where n is a positive integer.
  • the first generation unit 72 sequentially detects the state of the block of each partition according to the original block number of the n partitions parsed by the parsing unit and the original start address of the first partition of the n partitions.
  • the n partitions generate dynamic partition information and send to the storage unit, where the dynamic partition information includes a dynamic start address and a dynamic block number of the n partitions.
  • the storage unit 73 stores the dynamic partition information generated by the first generation unit to a specified Area.
  • the storage unit 73 uniformly stores the dynamic partition information of all the partitions in a planned place, for example, may be stored in a designated area of the first block of the Nand flash memory, or may be stored in the attribute area of the Nand flash memory, or may be Stored in Nor flash memory for use with Nand flash.
  • the device of the embodiment of the present invention solves the problem of resource waste caused by the fact that the storage medium has a random distribution of bad blocks, and reserves more blocks for the partition to avoid the problem, and also includes the partitioning caused by not considering the feature.
  • Reliability problem by parsing the original partition information, performing good and bad detection for each block in each partition, re-counting the number of blocks in each partition and the starting address, and generating dynamic partition information, so that the partition information can be dynamically changed.
  • the block resources of the storage medium are saved, and the utilization rate of the storage medium is improved.
  • FIG 8 is a schematic block diagram of another apparatus 80 for generating dynamic partition information in a Nand flash memory in accordance with an embodiment of the present invention.
  • the apparatus 80 includes: a parsing unit 81, a first generating unit 82, a storage unit 83, an erasing unit 84, a programming unit 85, and a second generating unit 86 or an obtaining unit 87.
  • the parsing unit 81, the first generating unit 82, and the storage unit 83 of the device 80 are the same as or similar to the parsing unit 71 of the device 70, the first generating unit 72, and the storage unit 73.
  • the first generating unit 82 of the device 80 may include a detecting module 821, a counting module 822, and a determining module 823.
  • the device 80 may further include an erasing unit 84 and a programming unit 85, and a second generating unit 86 or an obtaining unit 87. .
  • the parsing unit 81 parses the original partition information and sends it to the first generating unit, the original partition information including the named n partitions and the number of original blocks of each of the partitions, where n is a positive integer.
  • the first generation unit 82 sequentially detects the state of the block of each partition according to the number of original blocks of the n partitions parsed by the parsing unit and the original start address of the first partition of the n partitions.
  • the n partitions generate dynamic partition information and send to the storage unit, where the dynamic partition information includes a dynamic start address and a dynamic block number of the n partitions.
  • the storage unit 83 stores the dynamic partition information generated by the first generation unit to a designated area.
  • the storage unit 83 uniformly stores the dynamic partition information of all the partitions in a planned place, for example, may be stored in a specified area of the first block of the Nand flash memory, or may be stored in the attribute area of the Nand flash memory, or may be Stored in Nor flash memory for use with Nand flash.
  • the detecting module 821 divides the first part of the n partitions The original starting address of the area is used as the dynamic starting address of the first partition, and the state of each block in the i-th partition is detected in turn from the first partition until the nth partition, where n ⁇ ;
  • the detecting module 821 detects that the state of the current block is good, the counting module 822 adds 1 to the good block number; and when the detecting module 821 detects that the current block state is bad, the counting module 822 will block the bad block.
  • the number is increased by 1; and when the number of good blocks > the number of original blocks of the i-th partition, the determining module 823 uses the sum of the number of good blocks and the number of bad blocks as the number of dynamic blocks of the i-th partition, and A dynamic start address of the i+1th partition is determined by a dynamic start address of the i th partition and a dynamic block number of the i th partition.
  • the dynamic start address of the partition the dynamic start address of the i-th partition + the number of dynamic blocks of the i-th partition X block size.
  • the erasing unit 84 when the detecting module 821 detects that the state of the current block is good, the erasing unit 84 is configured to erase the current block and the programming unit 85 is in the Writing data in the current block; or when the detecting module 821 detects that the state of the current block is bad, the erasing unit 84 skips the current block and the programming unit 85 is in the current block Do not write data.
  • the device 80 may further include a second generating unit 86.
  • the second generation unit 86 generates raw partition information.
  • the device 80 may further include an obtaining unit 87, and the obtaining unit 87 may acquire the generated original partition information from other devices.
  • the dynamic partition information and the burn data are generated by parsing the original partition information.
  • the programming unit 85 may write a boot program in the first block of the first partition of the Nand flash memory before parsing the original partition information.
  • the device 80 first programs the boot program, and then the boot program unifies the programming data into the Nand flash memory.
  • the application process in the boot program can use the method 40 or 50 of the embodiment of the present invention.
  • the device of the embodiment of the present invention solves the problem of resource waste caused by the fact that the storage medium has a random distribution of bad blocks, and reserves more blocks for the partition to avoid the problem, and also includes the partitioning caused by not considering the feature. Reliability problem, by obtaining and parsing the original partition information, performing good and bad detection for each block in each partition, re-counting the number of blocks in each partition and the starting address, generating dynamic partition information, so that the partition can be dynamically changed. The information saves the block resources of the storage medium and improves the utilization rate of the storage medium.
  • the device in the embodiment of the present invention changes the traditional static partition, which avoids the partition being unusable when the partition has many bad blocks, and also prevents the Nand flash memory from being used normally when the partition information is lost.
  • Figure 9 is a schematic block diagram of another apparatus 90 for generating dynamic partition information in a Nand flash memory in accordance with an embodiment of the present invention.
  • the device 90 includes a processor 91 and a memory 92.
  • the memory 92 may be a RAM and a ROM, or any fixed storage medium, or a removable storage medium for storing data that can be executed in the program of the embodiment of the present invention or in the embodiment of the present invention.
  • the memory 92 can also be used to store raw partition information including the named n partitions and the original number of blocks for each of the partitions, where n is a positive integer and the generated dynamic partition information.
  • the processor 91 is operative to execute the program of the embodiment of the present invention stored by the memory 92.
  • the processor 91 can be a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic steps and logic block diagrams.
  • the general purpose processor may be a microprocessor or the processor or any conventional processor or the like.
  • the steps of the method disclosed in the embodiments of the present invention may be directly implemented by the hardware decoding processor, or may be performed by a combination of hardware and software modules in the decoding processor.
  • the software modules can be located in a conventional storage medium such as random access memory, flash memory, read only memory, programmable read only memory or electrically erasable programmable memory, registers, and the like.
  • the storage medium is located in the memory 92, and the processor 91 reads the information in the memory 92 and combines the hardware to perform the steps of the above method.
  • the processor 91 parses the original partition information, where the original partition information includes the named n partitions and the number of original blocks of each of the partitions, where n is a positive integer; according to the parsed number of original blocks of the n partitions And the original starting address of the first partition of the n partitions, by sequentially detecting the state of the blocks of each partition, generating dynamic partition information for the n partitions, where the dynamic partition information includes the n partitions Dynamic start address and dynamic block number; store the generated dynamic partition information to a specified area.
  • the processor 91 uniformly stores the dynamic partition information of all the partitions in a planned place, for example, may be stored in a designated area of the first block of the Nand flash memory, or may be stored in the attribute area of the Nand flash memory, or It can also be stored to Nor flash in conjunction with Nand flash.
  • the processor 91 uses the original start address of the first partition of the n partitions as the dynamic start address of the first partition, starting from the first partition to the nth Up to the partition, the state of each block in the i-th partition is detected in turn, where n ⁇ ; when the state of the current block is detected to be good, the number of good blocks is increased by 1; and when the state of the current block is detected as bad, Adding the number of bad blocks to 1; and when the number of good blocks > the number of original blocks of the i-th partition, the sum of the number of good blocks and the number of bad blocks is taken as the number of dynamic blocks of the i-th partition, and
  • the dynamic start address of the i-th partition and the dynamic block number of the i-th partition determine a dynamic start address of the i+1th partition.
  • the processor 91 erases the current block and writes data when detecting that the current block status is good; or jumps when detecting that the current block status is bad. The current block is passed and no data is written.
  • the processor 91 generates the original partition information.
  • the processor 91 writes a boot program in the first block of the first partition of the Nand flash memory before the parsing the original partition information.
  • the embodiment of the invention solves the problem of resource waste caused by the random distribution of bad blocks in the storage medium, and reserves more blocks for the partition to avoid the problem, and also includes the reliability caused by partitioning without considering the feature.
  • the problem is that by parsing the original partition information, performing good and bad detection for each block in each partition, re-counting the number of blocks in each partition and the starting address, and generating dynamic partition information, thereby dynamically changing the partition information, thereby saving
  • the block resource of the storage medium improves the utilization of the storage medium.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
  • the components displayed for the unit may or may not be physical units, ie may be located in one place, or may be distributed over multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the functions, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium.
  • the technical solution of the present invention which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including
  • the instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and the like, which can store program codes. .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)
  • Read Only Memory (AREA)

Abstract

Embodiments of the present invention provide a method and a device for generating dynamic partition information in a Nand flash memory. The method comprises: analyzing original partition information which comprises n partitions and the number of original blocks of each partition, n being a positive integer; according to the number of the original blocks of the n partitions and the original start address of the first partition of the n partitions, detecting the state of each block of each partition in sequence, and generating the dynamic partition information of the n partitions, the dynamic partition information comprising the dynamic start addresses and the number of the dynamic blocks of the n partitions; and storing the dynamic partition information in a specified area. The device corresponding to the method is further provided. The above technical solutions solve the problem of resource waste caused by more blocks which are reserved for the partitions to avoid the problem of random distribution of broken blocks in a storage medium, and the problem of low reliability caused by partitioning without considering the random distribution of the broken blocks in the storage medium, so that block resources are saved, and the utilization rate of the storage medium is improved.

Description

在 Nand闪存中生成动态分区信息的方法和装置 本申请要求于 2012 年 11 月 28 日提交中国专利局、 申请号为 201210495157.7、 发明名称为 "在 Nand 闪存中生成动态分区信息的方法和 装置" 的中国专利申请的优先权, 其全部内容通过引用结合在本申请中。  Method and apparatus for generating dynamic partition information in Nand flash memory This application claims to be filed on November 28, 2012 with the Chinese Patent Office, application number 201210495157.7, and the invention titled "Method and apparatus for generating dynamic partition information in Nand flash memory" Priority of Chinese Patent Application, the entire contents of which is incorporated herein by reference.

技术领域 Technical field

本发明实施例涉及计算机领域, 更具体地, 涉及在 Nand闪存中生成动 态分区信息的方法和装置。 背景技术  Embodiments of the present invention relate to the field of computers, and more particularly, to a method and apparatus for generating dynamic partition information in a Nand flash memory. Background technique

Nand 闪存是一种能够进行读写、 擦除的存储介质, 其容量大、 擦写速 度快, 且具有价格低廉等优势, 被广泛应用在机顶盒、 数码相机、 手机、 平 板电脑等其他电子产品上, 用来存放程序、 参数、 媒体数据等。 而大多数产 品釆用的操作系统中,通过抽象设备访问层,提供了一种例如 MTD( Memory Technology Device , 内存技术设备 )的系统, MTD为该操作系统提供了针对 闪存访问的统一、 抽象的接口。  Nand flash memory is a storage medium capable of reading, writing and erasing. It has the advantages of large capacity, fast erasing speed and low price. It is widely used in set-top boxes, digital cameras, mobile phones, tablet computers and other electronic products. , used to store programs, parameters, media data, etc. In most operating systems, the abstract device access layer provides a system such as MTD (Memory Technology Device), which provides unified, abstract access to flash memory for the operating system. interface.

对 MTD设备的使用过程来说, 进行分区是其中一个重要的步骤。 所谓 分区, 就是在闪存上划分多个区域, 划分后的区域简称为分区, 每一个分区 都有固定的物理的起始地址和分区大小, 其中分区大小通常由每个分区所包 括的块(block )的数量决定, 每个块的大小为默认值。 分区的起始地址和块 数量在本文中也称为分区信息。 这些分区信息是系统在启动和运行过程, 闪 存上读取数据和挂载文件系统等操作的重要参数。  Partitioning is an important step in the use of MTD equipment. The so-called partitioning is to divide multiple areas on the flash memory. The divided areas are simply referred to as partitions. Each partition has a fixed physical starting address and partition size, where the partition size is usually composed of blocks included in each partition (block). The number of ) determines the size of each block as the default. The starting address and number of blocks of a partition are also referred to herein as partition information. These partition information are important parameters for the system to start and run, to read data on the flash and mount the file system.

尽管 Nand闪存容量大、 价格便宜, 但是本身 Nand闪存存在一个固有 缺陷: 出厂时就存在坏块, 而且这些坏块随机分布。 Nand 闪存是以块为单 位进行管理的。 按照本领域的经验, 坏块占整个 Nand闪存的块数的比例小 于一定值都是可以接收的, 该定值例如为 2%。 因此, 很可能在同一分区内 会连续出现多个坏块。正是由于这个缺陷,给使用中带来一定的可靠性问题, 尤其是对于系统中可能出现的大小较小的分区影响较大。 比如用来保存一些 参数数据的分区, 其大小可能才共占 2~4个 block, 当出现连续多个坏块时, 该分区将无法正常写入参数, 系统启动时则也无法读出参数。 Despite the large capacity and low price of Nand flash memory, there is an inherent defect in Nand flash memory itself: there are bad blocks at the factory, and these bad blocks are randomly distributed. Nand flash is managed in blocks. According to the experience in the art, the ratio of bad blocks to the number of blocks of the entire Nand flash memory is less than a certain value, and the fixed value is, for example, 2%. Therefore, it is likely that multiple bad blocks will appear consecutively in the same partition. It is because of this defect that it brings certain reliability problems to the use, especially for the smaller partitions that may appear in the system. For example, a partition used to store some parameter data may occupy a total of 2 to 4 blocks. When there are multiple consecutive bad blocks, The partition will not be able to write parameters properly, nor will it be able to read the parameters when the system starts up.

为此, 现有技术中通过为 Nand闪存的每个分区预留若干块以解决遇到 坏块时引起的问题。 分区信息的块数量中包括预留的块数量。 当该 Nand闪 存的坏块数量较少时, 则预留的块中较多没有用到, 而现有技术中分区信息 无法更改, 造成了资源浪费。 发明内容  For this reason, in the prior art, a number of blocks are reserved for each partition of the Nand flash memory to solve the problem caused when a bad block is encountered. The number of blocks of partition information includes the number of reserved blocks. When the number of bad blocks in the Nand flash is small, more of the reserved blocks are not used, and the partition information cannot be changed in the prior art, resulting in waste of resources. Summary of the invention

有鉴于此, 本发明实施例提供一种在 Nand闪存中生成动态分区信息的 方法和装置, 以解决为规避存储介质存在坏块随机分布的特性而为分区预留 较多数量的块而引起的资源浪费的问题。  In view of the above, the embodiments of the present invention provide a method and an apparatus for generating dynamic partition information in a Nand flash memory, so as to solve the problem that a large number of blocks are reserved for a partition in order to avoid the random distribution of bad blocks in the storage medium. The problem of wasting resources.

第一方面,提供了一种在 Nand闪存中生成动态分区信息的方法, 包括: 解析原始分区信息,原始分区信息包括命名的 n个分区和每个分区的原始块 数量, 其中 n为正整数; 根据 n个分区的原始块数量和 n个分区的第 1个分 区的原始起始地址, 通过顺序检测各分区的块的状态, 为 n个分区生成动态 分区信息, 动态分区信息包括 n个分区的动态起始地址和动态块数量; 将动 态分区信息存储到指定区域。  The first aspect provides a method for generating dynamic partition information in a Nand flash memory, including: parsing original partition information, where the original partition information includes a named n partitions and a number of original blocks of each partition, where n is a positive integer; According to the original block number of n partitions and the original start address of the first partition of n partitions, dynamic partition information is generated for n partitions by sequentially detecting the states of the blocks of each partition, and the dynamic partition information includes n partitions. Dynamic start address and number of dynamic blocks; store dynamic partition information to a specified area.

在第一种可能的实现方式中,将 n个分区的第 1个分区的原始起始地址 作为第 1个分区的动态起始地址, 从第 1个分区开始直到第 n个分区为止, 依次检测第 i个分区中的各个块的状态, 其中 n} ; 当检测到当前块的 状态为好, 则将好块数量加 1 ; 且当检测到当前块的状态为坏, 则将坏块数 量加 1 ; 且当好块数量 >第 i个分区的原始块数量时, 将好块数量与坏块数 量的和作为第 i个分区的动态块数量, 且通过第 i个分区的动态起始地址和 第 i个分区的动态块数量确定第 i+1个分区的动态起始地址。  In the first possible implementation, the original start address of the first partition of the n partitions is used as the dynamic start address of the first partition, and is detected from the first partition to the nth partition. The state of each block in the i-th partition, where n}; when the state of the current block is detected to be good, the number of good blocks is increased by 1; and when the state of the current block is detected to be bad, the number of bad blocks is added 1 ; and when the number of good blocks > the number of original blocks of the i-th partition, the sum of the number of good blocks and the number of bad blocks is taken as the number of dynamic blocks of the i-th partition, and the dynamic start address of the i-th partition is The number of dynamic blocks of the i-th partition determines the dynamic start address of the i+1th partition.

结合第一方面的第一种可能的实现方式, 在第二种可能的实现方式中, 第 i+1个分区的动态起始地址=第 i个分区的动态起始地址 +第 i个分区的动 态块数量 X块大小。  In conjunction with the first possible implementation of the first aspect, in a second possible implementation, the dynamic start address of the i+1th partition = the dynamic start address of the i th partition + the i th partition The number of dynamic blocks is X block size.

结合第一方面或第一方面的上述可能的实现方式,在第三种可能的实现 方式中, 当检测到当前块的状态为好时, 则擦除当前块并写入数据; 或当检 测到当前块的状态为坏时, 则跳过当前块且不写入数据。  With reference to the first aspect or the foregoing possible implementation manner of the first aspect, in a third possible implementation manner, when detecting that the current block state is good, erasing the current block and writing data; or when detecting When the current block status is bad, the current block is skipped and no data is written.

结合第一方面或第一方面的上述可能的实现方式,在第四种可能的实现 方式中, 在解析原始分区信息前, 生成原始分区信息。 结合第一方面或第一方面的上述可能的实现方式,在第五种可能的实现 方式中, 在解析原始分区信息前, 还在 Nand闪存的第一个分区的第一个块 中写入引导程序。 With reference to the first aspect or the foregoing possible implementation manner of the first aspect, in a fourth possible implementation, the original partition information is generated before the original partition information is parsed. With reference to the first aspect or the foregoing possible implementation manner of the first aspect, in the fifth possible implementation, before the original partition information is parsed, the boot is also written in the first block of the first partition of the Nand flash memory. program.

第二方面, 提供了一种在 Nand闪存中生成分区信息的装置, 包括解析 单元、 第一生成单元和存储单元: 解析单元, 用于解析原始分区信息并发送 到第一生成单元,原始分区信息包括命名的 n个分区和每个分区的原始块数 量, 其中 n为正整数; 第一生成单元, 用于根据解析单元解析的 n个分区的 原始块数量和 n个分区的第 1个分区的原始起始地址,通过顺序检测各分区 的块的状态, 为 n个分区生成动态分区信息并发送到存储单元, 动态分区信 息包括 n个分区的动态起始地址和动态块数量; 存储单元, 用于将第一生成 单元生成的动态分区信息存储到指定区域。  A second aspect provides an apparatus for generating partition information in a Nand flash memory, including a parsing unit, a first generating unit, and a storage unit: a parsing unit, configured to parse the original partition information and send the information to the first generating unit, the original partition information The number of original blocks including the named n partitions and each partition, where n is a positive integer; the first generating unit, the number of original blocks of n partitions parsed according to the parsing unit and the first partition of n partitions The original starting address, by sequentially detecting the state of the blocks of each partition, generating dynamic partition information for the n partitions and transmitting to the storage unit, the dynamic partition information includes the dynamic start address and the number of dynamic blocks of the n partitions; The dynamic partition information generated by the first generation unit is stored in the designated area.

在第一种可能的实现方式中, 第一生成单元包括检测模块、 计数模块和 确定模块: 检测模块, 用于将 n个分区的第 1个分区的原始起始地址作为第 1个分区的动态起始地址, 从第 1个分区开始直到第 n个分区为止, 依次检 测第 i个分区中的各个块的状态, 其中 n} ; 当检测模块检测到当前块 的状态为好, 则计数模块将好块数量加 1 ; 且当检测模块检测到当前块的状 态为坏, 则计数模块将坏块数量加 1 ; 且当好块数量 >第 i个分区的原始块 数量时,确定模块将好块数量与坏块数量的和作为第 i个分区的动态块数量, 且通过第 i个分区的动态起始地址和第 i个分区的动态块数量确定第 i+1个 分区的动态起始地址。  In a first possible implementation, the first generating unit includes a detecting module, a counting module, and a determining module: a detecting module, configured to use the original starting address of the first partition of the n partitions as the dynamic of the first partition The starting address, starting from the first partition until the nth partition, sequentially detecting the state of each block in the i-th partition, where n}; when the detecting module detects that the current block state is good, the counting module will The number of good blocks is increased by 1; and when the detection module detects that the current block status is bad, the counting module adds 1 to the number of bad blocks; and when the number of good blocks > the number of original blocks of the i-th partition, the module is determined to be a good block. The sum of the number and the number of bad blocks is the number of dynamic blocks of the i-th partition, and the dynamic start address of the i+1th partition is determined by the dynamic start address of the i-th partition and the number of dynamic blocks of the i-th partition.

结合第二方面的第一种可能的实现方式, 在第二种可能的实现方式中, 确定模块具体用于下述公式以确定动态起始地址: 第 i+1个分区的动态起始 地址 =第 i个分区的动态起始地址 +第 i个分区的动态块数量 X块大小。  In conjunction with the first possible implementation of the second aspect, in a second possible implementation, the determining module is specifically configured to determine a dynamic starting address: a dynamic starting address of the i+1th partition= Dynamic start address of the i-th partition + number of dynamic blocks of the i-th partition X block size.

结合第二方面或第二方面的上述可能的实现方式,在第三种可能的实现 方式中, 装置还包括擦除单元和烧写单元: 当检测模块检测到当前块的状态 为好时, 则擦除单元用于擦除当前块且烧写单元在当前块中写入数据; 或当 检测模块检测到当前块的状态为坏时, 则擦除单元用于跳过当前块且烧写单 元在当前块不写入数据。  With reference to the second aspect or the foregoing possible implementation manner of the second aspect, in a third possible implementation, the device further includes: an erasing unit and a programming unit: when the detecting module detects that the current block state is good, The erasing unit is for erasing the current block and the programming unit writes data in the current block; or when the detecting module detects that the state of the current block is bad, the erasing unit is used to skip the current block and the programming unit is The current block does not write data.

结合第二方面或第二方面的上述可能的实现方式,在第四种可能的实现 方式中, 装置还包括第二生成单元: 第二生成单元, 用于在解析原始分区信 息前, 生成原始分区信息。 结合第二方面或第二方面的上述可能的实现方式,在第五种可能的实现 方式中, 装置还包括烧写单元: 烧写单元, 用于在解析原始分区信息前, 在With reference to the second aspect or the foregoing possible implementation manner of the second aspect, in a fourth possible implementation, the apparatus further includes: a second generating unit, configured to generate the original partition before parsing the original partition information information. With reference to the second aspect or the foregoing possible implementation manner of the second aspect, in a fifth possible implementation, the device further includes: a programming unit, configured to: before parsing the original partition information,

Nand闪存的第一个分区的第一个块中写入引导程序。 The boot program is written in the first block of the first partition of the Nand flash.

通过上述技术方案解析原始分区信息,针对每个分区中的每个块进行好 坏检测, 重新统计每个分区中块的数量以及起始地址, 生成动态分区信息, 从而可以动态改变分区信息, 节省了存储介质的块资源, 提高了存储介质的 利用率。 附图说明  The original partition information is parsed by the foregoing technical solution, and each block in each partition is tested for good or bad, the number of blocks in each partition and the starting address are re-stated, and dynamic partition information is generated, so that the partition information can be dynamically changed, thereby saving The block resource of the storage medium improves the utilization rate of the storage medium. DRAWINGS

为了更清楚地说明本发明实施例的技术方案, 下面将对本发明实施例中 所需要使用的附图作简单地介绍, 显而易见地, 下面所描述的附图仅仅是本 发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动的 前提下, 还可以根据这些附图获得其他的附图。  In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings to be used in the embodiments of the present invention will be briefly described below. It is obvious that the drawings described below are only some embodiments of the present invention, Those skilled in the art can also obtain other drawings based on these drawings without paying any creative work.

图 1是现有技术中一种在 Nand闪存中生成分区信息的方法的示意图。 图 2是现有技术另一种在 Nand闪存中生成分区信息的方法的示意图。 图 3是现有技术的又一种在 Nand闪存中生成分区信息的方法的示意图。 图 4是本发明实施例的在 Nand闪存中生成动态分区信息的方法的示意 流程图。  FIG. 1 is a schematic diagram of a method for generating partition information in a Nand flash memory in the prior art. 2 is a schematic diagram of another method for generating partition information in a Nand flash memory in the prior art. FIG. 3 is a schematic diagram of another method of generating partition information in a Nand flash memory in the prior art. 4 is a schematic flow chart of a method for generating dynamic partition information in a Nand flash memory according to an embodiment of the present invention.

图 5是本发明实施例的在 Nand闪存中生成动态分区信息的方法的示意 流程图。  FIG. 5 is a schematic flow chart of a method for generating dynamic partition information in a Nand flash memory according to an embodiment of the present invention.

图 6是本发明实施例的生成分区信息的方法的示意原理图。  FIG. 6 is a schematic schematic diagram of a method for generating partition information according to an embodiment of the present invention.

图 7是本发明实施例的在 Nand闪存中生成动态分区信息的装置的示意 框图。  Figure 7 is a schematic block diagram of an apparatus for generating dynamic partition information in a Nand flash memory in accordance with an embodiment of the present invention.

图 8是本发明实施例的在 Nand闪存中生成动态分区信息的另一装置的 示意框图。  Figure 8 is a schematic block diagram of another apparatus for generating dynamic partition information in a Nand flash memory in accordance with an embodiment of the present invention.

图 9是本发明实施例的在 Nand闪存中生成动态分区信息的另一装置的 示意框图。 具体实施方式  Figure 9 is a schematic block diagram of another apparatus for generating dynamic partition information in a Nand flash memory in accordance with an embodiment of the present invention. detailed description

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行 清楚、 完整地描述, 显然, 所描述的实施例是本发明的一部分实施例, 而不 是全部实施例。 基于本发明中的实施例, 本领域普通技术人员在没有做出创 造性劳动的前提下所获得的所有其他实施例, 都应属于本发明保护的范围。 The technical solutions in the embodiments of the present invention will be clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are a part of the embodiments of the present invention, and It is all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts shall fall within the scope of the present invention.

图 1是现有技术中一种在 Nand闪存中生成分区信息的方法的示意图。 图 1中示意了 4个分区, 第一分区 11、 第二分区 12、 第三分区 13和第四分 区 14, 分别用于存储引导(boot )程序、 系统核心 (Linux Kernel )程序、 根文件系统( Root file System )和参数数据( Parameters Data )。 为说明方便, 此处各分区以序号命名, 但其中分区的命名可以釆用其他方式, 例如第一分 区 11也可以命名为引导分区、 第四分区 14也可以命名为参数分区等。 一块 Nand 闪存包括若干块。 块大小为出厂缺省值。 以下将一个分区中包括的块 数量简称为块数量。 此处, 假设 1个块大小为 128K字节。 各分区的起始地 址和大小如图 1所示,分别为:第一分区 11的起始地址为 0x0,大小为 512K 字节, 块数量为 2; 第二分区 121的起始地址为 0x80000 , 大小为 4M字节, 块数量为 31250; 第三分区 13的起始地址为 0x480000, 大小为 40M字节, 块数量为 312500; 第四分区 14的起始地址为 0x2C80000, 大小为 512K字 节, 块数量为 2。 第一分区的起始地址是已知的, 可选地, 可以从 0x0开始; 当然, 也可以从指定地址开始。 这样, 一个分区的块数量 X块大小加上起始 地址得到的字节数就是下一个分区的起始地址。本文中的分区信息至少包括 分区的命名和块数量。  FIG. 1 is a schematic diagram of a method for generating partition information in a Nand flash memory in the prior art. FIG. 1 illustrates four partitions, a first partition 11, a second partition 12, a third partition 13, and a fourth partition 14, respectively, for storing a boot program, a system kernel (Linux Kernel) program, and a root file system. ( Root file System ) and parameter data ( Parameters Data ). For convenience of explanation, each partition is named by a serial number, but the partition can be named by other methods. For example, the first partition 11 can also be named as a boot partition, and the fourth partition 14 can also be named as a parameter partition. A piece of Nand flash memory consists of several blocks. The block size is the factory default. The number of blocks included in one partition is simply referred to as the number of blocks. Here, assume that one block size is 128K bytes. The starting address and size of each partition are as shown in FIG. 1, which are: the starting address of the first partition 11 is 0x0, the size is 512K bytes, the number of blocks is 2; the starting address of the second partition 121 is 0x80000, The size is 4M bytes, the number of blocks is 31250; the starting address of the third partition 13 is 0x480000, the size is 40M bytes, the number of blocks is 312500; the starting address of the fourth partition 14 is 0x2C80000, and the size is 512K bytes. The number of blocks is 2. The starting address of the first partition is known, optionally starting from 0x0; of course, it is also possible to start from the specified address. Thus, the number of blocks in a partition X block size plus the starting address The number of bytes is the starting address of the next partition. The partition information in this article includes at least the name of the partition and the number of blocks.

通常情况, 系统上电复位后, 会启动第一分区 11 的引导程序, 然后引 导程序会从第二分区 12 中读取系统核心程序并运行, 接着系统核心程序会 才艮据分区信息, 将第三分区 13挂载引导文件系统, 并启动相关应用, 最后 将第四分区 14挂载, 读取相关的参数数据。 由此可见, 分区信息对系统的 启动和运行至关重要。  Normally, after the system power-on reset, the boot program of the first partition 11 is started, and then the boot program reads the system core program from the second partition 12 and runs, and then the system core program will calculate the partition information. The third partition 13 mounts the boot file system, starts the related application, and finally mounts the fourth partition 14 to read the relevant parameter data. Thus, partition information is critical to the startup and operation of the system.

一种现有技术, 参考图 2, 不考虑 Nand闪存的坏块随机分布的特性, 仅仅根据分区实际用到的块数量, 以及考虑到为防止分区在使用过程中可能 出现坏块而预留的块数量, 而进行分区。  A prior art, referring to FIG. 2, does not consider the characteristics of the random distribution of bad blocks of the Nand flash memory, only according to the number of blocks actually used by the partition, and considering that the partition may be reserved to prevent bad blocks from being used during use. The number of blocks, while partitioning.

图 2是现有技术另一种在 Nand闪存中生成分区信息的方法的示意图。 其中, 图 2中示出第一分区 21、 第二分区 22和第三分区 23 , 以第二分区 22 为例进行说明。 第二分区 22 , 也可以称为参数分区, 用于存储参数数据 ( Parameter Data )„ 通常情况下, 参数分区的数据量比较小, 假设只占 2个 块(共 2 χ 128Κ字节 =256K字节)。 考虑使用过程, 可能会因为长时间的擦 写产生坏块, 因此, 规划参数分区时, 多预留两个 2个, 这样参数分区一共 是 4个块。 2 is a schematic diagram of another method for generating partition information in a Nand flash memory in the prior art. The first partition 21, the second partition 22, and the third partition 23 are shown in FIG. 2, and the second partition 22 is taken as an example for description. The second partition 22, also called parameter partition, is used to store parameter data (Parameter Data) „ Normally, the data volume of the parameter partition is relatively small, assuming only 2 blocks (2 χ 128Κ bytes = 256K words) Section). Considering the use process, it may be due to long time rubbing Write generates bad blocks. Therefore, when planning parameter partitioning, reserve two more, so the parameter partition is a total of 4 blocks.

由于该分区的方法中没有考虑到 Nand闪存的坏块的随机分布的特性, 其缺陷非常明显。 以第二分区 22为例,如果该分区的 4 个块刚好都是坏块, 那么就意味着该分区将无法写入数据, 系统启动时, 将无法正确读写数据, 导致系统异常。 而现有技术中, 分区信息是不能更改的, 那么就意味着这块 Nand闪存将无法使用, 只能作为不良品。 但实际上这块 Nand闪存是符合要 求的, 只不过出厂时的坏块刚好集中到该分区而已。 因此, 按照图 2的现有 技术分区, 实际上会造成物料的浪费。  Since the method of the partition does not take into account the random distribution characteristics of the bad blocks of the Nand flash memory, the defects are very obvious. Taking the second partition 22 as an example, if the 4 blocks of the partition are just bad blocks, it means that the partition cannot write data, and when the system starts, the data cannot be read and written correctly, resulting in a system exception. In the prior art, the partition information cannot be changed, which means that the Nand flash memory will be unusable and can only be used as a defective product. But in fact, this Nand flash memory is in compliance with the requirements, except that the bad blocks at the factory are just concentrated in the partition. Therefore, according to the prior art partition of Fig. 2, material waste is actually caused.

另一种现有技术, 参考图 3 , 在分区时, 充分考虑 Nand闪存的坏块随 机分布的特性。 即在规划分区时, 除了考虑正常的数据存储区域外, 还要考 虑因为坏块的随机分布特性, 而为每个分区预留一定数量的块; 按照本领域 通用的做法, 最可靠的是为每个分区预留 Nand闪存总块数的 2 % , 以容量 为 512M字节的 Nand闪存来说, 需要为每个分区至少预留 80个块。  Another prior art, referring to Figure 3, takes full account of the random distribution of bad blocks of Nand flash memory during partitioning. That is, when planning the partition, in addition to considering the normal data storage area, it is also necessary to reserve a certain number of blocks for each partition because of the random distribution characteristics of the bad blocks; according to the general practice in the art, the most reliable is Each partition reserves 2% of the total number of Nand flash memory. For Nand flash memory with a capacity of 512 Mbytes, at least 80 blocks need to be reserved for each partition.

图 3是现有技术的又一种在 Nand闪存中生成分区信息的方法的示意图。 图 3中示意性包括了六个分区, 第一分区 31至第六分区 36 , 其中每个分区 中包括的预留区域分别为 31A至 36A。  FIG. 3 is a schematic diagram of another method of generating partition information in a Nand flash memory in the prior art. The three partitions, the first partition 31 to the sixth partition 36, are schematically illustrated in Fig. 3, wherein the reserved areas included in each partition are 31A to 36A, respectively.

如果分区较多, 例如有较多的分区用于存储参数数据, 按照图 3的技术 方案, 必须要为每个分区至少都预留 80个块, 每个块大小为 128K字节, 假 设如图 3示例有 6个分区, 那么系统中的预留区域共有 6 X 80 X 128K = 60M 字节。 这意味着为了规避 Nand闪存坏块随机分布的特性带来的风险, 而导 致系统中会有更多的块被作为预留区。 但是在实际应用中, 大部分情况下, 坏块并没有那么多, 而且也不会恰好都分布在参数分区。 从实际出发, 像参 数分区本身很小, 只需预留较少数量的块即可。 图 3所示的分区方法会造成 较多数量的块被浪费掉。  If there are more partitions, for example, there are more partitions for storing parameter data, according to the technical scheme of FIG. 3, at least 80 blocks must be reserved for each partition, each block size is 128 Kbytes, assuming 3 The example has 6 partitions, then the reserved area in the system has 6 X 80 X 128K = 60M bytes. This means that in order to avoid the risk of the random distribution of bad blocks of Nand flash memory, more blocks will be used as reserved areas in the system. However, in practical applications, in most cases, there are not many bad blocks, and they are not all distributed in the parameter partition. From a practical point of view, the parameter partition itself is small, and only a small number of blocks need to be reserved. The partitioning method shown in Figure 3 causes a larger number of blocks to be wasted.

为了避免上述现有技术中的各种资源浪费, 本发明实施例提供了一种在 Nand 闪存中生成动态分区信息的方法和装置, 可以动态地调整分区, 生成 新的分区信息。  In order to avoid the waste of various resources in the foregoing prior art, embodiments of the present invention provide a method and apparatus for generating dynamic partition information in a Nand flash memory, which can dynamically adjust partitions and generate new partition information.

图 4是本发明实施例的在 Nand闪存中生成动态分区信息的方法 40的示 意流程图, 包括以下内容。  4 is a schematic flow diagram of a method 40 of generating dynamic partition information in a Nand flash memory according to an embodiment of the present invention, including the following.

S41 , 解析原始分区信息, 原始分区信息包括命名的 n个分区和每个所 述分区的原始块数量, 其中 n为正整数。 S41, parsing the original partition information, the original partition information includes the named n partitions and each of the The number of original blocks of the partition, where n is a positive integer.

在 Nand闪存中烧写数据时, 都会参考一个原始分区信息。 原始分区信 息可以从其他设备处获取, 也可以由执行本方法 40的装置生成。 从原始分 区信息中, 可以得知 Nand闪存被划分成 n个分区, n个分区的名字, 以及 每个分区所包括的原始块数量。 n个分区中的第一个分区的原始起始地址已 知, 因此通过每个分区所包括的原始块数量可以确定每个分区的原始大小和 原始起始地址。 需要提取原始分区信息中的信息, 例如分区的顺序、 每个分 区所包括的原始块数量等。  When programming data in the Nand flash memory, it will refer to a raw partition information. The raw partition information may be obtained from other devices or may be generated by the device performing the method 40. From the original partition information, it can be known that the Nand flash is divided into n partitions, the names of n partitions, and the number of original blocks included in each partition. The original starting address of the first of the n partitions is known, so the original size and original starting address of each partition can be determined by the number of original blocks included in each partition. It is necessary to extract information in the original partition information, such as the order of the partitions, the number of original blocks included in each partition, and the like.

542, 根据 n个分区的原始块数量和 n个分区的第 1个分区的原始起始 地址, 通过顺序检测各分区的块的状态, 为 n个分区生成动态分区信息, 动 态分区信息包括 n个分区的动态起始地址和动态块数量。  542. Generate dynamic partition information for n partitions by sequentially detecting the status of the blocks of each partition according to the original block number of the n partitions and the original start address of the first partition of the n partitions, where the dynamic partition information includes n The dynamic start address and dynamic block number of the partition.

本发明实施例中考虑到 Nand闪存的坏块是可以检测到的。 通过在构造 分区的时候, 能够根据分区时每个分区的原始大小, 对每个分区内的块做状 态检查, 主动跳过坏块, 使得分区中好块数量能满足每个分区的原始大小, 从而动态地调整分区, 生成新的分区信息即动态分区信息。  In the embodiment of the present invention, the bad block of the Nand flash memory is considered to be detectable. By constructing a partition, it is possible to check the blocks in each partition according to the original size of each partition at the time of partitioning, and actively skip the bad blocks, so that the number of good blocks in the partition can satisfy the original size of each partition. Thereby dynamically adjusting the partition and generating new partition information, that is, dynamic partition information.

543 , 将所述动态分区信息存储到指定区域。  543. Store the dynamic partition information in a specified area.

生成上述动态分区信息后, 需存储该动态分区信息, 可以存储到指定区 域。 系统启动后, 将读取该动态分区信息, 进行数据操作, 包括读取或运行 核心程序、 挂载文件系统、 读取参数等操作。 在系统核心程序启动后, 还要 根据该分区进行文件系统的挂载等操作。 因此, 对该分区信息的保存至关重 要。  After the dynamic partition information is generated, the dynamic partition information needs to be stored and can be stored in the specified area. After the system is started, the dynamic partition information will be read and data operations will be performed, including reading or running the core program, mounting the file system, and reading parameters. After the system core program is started, the file system is mounted according to the partition. Therefore, the preservation of the partition information is crucial.

可选的, 如果可以确定以后对上述动态分区信息不做更改, 可以进行一 次性编程 ( OTP, once time program )保护。  Optionally, if it can be determined that no changes are made to the above dynamic partition information, an OTP (once time program) protection may be performed.

本发明实施例解决了因存储介质存在坏块随机分布的特性, 为规避该问 题而为分区预留较多的块而引起的资源浪费问题,也包括未考虑该特性而进 行分区导致的可靠性问题, 通过解析原始分区信息, 针对每个分区中的每个 块进行好坏检测, 重新统计每个分区中块的数量以及起始地址, 生成动态分 区信息, 从而可以动态改变分区信息, 节省了存储介质的块资源, 提高了存 储介质的利用率。  The embodiment of the invention solves the problem of resource waste caused by the random distribution of bad blocks in the storage medium, and reserves more blocks for the partition to avoid the problem, and also includes the reliability caused by partitioning without considering the feature. The problem is that by parsing the original partition information, performing good and bad detection for each block in each partition, re-counting the number of blocks in each partition and the starting address, and generating dynamic partition information, thereby dynamically changing the partition information, thereby saving The block resource of the storage medium improves the utilization of the storage medium.

可选的, 本发明实施例的方法可以应用在生产 Nand闪存的过程中。 在 工厂生产加工时, 通常需要对 Nand闪存进行烧片处理。 在一个实施例中, 通过本发明实施例的方法, 首先要先规划出原始分区 信息, 然后将原始分区信息传递给烧片机, 烧片机解析该原始分区信息后, 动态计算各个分区的块数量, 依次创建新的分区并擦除和烧录数据, 并将产 生的新的分区信息作为动态分区信息存储到事先规划好的地方, 举例来说, 可以存储到 Nand 闪存的第一个块的指定区域中, 或者也可以存储到 Nand 闪存的属性区中。 其中 Nand闪存的属性区是独立于主存储区的一块特殊的 储存区域, 用于存放 Nand闪存的配置信息, 用户使用 Nand闪存进行数据 的擦写不会影响属性区中的内容。 可选的, 作为一种实施方式, 也可以将动 态分区信息存储到与 Nand闪存结合使用的 Nor闪存中。 Nor闪存同样能够 进行读写、擦除, 其特点是读取速度块, 可靠性好, 但容量小, 擦写速度慢, 且价格昂贵。 Nor闪存没有 Nand闪存固有的存在坏块随机分布的特性, 因 此,两种闪存可以结合使用为用户提供更可靠的存储功能。在该实施方法中, Nor闪存可以用来存储 Nand闪存的引导程序或动态分区信息, 从而避免由 在本领域的技术中,会确保出厂时 Nand闪存的第一个块是好块。 因此, 通常也会将引导程序存储在第一个块的指定区域中。 Optionally, the method of the embodiment of the present invention may be applied in the process of producing a Nand flash memory. When manufacturing and processing at the factory, it is usually necessary to burn the Nand flash memory. In an embodiment, by using the method of the embodiment of the present invention, the original partition information is first planned, and then the original partition information is transmitted to the burning machine. After the burning machine analyzes the original partition information, the blocks of each partition are dynamically calculated. Quantity, create new partitions in turn and erase and burn data, and store the generated new partition information as dynamic partition information in a pre-planned place, for example, can be stored in the first block of Nand flash memory In the specified area, or in the attribute area of the Nand flash memory. The attribute area of the Nand flash memory is a special storage area independent of the main storage area, and is used for storing the configuration information of the Nand flash memory. The user's use of the Nand flash memory for data erasing does not affect the content in the attribute area. Optionally, as an implementation manner, the dynamic partition information may also be stored in a Nor flash memory used in combination with the Nand flash memory. Nor flash can also be read, write, and erase. It is characterized by a read speed block and good reliability, but its capacity is small, the erasing speed is slow, and it is expensive. Nor flash does not have the inherently bad distribution of bad blocks in Nand flash, so the two flashes can be combined to provide users with more reliable storage. In this implementation method, the Nor flash memory can be used to store the boot program or dynamic partition information of the Nand flash memory, thereby avoiding ensuring that the first block of the Nand flash memory is a good block at the time of shipment in the art. Therefore, the bootstrap is usually also stored in the specified area of the first block.

可选的, 在本发明的另一个实施例中, 如果对 Nand闪存的数据的烧录 釆用的是以下方法: 先烧写引导程序, 然后由引导程序统一进行烧写数据到 Nand闪存中, 则引导程序中的应用过程同样可以使用本发明实施例的方法。 首先使引导程序获取到原始分区信息, 包括但不限于: 实现原始分区信息到 引导程序中, 或通过串口或网络读取原始分区信息, 引导程序解析该原始分 区信息, 然后读取烧录数据, 动态计算各个分区的块数量, 并擦除和烧写数 据到 Nand闪存, 最后将新生成的分区信息作为动态分区信息存储到事先规 划好的地方, 举例来说, 可以存储到 Nand闪存的第一个块的指定区域中, 或者也可以存储到 Nand闪存的属性区中, 或者还可以存储到与 Nand闪存 结合使用的 Nor闪存。  Optionally, in another embodiment of the present invention, if the data of the Nand flash memory is used, the following method is used: first, the boot program is programmed, and then the boot program uniformly writes the data to the Nand flash memory. Then, the application process in the boot program can also use the method of the embodiment of the present invention. First, the boot program obtains the original partition information, including but not limited to: implementing the original partition information into the boot program, or reading the original partition information through the serial port or the network, the boot program parsing the original partition information, and then reading the burned data, Dynamically calculate the number of blocks in each partition, erase and burn data to the Nand flash memory, and finally store the newly generated partition information as dynamic partition information in a pre-planned place, for example, the first to be stored in the Nand flash memory. In the specified area of the block, it can also be stored in the attribute area of the Nand flash memory, or it can also be stored in the Nor flash memory used in conjunction with the Nand flash memory.

图 5是本发明实施例的在 Nand闪存中生成动态分区信息的方法 50的示 意流程图, 包括以下内容。  FIG. 5 is a schematic flow diagram of a method 50 of generating dynamic partition information in a Nand flash memory according to an embodiment of the present invention, including the following.

S51 , 生成原始分区信息。  S51, generating raw partition information.

原始分区信息中定义了 Nand闪存中需要顺序生成的 n个分区, 每个分 区的名字和每个分区中包括的块数量。 其中, 第 i个分区为 n个分区中的一 个, n为正整数, i G {1 , n}。 The original partition information defines the n partitions that need to be generated sequentially in the Nand flash, the name of each partition, and the number of blocks included in each partition. Where the i-th partition is one of n partitions , n is a positive integer, i G {1 , n}.

通过每个分区中包括的块数量, 以及块大小的缺省值, 可以确定每个分 区的大小。  The size of each partition can be determined by the number of blocks included in each partition and the default value of the block size.

可选的, 作为一种实现方式, 可以由实施本发明实施例方法的装置生成 原始分区信息。  Optionally, as an implementation manner, the original partition information may be generated by a device that implements the method of the embodiment of the present invention.

原始分区信息包括多个分区, 可以通过分区表的形式呈现。 分区表中的 信息包括: 每个分区的名字, 可以任意命名, 以及每个分区包括的原始块数 量。 作为一种实现方法, 原始分区表的表项信息可以抽象为如下表示: typedef struct {  The raw partition information includes multiple partitions, which can be presented in the form of a partition table. The information in the partition table includes: The name of each partition, which can be arbitrarily named, and the number of original blocks included in each partition. As an implementation method, the table item information of the original partition table can be abstracted as follows: typedef struct {

char PartName[50]; /*分区的名字 */  Char PartName[50]; /*Name of the partition */

unsigned int ulLogBlockNum; /*分区中的块数, 包括实际使用到 的块数, 和为预防擦写过程产生坏块而预留的块数 */  Unsigned int ulLogBlockNum; / * The number of blocks in the partition, including the number of blocks actually used, and the number of blocks reserved for preventing bad blocks during the erasure process */

}LogPartInfor„  }LogPartInfor„

552, 获取原始分区信息。 552. Obtain original partition information.

S52为 S51的可替代方式。 可选的, 也可以由其他设备生成原始分区信 息, 通过本发明实施例的装置实现原始分区信息到引导程序中, 或通过串口 或网络从其他设备处读取原始分区信息。  S52 is an alternative to S51. Optionally, the original partition information may be generated by other devices, and the original partition information is implemented in the boot program by using the device in the embodiment of the present invention, or the original partition information is read from other devices through a serial port or a network.

553 , 解析每一个分区的原始分区信息。  553, parsing the original partition information of each partition.

首先从第一个分区开始顺序确定每一个分区的原始起始地址和原始块 数量。  The original starting address and the number of original blocks for each partition are first determined in order from the first partition.

举例来说, 首先指定第一分区的原始起始地址为 0x0 , 假设 1个块大小 为 128K字节, 原始块数量为 2。 从第一分区开始, 逐块检测, 根据块状态 的好与坏, 存储新的也就是动态块数量, 以及新的即动态起始地址。 其中, 第一分区的原始起始地址和动态起始地址相同。 接下来, 依次检测每一个分 区内的块状态, 直至检测完最后一个分区。  For example, first specify the original starting address of the first partition as 0x0, assuming that 1 block size is 128K bytes and the number of original blocks is 2. Starting from the first partition, block-by-block detection, according to the state of the block, the new one is the number of dynamic blocks, and the new dynamic start address. The original starting address of the first partition is the same as the dynamic starting address. Next, the block status in each partition is detected in turn until the last partition is detected.

554, 检测块的状态, 是否是好块。  554, detecting the status of the block, whether it is a good block.

如果是好块, 即 S54的 "是 " , 则执行 S55。  If it is a good block, that is, "Yes" of S54, execute S55.

555 , 擦除并烧录数据, 将好块数量加 1。  555, erase and burn data, add 1 to the number of good blocks.

如果是坏块, 即 S54的 "否 " , 则执行 S56  If it is a bad block, that is, "No" of S54, execute S56.

S56, 跳过该坏块, 将坏块数量加 1。 跳过(skip )该坏块, 不做任何例如擦除或烧写的处理。 S56, skip the bad block and increase the number of bad blocks by one. The bad block is skipped and no processing such as erasing or programming is performed.

557 , 确定好块数量是否大于等于原始块数量。  557, determine whether the number of blocks is greater than or equal to the number of original blocks.

在该分区中,如果好块数量 >原始块数量, 即 S57的 "是",则执行 S58。 In this partition, if the number of good blocks > the number of original blocks, that is, "Yes" of S57, S58 is executed.

558, 存储生成的动态分区信息。 558, storing the generated dynamic partition information.

将好块数量与坏块数量的和作为该分区的动态块数量,将该分区的动态 起始地址和动态块数量作为该分区的动态分区信息。且通过该分区的动态起 始地址和该分区的动态块数量确定下一个分区的动态起始地址。  The sum of the number of good blocks and the number of bad blocks is taken as the number of dynamic blocks of the partition, and the dynamic start address and the number of dynamic blocks of the partition are used as dynamic partition information of the partition. The dynamic start address of the next partition is determined by the dynamic start address of the partition and the number of dynamic blocks of the partition.

将所有分区的动态分区信息统一存储在事先规划好的地方, 例如可以存 储到 Nand闪存的第一个块的指定区域中, 或者也可以存储到 Nand闪存的 属性区中, 或者还可以存储到与 Nand闪存结合使用的 Nor闪存。  The dynamic partition information of all partitions is uniformly stored in a planned place, for example, may be stored in a specified area of the first block of the Nand flash memory, or may be stored in the attribute area of the Nand flash memory, or may be stored in Nand flash memory combined with Nor flash.

其中, 第一分区的原始起始地址和动态起始地址相同。 根据块状态的检 测, 各分区的原始块数量和动态块数量可能是相同的也可能是不同的; 第一 个分区后的分区的原始起始地址和动态起始地址可能是相同的也可能是不 同的。其中, 第 i+1个分区的动态起始地址=所述第 i个分区的动态起始地址 +第 i个分区的动态块数量 X块大小。  The original starting address of the first partition is the same as the dynamic starting address. According to the detection of the block status, the original block number and the dynamic block number of each partition may be the same or different; the original start address and the dynamic start address of the partition after the first partition may be the same or may be different. The dynamic start address of the i+1th partition=the dynamic start address of the i th partition + the dynamic block number of the i th partition X block size.

动态分区信息的表项信息, 可抽象为如下表示:  The entry information of the dynamic partition information can be abstracted as follows:

typedef struct {  Typedef struct {

char PartName [50]; /*分区的名字 */  Char PartName [50]; /* The name of the partition */

unsigned int ulPhyPartAddr; /*物理分区的起始地址 */  Unsigned int ulPhyPartAddr; /* starting address of the physical partition */

unsigned int ulPhyBlockNum; /*物理分区的块数, 包括好块和坏块 数 */  Unsigned int ulPhyBlockNum; / * The number of blocks in the physical partition, including the number of good and bad blocks * /

}PhyPartInfor„ 图 6是本发明实施例的生成分区信息的方法的示意原理图。  } PhyPartInfor „ Figure 6 is a schematic schematic diagram of a method of generating partition information according to an embodiment of the present invention.

举例来说, 参考图 6 , 原始分区信息中第二分区 61的原始块数量为 4, 即需要有 4个好块。 如果通过块状态检测、 确定在保证第二分区 61 内至少 包括 4个好块前, 检测出 3个坏块, 则重新确定的第二分区的动态块数量为 好块数量与坏块数量之和,等于 7。 当重新确定了第二分区的动态块数量后, 第三分区的动态起始地址从第二分区结尾开始,也就是第三分区的动态起始 地址 =第二分区的动态起始地址 +第二分区的动态块数量 X块大小。  For example, referring to FIG. 6, the number of original blocks of the second partition 61 in the original partition information is 4, that is, 4 good blocks are required. If, by block state detection, it is determined that 3 bad blocks are detected before ensuring that at least 4 good blocks are included in the second partition 61, the number of dynamic blocks of the re-determined second partition is the sum of the number of good blocks and the number of bad blocks. , equal to 7. After the number of dynamic blocks of the second partition is re-determined, the dynamic start address of the third partition starts from the end of the second partition, that is, the dynamic start address of the third partition = the dynamic start address of the second partition + the second The number of dynamic blocks of the partition X block size.

在该分区中,如果好块数量 <原始块数量, 即 S57的 "否",则执行 S59。 S59, 检测下一个块的状态。 In the partition, if the number of good blocks < the number of original blocks, that is, "NO" of S57, S59 is executed. S59, detecting the state of the next block.

本发明实施例通过获取并解析原始分区信息,针对每个分区中的每个块 进行好坏检测, 重新统计每个分区中块的数量以及起始地址, 生成动态分区 信息, 从而可以动态改变分区信息, 节省了存储介质的块资源, 提高了存储 介质的利用率。  In the embodiment of the present invention, by acquiring and parsing the original partition information, performing good and bad detection for each block in each partition, re-counting the number of blocks in each partition and the starting address, and generating dynamic partition information, so that the partition can be dynamically changed. The information saves the block resources of the storage medium and improves the utilization rate of the storage medium.

由于本发明实施例是动态产生分区信息, 系统启动后才进行读取该分区 信息,进行数据读取和分区挂载等。 因此,只要有需要重新生成分区的时候, 都可以釆用该方法, 因此, 可选的, 也适用于以下情况。  Since the embodiment of the present invention dynamically generates partition information, the system reads the partition information, performs data reading, partition mounting, and the like. Therefore, this method can be used whenever there is a need to regenerate the partition, so it is also applicable to the following cases.

在本发明一个实施例中, 如果在后续使用过程中, 由于 Nand闪存的块 在多次擦写并超过寿命后, 会变成坏块, 最终会导致因分区上的好块数量不 足, 而无法使用该分区, 从而造成整个系统无法使用。 但基于 Nand闪存大 容量的特点, 还有足够的空间使用, 因此只需要通过重新调整分区即可正常 工作。 由此, 通过本发明实施例, 可以改变传统的静态分区, 避免了分区所 在的坏块较多时导致分区无法使用, 或者预留的块数量过多造成分区浪费等 问题。  In an embodiment of the present invention, if the block of the Nand flash memory becomes a bad block after being erased multiple times and exceeds the lifetime in the subsequent use process, the number of good blocks on the partition may not be sufficient. Use this partition, making the entire system unusable. However, based on the large capacity of Nand flash memory, there is still enough space to use, so it only needs to be re-adjusted to work properly. Therefore, the traditional static partition can be changed by using the embodiment of the present invention, which avoids the problem that the partition cannot be used when the number of bad blocks of the partition is large, or the number of reserved blocks is too large, resulting in waste of the partition.

在本发明另一个实施例中, 如果生成的分区信息不幸遭到破坏, 需要通 过引导程序进行升级系统时,需要进行重新分区。 由此,通过本发明实施例, 可以改变传统的静态分区, 避免了分区信息丟失时导致 Nand闪存无法正常 使用, 或者预留的块数量过多造成分区浪费等问题。  In another embodiment of the present invention, if the generated partition information is unfortunately damaged and needs to be upgraded by the boot program, repartitioning is required. Therefore, the traditional static partition can be changed by using the embodiment of the present invention, which avoids the problem that the Nand flash memory cannot be used normally when the partition information is lost, or the number of reserved blocks is too large, resulting in waste of the partition.

以上两种情况, 都可釆用本发明实施例的方法, 例如方法 40或 50 , 生 成动态分区信息。  In both cases, the method of the embodiment of the present invention, such as method 40 or 50, can be used to generate dynamic partition information.

图 7是本发明实施例的在 Nand闪存中生成动态分区信息的装置 70的示 意框图。 装置 70包括: 解析单元 71、 第一生成单元 72和存储单元 73。  Figure 7 is a schematic block diagram of an apparatus 70 for generating dynamic partition information in a Nand flash memory in accordance with an embodiment of the present invention. The apparatus 70 includes: a parsing unit 71, a first generating unit 72, and a storage unit 73.

解析单元 71解析原始分区信息并发送到所述第一生成单元, 所述原始 分区信息包括命名的 n个分区和每个所述分区的原始块数量, 其中 n为正整 数。  The parsing unit 71 parses the original partition information and sends it to the first generating unit, the original partition information including the named n partitions and the number of original blocks of each of the partitions, where n is a positive integer.

第一生成单元 72根据所述解析单元解析的所述 n个分区的原始块数量 和所述 n个分区的第 1个分区的原始起始地址,通过顺序检测各分区的块的 状态, 为所述 n个分区生成动态分区信息并发送到所述存储单元, 所述动态 分区信息包括所述 n个分区的动态起始地址和动态块数量。  The first generation unit 72 sequentially detects the state of the block of each partition according to the original block number of the n partitions parsed by the parsing unit and the original start address of the first partition of the n partitions. The n partitions generate dynamic partition information and send to the storage unit, where the dynamic partition information includes a dynamic start address and a dynamic block number of the n partitions.

存储单元 73将所述第一生成单元生成的所述动态分区信息存储到指定 区域。 存储单元 73将所有分区的动态分区信息统一存储在事先规划好的地 方, 例如可以存储到 Nand闪存的第一个块的指定区域中, 或者也可以存储 到 Nand闪存的属性区中, 或者还可以存储到与 Nand闪存结合使用的 Nor 闪存。 The storage unit 73 stores the dynamic partition information generated by the first generation unit to a specified Area. The storage unit 73 uniformly stores the dynamic partition information of all the partitions in a planned place, for example, may be stored in a designated area of the first block of the Nand flash memory, or may be stored in the attribute area of the Nand flash memory, or may be Stored in Nor flash memory for use with Nand flash.

本发明实施例的装置解决了因存储介质存在坏块随机分布的特性, 为规 避该问题而为分区预留较多的块而引起的资源浪费问题,也包括未考虑该特 性而进行分区导致的可靠性问题, 通过解析原始分区信息, 针对每个分区中 的每个块进行好坏检测, 重新统计每个分区中块的数量以及起始地址, 生成 动态分区信息, 从而可以动态改变分区信息, 节省了存储介质的块资源, 提 高了存储介质的利用率。  The device of the embodiment of the present invention solves the problem of resource waste caused by the fact that the storage medium has a random distribution of bad blocks, and reserves more blocks for the partition to avoid the problem, and also includes the partitioning caused by not considering the feature. Reliability problem, by parsing the original partition information, performing good and bad detection for each block in each partition, re-counting the number of blocks in each partition and the starting address, and generating dynamic partition information, so that the partition information can be dynamically changed. The block resources of the storage medium are saved, and the utilization rate of the storage medium is improved.

图 8是本发明实施例的在 Nand闪存中生成动态分区信息的另一装置 80 的示意框图。 装置 80包括: 解析单元 81、 第一生成单元 82、 存储单元 83、 擦除单元 84、 烧写单元 85、 以及第二生成单元 86或获取单元 87。 装置 80 的解析单元 81、 第一生成单元 82和存储单元 83与装置 70的解析单元 71 第一生成单元 72和存储单元 73相同或相似。 不同在于, 装置 80的第一生 成单元 82可以包括检测模块 821、 计数模块 822和确定模块 823 , 装置 80 还可以包括擦除单元 84和烧写单元 85 , 以及第二生成单元 86或获取单元 87。  Figure 8 is a schematic block diagram of another apparatus 80 for generating dynamic partition information in a Nand flash memory in accordance with an embodiment of the present invention. The apparatus 80 includes: a parsing unit 81, a first generating unit 82, a storage unit 83, an erasing unit 84, a programming unit 85, and a second generating unit 86 or an obtaining unit 87. The parsing unit 81, the first generating unit 82, and the storage unit 83 of the device 80 are the same as or similar to the parsing unit 71 of the device 70, the first generating unit 72, and the storage unit 73. The difference is that the first generating unit 82 of the device 80 may include a detecting module 821, a counting module 822, and a determining module 823. The device 80 may further include an erasing unit 84 and a programming unit 85, and a second generating unit 86 or an obtaining unit 87. .

解析单元 81解析原始分区信息并发送到所述第一生成单元, 所述原始 分区信息包括命名的 n个分区和每个所述分区的原始块数量, 其中 n为正整 数。  The parsing unit 81 parses the original partition information and sends it to the first generating unit, the original partition information including the named n partitions and the number of original blocks of each of the partitions, where n is a positive integer.

第一生成单元 82根据所述解析单元解析的所述 n个分区的原始块数量 和所述 n个分区的第 1个分区的原始起始地址,通过顺序检测各分区的块的 状态, 为所述 n个分区生成动态分区信息并发送到所述存储单元, 所述动态 分区信息包括所述 n个分区的动态起始地址和动态块数量。  The first generation unit 82 sequentially detects the state of the block of each partition according to the number of original blocks of the n partitions parsed by the parsing unit and the original start address of the first partition of the n partitions. The n partitions generate dynamic partition information and send to the storage unit, where the dynamic partition information includes a dynamic start address and a dynamic block number of the n partitions.

存储单元 83将所述第一生成单元生成的所述动态分区信息存储到指定 区域。 存储单元 83将所有分区的动态分区信息统一存储在事先规划好的地 方, 例如可以存储到 Nand闪存的第一个块的指定区域中, 或者也可以存储 到 Nand闪存的属性区中, 或者还可以存储到与 Nand闪存结合使用的 Nor 闪存。  The storage unit 83 stores the dynamic partition information generated by the first generation unit to a designated area. The storage unit 83 uniformly stores the dynamic partition information of all the partitions in a planned place, for example, may be stored in a specified area of the first block of the Nand flash memory, or may be stored in the attribute area of the Nand flash memory, or may be Stored in Nor flash memory for use with Nand flash.

可选的, 作为不同的实施例, 检测模块 821将所述 n个分区的第 1个分 区的原始起始地址作为第 1个分区的动态起始地址,从第 1个分区开始直到 第 n个分区为止, 依次检测第 i个分区中的各个块的状态, 其中 n} ; 当所述检测模块 821检测到当前块的状态为好, 则所述计数模块 822将好块 数量加 1 ; 且当所述检测模块 821检测到当前块的状态为坏, 则所述计数模 块 822将坏块数量加 1 ; 且当好块数量 >所述第 i个分区的原始块数量时, 所述确定模块 823将好块数量与坏块数量的和作为所述第 i个分区的动态块 数量, 且通过所述第 i个分区的动态起始地址和所述第 i个分区的动态块数 量确定第 i+1个分区的动态起始地址。 分区的动态起始地址 =所述第 i个分区的动态起始地址 +第 i个分区的动态块 数量 X块大小。 Optionally, as a different embodiment, the detecting module 821 divides the first part of the n partitions The original starting address of the area is used as the dynamic starting address of the first partition, and the state of each block in the i-th partition is detected in turn from the first partition until the nth partition, where n}; The detecting module 821 detects that the state of the current block is good, the counting module 822 adds 1 to the good block number; and when the detecting module 821 detects that the current block state is bad, the counting module 822 will block the bad block. The number is increased by 1; and when the number of good blocks > the number of original blocks of the i-th partition, the determining module 823 uses the sum of the number of good blocks and the number of bad blocks as the number of dynamic blocks of the i-th partition, and A dynamic start address of the i+1th partition is determined by a dynamic start address of the i th partition and a dynamic block number of the i th partition. The dynamic start address of the partition = the dynamic start address of the i-th partition + the number of dynamic blocks of the i-th partition X block size.

可选的, 作为不同的实施例, 当所述检测模块 821检测到当前块的状态 为好时, 则所述擦除单元 84用于擦除所述当前块且所述烧写单元 85在所述 当前块中写入数据; 或当所述检测模块 821检测到当前块的状态为坏时, 则 所述擦除单元 84跳过所述当前块且所述烧写单元 85在所述当前块不写入数 据。  Optionally, as a different embodiment, when the detecting module 821 detects that the state of the current block is good, the erasing unit 84 is configured to erase the current block and the programming unit 85 is in the Writing data in the current block; or when the detecting module 821 detects that the state of the current block is bad, the erasing unit 84 skips the current block and the programming unit 85 is in the current block Do not write data.

可选的, 作为不同的实施例, 装置 80还可以包括第二生成单元 86。 第 二生成单元 86生成原始分区信息。 或者, 可选的, 装置 80还可以包括获取 单元 87 , 获取单元 87可以从其他设备获取所生成的原始分区信息。  Alternatively, as a different embodiment, the device 80 may further include a second generating unit 86. The second generation unit 86 generates raw partition information. Alternatively, the device 80 may further include an obtaining unit 87, and the obtaining unit 87 may acquire the generated original partition information from other devices.

装置 80可以生成或获取原始分区信息后, 通过解析原始分区信息后, 生成动态分区信息和烧录数据。 可选的, 作为不同的实施例, 烧写单元 85 可以在解析原始分区信息前, 在 Nand闪存的第一分区的第一个块中写入引 导程序。 这样, 装置 80先烧写好引导程序, 然后由引导程序统一进行烧写 数据到 Nand闪存中, 则引导程序中的应用过程可以使用本发明实施例的方 法 40或 50。  After the device 80 can generate or acquire the original partition information, the dynamic partition information and the burn data are generated by parsing the original partition information. Alternatively, as a different embodiment, the programming unit 85 may write a boot program in the first block of the first partition of the Nand flash memory before parsing the original partition information. Thus, the device 80 first programs the boot program, and then the boot program unifies the programming data into the Nand flash memory. The application process in the boot program can use the method 40 or 50 of the embodiment of the present invention.

本发明实施例的装置解决了因存储介质存在坏块随机分布的特性, 为规 避该问题而为分区预留较多的块而引起的资源浪费问题,也包括未考虑该特 性而进行分区导致的可靠性问题, 通过获取并解析原始分区信息, 针对每个 分区中的每个块进行好坏检测, 重新统计每个分区中块的数量以及起始地 址, 生成动态分区信息, 从而可以动态改变分区信息, 节省了存储介质的块 资源, 提高了存储介质的利用率。 此外, 本发明实施例装置改变了传统的静态分区, 避免了分区所在的坏 块较多时导致分区无法使用、 还避免了分区信息丟失时导致 Nand闪存无法 正常使用。 The device of the embodiment of the present invention solves the problem of resource waste caused by the fact that the storage medium has a random distribution of bad blocks, and reserves more blocks for the partition to avoid the problem, and also includes the partitioning caused by not considering the feature. Reliability problem, by obtaining and parsing the original partition information, performing good and bad detection for each block in each partition, re-counting the number of blocks in each partition and the starting address, generating dynamic partition information, so that the partition can be dynamically changed. The information saves the block resources of the storage medium and improves the utilization rate of the storage medium. In addition, the device in the embodiment of the present invention changes the traditional static partition, which avoids the partition being unusable when the partition has many bad blocks, and also prevents the Nand flash memory from being used normally when the partition information is lost.

图 9是本发明实施例的在 Nand闪存中生成动态分区信息的另一装置 90 的示意框图。 装置 90包括处理器 91和存储器 92。  Figure 9 is a schematic block diagram of another apparatus 90 for generating dynamic partition information in a Nand flash memory in accordance with an embodiment of the present invention. The device 90 includes a processor 91 and a memory 92.

存储器 92可以是包括 RAM和 ROM、 或任何固定的存储介质、 或可移 动的存储介质, 用于存储可以执行本发明实施例的程序或本发明实施例中待 处理的数据。  The memory 92 may be a RAM and a ROM, or any fixed storage medium, or a removable storage medium for storing data that can be executed in the program of the embodiment of the present invention or in the embodiment of the present invention.

存储器 92还可以用于存储原始分区信息, 所述原始分区信息包括命名 的 n个分区和每个所述分区的原始块数量, 其中 n为正整数, 以及生成的动 态分区信息。  The memory 92 can also be used to store raw partition information including the named n partitions and the original number of blocks for each of the partitions, where n is a positive integer and the generated dynamic partition information.

处理器 91用于执行存储器 92存储的本发明实施例的程序。 处理器 91 可以是通用处理器、 数字信号处理器(DSP )、 专用集成电路(ASIC )、 现成 可编程门阵列 (FPGA )或者其他可编程逻辑器件、 分立门或者晶体管逻辑 步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常 规的处理器等。 结合本发明实施例所公开的方法的步骤可以直接体现为硬件 译码处理器执行完成, 或者用译码处理器中的硬件及软件模块组合执行完 成。 软件模块可以位于随机存储器, 闪存、 只读存储器, 可编程只读存储器 或者电可擦写可编程存储器、 寄存器等本领域成熟的存储介质中。 该存储介 质位于存储器 92,处理器 91读取存储器 92中的信息, 结合其硬件完成上述 方法的步骤。  The processor 91 is operative to execute the program of the embodiment of the present invention stored by the memory 92. The processor 91 can be a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic steps and logic block diagrams. The general purpose processor may be a microprocessor or the processor or any conventional processor or the like. The steps of the method disclosed in the embodiments of the present invention may be directly implemented by the hardware decoding processor, or may be performed by a combination of hardware and software modules in the decoding processor. The software modules can be located in a conventional storage medium such as random access memory, flash memory, read only memory, programmable read only memory or electrically erasable programmable memory, registers, and the like. The storage medium is located in the memory 92, and the processor 91 reads the information in the memory 92 and combines the hardware to perform the steps of the above method.

其中, 处理器 91 解析原始分区信息, 所述原始分区信息包括命名的 n 个分区和每个所述分区的原始块数量, 其中 n为正整数; 根据解析的所述 n 个分区的原始块数量和所述 n个分区的第 1个分区的原始起始地址,通过顺 序检测各分区的块的状态, 为所述 n个分区生成动态分区信息, 所述动态分 区信息包括所述 n个分区的动态起始地址和动态块数量; 将生成的所述动态 分区信息存储到指定区域。 其中, 处理器 91将所有分区的动态分区信息统 一存储在事先规划好的地方, 例如可以存储到 Nand闪存的第一个块的指定 区域中,或者也可以存储到 Nand闪存的属性区中,或者还可以存储到与 Nand 闪存结合使用的 Nor闪存。 可选的, 作为不同的实施例, 处理器 91将所述 n个分区的第 1个分区 的原始起始地址作为第 1个分区的动态起始地址,从第 1个分区开始直到第 n个分区为止, 依次检测第 i个分区中的各个块的状态, 其中 n} ; 当 检测到当前块的状态为好, 则将好块数量加 1 ; 且当检测到当前块的状态为 坏, 则将坏块数量加 1 ; 且当好块数量 >所述第 i个分区的原始块数量时, 将好块数量与坏块数量的和作为所述第 i个分区的动态块数量, 且通过所述 第 i个分区的动态起始地址和所述第 i个分区的动态块数量确定第 i+1个分 区的动态起始地址。 The processor 91 parses the original partition information, where the original partition information includes the named n partitions and the number of original blocks of each of the partitions, where n is a positive integer; according to the parsed number of original blocks of the n partitions And the original starting address of the first partition of the n partitions, by sequentially detecting the state of the blocks of each partition, generating dynamic partition information for the n partitions, where the dynamic partition information includes the n partitions Dynamic start address and dynamic block number; store the generated dynamic partition information to a specified area. The processor 91 uniformly stores the dynamic partition information of all the partitions in a planned place, for example, may be stored in a designated area of the first block of the Nand flash memory, or may be stored in the attribute area of the Nand flash memory, or It can also be stored to Nor flash in conjunction with Nand flash. Optionally, as a different embodiment, the processor 91 uses the original start address of the first partition of the n partitions as the dynamic start address of the first partition, starting from the first partition to the nth Up to the partition, the state of each block in the i-th partition is detected in turn, where n}; when the state of the current block is detected to be good, the number of good blocks is increased by 1; and when the state of the current block is detected as bad, Adding the number of bad blocks to 1; and when the number of good blocks > the number of original blocks of the i-th partition, the sum of the number of good blocks and the number of bad blocks is taken as the number of dynamic blocks of the i-th partition, and The dynamic start address of the i-th partition and the dynamic block number of the i-th partition determine a dynamic start address of the i+1th partition.

可选的, 作为不同的实施例, 处理器 91根据以下公式确定动态起始地 址: 第 i+1个分区的动态起始地址=所述第 i个分区的动态起始地址 +第 i个 分区的动态块数量 X块大小。  Optionally, as a different embodiment, the processor 91 determines the dynamic start address according to the following formula: a dynamic start address of the i+1th partition=the dynamic start address of the i-th partition+the i-th partition The number of dynamic blocks is X block size.

可选的, 作为不同的实施例, 处理器 91当检测到当前块的状态为好时, 则擦除所述当前块并写入数据; 或当检测到当前块的状态为坏时, 则跳过所 述当前块且不写入数据。  Optionally, as a different embodiment, the processor 91 erases the current block and writes data when detecting that the current block status is good; or jumps when detecting that the current block status is bad. The current block is passed and no data is written.

可选的, 作为不同的实施例, 处理器 91生成所述原始分区信息。  Optionally, as a different embodiment, the processor 91 generates the original partition information.

可选的, 作为不同的实施例, 处理器 91在所述解析原始分区信息前, 还在所述 Nand闪存的第一个分区的第一个块中写入引导程序。  Optionally, as a different embodiment, the processor 91 writes a boot program in the first block of the first partition of the Nand flash memory before the parsing the original partition information.

本发明实施例解决了因存储介质存在坏块随机分布的特性, 为规避该问 题而为分区预留较多的块而引起的资源浪费问题,也包括未考虑该特性而进 行分区导致的可靠性问题, 通过解析原始分区信息, 针对每个分区中的每个 块进行好坏检测, 重新统计每个分区中块的数量以及起始地址, 生成动态分 区信息, 从而可以动态改变分区信息, 节省了存储介质的块资源, 提高了存 储介质的利用率。  The embodiment of the invention solves the problem of resource waste caused by the random distribution of bad blocks in the storage medium, and reserves more blocks for the partition to avoid the problem, and also includes the reliability caused by partitioning without considering the feature. The problem is that by parsing the original partition information, performing good and bad detection for each block in each partition, re-counting the number of blocks in each partition and the starting address, and generating dynamic partition information, thereby dynamically changing the partition information, thereby saving The block resource of the storage medium improves the utilization of the storage medium.

本领域普通技术人员可以意识到, 结合本文中所公开的实施例描述的各 示例的单元及算法步骤, 能够以电子硬件、 或者计算机软件和电子硬件的结 合来实现。 这些功能究竟以硬件还是软件方式来执行, 取决于技术方案的特 定应用和设计约束条件。 专业技术人员可以对每个特定的应用来使用不同方 法来实现所描述的功能, 但是这种实现不应认为超出本发明的范围。  Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the various examples described in connection with the embodiments disclosed herein can be implemented in a combination of electronic hardware or computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the solution. A person skilled in the art can use different methods for implementing the described functions for each particular application, but such implementation should not be considered to be beyond the scope of the present invention.

所属领域的技术人员可以清楚地了解到, 为描述的方便和简洁, 上述描 述的系统、 装置和单元的具体工作过程, 可以参考前述方法实施例中的对应 过程, 在此不再赘述。 在本申请所提供的几个实施例中, 应该理解到, 所揭露的系统、 装置和 方法, 可以通过其它的方式实现。 例如, 以上所描述的装置实施例仅仅是示 意性的, 例如, 所述单元的划分, 仅仅为一种逻辑功能划分, 实际实现时可 以有另外的划分方式, 例如多个单元或组件可以结合或者可以集成到另一个 系统, 或一些特征可以忽略, 或不执行。 另一点, 所显示或讨论的相互之间 的耦合或直接耦合或通信连接可以是通过一些接口, 装置或单元的间接耦合 或通信连接, 可以是电性, 机械或其它的形式。 为单元显示的部件可以是或者也可以不是物理单元, 即可以位于一个地方, 或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或 者全部单元来实现本实施例方案的目的。 A person skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working process of the system, the device and the unit described above may refer to the corresponding processes in the foregoing method embodiments, and details are not described herein again. In the several embodiments provided herein, it should be understood that the disclosed systems, devices, and methods may be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division. In actual implementation, there may be another division manner, for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form. The components displayed for the unit may or may not be physical units, ie may be located in one place, or may be distributed over multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.

另外, 在本发明各个实施例中的各功能单元可以集成在一个处理单元 中, 也可以是各个单元单独物理存在, 也可以两个或两个以上单元集成在一 个单元中。  In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使 用时, 可以存储在一个计算机可读取存储介质中。 基于这样的理解, 本发明 的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部 分可以以软件产品的形式体现出来, 该计算机软件产品存储在一个存储介质 中, 包括若干指令用以使得一台计算机设备(可以是个人计算机, 服务器, 或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。 而前 述的存储介质包括: U盘、移动硬盘、只读存储器( ROM, Read-Only Memory )、 随机存取存储器(RAM, Random Access Memory ), 磁碟或者光盘等各种可 以存储程序代码的介质。  The functions, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention, which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including The instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and the like, which can store program codes. .

以上所述, 仅为本发明的具体实施方式, 但本发明的保护范围并不局限 于此, 任何熟悉本技术领域的技术人员在本发明揭露的技术范围内, 可轻易 想到变化或替换, 都应涵盖在本发明的保护范围之内。 因此, 本发明的保护 范围应所述以权利要求的保护范围为准。  The above is only the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily think of changes or substitutions within the technical scope of the present invention. It should be covered by the scope of the present invention. Therefore, the scope of the invention should be determined by the scope of the claims.

Claims

权 利 要求 Rights request 1. 一种在 Nand闪存中生成分区信息的方法, 其特征在于, 包括: 解析原始分区信息, 所述原始分区信息包括的 n个分区和每个所述分区 的原始块数量, 其中 n为正整数; A method for generating partition information in a Nand flash memory, comprising: parsing original partition information, wherein the original partition information includes n partitions and a number of original blocks of each of the partitions, wherein n is positive Integer 根据所述 n个分区的原始块数量和所述 n个分区的第 1个分区的原始起 始地址, 通过顺序检测各分区的块的状态, 为所述 n个分区生成动态分区信 息, 所述动态分区信息包括所述 n个分区的动态起始地址和动态块数量; 将所述动态分区信息存储到指定区域。  And generating dynamic partition information for the n partitions by sequentially detecting states of blocks of each partition according to the original block number of the n partitions and the original start address of the first partition of the n partitions, The dynamic partition information includes a dynamic start address and a dynamic block number of the n partitions; and the dynamic partition information is stored in the designated area. 2. 根据权利要求 1所述的方法, 其特征在于, 根据所述 n个分区的原 始块数量和所述 n个分区的第 1个分区的原始起始地址,通过顺序检测各分 区的块的状态, 为所述 n个分区生成动态分区信息, 所述动态分区信息包括 n个分区的动态起始地址和动态块数量, 包括:  2. The method according to claim 1, wherein the blocks of each partition are sequentially detected according to the original block number of the n partitions and the original start address of the first partition of the n partitions a state, the dynamic partition information is generated for the n partitions, where the dynamic partition information includes a dynamic start address and a dynamic block number of the n partitions, including: 将所述 n个分区的第 1个分区的原始起始地址作为第 1个分区的动态起 始地址, 从第 1个分区开始直到第 n个分区为止, 依次检测第 i个分区中的 各个块的状态, 其中 i e {1 , n} ;  The original start address of the first partition of the n partitions is used as the dynamic start address of the first partition, and the blocks in the i-th partition are sequentially detected from the first partition to the nth partition. State, where ie {1 , n} ; 当检测到当前块的状态为好, 则将好块数量加 1 ; 且当检测到当前块的 状态为坏, 则将坏块数量加 1 ; 且  When it is detected that the state of the current block is good, the number of good blocks is increased by 1; and when it is detected that the state of the current block is bad, the number of bad blocks is increased by 1; 当好块数量 >所述第 i个分区的原始块数量时, 将好块数量与坏块数量 的和作为所述第 i个分区的动态块数量, 且通过所述第 i个分区的动态起始 地址和所述第 i个分区的动态块数量确定第 i+1个分区的动态起始地址。  When the number of good blocks > the number of original blocks of the i-th partition, the sum of the number of good blocks and the number of bad blocks is taken as the number of dynamic blocks of the i-th partition, and the dynamic of the i-th partition is The start address and the number of dynamic blocks of the i-th partition determine the dynamic start address of the i+1th partition. 3. 根据权利要求 2所述的方法, 其特征在于, 所述通过所述第 i个分区 的动态起始地址和所述第 i个分区的动态块数量确定第 i+1个分区的动态起 始地址, 包括:  The method according to claim 2, wherein the dynamic start address of the i-th partition and the dynamic block number of the i-th partition determine the dynamic of the i+1th partition Start address, including: 第 i+1个分区的动态起始地址=所述第 i个分区的动态起始地址 +第 i个 分区的动态块数量 X块大小。  The dynamic start address of the i+1th partition = the dynamic start address of the i th partition + the number of dynamic blocks of the i th partition X block size. 4. 根据权利要求 1至 3任一项所述的方法, 其特征在于, 所述方法还 包括:  The method according to any one of claims 1 to 3, wherein the method further comprises: 当检测到当前块的状态为好时, 则擦除所述当前块并写入数据; 或 当检测到当前块的状态为坏时, 则跳过所述当前块且不写入数据。 When it is detected that the state of the current block is good, the current block is erased and data is written; or when it is detected that the state of the current block is bad, the current block is skipped and data is not written. 5. 根据权利要求 1至 4任一项所述的方法, 其特征在于, 在所述解析 原始分区信息前, 所述方法还包括: The method according to any one of claims 1 to 4, characterized in that in the parsing Before the original partition information, the method further includes: 生成所述原始分区信息。  The raw partition information is generated. 6. 根据权利要求 1至 4任一项所述的方法, 其特征在于, 在所述解析 原始分区信息前, 所述方法还包括:  The method according to any one of claims 1 to 4, wherein before the parsing the original partition information, the method further comprises: 在所述 Nand闪存的第一个分区的第一个块中写入引导程序。  The boot program is written in the first block of the first partition of the Nand flash. 7. 一种在 Nand闪存中生成分区信息的装置, 其特征在于, 包括解析单 元、 第一生成单元和存储单元:  7. An apparatus for generating partition information in a Nand flash memory, comprising: a parsing unit, a first generating unit, and a storage unit: 所述解析单元, 用于解析原始分区信息并发送到所述第一生成单元, 所 述原始分区信息包括的 n个分区和每个所述分区的原始块数量, 其中 n为正 整数;  The parsing unit is configured to parse the original partition information and send the information to the first generating unit, where the original partition information includes n partitions and the original block number of each of the partitions, where n is a positive integer; 所述第一生成单元, 用于根据所述解析单元解析的所述 n个分区的原始 块数量和所述 n个分区的第 1个分区的原始起始地址,通过顺序检测各分区 的块的状态, 为所述 n个分区生成动态分区信息并发送到所述存储单元, 所 述动态分区信息包括所述 n个分区的动态起始地址和动态块数量;  The first generating unit is configured to sequentially detect blocks of each partition according to the original block number of the n partitions parsed by the parsing unit and the original start address of the first partition of the n partitions a state, generating dynamic partition information for the n partitions and sending the information to the storage unit, where the dynamic partition information includes a dynamic start address and a dynamic block number of the n partitions; 所述存储单元, 用于将所述第一生成单元生成的所述动态分区信息存储 到指定区域。  The storage unit is configured to store the dynamic partition information generated by the first generating unit to a designated area. 8. 根据权利要求 7所述的装置, 其特征在于, 所述第一生成单元包括 检测模块、 计数模块和确定模块:  The device according to claim 7, wherein the first generating unit comprises a detecting module, a counting module and a determining module: 所述检测模块, 用于将所述 n个分区的第 1个分区的原始起始地址作为 第 1个分区的动态起始地址, 从第 1个分区开始直到第 n个分区为止, 依次 检测第 i个分区中的各个块的状态, 其中 n} ;  The detecting module is configured to use the original starting address of the first partition of the n partitions as the dynamic starting address of the first partition, starting from the first partition to the nth partition, and detecting the first The state of each block in i partitions, where n}; 当所述检测模块检测到当前块的状态为好, 则所述计数模块将好块数量 加 1 ; 且当所述检测模块检测到当前块的状态为坏, 则所述计数模块将坏块 数量加 1 ; 且  When the detecting module detects that the state of the current block is good, the counting module adds 1 to the number of good blocks; and when the detecting module detects that the state of the current block is bad, the counting module will count the number of bad blocks. Add 1; and 当好块数量》所述第 i个分区的原始块数量时, 所述确定模块将好块数 量与坏块数量的和作为所述第 i个分区的动态块数量, 且通过所述第 i个分 区的动态起始地址和所述第 i个分区的动态块数量确定第 i+1个分区的动态 起始地址。  When the number of original blocks of the i-th partition is the number of blocks, the determining module uses the sum of the number of good blocks and the number of bad blocks as the number of dynamic blocks of the i-th partition, and passes the ith The dynamic start address of the partition and the number of dynamic blocks of the i-th partition determine the dynamic start address of the i+1th partition. 9. 根据权利要求 8所述的装置, 其特征在于, 所述确定模块具体用于 下述公式以确定动态起始地址:  9. The apparatus according to claim 8, wherein the determining module is specifically configured to determine a dynamic starting address by: 第 i+1个分区的动态起始地址=所述第 i个分区的动态起始地址 +第 i个 分区的动态块数量 X块大小。 Dynamic start address of the i+1th partition = dynamic start address of the i th partition + ith The number of dynamic blocks of the partition X block size. 10. 根据权利要求 7至 9任一项所述的装置, 其特征在于, 所述装置还 包括擦除单元和烧写单元:  The device according to any one of claims 7 to 9, wherein the device further comprises an erasing unit and a programming unit: 当所述检测模块检测到当前块的状态为好时, 则所述擦除单元用于擦除 所述当前块且所述烧写单元在所述当前块中写入数据; 或  When the detecting module detects that the state of the current block is good, the erasing unit is configured to erase the current block and the programming unit writes data in the current block; or 当所述检测模块检测到当前块的状态为坏时, 则所述擦除单元用于跳过 所述当前块且所述烧写单元在所述当前块不写入数据。  When the detecting module detects that the state of the current block is bad, the erasing unit is configured to skip the current block and the programming unit does not write data in the current block. 11. 根据权利要求 7至 10任一项所述的装置, 其特征在于, 所述装置 还包括第二生成单元:  The device according to any one of claims 7 to 10, wherein the device further comprises a second generating unit: 所述第二生成单元, 用于在所述解析原始分区信息前, 生成所述原始分 区信息。  The second generating unit is configured to generate the original partition information before the parsing the original partition information. 12. 根据权利要求 7至 9任一项所述的装置, 其特征在于, 所述装置还 包括烧写单元:  12. Apparatus according to any one of claims 7 to 9, wherein the apparatus further comprises a programming unit: 所述烧写单元, 用于在解析原始分区信息前, 在所述 Nand闪存的第一 个分区的第一个块中写入引导程序。  The programming unit is configured to write a boot program in a first block of the first partition of the Nand flash memory before parsing the original partition information.
PCT/CN2013/088017 2012-11-28 2013-11-28 Method and device for generating dynamic partition information in nand flash memory Ceased WO2014082583A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201210495157.7A CN102999436B (en) 2012-11-28 2012-11-28 The method and apparatus of dynamic partition information is generated in Nand flash memory
CN201210495157.7 2012-11-28

Publications (1)

Publication Number Publication Date
WO2014082583A1 true WO2014082583A1 (en) 2014-06-05

Family

ID=47928029

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/088017 Ceased WO2014082583A1 (en) 2012-11-28 2013-11-28 Method and device for generating dynamic partition information in nand flash memory

Country Status (2)

Country Link
CN (1) CN102999436B (en)
WO (1) WO2014082583A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10635451B2 (en) 2016-09-08 2020-04-28 Hewlett-Packard Development Company, L.P. Mass storage medium having an operating system but not a partition table pre-installed

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102999436B (en) * 2012-11-28 2015-09-09 华为终端有限公司 The method and apparatus of dynamic partition information is generated in Nand flash memory
CN103744694B (en) * 2013-12-24 2017-08-11 武汉烽火众智数字技术有限责任公司 Dynamic partition searcher and its method based on Nand flash memories
TWI515733B (en) * 2013-12-27 2016-01-01 緯創資通股份有限公司 Method for programming flash memory and computer-readable medium
CN106339246A (en) * 2016-08-31 2017-01-18 福建联迪商用设备有限公司 Programming method and programming system used in production phase of NANDFLASH
CN107357878A (en) * 2017-07-06 2017-11-17 成都睿胜科技有限公司 Extension type mini-file system and its implementation
CN107436734A (en) * 2017-07-28 2017-12-05 郑州云海信息技术有限公司 The logical partition implementation method and device of a kind of solid-state disk
CN110825714A (en) * 2019-11-08 2020-02-21 珠海奔图电子有限公司 File storage control method and device, file storage device and electronic device
CN113535255A (en) * 2021-06-07 2021-10-22 山东泰物信息技术有限公司 Method for asynchronously updating embedded linux firmware based on cryptographic algorithm
CN116594639A (en) * 2021-06-15 2023-08-15 荣耀终端有限公司 System installation package management method, device, storage medium and program product

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1716450A (en) * 2004-06-30 2006-01-04 深圳市朗科科技有限公司 Method for managing access to flash storage data
US20060250720A1 (en) * 2005-05-04 2006-11-09 Apacer Technology Inc. Portable data storage device and method of dynamic memory management therefor
CN101281493A (en) * 2008-05-26 2008-10-08 中兴通讯股份有限公司 NAND flash memory and its management method
US7818701B1 (en) * 2006-12-22 2010-10-19 Cypress Semiconductor Corporation Memory controller with variable zone size
CN102999436A (en) * 2012-11-28 2013-03-27 华为终端有限公司 Method and device for generating dynamic partition information in Nand flash memory

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100205006B1 (en) * 1996-10-08 1999-06-15 윤종용 Semiconductor memory device with automatic defect block mapping function
CN102104750B (en) * 2009-12-22 2015-02-11 康佳集团股份有限公司 Method for automatically upgrading network television

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1716450A (en) * 2004-06-30 2006-01-04 深圳市朗科科技有限公司 Method for managing access to flash storage data
US20060250720A1 (en) * 2005-05-04 2006-11-09 Apacer Technology Inc. Portable data storage device and method of dynamic memory management therefor
US7818701B1 (en) * 2006-12-22 2010-10-19 Cypress Semiconductor Corporation Memory controller with variable zone size
CN101281493A (en) * 2008-05-26 2008-10-08 中兴通讯股份有限公司 NAND flash memory and its management method
CN102999436A (en) * 2012-11-28 2013-03-27 华为终端有限公司 Method and device for generating dynamic partition information in Nand flash memory

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10635451B2 (en) 2016-09-08 2020-04-28 Hewlett-Packard Development Company, L.P. Mass storage medium having an operating system but not a partition table pre-installed

Also Published As

Publication number Publication date
CN102999436B (en) 2015-09-09
CN102999436A (en) 2013-03-27

Similar Documents

Publication Publication Date Title
WO2014082583A1 (en) Method and device for generating dynamic partition information in nand flash memory
TWI805323B (en) Storage device
CN103123608B (en) Method and apparatus for redistributing addressable space in storage arrangement
US20080201520A1 (en) Flash firmware management
CN103744694A (en) Dynamic partition searching device based on Nand flash memory and method thereof
BR112017027915B1 (en) DATA PROCESSING METHOD AND APPARATUS AND FLASH DEVICE
TW201245959A (en) Dynamic and static data for a system having non-volatile memory
CN108509215B (en) System software replacing method and device, terminal equipment and storage medium
TWI479505B (en) Data management method, memory controller and memory storage apparatus
TWI658361B (en) Memory management method, memory control circuit unit and memory storage apparatus
TWI479315B (en) Memory storage device, memory controller thereof, and method for programming data thereof
TW201802680A (en) Mapping table updating method, memory control circuit unit and memory storage device
TWI797464B (en) Data reading method, memory storage device and memory control circuit unit
WO2022252063A1 (en) Data access method, storage controller and storage device
CN103578566B (en) Memory storage device and repair method thereof
CN107239225A (en) Memory management method, memory storage device and memory control circuit unit
CN110390985B (en) Memory management method, memory storage device, and memory control circuit unit
TWI641948B (en) Data storage method, memory control circuit unit and memory storage device
CN115639971B (en) Data writing method, data writing device, electronic device, storage medium, and program product
TW201734795A (en) Memory management method, memory storage device and memory control circuit unit
WO2024087607A1 (en) Flash memory management algorithm debugging method, system and device, and readable storage medium
US11288204B2 (en) Logical and physical address field size reduction by alignment-constrained writing technique
US20250028468A1 (en) Reading a master boot record for a namespace after reformatting the namespace
CN111813708B (en) Block mapping system and method for storage device
CN116166200A (en) Data storage method, system, computer equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 13859156

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 13859156

Country of ref document: EP

Kind code of ref document: A1