A sector-based data writing method and related equipment

By traversing the last column in the sector to locate the write position, the problem of low data writing efficiency in the prior art is solved, and faster data storage is achieved.

CN113721847BActive Publication Date: 2024-11-15SHENZHEN JINGQUANHUA & EVERRISE INTELLIGENT ELECTRIC CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110949193.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-18
Publication Date
2024-11-15
Estimated Expiration
2041-08-18

AI Technical Summary

Technical Problem

In the prior art, sector-based data writing methods are inefficient, especially in large-capacity sectors, resulting in the data storage rate being affected.

Method used

Using sector-based data writing method, by obtaining the data to be written and preprocessing, determine the write sector with the number of rows and the length of the data, traversing the last column until the data tail is found or the number of columns is reached, and the write column is determined. , and write data from this column as the starting point, avoiding the previous reverse order traversal method.

Benefits of technology

It improves the starting point positioning rate of data writing, reduces the writing time, and improves the efficiency of data storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113721847B_ABST
    Figure CN113721847B_ABST
Patent Text Reader

Abstract

The present invention discloses a sector-based data writing method and related equipment, the method includes obtaining data to be written, wherein the data to be written includes a data tail; according to the data to be written, determining the writing sector corresponding to the data to be written; starting from the last byte of the writing sector, traversing the last column of the writing sector until the value of the traversed byte is the same as the data tail or the number of traversals is equal to the number of columns of the writing sector; when the value of the traversed byte is the same as the data tail, determining the next column of the byte as the writing column; and when the number of traversals is equal to the number of columns of the writing sector and the value of the last traversed byte is different from the data tail, determining the first column of the writing sector as the writing column; starting from the first byte of the writing column, sequentially writing the data to be written into the writing column. The present invention improves the data writing rate by converting the writing mode from writing in rows to writing in columns.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data storage, and in particular to a sector-based data writing method and related equipment. Background Art

[0002] FLASH is a program memory with a large space. It can save data without losing it even when the power is off. It is safe, fast, small, large capacity and low cost. In terms of reading and writing, its read and write life reaches 100,000 times. Every time the disk writes data, it stores data based on the disk. The sector is the basic unit of the disk for storing data. In order to improve the sector life of FLASH, FLASH sectors use the form of exchanging space for life to store data. For example, a sector size of 128 bytes and the number of bytes of data stored each time is 14 bytes. Each time data is stored, each stored data consists of: data header (0xaa) + 14 user data + data tail (0x55), a total of 16 bytes. A sector can be understood as a table of 128 squares, with 16 rows and 8 columns. Each time a data is stored, it occupies two rows, and the blank area is filled with zeros. Each time data is stored, the original data is no longer erased and rewritten, but written directly behind the original stored data. Therefore, after storing 8 sets of data, each square in the table is only written once, so the life is extended by 8 times. When 800,000 sets of data are written, according to the previous method of erasing the entire sector before writing each time, it would take 800,000 times to erase and write. However, by using the form of exchanging space for life, the actual number of writes to each square is only 100,000 times, which greatly improves the life.

[0003] However, this method has a key problem, that is, how to quickly locate the location of the data when writing new data. In the previous erase-write method, since all previous data are erased, it is only necessary to write from the first position of the sector immediately. However, for the space-for-life method, the first position of the sector has been filled with data and cannot be written directly. The existing method of determining the location where new data is written is mainly implemented through traversal reading. That is, read from the last position of the sector forward to determine whether it is zero, until the data in the square is not zero, and use the next position of the non-zero position as the starting point for writing new data. This method is time-consuming and inefficient, especially for large-capacity sectors, such as the popular 4k sectors, which will seriously affect the data storage rate. Summary of the invention

[0004] The technical problem to be solved by the present invention is that the data writing rate to a sector is relatively slow. Aiming at the shortcomings of the prior art, a data writing method based on a sector is provided.

