Bad block management method and device based on memory read-only partition and computer device

By detecting erase/write anomalies in the read-only partition of the memory and establishing a mapping relationship between bad blocks and normal blocks, the problem of bad block management in the read-only partition is solved, ensuring the normal operation of the device.

CN119311220BActive Publication Date: 2026-03-24ZHEJIANG DAHUA TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

Existing technologies do not manage bad blocks generated during the use of read-only partitions in memory, which causes the device program to fail to load due to bad blocks, and the device cannot operate normally.

Method used

When an abnormal erase/write operation is detected during the software program's partition update process, bad blocks are identified, and normal blocks are selected from the bad block reserve area. Data is written to the normal blocks, a mapping relationship is established, and the normal blocks are accessed to read data when data access is requested.

Benefits of technology

It manages bad blocks generated during the use of read-only partitions, preventing device program loading failures and ensuring normal device operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311220B_ABST
    Figure CN119311220B_ABST
Patent Text Reader

Abstract

The application relates to a bad block management method and device based on a memory read-only partition and computer equipment, wherein the bad block management method comprises the following steps: when detecting that an abnormality occurs in an erasing and writing operation in a software program partition update process, determining a first bad block in which the erasing and writing abnormality occurs in the software program partition; selecting a first normal block from a bad block reservation area, writing data for updating the first bad block into the first normal block; establishing a first mapping relationship between the first bad block and the first normal block; and in response to data access for the first bad block, accessing the first normal block pointed by the first mapping relationship and reading data stored in the first normal block. Through the application, the problem that a bad block generated in the use process of a read-only partition is not managed, a related partition device program loading fails, and a device cannot normally operate is solved, the bad block generated in the use process of the read-only partition is managed, and the normal operation of the device is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data storage, in particular to a bad block management method and device based on a read-only partition of a memory and a computer device. BACKGROUND

[0002] The storage space of a non-volatile memory can be divided into several regions to store different contents, such as NAND Flash, NOR Flash, etc., which include a read-write partition and a read-only partition, each of which can be divided into a plurality of blocks, and bad blocks can be generated in the production process of the memory, and new bad blocks can also be generated in the use process of the memory. For bad blocks caused by manufacturing defects or use damage, normal erase and read operations cannot be performed.

[0003] In the existing bad block management method of the memory, the bad block management is usually performed on the read-write partition of the memory, and the bad blocks generated in the use process of the read-only partition are not managed. The bad blocks of the read-only partition will cause the program loading of the related partition device to fail, and the device will be abnormal.

[0004] In the related art, there is no effective solution to the problem that the bad blocks generated in the use process of the read-only partition are not managed, which causes the program loading of the related partition device to fail due to the bad blocks, and the device cannot operate normally. SUMMARY

[0005] A bad block management method and device based on a read-only partition of a memory and a computer device are provided in the present embodiment to solve the problem that the bad blocks generated in the use process of the read-only partition are not managed in the related art, which causes the program loading of the related partition device to fail due to the bad blocks, and the device cannot operate normally.

[0006] In a first aspect, a bad block management method based on a read-only partition of a memory is provided in the present embodiment, and the read-only partition includes a program data region and a bad block reservation region. The program data region includes a plurality of software program partitions. The method includes:

[0007] When it is detected that an abnormality occurs in an erase operation in the update process of the software program partition, a first bad block in the software program partition in which the abnormality occurs in the erase operation is determined;

[0008] A first normal block is selected from the bad block reservation region, and data for updating the first bad block is written into the first normal block;

[0009] A first mapping relationship between the first bad block and the first normal block is established;

[0010] In response to a data access for the first bad block, the first normal block pointed by the first mapping relationship is accessed, and data stored in the first normal block is read.

[0011] In some embodiments, the accessing the first normal block pointed by the first mapping relationship and reading data stored in the first normal block in response to the data access for the first bad block comprises:

[0012] In response to a data access for the first bad block, a target address of the first normal block is determined according to a first mapping relationship between the first bad block and the first normal block; the target address is an offset of the first normal block relative to a start address of the software program partition;

[0013] Based on the target address of the first normal block, data stored in the first normal block is read.

[0014] In some embodiments, when the read-only partition further comprises a data verification area, after the first mapping relationship between the first bad block and the first normal block is established, the method further comprises:

[0015] After the upgrade program data is written into the software program partition, it is determined whether there is an available data block in the data verification area; the upgrade program data is data for updating the software program partition;

[0016] When the available data block exists in the data verification area, the data blocks occupied by the software program partition are grouped according to the number of the available data blocks and the number of data blocks occupied by the software program partition, to obtain a plurality of verification units;

[0017] The upgrade program data of each data block in each verification unit is verified to obtain corresponding redundant verification information, and the redundant verification information is written into a data block in the data verification area.

[0018] In some embodiments, after the redundant verification information is written into the data block in the data verification area, the method further comprises:

[0019] When it is detected that an abnormality occurs in an erase-write operation in the process of writing the redundant verification information, a second bad block in the data verification area in which the abnormality occurs in the erase-write operation is determined;

[0020] A second normal block is selected from the bad block reservation area, and the redundant verification information is written into the second normal block;

[0021] A second mapping relationship between the second bad block and the second normal block is established.

[0022] In some embodiments, the accessing the first normal block pointed by the first mapping relationship and reading data stored in the first normal block in response to the data access for the first bad block further comprises:

[0023] In response to an abnormal data read state of the first normal block, determining the check unit to which the first bad block belongs;

[0024] Based on the redundant check information corresponding to the first bad block and data stored in each normal block in the check unit to which the first bad block belongs, recovering data stored in the first bad block, and returning the target data obtained by the recovery.

[0025] In some embodiments, the determining the check unit to which the first bad block belongs comprises:

[0026] In the range from the software program partition start address to the current address of the first bad block, determining the number of fixed bad blocks marked in advance; the current address is the offset of the first bad block relative to the software program partition start address;

[0027] Based on the check area information corresponding to the first bad block, determining the number of data blocks contained in each check unit;

[0028] Based on the preset data block size, the number of fixed bad blocks, the number of data blocks contained in each check unit, and the current address of the first bad block, determining the check unit to which the first bad block belongs.

[0029] In some embodiments, after the recovering data stored in the first bad block, the method further comprises:

[0030] Selecting a third normal block from the bad block reserved area, and writing the target data obtained by the recovery into the third normal block;

[0031] Establishing a third mapping relationship between the first bad block and the third normal block;

