Data access method and device of terminal equipment, electronic equipment and storage medium
By acquiring and utilizing inherent bad block information for address translation, the problem of data read/write errors caused by bad blocks in Nand memory is solved, thereby improving the reliability and efficiency of data access.
Patent Information
- Application Number
- CN202210864725.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-21
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2042-07-21
AI Technical Summary
Nand memory chips have randomly distributed bad blocks when they leave the factory, which causes data reading and writing errors.
By obtaining the inherent bad block information stored in the terminal device, performing storage address translation processing, avoiding bad blocks, and determining the correct physical block address of the target data in the Nand memory for access.
It effectively avoids data reading and writing errors caused by bad blocks and improves the reliability and efficiency of data access.
Smart Images

Figure CN115171756B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The technical solution of the present disclosure relates to the technical field of electronic devices, and in particular to a data access method and device for a terminal device, an electronic device, and a storage medium. BACKGROUND
[0002] In a Nand memory chip, the basic storage unit of erasing is called a block, and a block that cannot normally read and write data is called a bad block. Due to Nand memory process problems, a Nand memory chip is allowed to have a limited number of bad blocks when it is shipped. And, in general, these bad blocks are randomly distributed, and the existence of these bad blocks can cause data read and write errors. SUMMARY
[0003] To solve the above problems, the present disclosure provides a data access method and device for a terminal device, an electronic device, and a storage medium.
[0004] According to a first aspect of the present disclosure, a data access method for a terminal device is provided, the method comprising:
[0005] In response to receiving a data access request for target data, obtaining inherent bad block information of a peripheral storage stored in the terminal device, wherein the inherent bad block information comprises inherent bad block address information;
[0006] Based on the inherent bad block information, performing storage address conversion processing on a logical block address of the target data to obtain a target physical block address corresponding to the target data in the peripheral storage;
[0007] Accessing the target data stored in a physical block corresponding to the target physical block address.
[0008] According to a second aspect of the present disclosure, a data access device for a terminal device is provided, the device comprising:
[0009] An inherent bad block information obtaining module, configured to, in response to receiving a data access request for target data, obtain inherent bad block information of a peripheral storage stored in the terminal device, wherein the inherent bad block information comprises inherent bad block address information;
[0010] An address conversion module, configured to, based on the inherent bad block information, perform storage address conversion processing on a logical block address of the target data to obtain a target physical block address corresponding to the target data in the peripheral storage;
[0011] A target data access module, configured to access the target data stored in a physical block corresponding to the target physical block address.
[0012] According to a third aspect of the present disclosure, an electronic device is provided, comprising:
[0013] a processor;
[0014] a memory for storing intrinsic bad block information;
[0015] The processor is configured to perform the data access method of the terminal device according to any embodiment of the present disclosure.
[0016] According to a fourth aspect of the present disclosure, a computer readable storage medium is provided, which stores machine readable instructions, when invoked and executed by a processor, the machine readable instructions cause the processor to implement the data access method of the terminal device according to any embodiment of the present disclosure.
[0017] The technical solutions provided by the embodiments of the present disclosure can include the following beneficial effects:
[0018] The data access method and device of the terminal device, the electronic device and the storage medium provided by the embodiments of the present disclosure, in response to receiving a data access request for target data, obtaining intrinsic bad block information of a peripheral storage memory stored in the terminal device, wherein the intrinsic bad block information includes intrinsic bad block address information; based on the intrinsic bad block information, performing storage address conversion processing on the logical block address of the target data to obtain the corresponding target physical block address of the target data in the peripheral storage memory; accessing the target data stored in the physical block corresponding to the target physical block address. Through the data access method of the terminal device according to the embodiments of the present disclosure, the problem of data read / write error caused by the existence of bad blocks can be avoided.
[0019] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the one or more embodiments of the present disclosure or the related art, the drawings needed to be used in the embodiment or related art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments described in the one or more embodiments of the present disclosure, and those skilled in the art can obtain other drawings without creative labor based on these drawings:
[0021] Figure 1 is a structural schematic diagram of an image file according to an exemplary embodiment of the present disclosure;
[0022] Figure 2 is a structural schematic diagram of a Nand memory according to an exemplary embodiment of the present disclosure;
[0023] Figure 3 is another structure diagram of a Nand memory according to an example embodiment of the present disclosure;
[0024] Figure 4 is a structure diagram of a wearable device according to an example embodiment of the present disclosure;
[0025] Figure 5 is a flowchart of a data access method of a terminal device according to an example embodiment of the present disclosure;
[0026] Figure 6 is another structure diagram of a Nand memory according to an example embodiment of the present disclosure;
[0027] Figure 7 is a structure diagram of intrinsic bad block information according to an example embodiment of the present disclosure;
[0028] Figure 8 is a structure diagram of unified bad block information according to an example embodiment of the present disclosure;
[0029] Figure 9 is a structure diagram of a data access apparatus of a terminal device according to an example embodiment of the present disclosure;
[0030] Figure 10 is another structure diagram of a data access apparatus of a terminal device according to an example embodiment of the present disclosure;
[0031] Figure 11 is a structure diagram of an electronic device according to an example embodiment of the present disclosure. DETAILED DESCRIPTION
[0032] The example embodiments will now be described in detail with reference to the accompanying drawings. If the description of the example embodiments refers to accompanying drawings, then the description is illustrative of the example embodiments and does not limit the present disclosure. Thus, it should be understood that various modifications and changes can be made to the implementation of the present disclosure without departing from the scope thereof. Accordingly, the exemplary embodiments are to be considered in a descriptive sense only and not for purposes of limitation. Therefore, the scope of the present disclosure is defined not by the detailed description of the example embodiments but by the appended claims, and their equivalents.
[0033] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the present disclosure. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and / or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0034] It should be understood that, although the terms first, second, third, etc. can be employed in this disclosure to describe various information, these information should not be limited to these terms. These terms are only used to differentiate one piece of information from another. For example, a first information can also be termed a second information without departing from the scope of this disclosure, and similarly, a second information can also be termed a first information. Depending on the context, the word "if' as used herein can be interpreted to mean "when" or "in response to determining" or "in response to ascertaining".
[0035] In embedded devices, file data such as pictures and fonts that occupy relatively large storage resources are usually stored in external storage. For example, in embedded devices such as wristbands and watches, the file data described above are usually stored in external storage, which can be a Nand memory, for example.
[0036] To make the scheme more clear, first, the process of storing the file data described above in the Nand memory is described in detail. Usually, the process described above is performed in a professional burning factory. Specifically, a burner can burn the file data described above in the Nand memory.
[0037] Before the burner performs the burning operation, an image file corresponding to the current Nand memory can be obtained first, and the image file contains the picture, font and other file data required by the Nand memory. For example, the current Nand memory is a Nand memory used to produce a wristband of a certain model, and the picture, font and other file data required by the Nand memory are actually the file data required by the wristband of the model set by the relevant staff.
[0038] For example, the structure of the image file can be as shown in Figure 1 The image file can contain multiple blocks, and different blocks are used to store different file data, such as picture file 1, picture file 2, etc. In this example, the blocks can be referred to as logical blocks. As shown in Figure 1 The mapping relationship between the current logical block and the physical block is also recorded in different logical blocks, for example, the mapping relationship between logical block 1 and physical block 1 is recorded in logical block 1, and the physical block refers to the physical block in the Nand memory. For example, the structure of the Nand memory can be as shown in Figure 2 A Nand memory can contain multiple physical blocks.
[0039] After receiving the mirror file, the burner can burn the file data and the mapping relationship in each logical block in the mirror file in the physical block recorded by the current logical block. For example, the picture file 1 stored in the logical block 1 in the mirror file and the mapping relationship logical block 1-physical block 1 can be burned in the physical block 1. The picture file 2 stored in the logical block 2 and the mapping relationship logical block 2-physical block 2 are burned in the physical block 2.
[0040] Due to the process problem of Nand memory, Nand memory sometimes has a limited number of bad blocks when it is shipped, that is, physical blocks that fail to normally read and write data. And, usually, these bad blocks are randomly distributed. For example, an example diagram of a Nand memory with bad blocks can be as shown in Figure 3
[0041] In the actual burning process, the burner can determine whether the physical block is a bad block according to the bad block marker of each physical block in the Nand memory. And when it is determined that the physical block is a normal physical block, the corresponding file data is burned into the physical block. If it is determined that the physical block is a bad block, the file data that should be burned in the bad block is burned in the next normal physical block adjacent to the bad block.
[0042] For example, as shown in Figure 3 Since the physical block 1 is a normal physical block, the burner can burn the picture file 1 in the logical block 1 in the mirror file and the mapping relationship logical block 1-physical block 1 in the physical block 1 of the Nand memory. Since the physical block 2 is a bad block, the burner will skip the bad block when burning, and burn the picture file 2 in the logical block 2 and the mapping relationship logical block 2-physical block 2 in the physical block 3. Since the physical block 4 is a bad block, the burner will burn the font file 1 in the logical block 3 and the mapping relationship logical block 3-physical block 3 in the physical block 5. The subsequent burning mapping relationship between the logical block and the physical block is similar, which is not described here.
[0043] In practical applications, although the burning process will take the above-mentioned way of skipping bad blocks, since the mapping relationship stored in each logical block in the mirror file does not change, the mapping relationship written in the physical block is also the mapping relationship before the change. When the terminal device is started for the first time, the terminal device will obtain the above-mentioned mapping relationship recorded in each physical block. When it is necessary to read the logical block address 2, the terminal device will find the physical block address 2 corresponding thereto from the above-mentioned mapping relationship obtained, and access the data stored in the physical block address 2. Since the physical block 2 is a bad block, an error will occur at this time.
[0044] To solve the above problems, the present disclosure provides a data access method of a terminal device. The data access method of the terminal device according to the present disclosure is described in detail below with reference to the accompanying drawings.
[0045] The method is described below with a wearable device as an example. Figure 4 A structural schematic diagram of a wearable device according to an example embodiment of the present disclosure is shown in FIG. 1. As shown in FIG. 1, the wearable device can include a file system 41, an address converter 42, a driver 43, and a peripheral memory 44, for example, the peripheral memory 44 can be a Nand memory. Figure 4
[0046] The file system 41 is configured to perform read and write operations on logical block addresses. For example, the wearable device is a bracelet, when a user uses the bracelet, assuming that the user wants to obtain a picture in the bracelet, the file system 41 can determine the logical block address corresponding to the picture based on the request sent by the user, and transmit the logical block address to the address converter 42.
[0047] The address converter 42 is configured to convert the logical block address obtained to obtain the corresponding physical block address. The picture is actually stored in the physical block of the Nand memory, and the address converter 42 can convert the received logical block address to obtain the physical block address in the Nand memory based on the mapping relationship.
[0048] The driver 43 is configured to perform read and write operations on the physical block address. For example, the driver can access the physical block corresponding to the address in the Nand memory according to the physical block address converted by the address converter 42, and obtain the picture stored in the physical block.
[0049] The peripheral memory 44 can include a plurality of physical blocks, and the driver 43 can perform read and write operations on the plurality of physical blocks.
[0050] Figure 5 FIG. 2 is a flowchart of a data access method of a terminal device according to an example embodiment of the present disclosure, the method is performed by a terminal device, for example, the terminal device can be a bracelet or a watch. As shown in FIG. 2, the example embodiment method can include the following steps: Figure 5
[0051] In step 500, in response to receiving a data access request for target data, obtaining inherent bad block information of a peripheral memory stored in the terminal device.
[0052] The data access request for the target data is a request received by a file system 41 in the terminal device to access the target data. For example, as described above, when a user uses a bracelet, it is assumed that the user wants to obtain a picture in the bracelet, and the file system 41 receives a request to obtain the picture, and the picture is the target data. Further, the file system 41 can determine the logical block address corresponding to the picture based on the request.
[0053] The intrinsic bad block information includes intrinsic bad block address information, and the intrinsic bad block information includes address information of at least one bad block inherent to the peripheral memory. The intrinsic bad block information can be generated by an algorithm module on a burner when the burner is used by a burning factory to burn the peripheral memory. Specifically, when the burner detects a bad block during burning, the address information of the bad block can be recorded in the intrinsic bad block information. Then, the generated intrinsic bad block information is saved in the last normal physical block of the peripheral memory.
[0054] The peripheral memory can be, for example, a Nand memory. When the file system 41 in the terminal device receives a request to access target data, the driving device 43 can be called to obtain the intrinsic bad block information from the Nand memory 44.
[0055] In step 502, based on the intrinsic bad block information, the logical block address of the target data is subjected to storage address conversion processing to obtain the target physical block address corresponding to the target data in the peripheral memory.
[0056] In an optional example, when the terminal device receives a data access request, the address converter 42 in the terminal device can call the driving device 43 to obtain the mapping relationship stored in each physical block of the Nand memory, or the address mapping information, and save the obtained address mapping information in the address converter 42. The address mapping information includes the mapping relationship between the preset logical block address and the preset physical block address.
[0057] As described above, after the file system 41 determines the logical block address corresponding to the picture, the logical block address is transmitted to the address converter 42, and the address converter 42 performs first address conversion on the logical block address based on the address mapping information to obtain an initial physical block address in the Nand memory, and sends the converted initial physical block address to the driving device 43. The logical block address corresponds to the preset logical block address in the address mapping information, and the initial physical block address corresponds to the preset physical block address in the address mapping information.
[0058] Since there can be bad blocks in the Nand memory, the physical block address obtained by the first address conversion processing of the address converter 42 can be the physical block address of a physical block that is faulty and cannot be normally read and written. The data access method of the terminal device of the present example can perform second address conversion processing on the obtained initial physical block address based on the obtained intrinsic bad block information to obtain a target physical block address corresponding to the target data.
[0059] Since the aforementioned bad block skipping method is used during burning, the driving device 43 can compare the obtained initial physical block address with at least one intrinsic bad block address information in the intrinsic bad block information to obtain the number of target intrinsic bad block addresses in the intrinsic bad block information. The target intrinsic bad block address is an intrinsic bad block address that is less than or equal to the initial physical block address. That is, the number of bad blocks before the initial physical block address can be determined according to the intrinsic bad block information. If the number of bad blocks before the initial physical block address is 1, it indicates that there is one bad block before the physical block, so one bad block should be skipped during burning, and the target physical block address = the initial physical block address + 1. If the number of bad blocks before the initial physical block address is 2, it indicates that there are two bad blocks before the initial physical block address, so two bad blocks should be skipped during burning, and the target physical block address = the initial physical block address + 2.
[0060] The data access method of the terminal device of the present step will be described in detail below.
[0061] In an optional example, if the obtained intrinsic bad block address information in the intrinsic bad block information is {2, 4, 0xFFFF}. The 0xFFFF is the initial value of the intrinsic bad block address information in the intrinsic bad block information, and in the comparison of the present example, the initial value can be defaulted to be greater than any obtained initial physical block address.
[0062] For example, the file system 41 determines that the logical block address corresponding to the picture is 1, and after sending it to the address converter 42, the address converter 42 can convert the logical block address 1 to obtain the initial physical block address 1 in the Nand memory.
[0063] Then, the initial physical block address 1 can be compared with at least one intrinsic bad block address information obtained from the intrinsic bad block information, and the number of intrinsic bad block addresses less than or equal to the initial physical block address 1 in the intrinsic bad block information is 0, that is, there is no bad block before the obtained physical block address, so the target physical block address corresponding to the logical block address 1 can be obtained as 1 + 0 = 1.
[0064] For another example, when the file system 41 determines that the logical block address corresponding to the picture is 2, and sends it to the address converter 42, the address converter 42 can convert the logical block address 2 to obtain the initial physical block address 2 in the Nand memory.
[0065] Then, the initial physical block address 2 can be compared with at least one of the obtained inherent bad block address information in the inherent bad block information, and the number of the obtained physical block address less than or equal to the physical block address 2 in the inherent bad block information is 1, that is, there is a bad block before the obtained physical block address, and therefore, the target physical block address corresponding to the logical block address 2 can be obtained as 2+1=3.
[0066] In step 504, the target data stored in the target physical block corresponding to the target physical block address is accessed.
[0067] As described above, when the drive device 43 obtains the target physical block address through conversion, the data stored in the target physical block corresponding to the target physical block address can be accessed, and the data is the target data. For example, it can be the picture in the bracelet that the user wants to obtain.
[0068] The data access method of the terminal device provided by the embodiments of the present disclosure can avoid the problem of data read / write error caused by the existence of bad blocks.
[0069] The part of the data access method of the terminal device will be further described below.
[0070] For the above step 500, in an optional example, when the data access request is the first data access request received by the terminal device after the current start, the inherent bad block information stored in the peripheral storage is obtained.
[0071] As described above, the data access request can be, for example, the request of the user to obtain a picture in the bracelet. When the request is the first request received by the bracelet after the current start, such as the first request received by the bracelet after the shutdown and the startup, the inherent bad block information can be obtained from the Nand memory, and the obtained inherent bad block information is stored in the internal storage of the Nand memory.
[0072] According to the foregoing, after the algorithm module in the burner obtains the inherent bad block information, the inherent bad block information can be stored in the last good block of the Nand memory. Therefore, when obtaining the inherent bad block information from the Nand memory, the physical blocks in the Nand memory can be scanned in descending order of physical block addresses. When it is determined that the first physical block currently scanned is a normal physical block, the inherent bad block information is obtained from the first physical block.
[0073] As shown in the structure of the Nand memory in Figure 6 As shown in the structure of the Nand memory in
[0074] In an optional example, if the received data access request is not the first request received by the bracelet after this start, for example, it is a request sent by the user after accessing the picture in the bracelet, and the user wants to access a certain font in the bracelet. At this time, the inherent bad block information can be directly obtained from the built-in memory. Thus, the speed of obtaining the inherent bad block information is accelerated, and the working efficiency of the terminal device is improved.
[0075] As shown in Figure 7 In an optional example, the inherent bad block information can include a signature, a bad block number, a check, and a plurality of bad block numbers. The signature is used to represent that the information stored in the physical block is inherent bad block information. The bad block number is used to represent the number of bad blocks in the Nand memory. The check bit stores a check value generated according to the subsequent bad block number data. The check value stored in this position can be compared with the previous check value. If the check value is consistent with the previous check value, it is considered that the subsequent bad block number data is not damaged. Subsequent operations can be performed. Otherwise, it is considered that the subsequent bad block number data is damaged. This information can be reported to the relevant staff for processing.
[0076] In an optional example, the inherent bad block information can only include a number field and a plurality of address fields. The number field is used to indicate the number of inherent bad blocks of the Nand memory, and each of the plurality of address fields is used to indicate the address of an inherent bad block.
[0077] For example, the number field in the inherent bad block information is 4. This indicates that there are 4 inherent bad blocks in the Nand memory. Correspondingly, the inherent bad block information includes 4 address fields, each of which indicates the address of one of the inherent bad blocks.
[0078] In an optional example, when it is detected that the inherent bad block information exists in the Nand memory and the number of bad blocks stored in the inherent bad block information is equal to 0, the target data is obtained from the initial physical block address of the Nand memory after receiving the initial physical block address obtained after the first address conversion processing.
[0079] When the number of bad blocks stored in the inherent bad block information is 0, it indicates that all the physical blocks in the Nand memory are normal physical blocks. Therefore, when the storage device is programmed in the programming factory using a programmer, it is programmed according to the original mapping relationship. At this time, the data at the initial physical block address obtained can be obtained.
[0080] In an optional example, when it is detected that the inherent bad block information does not exist in the Nand memory, the data is also obtained from the initial physical block address in the Nand memory after receiving the initial physical block address obtained after the first address conversion processing.
[0081] When the bad block management table does not exist in the Nand memory, it indicates that the Nand memory has not used the skip bad block programming method of the present example when programming. Therefore, the above address conversion is not performed.
[0082] In an optional example, when it is determined that the terminal device is not started for the first time, a plurality of physical blocks in the peripheral memory can be scanned to determine whether a secondary bad block has occurred in the peripheral memory during use, and when it is determined that a secondary bad block has occurred, a secondary bad block management table is established based on the information of the secondary bad block, and the secondary bad block management table stores the address mapping relationship between the secondary bad block and the available bad block.
[0083] During use, due to reasons such as operating voltage or operation times exceeding the limit, some new bad blocks may appear in the Nand memory. These are called secondary bad blocks. Therefore, when it is determined that the terminal device is not being started for the first time, it is possible to further detect whether there are secondary bad blocks in the Nand memory.
[0084] Specifically, the stored inherent bad block information can be compared with the address information of the detected multiple bad blocks. If a bad block address does not exist in the inherent bad block information, it indicates that a secondary bad block has occurred. In this case, an available block can be searched from the Nand memory, the file data in the secondary bad block can be stored in the available block, and a mapping relationship between the secondary bad block and the available block can be established, and the mapping relationship can be stored in the secondary bad block management table stored in the Nand memory.
[0085] In some embodiments, the secondary bad block management table and the inherent bad block information can be stored together, such as Figure 8 As shown. Figure 3 For example, the inherent bad block address information of the Nand memory shown is 2 and 4. If, after a period of use, the terminal device detects that a secondary bad block has appeared in the Nand memory, and its bad block address information is 3. At this time, a physical block can be selected from the normal physical blocks of the Nand memory, for example, the normal physical block is 12. Then, the file data stored in the bad block with address information 3 is transferred to the normal physical block 12, and a mapping relationship between the secondary bad block address 3 and the normal physical block 12 is established, and the mapping relationship is stored in Figure 8 In the unified bad block information shown.
[0086] The normal physical block of the Nand memory may be a normal physical block in a preset backup area, or may be the first normal physical block obtained by searching from back to front in the Nand memory, which is not limited in the present disclosure.
[0087] After determining the existence of a secondary bad block, the data access method of the terminal device described in this example needs to compare the target physical block address obtained by conversion with the mapping relationship in the secondary bad block management table after the above-mentioned second address conversion processing to determine whether a third address conversion processing is required.
[0088] Specifically, when the target physical block address exists in a mapping relationship in the successor bad block management table, it indicates that the target physical block address is damaged in use, and the drive device has transferred the file data stored in the target physical block to another physical block mentioned in the mapping relationship of the successor bad block management table. Therefore, the third address conversion processing needs to be performed on the target physical block address according to the mapping relationship.
[0089] For example, after the second address conversion processing in the foregoing embodiment, the obtained target physical block address is 3. The physical block address 3 is compared with the mapping relationship in the successor bad block management table, and it is found that there is a mapping relationship of physical block address 3-physical block address 12 in the mapping relationship. Therefore, the third address conversion processing can be performed on the physical block address 3 according to the mapping relationship, and the physical block address 12 is obtained. The physical block address 12 is the physical block address corresponding to the target data in the foregoing embodiment.
[0090] The data access method of the terminal device provided by the embodiment of the disclosure further provides a data access method when a successor bad block occurs, which can avoid the problem of data read / write error caused by the occurrence of the successor bad block.
[0091] Figure 9 is a structural schematic diagram of a data access device of a terminal device according to an example embodiment of the disclosure, as Figure 9 shown, the data access device of the terminal device can include:
[0092] The inherent bad block information acquisition module 91 is configured to acquire inherent bad block information of a peripheral storage device stored in the terminal device in response to receiving a data access request for target data, wherein the inherent bad block information includes inherent bad block address information.
[0093] The address conversion module 92 is configured to perform storage address conversion processing on a logical block address of the target data based on the inherent bad block information, to obtain a target physical block address corresponding to the target data in the peripheral storage device.
[0094] The target data acquisition module 93 is configured to access the target data stored in a physical block corresponding to the target physical block address.
[0095] Optionally, when acquiring the inherent bad block information of the peripheral storage device stored in the terminal device, the inherent bad block information acquisition module 91 includes:
[0096] In response to the data access request being a data access request received for the first time after the terminal device is started this time, the inherent bad block information stored in the peripheral storage device is acquired.
[0097] and / or,
[0098] In response to the data access request being a data access request not received for the first time by the terminal device after the current startup, the inherent bad block information stored in the built-in memory of the terminal device is obtained.
[0099] Optionally, the inherent bad block information obtaining module 91, when used to obtain the inherent bad block information stored in the external memory, includes:
[0100] At least one physical block in the peripheral memory is scanned in descending order of physical block addresses until it is determined that the first physical block currently being scanned is a normal physical block.
[0101] The inherent bad block information stored in the first physical block is obtained.
[0102] Optionally, the address conversion module 92, when performing storage address conversion processing on the logical block address of the target data based on the inherent bad block information to obtain the target physical block address corresponding to the target data in the external memory, includes:
[0103] Based on the address mapping information stored in the terminal device, a first address conversion process is performed on the logical block address of the target data to obtain an initial physical block address corresponding to the target data, and the address mapping information includes a mapping relationship between a preset logical block address and a preset physical block address.
[0104] Based on the inherent bad block information, a second address conversion process is performed on the initial physical block address corresponding to the target data to obtain a target physical block address corresponding to the target data.
[0105] Optionally, the inherent bad block information includes a quantity field and multiple address fields, the quantity field is used to indicate the number of inherent bad blocks of the peripheral memory, and each address field in the multiple address fields is used to indicate an address of an inherent bad block.
[0106] Optionally, the address conversion module 92, when performing storage address conversion processing on the logical block address of the target data based on the inherent bad block information to obtain the target physical block address corresponding to the target data in the external memory, includes:
[0107] The initial physical block address is compared with at least one inherent bad block address included in the inherent bad block information.
[0108] In response to determining that there is an intrinsic bad block address located before the initial physical block address in the at least one intrinsic bad block address, performing a second address conversion on the initial physical block address based on a quantity of intrinsic bad block addresses located before the initial physical block address to obtain the target physical block address.
[0109] Optionally, as shown in Figure 10 As shown in Figure 9 The data access apparatus of the terminal device can further include:
[0110] The scanning module 101 is configured to scan a plurality of physical blocks of the peripheral memory to determine whether a new bad block occurs in the peripheral memory during use.
[0111] The storage module 102 is configured to, in response to determining that a new bad block occurs, store data stored in the new bad block into an available block of the peripheral memory, and store new bad block information, the new bad block information including an address mapping relationship between the new bad block and the available block.
[0112] Optionally, the address conversion module 92, when used to perform storage address conversion processing on the logical block address of the target data based on the intrinsic bad block information to obtain a target physical block address corresponding to the target data in the peripheral memory, further includes:
[0113] Query the new bad block information.
[0114] In response to determining that the new bad block information includes an address mapping relationship corresponding to the target physical block address, performing a third address conversion on the target physical block address based on the corresponding address mapping relationship to obtain a converted target physical block address.
[0115] The implementation process of the functions and roles of each unit in the above apparatus is specifically described in the implementation process of the corresponding steps in the above method, which will not be repeated here.
[0116] For the device embodiment, since it basically corresponds to the method embodiment, the related parts are described in the part of the method embodiment. The above-described device embodiment is only illustrative, and the units described as separate components can be or can not be physically separated, and the components displayed as modules can be or can not be physical modules, that is, they can be located in one place or distributed on multiple network units. According to actual needs, part or all of the modules can be selected to achieve the purpose of the technical solutions of the present disclosure. Those skilled in the art can understand and implement without creative labor.
[0117] The embodiment of the present disclosure further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the data access method of the terminal device according to any one of the embodiments of the present disclosure.
[0118] The embodiment of the present disclosure further provides an electronic device, which comprises a memory 111 and a processor 112, the memory 111 is used to store computer instructions executable on the processor, and the processor 112 is used to implement the data access method of the terminal device according to any one of the embodiments of the present disclosure when executing the computer instructions. Figure 11
[0119] The various embodiments in the specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment mainly describes the difference from other embodiments.
[0120] Although the present specification contains many specific implementation details, these should not be construed as limiting the scope or the scope of protection of any invention, but mainly for describing the features of the specific embodiments of the particular invention. Some features described in the specification in multiple embodiments can also be implemented in a single embodiment. On the other hand, various features described in a single embodiment can also be implemented separately in multiple embodiments or in any suitable subcombination. In addition, although the features can function as described above in some combinations and even originally claimed, one or more features from the claimed combination can be removed in some cases, and the claimed combination can refer to a subcombination or a variation of a subcombination.
[0121] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the claims. In some cases, the actions recited in the claims can be performed in a different order and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve the desired results. In some implementations, multitasking and parallel processing can be advantageous.
[0122] The above only describes the preferred embodiments of the present disclosure and does not limit the present disclosure. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A data access method for a terminal device, characterized in that: The method comprises: In response to receiving a data access request for target data, acquiring inherent bad block information of the peripheral memory stored in the terminal device, wherein the inherent bad block information includes inherent bad block address information; Based on the inherent bad block information, performing storage address conversion processing on the logical block address of the target data to obtain a target physical block address corresponding to the target data in the peripheral memory; Accessing the target data stored in the physical block corresponding to the target physical block address; The performing storage address conversion processing on the logical block address of the target data based on the inherent bad block information to obtain the target physical block address corresponding to the target data in the peripheral memory includes: performing a first address conversion process on the logical block address of the target data based on address mapping information stored in the terminal device to obtain an initial physical block address corresponding to the target data, the address mapping information including a mapping relationship between a preset logical block address and a preset physical block address; comparing the initial physical block address with at least one inherent bad block address included in the inherent bad block information to determine whether the inherent bad block information includes an inherent bad block address located before the initial physical block address; In response to determining that the inherent bad block information includes an inherent bad block address located before the initial physical block address, the initial physical block address is subjected to a second address conversion based on the number of inherent bad block addresses located before the initial physical block address to obtain the target physical block address.
2. The method according to claim 1, characterized in that The obtaining of inherent bad block information of the peripheral memory stored in the terminal device includes: In response to the data access request being the first data access request received by the terminal device after current startup, obtaining the inherent bad block information stored in the peripheral memory; and / or, In response to the data access request being a data access request not being received for the first time by the terminal device after the current startup, the inherent bad block information stored in the built-in memory of the terminal device is obtained.
3. The method according to claim 2, characterized in that The obtaining of the inherent bad block information stored in the peripheral memory includes: Scanning at least one physical block in the peripheral memory in descending order of physical block addresses until determining that a first physical block currently being scanned is a normal physical block; The inherent bad block information stored in the first physical block is obtained.
4. The method according to any one of claims 1 to 3, characterized in that The inherent bad block information includes a quantity field and multiple address fields, the quantity field is used to indicate the quantity of the inherent bad blocks of the peripheral memory, and each address field in the multiple address fields is used to indicate an address of an inherent bad block.
5. The method according to any one of claims 1 to 3, characterized in that The step of performing a second address conversion on the initial physical block address based on the number of inherent bad block addresses located before the initial physical block address to obtain the target physical block address includes: The physical block corresponding to the initial physical block address is shifted backward according to the number of inherent bad block addresses located before the initial physical block address to obtain the target physical block address.
6. The method according to any one of claims 1 to 3, characterized in that The method further comprises: Scanning multiple physical blocks of the peripheral memory to determine whether secondary bad blocks appear in the peripheral memory during use; In response to determining that a secondary bad block has occurred, the data stored in the secondary bad block is stored in an available block of the peripheral memory, and secondary bad block information is stored, the secondary bad block information including an address mapping relationship between the secondary bad block and the available block.
7. The method according to claim 6, characterized in that The step of performing storage address conversion processing on the logical block address of the target data based on the inherent bad block information to obtain a target physical block address corresponding to the target data in the peripheral memory further includes: Querying the secondary bad block information; In response to determining that the secondary bad block information includes an address mapping relationship corresponding to the target physical block address, a third address conversion is performed on the target physical block address based on the corresponding address mapping relationship to obtain the converted target physical block address.
8. An electronic device, characterized in that: include: A memory storing inherent bad block information, wherein the inherent bad block information includes inherent bad block address information; A processor, configured to execute the method according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Flash memory and bad block managing method thereof
CN103778065A
Memorizer processing method and device
CN107783723A