[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is as follows:

[0006] A sector-based data writing method, the method comprising:

[0007] Acquire data to be written, wherein the data to be written includes a data tail;

[0008] According to the data to be written, determining a writing sector whose number of rows is equal to the data length of the data to be written as a destination sector;

[0009] Taking the last byte of the destination sector as the starting point, traverse the last column of the destination sector until the value of the traversed byte is the same as the data tail or the number of traversals is equal to the number of columns of the destination sector;

[0010] When the value of the traversed byte is the same as the data tail, determining the next column of the byte as the write column; and,

[0011] When the number of traversals is equal to the number of columns of the target sector and the value of the last traversed byte is different from the data tail, determining the first column of the target sector as a write column;

[0012] Taking the first byte of the write column as a starting point, the data to be written is written into the write column in sequence.

[0013] The sector-based data writing method, before obtaining the data to be written, further includes:

[0014] Get initial data;

[0015] The initial data is preprocessed to obtain the data to be written including the data tail.

[0016] The sector-based data writing method, wherein the initial data includes fixed data; the preprocessing of the initial data to obtain the data to be written including the data tail includes:

[0017] A preset data header is added to the header of the initial data, and a preset data tail is added to the tail of the initial data to obtain the data to be written.

[0018] The sector-based data writing method, wherein the initial data includes variable data; the preprocessing of the initial data to obtain the data to be written including the data tail includes:

[0019] According to a preset write length, the initial data is zero-filled to obtain intermediate data having a data length equal to that of the write data;

[0020] A preset data header is added to the header of the intermediate data, and a preset data tail is added to the tail of the intermediate data to obtain the data to be written.

[0021] The sector-based data writing method, wherein the initial data includes variable data; the preprocessing of the initial data to obtain the data to be written including the data tail includes:

[0022] Concatenate the preset data header with the initial length of the initial data to obtain a data label;

[0023] The data tag is added to the header of the initial data, and a preset data tail is added to the tail of the initial data to obtain the data to be written.

[0024] The sector-based data writing method, wherein the written sector is an initial sector with a determined number of rows and columns; before determining, based on the data to be written, a written sector with a number of rows equal to the data length of the data to be written as a destination sector, the method comprises:

[0025] Get the written length;

[0026] The write length is used as the number of columns corresponding to the preset initial sector;

[0027] The number of rows corresponding to the initial sector is calculated according to the size of the initial sector and the number of columns to obtain a write sector.

[0028] The sector-based data writing method, wherein the step of determining, according to the data to be written, a writing sector having a row number equal to a data length of the data to be written as a destination sector, comprises:

[0029] According to the data length of the data to be written and a preset length index table, determining whether the destination sector corresponds to the data to be written;

[0030] If it does not exist, the data length is used as the write length, the number of rows and columns of the initial sector corresponding to the data to be written is determined, the destination sector corresponding to the data to be written is obtained, and the sector information of the destination sector is written into the length index table;

[0031] The written sector is used as the destination sector corresponding to the data to be written.

[0032] A sector-based data writing device, which specifically includes:

[0033] An acquisition module, used for acquiring data to be written, wherein the data to be written includes a data tail;

[0034] A first determination module, configured to determine, according to the data to be written, a writing sector having a row number equal to a data length of the data to be written as a destination sector;

[0035] A traversal module, used for traversing the last column of the destination sector starting from the last byte of the destination sector, until the value of the traversed byte is the same as the data tail or the number of traversals is equal to the number of columns of the destination sector;

[0036] A second determination module is used to determine that the next column of the byte is a write column when the value of the traversed byte is the same as the data tail; and when the number of traversals is equal to the number of columns of the target sector and the value of the last traversed byte is different from the data tail, determine that the first column of the target sector is a write column;

[0037] The writing module is used to write the data to be written into the writing column in sequence starting from the first byte of the writing column.

[0038] A computer-readable storage medium stores one or more programs, wherein the one or more programs can be executed by one or more processors to implement the steps in any of the above-mentioned sector-based data writing methods.

[0039] A terminal device comprises: a processor, a memory and a communication bus; the memory stores a computer-readable program executable by the processor;

[0040] The communication bus realizes the connection and communication between the processor and the memory;

[0041] When the processor executes the computer-readable program, the processor implements the steps in any of the above-mentioned sector-based data writing methods.

[0042] Beneficial effect: Compared with the prior art, the present invention provides a sector-based data writing method and related equipment, which converts the method into a matrix rolling storage method, and changes the original way of writing and storing data in rows to storing data in columns. The number of rows and columns of the sector to be written is preset, and then before writing, the last row of the written sector is traversed, and the bytes of each traversal are compared with the data tail at the end of the data to be written. If there is a same, the column before the byte is traversed is used as the writing column. If there is no same until the first byte of the last row is traversed, the first column is used as the writing column. Finally, the data to be written is written in the form of columns. Therefore, when writing new data, it is only necessary to read the value of the last column to determine whether the data is stored, and there is no need to traverse in reverse order in units of rows as in the past, which improves the rate of determining the starting point of data writing. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 This is a schematic diagram of the traditional method of writing data to a sector.

[0044] Figure 2 The present invention provides a flow chart of a sector-based data writing method.

[0045] Figure 3 A sector schematic diagram of the sector-based data writing method provided by the present invention.

[0046] Figure 4 A schematic structural diagram of a sector-based data writing device provided by the present invention.

[0047] Figure 5 This is a structural principle diagram of the terminal device provided by the present invention. DETAILED DESCRIPTION

[0048] The present invention provides a sector-based data writing method and related equipment. In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0049] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.