[0032] Updating the first mapping relationship corresponding to the first bad block to the third mapping relationship.

[0033] In a second aspect, the present embodiment provides a bad block management device based on a memory read-only partition, the read-only partition comprising a program data area and a bad block reserved area; wherein the program data area comprises a plurality of software program partitions; the device comprises a detection module, a writing module, a mapping module, and a reading module.

[0034] The detection module is configured to determine a first bad block in the software program partition that has a write abnormality when detecting that the write abnormality occurs in the software program partition update process.

[0035] The writing module is configured to select a first normal block from the bad block reserved area, and write data for updating the first bad block into the first normal block.

[0036] The mapping module is configured to establish a first mapping relationship between the first bad block and the first normal block.

[0037] The reading module is configured to, in response to data access for the first bad block, access the first normal block pointed to by the first mapping relationship, and read data stored in the first normal block.

[0038] In a third aspect, a computer device is provided in the embodiment, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the read-only partition based bad block management method of the first aspect when executing the computer program.

[0039] In a fourth aspect, a storage medium is provided in the embodiment, which stores a computer program executable by a processor to implement the read-only partition based bad block management method of the first aspect.

[0040] Compared with the related art, the read-only partition based bad block management method, device and computer device provided in the embodiment determine a first bad block in a software program partition that has a write abnormality when detecting that the write abnormality occurs in a software program partition update process, select a first normal block from a bad block reserved area, write data for updating the first bad block into the first normal block, establish a first mapping relationship between the first bad block and the first normal block, and further, in response to data access for the first bad block, access the first normal block pointed to by the first mapping relationship, and read data stored in the first normal block, thereby solving the problem that a bad block generated in the use of a read-only partition is not managed, causing a program of a related partition device of the bad block to fail to be loaded, and the device cannot normally operate, and achieving management of the bad block generated in the use of the read-only partition, avoiding the program of the related partition device of the bad block from failing to be loaded, and ensuring normal operation of the device.

[0041] Details of one or more embodiments of the present application are presented in the following drawings and description to make other features, objects and advantages of the present application more apparent. BRIEF DESCRIPTION OF DRAWINGS

[0042] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application. In the drawings:

[0043] Figure 1 is a hardware structure block diagram of a terminal device based on the bad block management method of the read-only partition of the memory provided by an embodiment of the application;

[0044] Figure 2 is a flowchart of the bad block management method based on the read-only partition of the memory provided by an embodiment of the application;

[0045] Figure 3 is a distribution diagram of the read-only partition of the memory provided by an embodiment of the application;

[0046] Figure 4 is a grouping diagram of the data verification process provided by an embodiment of the application;

[0047] Figure 5 is a diagram of the data recovery process provided by an embodiment of the application;

[0048] Figure 6 is a flowchart of the bad block management method based on the read-only partition of the memory provided by an embodiment of the application;

[0049] Figure 7 is a flowchart of the bad block management method based on the read-only partition of the memory provided by another embodiment of the application;

[0050] Figure 8 is a flowchart of the bad block management method based on the read-only partition of the memory provided by a preferred embodiment of the application;

[0051] Figure 9 is a structure block diagram of the bad block management device based on the read-only partition of the memory provided by an embodiment of the application.

[0052] In the drawings: 102, processor; 104, memory; 106, transmission device; 108, input and output device; 10, detection module; 20, writing module; 30, mapping module; 40, reading module. DETAILED DESCRIPTION

[0053] In order to more clearly understand the purpose, technical scheme and advantages of the application, the application is described and explained below in combination with the drawings and embodiments.

[0054] Unless otherwise defined, the technical or scientific terms used in this application shall have the general meaning as understood by one of ordinary skill in the art to which this application pertains. Words such as “a,” “an,” “an,” “the,” “the,” and “these,” used in this application, do not indicate quantitative limitation and may be singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that comprises a series of steps or modules (units) is not limited to the listed steps or modules (units) but may include steps or modules (units) not listed, or may include other steps or modules (units) inherent to such processes, methods, products, or devices. The terms “connected,” “linked,” and “coupled,” used in this application, are not limited to physical or mechanical connections but may include electrical connections, whether direct or indirect. The term “multiple” used in this application refers to two or more. The "and / or" operator describes the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: A alone, A and B simultaneously, and B alone. Typically, the character " / " indicates that the objects before and after it are in an "or" relationship. The terms "first," "second," and "third," etc., used in this application are merely for distinguishing similar objects and do not represent a specific ordering of the objects.

[0055] The method embodiments provided in this example can be executed on a terminal, computer, or similar computing device. For example, it can run on a terminal. Figure 1 This is a hardware structure block diagram of the terminal based on the bad block management method of read-only memory partitions in this embodiment. Figure 1 As shown, a terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 and a memory 104 for storing data are also included. The processor 102 may be, but is not limited to, a microprocessor (MCU) or a programmable logic device (FPGA). The terminal may also include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that… Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the terminal described above. For example, the terminal may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown are illustrated.

[0056] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the bad block management method based on memory read-only partitions in this embodiment. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0057] The transmission device 106 is used to receive or send data via a network. This network includes a wireless network provided by the terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 can be a Radio Frequency (RF) module used for wireless communication with the Internet.

[0058] This embodiment provides a bad block management method based on read-only partitions of memory. Figure 2 This is a flowchart of the bad block management method based on read-only memory partitions in this embodiment, as shown below. Figure 2 As shown, the process includes the following steps:

[0059] Step S210: When an abnormality is detected in the erase / write operation during the software program partition update process, the first bad block in the software program partition that has an erase / write abnormality is identified.

[0060] Step S220: Select the first normal block from the bad block reservation area and write the data used to update the first bad block into the first normal block;

[0061] Step S230: Establish a first mapping relationship between the first bad block and the first normal block;

[0062] In step S240, in response to data access to the first bad block, the first normal block pointed to by the first mapping relationship is accessed, and the data stored in the first normal block is read.

[0063] In this embodiment, the readable storage area includes a program data area, a data verification area, and a bad block reservation area. The program data area includes multiple software program partitions, such as a bootloader partition, a kernel file partition, and a root file system partition, etc. Figure 3 As shown, the arrangement of the areas is typically as follows: program data area, data verification area, and bad block reserve area. Data blocks 1 to m constitute the program data area, while data blocks m+1 to k include the data verification area and the bad block reserve area. It should be noted that compared to the actual size of each software program, the storage space of the readable partition is usually quite large. In addition to the storage space occupied by the software program data, there is also some reserved space within the readable partition. In this embodiment, a data verification area and a bad block reserve area are provided in this reserved space to improve space utilization.

