Bad block management method and device based on read-only partition of memory and computer equipment
By detecting and managing bad blocks in the memory read-only partition and establishing a mapping relationship with normal blocks, the device loading failure caused by bad blocks in the read-only partition is solved, ensuring the normal operation of the device and the integrity of the data.
Patent Information
- Application Number
- CN202411359116.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2044-09-26
AI Technical Summary
The existing memory bad block management method fails to effectively manage bad blocks in read-only partitions, resulting in device program loading failure and failing to run normally.
When an erase exception is detected during software program partition update, determine the bad block and select the normal block from the bad block reserve area to establish a mapping relationship with the bad block. When responding to data access, access the normal block to read and redundant verification information is written and restored in the data verification area.
It realizes the management of bad blocks in read-only partitions, avoids failure of device program loading, ensures the normal operation of the device, and ensures the integrity of the data through the processing of redundant verification information.
Smart Images

Figure CN119311220A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data storage, and in particular to a bad block management method, device and computer equipment based on a memory read-only partition. Background Art
[0002] The storage space of non-volatile memory can be divided into several areas to store different contents. For example, NAND Flash, NOR Flash, etc. include readable and writable partitions and readable partitions. Each partition can be divided into multiple blocks. Bad blocks will be generated during the production process of the memory, and new bad blocks may also be generated during the use of the memory. For bad blocks caused by manufacturing defects or damage during use, normal erase and read operations cannot be performed.
[0003] In the existing memory bad block management method, bad block management is usually performed on the readable and writable partitions of the memory, and bad blocks generated during the use of the read-only partition are not managed. The bad blocks of the read-only partition will cause the failure of loading the program of the related partition device, causing the device to malfunction.
[0004] There is no effective solution to the problem in the related art that bad blocks generated during the use of read-only partitions are not managed, resulting in failure to load the partition device program related to the bad blocks and the device cannot operate normally. Summary of the invention
[0005] In this embodiment, a bad block management method, apparatus and computer device based on a read-only partition of a memory are provided to solve the problem in the related art that bad blocks generated during the use of read-only partitions are not managed, resulting in failure to load the partition device program related to the bad blocks and inability of the device to operate normally.
[0006] In a first aspect, a bad block management method based on a read-only partition of a memory is provided in this embodiment, wherein the read-only partition includes a program data area and a bad block reserved area; wherein the program data area includes a plurality of software program partitions; the method includes:
[0007] When detecting that an abnormality occurs in the erase operation during the updating process of the software program partition, determining a first bad block in the software program partition where the erase abnormality occurs;
[0008] Selecting a first normal block from the bad block reserved area, and writing data for updating the first bad block into the first normal block;
[0009] Establishing a first mapping relationship between the first bad block and the first normal block;
[0010] In response to data access to the first bad block, the first normal block pointed to by the first mapping relationship is accessed, and data stored in the first normal block is read.
[0011] In some embodiments, in response to data access to the first bad block, accessing the first normal block pointed to by the first mapping relationship and reading data stored in the first normal block includes:
[0012] In response to data access to the first bad block, determining a target address of the first normal block 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 includes a data check area, after establishing the first mapping relationship between the first bad block and the first normal block, the method further includes:
[0015] After the upgrade program data is written into the software program partition, determining whether there is an available data block in the data verification area; the upgrade program data is data used to update the software program partition;
[0016] 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 the available data blocks and the number of data blocks occupied by the software program partition to obtain a plurality of verification units;
[0017] Verification processing is performed on the upgrade program data of each data block in each verification unit to obtain corresponding redundant verification information, and the redundant verification information is written into the data block in the data verification area.
[0018] In some of the embodiments, after writing the redundant check information into the data block in the data check area, the method further includes:
[0019] When it is detected that an abnormality occurs in the erasing and writing operation during the writing process of the redundant check information, determining a second bad block in the data check area where the abnormality occurs;
[0020] Selecting a second normal block from the bad block reserved area, and writing the redundant check information 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, in response to data access to the first bad block, accessing the first normal block pointed to by the first mapping relationship and reading data stored in the first normal block further includes:
[0023] When the data reading state of the first normal block is abnormal, 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 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.
[0025] In some embodiments, the step of determining the check unit to which the first bad block belongs includes:
[0026] 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;
[0027] Determine the number of data blocks included in each of the verification units based on the verification area information corresponding to the first bad block;
[0028] The check unit to which the first bad block belongs is determined based on a preset data block size, the fixed number of bad blocks, the number of data blocks contained in each of the check units, and a current address of the first bad block.
[0029] In some embodiments, after the data stored in the first bad block is recovered, the method further includes:
[0030] Selecting a third normal block from the bad block reserved area, and writing the recovered target data into the third normal block;
[0031] Establishing a third mapping relationship between the first bad block and the third normal block;
[0032] The first mapping relationship corresponding to the first bad block is updated to the third mapping relationship.
[0033] In a second aspect, in this embodiment, a bad block management device based on a read-only partition of a memory is provided, wherein the read-only partition includes a program data area and a bad block reserved area; wherein the program data area includes a plurality of software program partitions; the device includes: a detection module, a writing module, a mapping module, and a reading module;
[0034] The detection module is used to determine the first bad block in the software program partition where the erasure abnormality occurs when detecting that the erasure operation in the software program partition update process is abnormal;
[0035] The writing module is used 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 used to establish a first mapping relationship between the first bad block and the first normal block;
[0037] The reading module is used to access the first normal block pointed to by the first mapping relationship in response to data access to the first bad block, and read the data stored in the first normal block.
[0038] In a third aspect, a computer device is provided in this embodiment, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the bad block management method based on memory read-only partitioning as described in the first aspect above is implemented.
[0039] In a fourth aspect, a storage medium is provided in this embodiment, on which a computer program is stored, and when the program is executed by a processor, the bad block management method based on the memory read-only partition described in the first aspect is implemented.
[0040] Compared with the related art, the bad block management method, device and computer equipment based on read-only partition of memory provided in the present embodiment, when detecting that an abnormality occurs in the erase operation during the update process of the software program partition, determine the first bad block in the software program partition where the erase abnormality occurs; select the first normal block from the bad block reserved 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; further, 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, thereby solving the problem that the bad blocks generated during the use of the read-only partition are not managed, resulting in the failure to load the related partition device program of the bad blocks and the inability of the device to operate normally, and realizing the management of the bad blocks generated during the use of the read-only partition, avoiding the failure to load the related partition device program of the bad blocks, and ensuring the normal operation of the device.
[0041] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0043] Figure 1 It is a hardware structure block diagram of a terminal device of a bad block management method based on a memory read-only partition provided by an embodiment of the present application;
[0044] Figure 2 It is a flowchart of a bad block management method based on a memory read-only partition provided by an embodiment of the present application;
[0045] Figure 3 It is a distribution diagram of a memory read-only partition provided by an embodiment of the present application;
[0046] Figure 4 It is a schematic diagram of a grouping process of a data verification process provided by an embodiment of the present application;
[0047] Figure 5 is a schematic diagram of a data recovery process provided by an embodiment of the present application;
[0048] Figure 6 It is a flowchart of a bad block management method based on a memory read-only partition provided by an embodiment of the present application;
[0049] Figure 7 It is a flowchart of a bad block management method based on a memory read-only partition provided by another embodiment of the present application;
[0050] Figure 8 It is a flowchart of a bad block management method based on a memory read-only partition provided by a preferred embodiment of the present application;
[0051] Fig. 9 It is a structural block diagram of a bad block management device based on a memory read-only partition provided in one embodiment of the present application.
[0052] In the figure: 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 solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.
[0054] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0055] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 FIG. 1 is a hardware structure diagram of a terminal of the bad block management method based on the memory read-only partition of this embodiment. Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown in the figure) processor 102 and memory 104 for storing data, wherein processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0056] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the bad block management method based on the memory read-only partition in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0057] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by the communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
[0058] In this embodiment, a bad block management method based on memory read-only partition is provided. Figure 2 FIG. 1 is a flowchart of a bad block management method based on a memory read-only partition according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0059] Step S210, when it is detected that an abnormality occurs in the erase operation during the update process of the software program partition, determining the first bad block in the software program partition where the erase abnormality occurs;
[0060] Step S220, selecting a first normal block from the bad block reserved area, and writing data for updating the first bad block into the first normal block;
[0061] Step S230, establishing a first mapping relationship between a first bad block and a first normal block;
[0062] Step S240: 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.
[0063] In this embodiment, the readable partition of the storage area includes a program data area, a data check area and a bad block reserved area. The program data area includes multiple software program partitions, such as a boot program partition, a kernel file partition and a root file system partition. Figure 3 As shown, the order of arrangement of each area is usually program data area, data check area and bad block reserved area, data blocks 1 to m are program data areas, and data blocks m+1 to k include data check area and bad block reserved area. It should be noted that compared with the actual size of each software program, the storage space of the readable partition of the memory is usually larger. In addition to the storage space occupied by the software program data, there is also a part of reserved space in the readable partition. In this embodiment, a data check area and a bad block reserved area are provided in the 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 the memory, and the data in the memory is updated to the read-only partition of the memory to update the corresponding software program partition. Before writing the upgrade program data, it is necessary to read the data of the first page in the first data block of the memory, and parse the data to see whether there is a partition information table. If not, it indicates that the read-only partition is being updated for the first time, and the corresponding partition information table is created in advance, and the partition information table is saved in the first page of the first data block of the memory. Among them, since the first data block of the memory is usually guaranteed to be a normal data block during the memory manufacturing process, the partition information table is saved in the first data block to improve its reliability and security.
[0065] For each software program partition, when updating data, if the data block currently being updated is a fixed bad block marked at the factory, then skip the data block and write the data to the next available block of the software program partition; if it is detected that there is a mapping relationship between the data block currently being updated and the data block in the bad block reserved area, then directly access the data block pointed to by the mapping relationship to update the data. In addition, if it is detected that an abnormality occurs in the erase and write operation during the update of the software program partition, determine the first bad block in the software program partition where the erase and write abnormality occurs, the first bad block is a bad block generated during use, select the first normal block from the bad block reserved area, write the data used to update the first bad block into the first normal block, and associate the physical block number of the first bad block with the physical block number of the first normal block and store them 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. The present embodiment does not limit the specific method of selecting an available data block from the bad block reserved area as the first normal block. Preferably, when the partitions are arranged in the order of program data area, data check area and bad block reserved area, and all data blocks in the read-only partition are arranged in ascending order according to the physical block number, the bad block reserved area is searched for available data blocks in reverse order.
[0066] After the upgrade program data is written into the corresponding software program partition, it is determined whether there are available data blocks in the data verification area, and the number of available data blocks usually needs to be greater than 1. If it is detected that 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, and 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; if it is detected that there are no available data blocks in the data verification area, it indicates that there is no additional space in the current readable partition that can be used for redundant verification, and the data update is completed.
[0067] Furthermore, during the use of the read-only partition, when the loading of the read-only partition data begins, the partition information table stored in the first page of the first data block of the memory is pre-loaded into the memory, and 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] Afterwards, data is read according to the memory address corresponding to the current data access, and 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. 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-level data access module; if the data block where the memory address is located is a fixed bad block marked at the factory, 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, and the first normal block pointed to by the first mapping relationship is accessed. According to the offset of the first normal block based on the starting address of the partition, the preset data block size and the preset page size, the specific page address in the first normal block is located to read data, and the acquired data is returned to the upper-level data access module.
[0069] Wherein, if the data reading state of the current data block is abnormal, the number of pre-marked fixed bad blocks is determined within the range from the starting address of the software program partition to the current address of the current data block, and the number of data blocks contained in each check unit is determined based on the check area information corresponding to the current data block, and the check unit to which the current data block belongs is calculated and determined 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 redundant check information corresponding to the current data block is obtained, and based on the redundant 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 to recover the data are other normal data blocks except the first bad block in the check unit to which the first bad block belongs. At this time, a third normal block is selected from the bad block reserved 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, update the first mapping relationship corresponding to the first bad block to the third mapping relationship, and return the recovered target data to the upper-level data access module.
[0070] It should be noted that after returning the recovered target data to the upper data access module, the data refresh process of the read-only partition is triggered, and the data update process is re-executed for the read-only partition. Among them, since there is no fixed boundary between the data verification area and the bad block reserved area, and the total number of data blocks in the data verification area and the bad block reserved area is unchanged, as the bad blocks increase during use, the data blocks used for bad block mapping in the bad block reserved area will also increase, so that the available data blocks in the data verification area are reduced accordingly. By triggering the data refresh process of the read-only partition, the redundant verification data of the data verification area is updated; in addition, there is a drift effect in the memory, that is, the voltage value of the storage unit will gradually change over time. By triggering the data refresh process of the read-only partition, the charge is re-injected, thereby solving the problem that the charge threshold may change due to the long-term non-update of the read-only partition data. When the data blocks contained in the partition where the current software program is located have a tendency to become bad blocks or have just become bad blocks, it is a more appropriate time for charge injection. Based on this, this embodiment performs charge re-injection at the stage where bad blocks are generated during use.
[0071] In the existing memory bad block management method, bad block management is usually performed on the readable and writable partitions of the memory, and bad blocks generated during the use of the read-only partition are not managed. The bad blocks of the read-only partition will cause the failure of loading the program of the related partition device, causing the device to malfunction.
[0072] Compared with the prior art, the present application determines the first bad block in the software program partition where the erasing and writing abnormality occurs when an abnormality is detected in the erasing and writing operation during the update process of the software program partition; selects the first normal block from the bad block reserved 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 to 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 a bad block is generated during the use of the read-only partition, a mapping relationship is established between the bad block and the normal block in the bad block reserved area, so that when the bad block needs to be accessed, the mapping relationship can be used to access the data of the normal block in the bad block reserved area to load the required data normally, which solves the problem that the bad blocks generated during the use of the read-only partition are not managed, resulting in the failure of the bad block's related partition device program to load, and the device cannot operate normally, and realizes the management of the bad blocks generated during the use of the read-only partition, avoids the failure of the bad block's related partition device program to load, and ensures the normal operation of the device.
[0073] In some embodiments, in response to data access to the first bad block, accessing the first normal block pointed to by the first mapping relationship and reading data stored in the first normal block in step S240 includes the following steps:
[0074] In response to data access to 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;
[0075] Based on the target address of the first normal block, data stored in the first normal block is read.
[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, and 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] Further, the first normal block pointed to by the first mapping relationship is accessed, and 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, the specific page address in the first normal block is located to read the data, and the acquired data is returned to the upper-layer data access module. The specific calculation formula is as follows:
[0078]
[0079] In formula (1), addr2 represents a specific page address in the first normal block; addr1 represents an offset of the first normal block based on the partition start address; a represents a preset data block size; and b represents a preset page size.
[0080] Through this embodiment, 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, and 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, thereby utilizing the mapping relationship between the first bad block and the first normal block to normally read the data required for program loading.
[0081] In some of the embodiments, when the read-only partition also includes a data check 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 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 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 a plurality of verification units;
[0084] Verification processing is performed on the upgrade program data of each data block in each verification unit to obtain 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 the memory is updated to the read-only partition of the memory. After the upgrade program data is written into the corresponding software program partition, it is determined whether there are available data blocks in the data verification area. Available data blocks refer to data blocks in the data verification area that have not been used for data verification, and do not include fixed bad blocks marked by factory in the data verification area. If it is detected that there are available data blocks in the data verification area, the number of currently available data blocks is determined. The specific calculation formula is as follows:
[0086] t=kmnl(2)
[0087] In formula (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 reserved area; l represents the number of fixed bad blocks marked by the factory in the address space [m, kn].
[0088] Afterwards, if Figure 4As shown, according to the number of available data blocks and the number of data blocks occupied by the current 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 formula (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, taking the data block as the basic data unit, redundant check processing is performed on the upgrade program data of each data block in each check unit, such as using parity check operation, etc., to obtain corresponding redundant check information, and the redundant check information is written into the data block in the data check area, and 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.
[0092] It should be noted that if there are no available data blocks in the data verification area, it indicates that there is no additional space in the current readable partition that can be used for redundancy verification, and the data update is completed.
[0093] Through this embodiment, after the upgrade program data is written into the software program partition, it is determined whether there are available data blocks in the data verification area. 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, and 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, so that in the case of subsequent data reading abnormality, the redundant verification information in the data verification area is used to recover the data, so as to ensure the normal reading of the program data and avoid the device from falling into abnormality.
[0094] In some of the embodiments, after the redundant check information is written into the data block in the data check area, the following steps are also included:
[0095] When it is detected that an abnormality occurs in the erasing and writing operation during the writing process of the redundant check information, a second bad block in the data check area where the abnormality occurs is determined;
[0096] Selecting a second normal block from the bad block reserved area, and writing the redundant check information into the second normal block;
[0097] A second mapping relationship between the second bad block and the second normal block is established.
[0098] Specifically, during the redundant check information writing process, if an erasure abnormality of the redundant check information is detected, a second bad block in the data check area where the erasure abnormality occurs is determined, and the second bad block is a bad block generated during use.
[0099] Further, a second normal block is selected from the bad block reserved area, redundant 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, so as to establish a second mapping relationship between the second bad block and the second normal block, and update the number of currently available data blocks. This embodiment does not limit the specific method of selecting an available data block from the bad block reserved area as the second normal block. Preferably, when the order of the partitions is the program data area, the data check area and the bad block reserved area, and all data blocks in the read-only partition are arranged from small to large according to the physical block number, the available data blocks are searched in reverse in the bad block reserved area.
[0100] It should be noted that if the data block where the memory address corresponding to the data access is located is the second bad block, the second normal block pointed to by the second mapping relationship is accessed, and the redundant check information stored in the second normal block is read, thereby achieving the acquisition of redundant check information.
[0101] Through this embodiment, when an abnormality is detected in the erase operation during the writing of redundant check information, the second bad block in the data check area where the erase abnormality occurs is determined, a second normal block is selected from the bad block reserved area, the redundant check information is written into the second normal block, and a second mapping relationship between the second bad block and the second normal block is established, so that in the event of an abnormality in the erase operation of the redundant check information, the second mapping relationship can be used to obtain the redundant check information normally in the future, thereby ensuring the recovery of related data.
[0102] In some embodiments, in response to data access to the first bad block, accessing the first normal block pointed to by the first mapping relationship and reading data stored in the first normal block in step S240 further includes the following steps:
[0103] Step S241, when the data reading state of the first normal block is abnormal, determining the check unit to which the first bad block belongs;
[0104] Step S242, based on the redundant 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.
[0105] Specifically, data is read from the first normal block. If the data reading state of the first normal block is detected to be abnormal, the number of pre-marked fixed bad blocks is determined within the range from the starting address of the software program partition to the current address of the first bad block, wherein the current address is the offset of the first bad block relative to the starting address of the software program partition. The number of data blocks contained in each check unit is determined according to the check area information corresponding to the first bad block, and the check unit to which the first bad block belongs is calculated and determined 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.
[0106] Furthermore, if Figure 5 As shown, the data stored in each data block in the check unit to which the first bad block belongs is saved to the preset first memory area, that is, data is read starting from the starting data block in the check unit to which the first bad block belongs, and the data block contents of the number of data blocks corresponding to each check unit are read in total, and the acquired data is stored in the first memory area. At the same time, according to the check unit to which the first bad block belongs, the redundant check information corresponding to the check unit is saved to the preset second memory area, and based on the redundant check 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 restored, and the restored target data is saved to the preset third memory area, and the target data is returned to the upper-layer data access module. It can be understood that the normal blocks used to recover data are other normal data blocks except the first bad block in the check unit to which the first bad block belongs.
[0107] Among them, when obtaining the redundant check information corresponding to the check unit to which the first bad block belongs, if the data block corresponding to the check unit in the data check area is the second bad block, the second mapping relationship associated with the second bad block is used to access the second normal block pointed to by the second mapping relationship, and the redundant check information corresponding to the check unit is read from the second normal block.
[0108] It should be noted that if the data block of the data to be read currently is a normal data block in the software program partition and the data reading status is abnormal, the data block is similarly applicable to the above data recovery method for the first bad block.
[0109] Through this embodiment, when the data reading state of the first normal block is abnormal, the check unit to which the first bad block belongs is determined, and based on the redundant 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, thereby realizing data recovery by using the pre-stored redundant check information, ensuring normal acquisition of required program data, and avoiding program loading failure.
[0110] In some embodiments, determining the check unit to which the first bad block belongs in step S241 includes the following steps:
[0111] 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;
[0112] Determine the number of data blocks included in each check unit based on the check area information corresponding to the first bad block;
[0113] The check unit to which the first bad block belongs is determined based on a preset data block size, a fixed number of bad blocks, the number of data blocks contained in each check unit, and a current address of the first bad block.
[0114] Specifically, the check area information corresponding to the current software program partition is obtained from the partition information table, the check area information includes the number of data blocks contained in each check unit, and the number of fixed bad blocks pre-marked by the manufacturer is determined within the range from the starting address of the software program partition to the current address of the first bad block. 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, and the specific calculation formula is as follows:
[0116]
[0117] In formula (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 number of fixed bad blocks in the address space range [0, addr]; S represents the number of data blocks contained in each check unit. Based on this, the start data block start block in the check unit to which the first bad block belongs is calculated as start block = index * S, so that the start 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 in the check unit is calculated, and the position of the first bad block in 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 formula (5), offset block represents the offset of the first bad block in 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 in 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 above-mentioned methods of 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 are also applicable to this data block.
[0121] Through this embodiment, the number of pre-marked fixed bad blocks is determined 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, and the number of data blocks contained in each check unit is determined based on the check area information corresponding to the first bad block. 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 first bad block, the check unit to which the first bad block belongs is accurately located, so as to facilitate subsequent data recovery using other normal blocks in the check unit to which the first bad block belongs.
[0122] In some of the embodiments, after the data stored in the first bad block is recovered, the following steps are further included:
[0123] Selecting a third normal block from the bad block reserved area, and writing the recovered target data into the third normal block;
[0124] Establishing a third mapping relationship between the first bad block and the third normal block;
[0125] The first mapping relationship corresponding to the first bad block is updated to a third mapping relationship.
[0126] Specifically, the data stored in the first bad block is recovered to obtain the target data. At this time, a third normal block is selected from the bad block reserved 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 a first mapping relationship has been established between the first bad block and the first normal block in the data update phase, and in the data loading phase, if the reading status of the first normal block is abnormal, a third mapping relationship between the first bad block and the third normal block is established, and the first mapping relationship corresponding to the first bad block is updated to the third mapping relationship, thereby ensuring that the mapping relationship stored in the bad block mapping table is the latest mapping relationship.
[0128] It can be understood that if the data block of the data 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 process. The above-mentioned data recovery method for the first bad block is applied to the data block, the target data is recovered, and a normal block is selected from the bad block reserved area to establish a mapping relationship between the data block and the normal block, and the mapping relationship is updated to the bad block mapping table corresponding to the current software program partition.
[0129] Through this embodiment, a third normal block is selected from the bad block reserved area, the recovered target data is written into the third normal block, a third mapping relationship between the first bad block and the third normal block is established, and the first mapping relationship corresponding to the first bad block is updated to the third mapping relationship, so that the latest mapping relationship can be used to achieve normal data acquisition while ensuring the accuracy of the acquired data.
[0130] The present embodiment is described and illustrated by means of specific examples below.
[0131] Figure 6 FIG. 1 is a flow chart of a bad block management method based on a memory read-only partition according to an embodiment of the present invention. Figure 6 As shown, in the data update phase of the read-only partition, the method specifically includes the following steps:
[0132] When the data update of the read-only partition begins, the upgrade program data is loaded into the memory, and the upgrade program data is used to update the corresponding software program partition S601, and it is determined whether an abnormality occurs in the erase operation during the software program partition update process S602. If an abnormality is detected in the erase operation during the software program partition update process, the first bad block in the software program partition where the erase abnormality occurs is determined, the first normal block is selected from the bad block reserved area, the data used to update the first bad block is written into the first normal block, and 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, so as to establish a first mapping relationship between the first bad block and the first normal block S603.
[0133] After the upgrade program data is written into the corresponding software program partition, the available space size of the data verification area is calculated S604, and it is determined whether the number of available data blocks in the data verification area is greater than 1 according to the available space size S605. If the number of available data blocks is greater than 1, 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 occupied by the current software program partition to obtain multiple verification units S606, and the upgrade program data of each data block in each verification unit is verified to obtain corresponding redundant verification information S607, and the redundant verification information is written into the data block in the data verification area. During the redundant check information writing process, determine whether the redundant check information is abnormally erased S608. If the redundant check information is detected to be abnormally erased, determine the second bad block in the data check area where the erasure abnormality occurs, select the second normal block from the bad block reserved area, write the redundant check information into the second normal block, and associate the physical block number of the second bad block with the physical block number of the second normal block and store them 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 S609, and update the number of currently available data blocks S610; if the redundant check information is normally erased, then after the information is written, update 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 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 is prompted that the current readable partition has no additional space available for redundancy checking, and the data update ends S612.
[0135] Figure 7 FIG. 1 is a flow chart of a bad block management method based on a memory read-only partition according to an embodiment of the present invention. Figure 7 As shown, in the process of loading data of the read-only partition, the method specifically includes the following steps:
[0136] When the read-only partition data loading starts S701, the partition information table stored in the first page of the first data block of the memory is pre-loaded into the memory, and 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] Afterwards, data is read according to the memory address corresponding to the current data access S703, and 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. It is determined whether the read state of the data block where the memory address is located is abnormal S704. If the read state of the data block is detected to be abnormal, the data stored in the data block is restored S705 based on the redundant 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, and the third normal block is selected from the bad block reserved area, and the recovered target data is written into the third normal block, and 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, and the recovered target data is returned to the upper-level data access module S707; further, the data refresh process of the read-only partition is triggered, and the data update process for the read-only partition is re-executed S708, and the loading of the read-only partition data ends S709. In addition, if it is detected that the read status of the data block is normal, the read data is returned to the upper layer data access module S707, and the loading of the read-only partition data is completed S709.
[0138] The present embodiment is described and illustrated below through preferred embodiments.
[0139] Figure 8 FIG. 1 is a flowchart of a bad block management method based on a memory read-only partition according to a preferred embodiment of the present invention. Figure 8 As shown, the bad block management method based on memory read-only partition includes the following steps:
[0140] Step S810, when it is detected that an abnormality occurs in the erase operation during the update process of the software program partition, determining the first bad block in the software program partition where the erase abnormality occurs;
[0141] Step S820, selecting a first normal block from the bad block reserved area, writing data for updating the first bad block into the first normal block, and establishing a first mapping relationship between the first bad block and the first normal block;
[0142] Step S830, 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 used to update the software program partition;
[0143] Step S840, when there are available data blocks in the data verification area, grouping the data blocks occupied by the software program partition according to the number of available data blocks and the number of data blocks occupied by the software program partition to obtain a plurality of verification units;
[0144] Step S850, performing verification processing on the upgrade program data of each data block in each verification unit to obtain corresponding redundant verification information, and writing 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 reading state of the first normal block is abnormal, determining the check unit to which the first bad block belongs;
[0147] Step S880, based on the redundant 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] Through this embodiment, when it is detected that an abnormality occurs in the erase and write operation during the update process of the software program partition, the first bad block in which the erase and write abnormality occurs in the software program partition is determined, the first normal block is selected from the bad block reserved area, the data used to update the first bad block is written into the first normal block, and a first mapping relationship between the first bad block and the first normal block is established, so that when accessing the first bad block, the data in the first normal block can be read using the mapping relationship and returned to the upper access module, thereby achieving management of the bad blocks generated during the use of the read-only partition, avoiding the failure of program data to be loaded normally, and solving the problem that the bad blocks generated during the use of the read-only partition are not managed, resulting in the failure of the related partition device program to load the bad blocks and the failure of the device to operate normally.
[0149] Furthermore, after the upgrade program data is written into the software program partition, it is determined whether there are available data blocks in the data verification area. 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 block in the data verification area so that in the event of subsequent data reading abnormalities, the redundant verification information in the data verification area can be used to recover the data, thereby ensuring the normal reading of the program data and avoiding the device from falling into abnormalities.
[0150] Afterwards, 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. If the data reading state of the first normal block is abnormal, the check unit to which the first bad block belongs is determined, and based on the redundant 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 restored, and the restored target data is returned, thereby realizing data recovery using the pre-stored redundant check information, ensuring the normal acquisition of required program data, 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 the flowchart in the accompanying drawings 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 can be executed in an order different from that shown here.
[0152] In this embodiment, a bad block management device based on a memory read-only partition is also provided, and the device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made are not repeated here. The terms "module", "unit", "subunit", etc. used below can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation in hardware, or a combination of software and hardware, is also possible and conceivable.
[0153] Fig. 9 is a structural block diagram of the bad block management device based on the memory read-only partition of this embodiment, such as Fig. 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 determine the first bad block in the software program partition where the erasing abnormality occurs when an abnormality is detected in the erasing operation during the updating process of the software program partition;
[0155] A writing module 20, used for selecting a first normal block from the bad block reserved area, and writing data for updating the first bad block into the first normal block;
[0156] A mapping module 30, configured to establish a first mapping relationship between a first bad block and a first normal block;
[0157] The reading module 40 is used to access the first normal block pointed to by the first mapping relationship in response to data access to the first bad block, and read the data stored in the first normal block.
[0158] Through the device provided by this embodiment, when it is detected that an abnormality occurs in the erase operation during the update process of the software program partition, the first bad block where the erase abnormality occurs in the software program partition is determined; the first normal block is selected from the bad block reserved area, and the data used to update the first bad block is written into the first normal block; a first mapping relationship between the first bad block and the first normal block is established; further, 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, thereby solving the problem of not managing the bad blocks generated during the use of the read-only partition, resulting in the failure to load the partition device program related to the bad blocks and the inability of the device to operate normally, and realizing the management of the bad blocks generated during the use of the read-only partition, avoiding the failure to load the partition device program related to the bad blocks, and ensuring the normal operation of the device.
[0159] In some of the embodiments, the reading module 40 is also used to respond to data access to the first bad block, determine the target address of the first normal block according to a 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.
[0160] In some of these embodiments, Fig. 9 On the basis of, the device also includes a verification module, which is used to determine whether there are available data blocks in the data verification area after the upgrade program data is written into the software program partition; the upgrade program data is 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 block in the data verification area.
[0161] In some of these embodiments, Fig. 9 On the basis of, the device also includes a verification module, which is used to determine the second bad block in the data verification area where the erasure abnormality occurs when an abnormality is detected in the erasure operation during the writing of redundant verification information; select a second normal block from the bad block reserved 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 of the embodiments, the reading module 40 is also used to determine the check unit to which the first bad block belongs when the data reading status of the first normal block is abnormal; based on the redundant 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 restored, and the restored target data is returned.
[0163] In some of the embodiments, the reading module 40 is also used 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; based on the check area information corresponding to the first bad block, the number of data blocks contained in each check unit is determined; 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, the check unit to which the first bad block belongs is determined.
[0164] In some of the embodiments, the reading module 40 is also used to select a third normal block from the bad block reserved 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 by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0166] In this embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one 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 may be configured to perform the following steps through a computer program:
[0169] S1, when detecting that an abnormality occurs in the erase operation during the update process of the software program partition, determining the first bad block in the software program partition where the erase abnormality occurs;
[0170] S2, selecting a first normal block from the bad block reserved area, and writing data for updating the first bad block into the first normal block;
[0171] S3, establishing a first mapping relationship between the first bad block and the first normal block;
[0172] S4, in response to data access to 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.
[0173] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.
[0174] In addition, in combination with the bad block management method based on the memory read-only partition provided in the above embodiment, a storage medium can also be provided in this embodiment to implement. The storage medium stores a computer program; when the computer program is executed by the processor, any one of the bad block management methods based on the memory read-only partition in the above embodiment is implemented.
[0175] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.
[0176] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.
[0177] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various locations in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.
[0178] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.
Claims
1. A bad block management method based on memory read-only partition, characterized in that: The read-only partition includes a program data area and a bad block reserved area; wherein the program data area includes a plurality of software program partitions; the method includes: When detecting that an abnormality occurs in the erase operation during the updating process of the software program partition, determining a first bad block in the software program partition where the erase abnormality occurs; Selecting a first normal block from the bad block reserved area, and 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; In response to data access to the first bad block, the first normal block pointed to by the first mapping relationship is accessed, and data stored in the first normal block is read.
2. The bad block management method based on memory read-only partition according to claim 1, characterized in that: In response to data access to the first bad block, accessing the first normal block pointed to by the first mapping relationship and reading data stored in the first normal block includes: In response to data access to the first bad block, determining a target address of the first normal block 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; Based on the target address of the first normal block, data stored in the first normal block is read.
3. The bad block management method based on memory read-only partition according to claim 1, characterized in that: In the case where the read-only partition further includes a data check area, after establishing a first mapping relationship between the first bad block and the first normal block, the method further includes: After the upgrade program data is written into the software program partition, determining whether there is an available data block in the data verification area; the upgrade program data is 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 the available data blocks and the number of data blocks occupied by the software program partition to obtain a plurality of verification units; Verification processing is performed on the upgrade program data of each data block in each verification unit to obtain corresponding redundant verification information, and the redundant verification information is written into the data block in the data verification area.
4. The bad block management method based on memory read-only partition according to claim 3, characterized in that: After writing the redundant check information into the data block in the data check area, the method further includes: When it is detected that an abnormality occurs in the erasing and writing operation during the writing of the redundant check information, determining a second bad block in the data check area where the abnormality occurs; Selecting a second normal block from the bad block reserved area, and writing the redundant check information into the second normal block; A second mapping relationship between the second bad block and the second normal block is established.
5. The bad block management method based on memory read-only partition according to claim 3, characterized in that: In response to data access to the first bad block, accessing the first normal block pointed to by the first mapping relationship and reading data stored in the first normal block further includes: When the data reading state of the first normal block is abnormal, determining the check unit to which the first bad block belongs; Based on the redundant 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.
6. The bad block management method based on memory read-only partition according to claim 5, characterized in that: The step of determining the check unit to which the first bad block belongs includes: 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 included in each of the verification units based on the verification area information corresponding to the first bad block; The check unit to which the first bad block belongs is determined based on a preset data block size, the fixed number of bad blocks, the number of data blocks contained in each of the check units, and a current address of the first bad block.
7. The bad block management method based on memory read-only partition according to claim 5, characterized in that: After the data stored in the first bad block is recovered, the method further includes: Selecting a third normal block from the bad block reserved area, and writing the recovered target data into the third normal block; Establishing a 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.
8. A bad block management device based on a memory read-only partition, characterized in that: The read-only partition includes a program data area and a bad block reserved area; wherein the program data area includes a plurality of software program partitions; the device includes: a detection module, a writing module, a mapping module and a reading module; The detection module is used to determine the first bad block in the software program partition where the erasure abnormality occurs when detecting that the erasure operation in the software program partition update process is abnormal; The writing module is used 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; 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 used to access the first normal block pointed to by the first mapping relationship in response to data access to the first bad block, and read the data stored in the first normal block.
9. A computer device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps of the bad block management method based on memory read-only partitions according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the bad block management method based on a memory read-only partition are implemented as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Bad block management (BBM) method and device for Nand Flash
CN101593157A
Bad block management method for flash memory
CN102722443A
Method and system for managing bad blocks in storage equipment
CN103186471A
Nand flash bad block management method and system
CN114546292A
Data block verification method and device, storage medium and electronic equipment
CN117472291A