[0050] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as herein.

[0051] For example, the embodiment of the present invention can be applied to writing data into the FLASH sector of a single-chip microcomputer, and can also be applied to other disk sectors. Figure 1 As shown, the existing scheme generally writes data in units of rows, wherein the columns with the same gray value background in the figure are the data written at one time, "0xaa" represents the data header, "0x55" represents the data tail, "x" represents the written data, and zero is used for padding. This scheme mainly adopts the matrix conversion rolling storage method, which changes the original method of writing and storing data in units of rows to storing data in units of columns. The number of rows and columns of the sector to be written is pre-set, and then the data to be written is stored in the sector in the form of columns. When new data is to be written later, it is only necessary to read the value of the last column to determine whether data is stored, and there is no need to traverse the rows in reverse order as before, which improves the rate of determining the starting point of data writing.

[0052] The invention is further described below by describing embodiments in conjunction with the accompanying drawings.

[0053] like Figure 2 As shown, this embodiment provides a sector-based data writing method, which can be executed by a data writing program. The method may include the following steps:

[0054] S10, obtaining data to be written.

[0055] Specifically, the data to be written to the disk sector is named as the data to be written. In this embodiment, the data to be written may be data such as execution parameters of the single-chip microcomputer during execution. The data to be written includes a data tail, which is end data used to mark the situation where the data to be written has been terminated. It is generally located at the end of the data to be written. Figure 3 The data tail used in is "0x55".

[0056] The data tail of the data to be written is executed by a program before being passed to the data writing program, or it can be executed by the data writing program itself. The data to which the data tail has not been added is called the initial data. The data writing program first obtains the initial program without the data tail, and then preprocesses the initial data. The preprocessing process at least includes adding the data tail to the tail of the initial data to obtain the data to be written including the data tail.

[0057] In order to ensure the fidelity of the data to be written during the writing process, that is, to prevent data loss, in the first preprocessing method of this embodiment, the preprocessing process of the initial data further includes adding a data header, which is added before the initial data and is used to identify the header to which subsequent data is to be connected. Figure 3The data header used in is "0xaa". In addition to marking the starting point and end point of the initial data, the data header and the data tail can also protect the data from being lost during the writing process. Therefore, the initial data preprocessing process includes: adding a preset data header to the header of the initial data, and adding a preset data tail to the tail of the initial data. Through this processing process, the data to be written can be obtained. Since the data header and the data tail are preset, the length of the added data header and data tail is also fixed. When the initial data is fixed data, that is, the length of all the initial data is the same, this method will not affect the subsequent matrix rolling storage method adopted in this embodiment.