[0064] Specifically, during the data update phase of the read-only partition, the upgrade program data used to update the software program partition is loaded into memory, and the data in memory is used to update the read-only partition of the storage to update the corresponding software program partition. Before writing the upgrade program data, it is necessary to read the data of the first page of the first data block of the storage and parse whether the partition information table exists. If it does not exist, it indicates that this is the first update of the read-only partition, and the corresponding partition information table is pre-created and stored in the first page of the first data block of the storage. Since the first data block of the storage is usually guaranteed to be a normal data block during the storage manufacturing process, storing the partition information table in the first data block improves its reliability and security.

[0065] For each software program partition, during data updates, if the currently updated data block is a factory-marked bad block, the data block is skipped, and the data is written to the next available block in the software program partition. If a mapping relationship already exists between the currently updated data block and a data block in the bad block reservation area, the data block pointed to by the mapping relationship is accessed directly for data updates. Furthermore, if an anomaly is detected during the erase / write operation in the software program partition update process, the first bad block in the software program partition that experienced the erase / write anomaly is identified. This first bad block is a bad block generated during use. A first normal block is selected from the bad block reservation area, and the data used to update the first bad block is written to the first normal block. The physical block number of the first bad block and the physical block number of the first normal block are associated and stored in the bad block mapping table corresponding to the current software program partition in the partition information table to establish a first mapping relationship between the first bad block and the first normal block. This embodiment does not limit the specific method for selecting a usable data block as the first normal block from the bad block reservation area. Preferably, when the order of each partition is program data area, data verification area and bad block reservation area, and all data blocks in the read-only partition are arranged in ascending order of physical block number, a usable data block is searched in reverse in the bad block reservation area.

[0066] After the upgrade program data is written to the corresponding software program partition, it is determined whether there are available data blocks in the data verification area. The number of available data blocks is typically greater than one. If available data blocks are detected in the data verification area, the data blocks occupied by the software program partition are grouped according to the number of available data blocks and the number of data blocks occupied by the software program partition, resulting in multiple verification units. The upgrade program data in each data block of each verification unit is verified to obtain corresponding redundancy verification information, which is then written to the data blocks in the data verification area. If no available data blocks are detected in the data verification area, it indicates that the currently readable partition has no additional space available for redundancy verification, and the data update ends.

[0067] Furthermore, during the use of the read-only partition, when the read-only partition data loading begins, the partition information table of the first page of the first data block stored in the memory is pre-loaded into memory. The current software program partition is located in the partition information table to obtain the bad block mapping table and check area information corresponding to the current software program partition. The check area information includes the number of data blocks contained in each check unit, the starting physical block number and the ending physical block number of the data check area corresponding to the current software program partition.

[0068] Next, data is read according to the memory address corresponding to the current data access. The memory address refers to the offset of the data block corresponding to the current data access based on the partition start address. If the data block where the memory address is located is a normal data block, data is read normally from the current data block and the acquired data is returned to the upper-layer data access module. If the data block where the memory address is located is a factory-marked fixed bad block, the data block is skipped and the next available block is accessed. If the data block where the memory address is located is the first bad block, the mapping relationship corresponding to the first bad block is obtained from the bad block mapping table, the first normal block pointed to by the first mapping relationship is accessed, and the specific page address in the first normal block is located according to the offset of the first normal block based on the partition start address, the preset data block size, and the preset page size, and the data is read and returned to the upper-layer data access module.

[0069] If the data read status of the current data block is abnormal, within the range from the starting address of the software program partition to the current address of the current data block, the number of pre-marked fixed bad blocks is determined. Based on the check area information corresponding to the current data block, the number of data blocks contained in each check unit is determined. Then, based on the preset data block size, the number of fixed bad blocks, the number of data blocks contained in each check unit, and the current address of the current data block, the check unit to which the current data block belongs is calculated and determined. Redundancy check information corresponding to the current data block is obtained. Based on the redundancy check information corresponding to the current data block and the data stored in each normal block in the check unit to which the current data block belongs, the data stored in the current data block is recovered to obtain the target data. It can be understood that the normal blocks used for data recovery are the other normal data blocks in the check unit to which the first bad block belongs, excluding the first bad block. At this point, the third normal block is selected from the bad block reservation area, the recovered target data is written into the third normal block, the physical block number of the first bad block and the physical block number of the third normal block are associated and stored in the bad block mapping table corresponding to the current software program partition in the partition information table to establish the third mapping relationship between the first bad block and the third normal block, the first mapping relationship corresponding to the first bad block is updated to the third mapping relationship, and the recovered target data is returned to the upper layer data access module.

[0070] It should be noted that after returning the recovered target data to the upper-layer data access module, a data refresh process for the read-only partition is triggered, re-executing the data update process for the read-only partition. Since there is no fixed boundary between the data verification area and the bad block reservation area, and the total number of data blocks in both areas remains constant, as bad blocks increase during use, the number of data blocks used for bad block mapping in the bad block reservation area also increases, correspondingly reducing the available data blocks in the data verification area. By triggering the data refresh process for the read-only partition, redundant verification data in the data verification area is updated. Furthermore, memory exhibits a drift effect, meaning the voltage value of memory cells gradually changes over time. Triggering the data refresh process for the read-only partition performs charge re-injection, thus addressing the issue of potential changes in the charge threshold caused by prolonged periods without data updates in the read-only partition. A suitable time for charge injection is when the data blocks in the partition containing the current software program show a tendency to become bad blocks or have just become bad blocks. Therefore, this embodiment performs charge re-injection during the stage when bad blocks are generated during use.

[0071] Existing bad block management methods for memory typically manage bad blocks only for the read-write partitions of the memory, neglecting to manage bad blocks generated during the use of read-only partitions. Bad blocks in read-only partitions will cause the related partition device program to fail to load, resulting in device malfunctions.

[0072] Compared to existing technologies, this application, when detecting an anomaly in the erase / write operation during the software program partition update process, identifies the first bad block in the software program partition where the erase / write anomaly occurred; selects a first normal block from the bad block reservation area, and writes the data used to update the first bad block into the first normal block; establishes a first mapping relationship between the first bad block and the first normal block; further, in response to data access for the first bad block, accesses the first normal block pointed to by the first mapping relationship and reads the data stored in the first normal block. Based on this, when bad blocks are generated during the use of a read-only partition, a mapping relationship is established between the bad block and the normal block in the bad block reservation area. This allows for data access to the normal block in the bad block reservation area using the mapping relationship when bad blocks need to be accessed, thus enabling the normal loading of the required data. This solves the problem of failure to manage bad blocks generated during the use of read-only partitions, leading to the failure of the device program to load the relevant partitions and the inability of the device to operate normally. It achieves management of bad blocks generated during the use of read-only partitions, avoids the failure of the device program to load the relevant partitions, and ensures the normal operation of the device.

[0073] In some embodiments, step S240, in response to data access to the first bad block, accessing the first normal block pointed to by the first mapping relationship and reading the data stored in the first normal block, includes the following steps:

[0074] In response to data access to the first bad block, the target address of the first normal block is determined according to the first mapping relationship between the first bad block and the first normal block; the target address is the offset of the first normal block relative to the starting address of the software program partition.

[0075] Based on the target address of the first normal block, read the data stored in the first normal block.

[0076] Specifically, data is read according to the memory address corresponding to the current data access. If the data block where the memory address corresponding to the current data access is located is the first bad block, the mapping relationship corresponding to the first bad block is obtained from the bad block mapping table. Based on the physical block number of the first bad block, the physical block number of the first normal block, the memory address corresponding to the current data access, and the preset data block size, the offset of the first normal block relative to the starting address of the software program partition is determined.

[0077] Furthermore, the system accesses the first normal block pointed to by the first mapping relationship. Based on the offset of the first normal block from the partition start address, the preset data block size, and the preset page size, it locates the specific page address within the first normal block for data reading and returns the acquired data to the upper-layer data access module. The specific calculation formula is as follows:

[0078]

[0079] In equation (1), addr2 represents the specific page address in the first normal block; addr1 represents the offset of the first normal block based on the partition start address; a represents the preset data block size; and b represents the preset page size.

[0080] In this embodiment, in response to data access for the first bad block, the target address of the first normal block is determined according to the first mapping relationship between the first bad block and the first normal block. The target address is the offset of the first normal block relative to the starting address of the software program partition. Then, based on the target address of the first normal block, the data stored in the first normal block is read. In this way, the data required for program loading can be read normally by utilizing the mapping relationship between the first bad block and the first normal block.

[0081] In some embodiments, where the read-only partition also includes a data verification area, after establishing the first mapping relationship between the first bad block and the first normal block, the following steps are further included:

[0082] After the upgrade program data is written to the software program partition, it is determined whether there are available data blocks in the data verification area; the upgrade program data is the data used to update the software program partition.

[0083] When there are available data blocks in the data verification area, the data blocks occupied by the software program partition are grouped according to the number of available data blocks and the number of data blocks occupied by the software program partition to obtain multiple verification units.

[0084] The upgrade program data of each data block in each verification unit is verified to obtain the corresponding redundant verification information, and the redundant verification information is written into the data block in the data verification area.

[0085] Specifically, the upgrade program data in memory is updated to the read-only partition of the storage. After the upgrade program data is written to the corresponding software program partition, it is determined whether there are usable data blocks in the data verification area. Usable data blocks refer to data blocks in the data verification area that have not yet been used for data verification, excluding fixed bad blocks marked by the factory in the data verification area. If usable data blocks are detected in the data verification area, the number of currently usable data blocks is determined, and the specific calculation formula is as follows:

[0086] t=kmnl(2)

[0087] In equation (2), t represents the number of available data blocks in the data verification area; k represents the total number of data blocks used by the read-only partition; m represents the number of data blocks occupied by the program data area; n represents the number of data blocks occupied by the bad block reserve area; and l represents the number of fixed bad blocks marked by the factory in the address space [m, kn].

[0088] After that, as Figure 4As shown, based on the number of available data blocks and the number of data blocks currently occupied by the software program partition, the data blocks occupied by the software program partition are grouped to obtain multiple verification units. The specific calculation formula is as follows:

[0089] S=(p+t-1) / t(3)

[0090] In equation (3), S represents the number of data blocks contained in each verification unit; p represents the number of data blocks occupied by the current software program partition; and t represents the number of available data blocks in the data verification area.

[0091] Furthermore, using data blocks as the basic data unit, redundancy verification processing is performed on the upgrade program data of each data block in each verification unit, such as using parity check operation, to obtain the corresponding redundancy verification information. The redundancy verification information is written into the data blocks in the data verification area, and the number of data blocks contained in each verification unit, the starting physical block number and the ending physical block number of the data verification area are updated to the verification area information corresponding to the current software program partition in the partition information table.

[0092] It should be noted that if there are no available data blocks in the data verification area, it means that there is no extra space available for redundant verification in the current readable partition, and the data update ends.

[0093] In this embodiment, after the upgrade program data is written to the software program partition, it is determined whether there are available data blocks in the data verification area. If available data blocks exist in the data verification area, the data blocks occupied by the software program partition are grouped according to the number of available data blocks and the number of data blocks occupied by the software program partition, resulting in multiple verification units. The upgrade program data of each data block in each verification unit is verified to obtain corresponding redundant verification information. The redundant verification information is written to the data blocks in the data verification area so that in the event of subsequent data reading anomalies, the redundant verification information in the data verification area can be used for data recovery, ensuring the normal reading of program data and preventing the device from falling into anomaly.

[0094] In some embodiments, after writing the redundancy check information into the data block in the data check area, the following steps are also included:

[0095] When an abnormal erase / write operation is detected during the writing of redundant verification information, the second bad block in the data verification area that has an erase / write abnormality is identified.

[0096] Select the second normal block from the bad block reservation area and write the redundancy check information into the second normal block;

[0097] Establish a second mapping relationship between the second bad block and the second normal block.

[0098] Specifically, during the writing of redundancy verification information, if an error in erasing or writing redundancy verification information is detected, the second bad block in the data verification area that has experienced an error in erasing or writing is identified. The second bad block is a bad block generated during use.

[0099] Furthermore, a second normal block is selected from the bad block reservation area, redundancy check information is written into the second normal block, and the physical block number of the second bad block and the physical block number of the second normal block are associated and stored in the bad block mapping table corresponding to the current software program partition in the partition information table to establish a second mapping relationship between the second bad block and the second normal block, and the number of currently available data blocks is updated. This embodiment does not limit the specific method for selecting available data blocks from the bad block reservation area as the second normal block. Preferably, when the partitions are arranged in the order of program data area, data check area, and bad block reservation area, and all data blocks in the read-only partition are arranged in ascending order of physical block number, available data blocks are searched in reverse order in the bad block reservation area.