[0058] But when initial data is variable data, i.e. data whose data length will change, for example, pointer variable (char) is generally 4 bytes, and the length of short integer variable (short int) is generally 2 bytes. If data head and data tail are directly added to the two ends of initial data, the length of data to be written is inconsistent. In this case, adopt transfer matrix rolling storage, even if a certain row has written data, it is also impossible to determine by the traversal of the last column. Therefore, for this situation, the present embodiment has two other pre-processing modes in the pre-processing stage.

[0059] In the second preprocessing method, the initial data is first padded according to the length of the number of columns of the sector to be written, i.e., the write length, to obtain intermediate data having a data length equal to the write data. The acquisition and determination of the write length will be described in detail later, so it will not be described here. A common method for filling the initial data is to use the value zero. Considering that the data is read in the order of rows when it is subsequently read, in this embodiment, the position of the zero filling is the tail of the initial data. Then, the data header is added to the head of the intermediate data, and the data tail is added to the tail of the intermediate data to obtain the data to be written.

[0060] In the third preprocessing method, after obtaining the initial data, the length of the initial data is determined to be the initial length of the initial data. Then the data header and the initial length are concatenated to obtain a data tag for identifying the start of the data and the data length. Then the data tag is added as a whole to the header of the initial data, and the data tail is added to the tail of the initial data to obtain the data to be written.

[0061] S20. According to the data to be written, determine a writing sector whose row number is equal to the data length of the data to be written as the destination sector.

[0062] Specifically, there are several sectors in the disk. After obtaining the data to be written, the writing sector corresponding to the data to be written is first determined.

[0063] Before determining the write sector, the number of rows and columns of the sector needs to be determined. In this embodiment, the sector whose number of rows and columns has not yet been determined is named the initial sector, and the write sector is the initial sector whose number of rows and columns has been determined. The method for determining the number of rows and columns of the initial sector is:

[0064] A10. Get the write length.

[0065] Specifically, the write length refers to the data length of the data to be written. The user can determine the write length according to the type of data to be written. For the single-chip microcomputer, since the data type of the initial data is relatively single, the write length is fixed for fixed data. For the data to be written obtained by the second preprocessing method, the longest data length value in the initial data is determined in advance according to the type of the initial data. Then the sum of the longest data length value, the length value of the data header, and the length value of the data tail is obtained to obtain the write length.

[0066] However, for the case where the length of the data to be written is inconsistent, such as the data to be written obtained by the third preprocessing method described above, since the data length of the data to be written is inconsistent, the write length is the length of the data to be written in the blank sector each time, where the blank sector is a sector where data has not been written yet.

[0067] A20. Using the write length as the number of rows corresponding to the preset initial sector.

[0068] Specifically, the write length is used as the number of rows corresponding to the preset initial sector. For example, if the write length is 16 bytes, the number of rows of the initial sector is 16.

[0069] A30. Calculate the number of columns corresponding to the initial sector according to the size of the initial sector and the number of rows to obtain a write sector.

[0070] Specifically, since the size of the matrix cannot exceed the size of the initial sector itself, the size of the initial sector is used as the dividend and the number of rows is used as the divisor to calculate the number of columns of the initial sector. For example, if the size of the initial sector is 128 bytes, the number of columns corresponding to the initial sector is 8. The initial sector with the number of rows and columns determined is used as the write sector where data can be written.

[0071] It is worth noting that the values ​​of the above-mentioned data header and data tail can be freely set according to the data type, etc.

[0072] After determining the number of rows and columns of the initial sector, the written sector is obtained. For the initial data of the fixed data type, since the number of rows and columns of all written sectors are the same, the destination sector in the written sector is determined by the destination of the initial data or the write address set by the user.

[0073] With respect to the data to be written obtained by the second preprocessing method, since the data length of the data to be written obtained by the second processing method is fixed, the method of determining the corresponding destination sector is the same as that of the fixed data.

[0074] For the data to be written obtained by the third preprocessing method, a length index table is pre-established, and the length index table records the writing sectors with the determined number of rows and columns.