[0100] It should be noted that if the data block containing the memory address corresponding to the data access is the second bad block, the second normal block pointed to by the second mapping relationship is accessed, and the redundancy check information stored in the second normal block is read, thereby realizing the acquisition of redundancy check information.

[0101] In this embodiment, when an abnormality is detected in the erase / write operation during the writing of redundant verification information, a second bad block with an erase / write abnormality is identified in the data verification area. A second normal block is selected from the bad block reservation area, the redundant verification information is written into the second normal block, and a second mapping relationship is established between the second bad block and the second normal block. This ensures that in the event of an abnormality in the erase / write of redundant verification information, the redundant verification information can be obtained normally using the second mapping relationship, thereby ensuring the recovery of the relevant data.

[0102] In some embodiments, step S240, in response to data access to the first bad block, accessing the first normal block pointed to by the first mapping relationship and reading the data stored in the first normal block, further includes the following steps:

[0103] Step S241: When the data reading status of the first normal block is abnormal, determine the verification unit to which the first bad block belongs;

[0104] Step S242: Based on the redundant verification information corresponding to the first bad block and the data stored in each normal block in the verification unit to which the first bad block belongs, the data stored in the first bad block is recovered, and the recovered target data is returned.

[0105] Specifically, data is read from the first normal block. If an abnormal data read status of the first normal block is detected, a pre-marked fixed number of bad blocks is determined within the range from the start address of the software program partition to the current address of the first bad block. Here, the current address is the offset of the first bad block relative to the start address of the software program partition. Based on the checksum information corresponding to the first bad block, the number of data blocks contained in each checksum unit is determined. And based on the preset data block size, the fixed number of bad blocks, the number of data blocks contained in each checksum unit, and the current address of the first bad block, the checksum unit to which the first bad block belongs is calculated and determined.

[0106] Furthermore, such as Figure 5 As shown, the data stored in each data block of the verification unit to which the first bad block belongs is saved to a preset first memory area. That is, data is read starting from the first data block in the verification unit to which the first bad block belongs, and a total of [number] data blocks corresponding to each verification unit are read. The acquired data is then stored in the first memory area. Simultaneously, based on the verification unit to which the first bad block belongs, the redundant verification information corresponding to that verification unit is saved to a preset second memory area. Based on the redundant verification information in the second memory area and the data stored in each normal block in the first memory area, the data stored in the first bad block is recovered. The recovered target data is saved to a preset third memory area and then returned to the upper-layer data access module. It can be understood that the normal blocks used for data recovery are the other normal data blocks in the verification unit to which the first bad block belongs, excluding the first bad block.

[0107] Specifically, when obtaining the redundant verification information corresponding to the verification unit to which the first bad block belongs, if the data block in the data verification area corresponding to the verification unit is the second bad block, then the second normal block pointed to by the second mapping relationship associated with the second bad block is accessed, and the redundant verification information corresponding to the verification unit is read from the second normal block.

[0108] It should be noted that if the data block to be read is a normal data block in the software program partition, and the data reading status is abnormal, the data block can also be recovered using the same data recovery method for the first bad block.

[0109] In this embodiment, when the data reading status of the first normal block is abnormal, the verification unit to which the first bad block belongs is determined. Based on the redundant verification information corresponding to the first bad block and the data stored in each normal block in the verification unit to which the first bad block belongs, the data stored in the first bad block is recovered, and the recovered target data is returned. In this way, data recovery is achieved by using the pre-stored redundant verification information, ensuring that the required program data is obtained normally and avoiding program loading failure.

[0110] In some embodiments, determining the verification unit to which the first bad block belongs in step S241 includes the following steps:

[0111] Within the range from the starting address of the software program partition to the current address of the first bad block, determine the number of pre-marked fixed bad blocks; the current address is the offset of the first bad block relative to the starting address of the software program partition.

[0112] Based on the check area information corresponding to the first bad block, determine the number of data blocks contained in each check unit;

[0113] Based on the preset data block size, fixed number of bad blocks, number of data blocks contained in each verification unit, and the current address of the first bad block, the verification unit to which the first bad block belongs is determined.

[0114] Specifically, the checksum information corresponding to the current software program partition is obtained from the partition information table. This checksum information includes the number of data blocks contained in each checksum unit. Within the range from the starting address of the software program partition to the current address of the first bad block, the number of fixed bad blocks pre-marked by the manufacturer is determined. Here, the current address of the first bad block is the offset of the first bad block relative to the starting address of the software program partition.

[0115] Furthermore, the check unit to which the first bad block belongs is calculated, using the following formula:

[0116]

[0117] In equation (4), index represents the check unit to which the first bad block belongs; addr represents the current address of the first bad block; a represents the preset data block size; c represents the fixed number of bad blocks within the address space range [0, addr]; and S represents the number of data blocks contained in each check unit. Based on this, the starting data block in the check unit to which the first bad block belongs is calculated as start block = index * S, so that the starting data block in the check unit to which the first bad block belongs can be located during data recovery. At the same time, the offset of the first bad block inside the check unit is calculated, and the position of the first bad block within the check unit to which the first bad block belongs is located, so that the first bad block in the check unit to which the first bad block belongs can be removed during data recovery. The specific calculation formula is as follows:

[0118]

[0119] In equation (5), offset block represents the offset of the first bad block within the check unit; addr represents the current address of the first bad block; a represents the preset data block size; c represents the fixed number of bad blocks within the address space range [0, addr]; and S represents the number of data blocks contained in each check unit.

[0120] It should be noted that if the data block to be read is a normal data block in the software program partition and the data reading status is abnormal, the same methods as above, such as determining the check unit to which the first bad block belongs, calculating the starting data block, and the offset of the first bad block within the check unit, shall be applied to the data block.

[0121] In this embodiment, within the range from the starting address of the software program partition to the current address of the first bad block, a pre-marked fixed number of bad blocks is determined. The current address is the offset of the first bad block relative to the starting address of the software program partition. Based on the check area information corresponding to the first bad block, the number of data blocks contained in each check unit is determined. Then, based on the preset data block size, the fixed number of bad blocks, the number of data blocks contained in each check unit, and the current address of the first bad block, the check unit to which the first bad block belongs is accurately located, which facilitates subsequent data recovery using other normal blocks in the check unit to which the first bad block belongs.

[0122] In some embodiments, after recovering the data stored in the first bad block, the following steps are also included:

[0123] Select the third normal block from the bad block reservation area and write the recovered target data into the third normal block;

[0124] Establish a third mapping relationship between the first bad block and the third normal block;

[0125] Update the first mapping relationship corresponding to the first bad block to the third mapping relationship.

[0126] Specifically, the data stored in the first bad block is recovered to obtain the target data. At this time, the third normal block is selected from the bad block reservation area, the recovered target data is written into the third normal block, and the physical block number of the first bad block and the physical block number of the third normal block are associated and stored in the bad block mapping table corresponding to the current software program partition in the partition information table to establish a third mapping relationship between the first bad block and the third normal block.

[0127] It should be noted that during the data update phase, a first mapping relationship is established between the first bad block and the first normal block. However, during the data loading phase, if the first normal block is abnormally read, a third mapping relationship is established between the first bad block and the third normal block. The first mapping relationship corresponding to the first bad block is updated to the third mapping relationship to ensure that the mapping relationship stored in the bad block mapping table is the latest mapping relationship.

[0128] It is understandable that if the data block to be read is a normal data block in the software program partition and the data reading status is abnormal, it indicates that the data block is a bad block generated during the current use. The above data recovery method for the first bad block is applied to the data block to recover the target data. Normal blocks are selected from the bad block reservation area to establish a mapping relationship between the data block and the normal blocks, and the mapping relationship is updated to the bad block mapping table corresponding to the current software program partition.

[0129] In this embodiment, a third normal block is selected from the bad block reservation area, the recovered target data is written into the third normal block, a third mapping relationship is established between the first bad block and the third normal block, and the first mapping relationship corresponding to the first bad block is updated to the third mapping relationship. Thus, the latest mapping relationship can be used to achieve normal data acquisition, while ensuring the accuracy of the acquired data.

[0130] The present embodiment will be described and explained below through specific examples.

[0131] Figure 6 This is a flowchart illustrating the bad block management method based on read-only memory partitions in this embodiment. Figure 6 As shown, during the data update phase of the read-only partition, the method specifically includes the following steps:

[0132] When data updates of the read-only partition begin, the upgrade program data is loaded into memory. This upgrade program data is used to update the corresponding software program partition (S601), and it is determined whether an error occurred during the erase / write operation in the software program partition update process (S602). If an error is detected during the erase / write operation in the software program partition update process, the first bad block in the software program partition that experienced the erase / write error is identified. The first normal block is selected from the bad block reservation area, and the data used to update the first bad block is written to the first normal block. The physical block number of the first bad block and the physical block number of the first normal block are associated and stored in the bad block mapping table corresponding to the current software program partition in the partition information table to establish the first mapping relationship between the first bad block and the first normal block (S603).

[0133] After the upgrade program data is written to the corresponding software program partition, the available space size of the data verification area is calculated (S604). Based on the available space size, it is determined whether the number of available data blocks in the data verification area is greater than one (S605). If the number of available data blocks is greater than one, the data blocks occupied by the software program partition are grouped according to the actual number of available data blocks and the number of data blocks currently occupied by the software program partition to obtain multiple verification units (S606). The upgrade program data of each data block in each verification unit is verified to obtain the corresponding redundant verification information (S607). The redundant verification information is written to the data blocks in the data verification area. During the writing of redundancy check information, it is determined whether the redundancy check information is erased or written abnormally (S608). If the redundancy check information is erased or written abnormally, the second bad block in the data check area that is erased or written abnormally is identified. The second normal block is selected from the bad block reservation area, the redundancy check information is written to the second normal block, and the physical block number of the second bad block and the physical block number of the second normal block are associated and stored in the bad block mapping table corresponding to the current software program partition in the partition information table to establish the second mapping relationship between the second bad block and the second normal block (S609), and the number of currently available data blocks is updated (S610). If the redundancy check information is erased or written normally, after the information is written, the number of data blocks contained in each check unit, the starting physical block number and the ending physical block number of the data check area are updated to the check area information corresponding to the current software program partition in the partition information table (S611), and the data update ends (S612).

[0134] In addition, if the number of available data blocks is less than or equal to 1, it indicates that there is no extra space available for redundancy verification in the current readable partition, and the data update ends (S612).

[0135] Figure 7 This is a flowchart illustrating the bad block management method based on read-only memory partitions in this embodiment. Figure 7 As shown, the method specifically includes the following steps during the data loading process of a read-only partition:

[0136] When the read-only partition data loading begins (S701), the partition information table of the first page of the first data block stored in the memory is pre-loaded into the memory. The current software program partition is located in the partition information table to obtain the bad block mapping table and check area information corresponding to the current software program partition (S702).

[0137] Next, data is read according to the memory address corresponding to the current data access (S703). The memory address refers to the offset of the data block corresponding to the current data access based on the starting address of the partition. The read status of the data block at the memory address is checked for abnormality (S704). If an abnormal read status is detected, the data stored in the data block is restored based on the redundancy check information corresponding to the data block and the data stored in each normal block in the check unit to which the data block belongs (S705). A third normal block is selected from the bad block reservation area, and the restored target data is written into the third normal block. The physical block number of the current data block and the physical block number of the third normal block are associated and stored in the bad block mapping table corresponding to the current software program partition in the partition information table to establish a third mapping relationship between the current data block and the third normal block (S706). The restored target data is then returned to the upper-layer data access module (S707). Furthermore, the data refresh process of the read-only partition is triggered, and the data update process is re-executed on the read-only partition (S708). The data loading of the read-only partition ends (S709). In addition, if the read status of the data block is detected to be normal, the read data is returned to the upper-layer data access module S707, and the read-only partition data loading ends S709.

[0138] The present embodiment will now be described and illustrated through preferred embodiments.

[0139] Figure 8 This is a flowchart of a bad block management method based on a read-only memory partition according to a preferred embodiment of the present invention, as shown below. Figure 8 As shown, the bad block management method based on memory read-only partitions includes the following steps:

[0140] Step S810: When an abnormality is detected in the erase / write operation during the software program partition update process, the first bad block in the software program partition that has an erase / write abnormality is identified.

[0141] Step S820: Select a first normal block from the bad block reservation area, write the data used to update the first bad block into the first normal block, and establish a first mapping relationship between the first bad block and the first normal block;

[0142] Step S830: After the upgrade program data is written to the software program partition, determine whether there are available data blocks in the data verification area; the upgrade program data is the data used to update the software program partition.

[0143] Step S840: When there are available data blocks in the data verification area, the data blocks occupied by the software program partition are grouped according to the number of available data blocks and the number of data blocks occupied by the software program partition to obtain multiple verification units.