[0075] For example, when acquiring the data to be written for the first time, first compare the data length of the data to be written with the preset length index table to determine whether it is a write sector corresponding to the data to be written. The write sector corresponding to the write data refers to a write sector with the same number of rows as the data length of the data to be written. Since it is the first time to acquire the data to be written, the write sector has not been created yet. Therefore, the information of the write sector does not exist in the length index table, so there is no destination sector. First, determine the initial sector corresponding to the data to be written in the same way as the fixed length of the data to be written in the previous text. Then use the data length of the data to be written as the write data, determine the number of columns corresponding to the initial sector, and calculate the number of rows corresponding to the initial sector based on the size and number of columns of the initial sector to obtain the write sector. This write sector is the destination sector of the data to be written.

[0076] Then the data to be written is stored in the destination sector, and the sector information of the destination sector is written into the length index table. The sector information of the destination sector includes the address of the write sector and the number of rows of the write data. Since the destination sector at this time is not necessarily the destination sector of the next data to be written, it can be used as the write information of the write sector.

[0077] When the data to be written is obtained for the second time, if the data length of the data to be written obtained for the second time is the same as the length of the data to be written obtained for the first time, then according to the length index table, the corresponding write sector can be determined for the data to be written for the second time, and the data to be written can be directly written into the corresponding write sector.

[0078] This embodiment provides three methods for determining the writing sectors and corresponding preprocessing methods. The user can select or selectively combine the three methods according to the characteristics of the data.

[0079] S30, starting from the last byte of the destination sector, traverse the last column of the destination sector until the value of the traversed byte is the same as the data tail or the number of traversals is equal to the number of columns of the destination sector.

[0080] Since the traversal of the sector starts from the last byte of the sector matrix, the last row is traversed, and then the last byte of the previous row is used as the starting point to traverse the second to last row, and this sequence is repeated until the first byte of the matrix is ​​traversed, or the value of the traversed byte is the same as the end of the data.

[0081] Therefore, this embodiment does not change the way of traversing sectors, such as Figure 3 As shown by the arrow in the figure, the last column of the destination sector is still traversed starting from the last byte. The circle in the figure is the last column of the traversal. This solution only needs to traverse the last column until the number of traversals is equal to the number of columns written to the sector, or the value of the traversed byte is the same as the end of the data, and then the traversal ends.

[0082] S40a: When the value of the traversed byte is the same as the data tail, determine that the column before the traversed byte is the write column.

[0083] Specifically, when the value of the traversed byte is the same as the data tail, it means that data has been written into the column where the byte is located, and the data to be written that needs to be rewritten should be written into the column before the traversed byte as the write column.

[0084] S40b: When the number of traversals is equal to the number of columns of the target sector and the value of the last traversed byte is different from the data tail, determine that the first column of the target sector is a write column.

[0085] Specifically, when the number of traversals is equal to the number of columns of the written sector, it means that the second column of the written sector is a column where no data is written. It is worth noting that the "unwritten" here means that no available data is written, and it may also be filled with zeros. If the last traversed byte, that is, the byte of the first column, is the same as the end of the data, it means that the first column has been written with data, so the next column of the byte, that is, the second column, is determined as the write column as described above. If the last traversed byte is different from the end of the data, it means that the first column has not been written with data, so the first column is used as the write column.

[0086] S50 , starting from the first byte of the write column, writing the data to be written into the write column in sequence.

[0087] Specifically, starting from the first byte of the write column, the data to be written is written into the write column. The writing process is to write in sequence according to the arrangement of each byte in the data to be written. For example, the size of the sector matrix is ​​M x N, where M is the number of rows and N is the number of columns, and the data to be written can be represented by a sequence, such as (n1, n2, ..., n M ), where n 1~MA number representing each byte of the data to be written. If the write column is the i-th column of the sector matrix, the coordinates of each byte of the data to be written after writing can be expressed as (i, 1), (i, 2), ..., (i, M), where i is a positive integer less than or equal to N.

[0088] Based on the above-mentioned sector-based data writing method, this embodiment provides a sector-based data writing device, wherein the sector-based data writing device 100 includes:

[0089] An acquisition module 110, configured to acquire data to be written, wherein the data to be written includes a data tail;

[0090] A first determination module 120 is used to determine, according to the data to be written, a writing sector whose number of rows is equal to the data length of the data to be written as a destination sector;

[0091] A traversal module 130, configured to traverse the last column of the destination sector starting from the last byte of the destination sector, until the value of the traversed byte is the same as the data tail or the number of traversals is equal to the number of columns of the destination sector;

[0092] The second determination module 140 is used to determine that the next column of the byte is a write column when the value of the traversed byte is the same as the data tail; and when the number of traversals is equal to the number of columns of the target sector and the value of the last traversed byte is different from the data tail, determine that the first column of the target sector is a write column;

[0093] The writing module 150 is used to write the data to be written into the writing column in sequence starting from the first byte of the writing column.

[0094] The data writing device 100 further includes a preprocessing module, which includes:

[0095] An acquisition unit, used for acquiring initial data;

[0096] The preprocessing unit is used to preprocess the initial data to obtain the data to be written including the data tail.

[0097] The initial data includes fixed data; and the preprocessing unit is specifically used for:

[0098] A preset data header is added to the header of the initial data, and a preset data tail is added to the tail of the initial data to obtain the data to be written.

[0099] Wherein, the initial data includes variable data; and the preprocessing unit is further used for:

[0100] According to a preset write length, the initial data is zero-filled to obtain intermediate data having a data length equal to that of the write data;

[0101] A preset data header is added to the header of the intermediate data, and a preset data tail is added to the tail of the intermediate data to obtain the data to be written.

[0102] Wherein, the initial data includes variable data; and the preprocessing unit is further used for:

[0103] Concatenate the preset data header with the initial length of the initial data to obtain a data label;

[0104] The data tag is added to the header of the initial data, and a preset data tail is added to the tail of the initial data to obtain the data to be written.

[0105] The written sector is an initial sector with a determined number of rows and columns; the data writing device 100 further includes a sector processing module, and the sector processing module is used to:

[0106] Get the written length;

[0107] The write length is used as the number of columns corresponding to the preset initial sector;

[0108] The number of rows corresponding to the initial sector is calculated according to the size of the initial sector and the number of columns to obtain a write sector.

[0109] The second determining module 140 is specifically used for:

[0110] According to the data length of the data to be written and a preset length index table, determining whether the destination sector corresponds to the data to be written;

[0111] If it does not exist, the data length is used as the write length, the number of rows and columns of the initial sector corresponding to the data to be written is determined, the destination sector corresponding to the data to be written is obtained, and the sector information of the destination sector is written into the length index table;

[0112] The written sector is used as the destination sector corresponding to the data to be written.

[0113] Based on the above-mentioned sector-based data writing method, this embodiment provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps in the sector-based data writing method as described in the above-mentioned embodiment.

[0114] Based on the above-mentioned sector-based data writing method, the present invention also provides a terminal device, such as Figure 5 As shown, it includes at least one processor (processor) 20; display screen 21; and memory (memory) 22, and may also include a communications interface (Communications Interface) 23 and a bus 24. Among them, the processor 20, the display screen 21, the memory 22 and the communication interface 23 can communicate with each other through the bus 24. The display screen 21 is configured to display a preset user guide interface in the initial setting mode. The communication interface 23 can transmit information. The processor 20 can call the logic instructions in the memory 22 to execute the method in the above embodiment.

[0115] In addition, the logic instructions in the memory 22 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.

[0116] The memory 22 is a computer-readable storage medium that can be configured to store software programs, computer executable programs, such as program instructions or modules corresponding to the methods in the embodiments of the present disclosure. The processor 20 executes functional applications and data processing by running the software programs, instructions or modules stored in the memory 22, that is, implementing the methods in the above embodiments.

[0117] The memory 22 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 22 may include a high-speed random access memory and may also include a non-volatile memory. For example, a variety of media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, may also be a transient computer-readable storage medium.

[0118] In addition, the specific process of loading and executing the above-mentioned computer-readable storage medium and the multiple instruction processors in the terminal device has been described in detail in the above-mentioned method, and will not be described one by one here.