[0144] Step S850: Perform verification processing on the upgrade program data of each data block in each verification unit to obtain the corresponding redundant verification information, and write the redundant verification information into the data block in the data verification area.

[0145] Step S860: In response to data access to the first bad block, access the first normal block pointed to by the first mapping relationship and read the data stored in the first normal block;

[0146] Step S870: When the data read status of the first normal block is abnormal, determine the verification unit to which the first bad block belongs;

[0147] Step S880: Based on the redundancy check information corresponding to the first bad block and the data stored in each normal block in the check unit to which the first bad block belongs, the data stored in the first bad block is recovered, and the recovered target data is returned.

[0148] This embodiment, when an anomaly is detected during the erase / write operation in the software program partition update process, identifies the first bad block in the software program partition where the erase / write anomaly occurred, selects a first normal block from the bad block reservation area, writes the data used to update the first bad block into the first normal block, and establishes a first mapping relationship between the first bad block and the first normal block. This allows the system to access the first bad block and use the mapping relationship to read data from the first normal block and return it to the upper-layer access module. This achieves management of bad blocks generated during the use of read-only partitions, preventing program data from failing to load correctly. It solves the problem of unmanaged bad blocks causing related partition device program loading failures and device malfunctions.

[0149] Furthermore, after the upgrade program data is written to the software program partition, it is determined whether there are available data blocks in the data verification area. If there are available data blocks in the data verification area, the data blocks occupied by the software program partition are grouped according to the number of available data blocks and the number of data blocks occupied by the software program partition to obtain multiple verification units. The upgrade program data of each data block in each verification unit is verified to obtain corresponding redundant verification information. The redundant verification information is written to the data blocks in the data verification area so that in the event of subsequent data reading anomalies, the redundant verification information in the data verification area can be used to recover the data, ensuring the normal reading of program data and preventing the device from falling into anomaly.

[0150] Subsequently, in response to data access for the first bad block, the system accesses the first normal block pointed to by the first mapping relationship, reads the data stored in the first normal block, and if the data reading status of the first normal block is abnormal, the system determines the verification unit to which the first bad block belongs, and recovers the data stored in the first bad block based on the redundant verification information corresponding to the first bad block and the data stored in each normal block in the verification unit to which the first bad block belongs, and returns the recovered target data. In this way, data recovery is achieved by using the pre-stored redundant verification information, ensuring that the required program data is obtained normally, avoiding program loading failure, and improving the stability of the device.

[0151] It should be noted that the steps shown in the above process or in the flowchart of the accompanying figures can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0152] This embodiment also provides a bad block management device based on a read-only memory partition. This device is used to implement the above embodiments and preferred embodiments, and details already described will not be repeated. The terms "module," "unit," "subunit," etc., used below can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0153] Figure 9 This is a structural block diagram of the bad block management device based on read-only memory partitions in this embodiment, as shown below. Figure 9 As shown, the device includes: a detection module 10, a writing module 20, a mapping module 30, and a reading module 40;

[0154] The detection module 10 is used to identify the first bad block in the software program partition that has an erase / write error when an abnormality is detected in the erase / write operation during the software program partition update process.

[0155] The write module 20 is used to select the first normal block from the bad block reservation area and write the data used to update the first bad block into the first normal block;

[0156] Mapping module 30 is used to establish a first mapping relationship between the first bad block and the first normal block;

[0157] The read module 40 is used to access the first normal block pointed to by the first mapping relationship in response to data access for the first bad block, and read the data stored in the first normal block.

[0158] The apparatus provided in this embodiment, when detecting an abnormality in the erase / write operation during the software program partition update process, identifies a first bad block in the software program partition where the erase / write abnormality occurred; selects a first normal block from the bad block reservation area, and writes the data used to update the first bad block into the first normal block; establishes a first mapping relationship between the first bad block and the first normal block; furthermore, in response to data access for the first bad block, accesses the first normal block pointed to by the first mapping relationship and reads the data stored in the first normal block. This solves the problem that the failure to manage bad blocks generated during the use of read-only partitions leads to the failure to load the related partition device program and the inability of the device to operate normally. It realizes the management of bad blocks generated during the use of read-only partitions, avoids the failure to load the related partition device program, and ensures the normal operation of the device.

[0159] In some embodiments, the reading module 40 is further configured to, in response to data access for the first bad block, determine the target address of the first normal block according to the first mapping relationship between the first bad block and the first normal block; the target address is the offset of the first normal block relative to the starting address of the software program partition; and read the data stored in the first normal block based on the target address of the first normal block.

[0160] In some of these embodiments, Figure 9 Based on this, the device also includes a verification module, used to determine whether there are available data blocks in the data verification area after the upgrade program data is written to the software program partition; the upgrade program data is the data used to update the software program partition; when there are available data blocks in the data verification area, the data blocks occupied by the software program partition are grouped according to the number of available data blocks and the number of data blocks occupied by the software program partition to obtain multiple verification units; the upgrade program data of each data block in each verification unit is verified to obtain the corresponding redundant verification information, and the redundant verification information is written to the data blocks in the data verification area.

[0161] In some of these embodiments, Figure 9 Based on this, the device also includes a verification module, which is used to identify the second bad block in the data verification area that has an erase / write abnormality when an abnormality is detected in the erase / write operation during the writing of redundant verification information; select the second normal block from the bad block reservation area, write the redundant verification information into the second normal block; and establish a second mapping relationship between the second bad block and the second normal block.

[0162] In some embodiments, the reading module 40 is further configured to determine the verification unit to which the first bad block belongs when the data reading status of the first normal block is abnormal; based on the redundant verification information corresponding to the first bad block and the data stored in each normal block in the verification unit to which the first bad block belongs, to recover the data stored in the first bad block and return the recovered target data.

[0163] In some embodiments, the reading module 40 is further configured to determine the number of pre-marked fixed bad blocks within the range from the starting address of the software program partition to the current address of the first bad block; the current address is the offset of the first bad block relative to the starting address of the software program partition; determine the number of data blocks contained in each verification unit based on the verification area information corresponding to the first bad block; and determine the verification unit to which the first bad block belongs based on the preset data block size, the number of fixed bad blocks, the number of data blocks contained in each verification unit, and the current address of the first bad block.

[0164] In some embodiments, the reading module 40 is further configured to select a third normal block from the bad block reservation area, write the recovered target data into the third normal block; establish a third mapping relationship between the first bad block and the third normal block; and update the first mapping relationship corresponding to the first bad block to the third mapping relationship.

[0165] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can reside in the same processor; or the above modules can be located in different processors in any combination.