[0119] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A sector-based data writing method, characterized in that: The method comprises: Acquire data to be written, wherein the data to be written includes a data tail; According to the data to be written, determining a writing sector whose number of rows is equal to the data length of the data to be written as a destination sector; Taking the last byte of the destination sector as the starting point, traverse the last column of the destination sector until the value of the traversed byte is the same as the data tail or the number of traversals is equal to the number of columns of the destination sector; When the value of the byte traversed is the same as the data tail, determining the column before the byte traversed as the write column; and, When the number of traversals is equal to the number of columns of the target sector and the value of the last traversed byte is different from the data tail, determining the first column of the target sector as a write column; Taking the first byte of the write column as a starting point, the data to be written is written into the write column in sequence.

2. The sector-based data writing method according to claim 1, characterized in that: Before obtaining the data to be written, the method further includes: Get initial data; The initial data is preprocessed to obtain the data to be written including the data tail.

3. The sector-based data writing method according to claim 2, characterized in that: The initial data includes fixed data; the preprocessing of the initial data to obtain the data to be written including the data tail includes: A preset data header is added to the header of the initial data, and a preset data tail is added to the tail of the initial data to obtain the data to be written.

4. The sector-based data writing method according to claim 2, characterized in that: The initial data includes variable data; the preprocessing of the initial data to obtain the data to be written including the data tail includes: According to a preset write length, the initial data is zero-filled to obtain intermediate data having a data length equal to that of the write data; A preset data header is added to the header of the intermediate data, and a preset data tail is added to the tail of the intermediate data to obtain the data to be written.

5. The sector-based data writing method according to claim 2, characterized in that: The initial data includes variable data; the preprocessing of the initial data to obtain the data to be written including the data tail includes: Concatenate the preset data header with the initial length of the initial data to obtain a data label; The data tag is added to the header of the initial data, and a preset data tail is added to the tail of the initial data to obtain the data to be written.

6. The sector-based data writing method according to claim 1, characterized in that: The written sector is an initial sector with a determined number of rows and columns; before determining, according to the data to be written, a written sector with a number of rows equal to the data length of the data to be written as a destination sector, the method includes: Get the written length; The write length is used as the number of columns corresponding to the preset initial sector; The number of rows corresponding to the initial sector is calculated according to the size of the initial sector and the number of columns to obtain a write sector.

7. The sector-based data writing method according to claim 6, characterized in that: The step of determining, according to the data to be written, a writing sector having a row number equal to a data length of the data to be written as a destination sector comprises: According to the data length of the data to be written and a preset length index table, determining whether there is a destination sector corresponding to the data to be written; If it does not exist, the data length is used as the write length, the number of rows and columns of the initial sector corresponding to the data to be written is determined, the destination sector corresponding to the data to be written is obtained, and the sector information of the destination sector is written into the length index table; The written sector is used as the destination sector corresponding to the data to be written.

8. A sector-based data writing device, characterized in that: The data writing device specifically comprises: An acquisition module, used for acquiring data to be written, wherein the data to be written includes a data tail; A first determination module, configured to determine, according to the data to be written, a writing sector having a row number equal to a data length of the data to be written as a destination sector; A traversal module, used for traversing the last column of the destination sector starting from the last byte of the destination sector, until the value of the traversed byte is the same as the data tail or the number of traversals is equal to the number of columns of the destination sector; A second determination module is used to determine that the next column of the byte is a write column when the value of the traversed byte is the same as the data tail; and when the number of traversals is equal to the number of columns of the target sector and the value of the last traversed byte is different from the data tail, determine that the first column of the target sector is a write column; The writing module is used to write the data to be written into the writing column in sequence starting from the first byte of the writing column.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps in the sector-based data writing method according to any one of claims 1 to 7.

10. A terminal device, characterized in that: include: Processor, memory and communication bus; The memory stores a computer-readable program executable by the processor; The communication bus realizes the connection and communication between the processor and the memory; When the processor executes the computer-readable program, the processor implements the steps in the sector-based data writing method according to any one of claims 1 to 7.