[0166] This embodiment also provides a computer device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

[0167] Optionally, the computer device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.

[0168] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:

[0169] S1, when an abnormal erase / write operation is detected during the software program partition update process, the first bad block in the software program partition where the erase / write abnormality occurred is identified.

[0170] S2, Select the first normal block from the bad block reservation area, and write the data used to update the first bad block into the first normal block;

[0171] S3, establish the first mapping relationship between the first bad block and the first normal block;

[0172] S4, in response to data access for the first bad block, access the first normal block pointed to by the first mapping relationship and read the data stored in the first normal block.

[0173] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated in this embodiment.

[0174] Furthermore, in conjunction with the bad block management method based on read-only memory partitions provided in the above embodiments, this embodiment can also provide a storage medium for implementation. This storage medium stores a computer program; when executed by a processor, the computer program implements any of the bad block management methods based on read-only memory partitions in the above embodiments.

[0175] It should be understood that the specific embodiments described herein are merely illustrative of the application and not intended to limit it. All other embodiments derived by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application.

[0176] Obviously, the accompanying drawings are merely some examples or embodiments of this application. Those skilled in the art can apply this application to other similar situations based on these drawings without any creative effort. Furthermore, it is understood that although the work done in this development process may be complex and lengthy, for those skilled in the art, certain design, manufacturing, or production modifications made based on the technical content disclosed in this application are merely conventional technical means and should not be considered as insufficient disclosure of this application.

[0177] The term "embodiment" in this application refers to a specific feature, structure, or characteristic described in connection with an embodiment that may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily imply the same embodiment, nor does it imply that it is mutually exclusive with or independent of other embodiments. It will be clearly or implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.

[0178] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of patent protection. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the appended claims.

Claims

1. A bad block management method based on read-only partitions of memory, characterized in that, The read-only partition includes a program data area and a bad block reservation area, and also includes a data verification area; wherein, the program data area includes multiple software program partitions; the method includes: When an abnormal erase / write operation is detected during the software program partition update process, the first bad block in the software program partition that has experienced an erase / write abnormality is identified. Select a first normal block from the bad block reservation area and write the data used to update the first bad block into the first normal block; Establish a first mapping relationship between the first bad block and the first normal block; After the upgrade program data is written to the software program partition, it is determined whether there are available data blocks in the data verification area; the upgrade program data is the data used to update the software program partition. When the available data blocks exist in the data verification area, the data blocks occupied by the software program partition are grouped according to the number of available data blocks and the number of data blocks occupied by the software program partition to obtain multiple verification units; The upgrade program data of each data block in each verification unit is verified to obtain corresponding redundant verification information, and the redundant verification information is written into the data block in the data verification area. In response to data access to the first bad block, the first normal block pointed to by the first mapping relationship is accessed, and the data stored in the first normal block is read.

2. The bad block management method based on read-only partitions of memory according to claim 1, characterized in that, The step of responding to data access for the first bad block by accessing the first normal block pointed to by the first mapping relationship and reading the data stored in the first normal block includes: In response to data access to the first bad block, the target address of the first normal block is determined according to the first mapping relationship between the first bad block and the first normal block; the target address is the offset of the first normal block relative to the starting address of the software program partition; Based on the target address of the first normal block, read the data stored in the first normal block.

3. The bad block management method based on read-only partitions of memory according to claim 1, characterized in that, After writing the redundancy check information into the data block in the data check area, the method further includes: When an abnormality is detected in the erase / write operation during the writing of the redundant verification information, a second bad block in the data verification area that has experienced an erase / write abnormality is identified. Select a second normal block from the bad block reservation area and write the redundancy check information into the second normal block; Establish a second mapping relationship between the second bad block and the second normal block.

4. The bad block management method based on read-only partitions of memory according to claim 1, characterized in that, The step of accessing the first normal block pointed to by the first mapping relationship and reading the data stored in the first normal block in response to data access to the first bad block further includes: When the data reading status of the first normal block is abnormal, determine the verification unit to which the first bad block belongs; Based on the redundant verification information corresponding to the first bad block and the data stored in each normal block in the verification unit to which the first bad block belongs, the data stored in the first bad block is recovered, and the recovered target data is returned.

5. The bad block management method based on read-only partitions of memory according to claim 4, characterized in that, The step of determining the verification unit to which the first bad block belongs includes: Within the range from the starting address of the software program partition to the current address of the first bad block, a fixed number of pre-marked bad blocks is determined; the current address is the offset of the first bad block relative to the starting address of the software program partition. Based on the check area information corresponding to the first bad block, determine the number of data blocks contained in each check unit; Based on the preset data block size, the fixed number of bad blocks, the number of data blocks contained in each verification unit, and the current address of the first bad block, the verification unit to which the first bad block belongs is determined.

6. The bad block management method based on read-only partitions of memory according to claim 4, characterized in that, After recovering the data stored in the first bad block, the method further includes: Select a third normal block from the bad block reservation area and write the recovered target data into the third normal block; Establish a third mapping relationship between the first bad block and the third normal block; Update the first mapping relationship corresponding to the first bad block to the third mapping relationship.

7. A bad block management device based on a read-only partition of a memory, characterized in that, The read-only partition includes a program data area and a bad block reservation area, and also includes a data verification area; wherein, the program data area includes multiple software program partitions; the device includes: a detection module, a writing module, a mapping module, a reading module, and a verification module; The detection module is used to determine the first bad block in the software program partition that has an erase / write anomaly when an abnormality is detected in the erase / write operation during the software program partition update process. The writing module is used to select a first normal block from the bad block reservation area and write the data used to update the first bad block into the first normal block; The mapping module is used to establish a first mapping relationship between the first bad block and the first normal block; The reading module is configured to, in response to data access to the first bad block, access the first normal block pointed to by the first mapping relationship and read the data stored in the first normal block; The verification module is used to determine whether there are available data blocks in the data verification area after the upgrade program data is written to the software program partition; the upgrade program data is the data used to update the software program partition; when there are available data blocks in the data verification area, the data blocks occupied by the software program partition are grouped according to the number of available data blocks and the number of data blocks occupied by the software program partition to obtain multiple verification units; the upgrade program data of each data block in each verification unit is verified to obtain corresponding redundant verification information, and the redundant verification information is written into the data blocks in the data verification area.

8. A computer device, comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the steps of the bad block management method based on a read-only partition of memory as described in any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the bad block management method based on the read-only partition of memory as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Bad block management method for flash memory

    CN102722443A