CN109857340B - Method and device for storing and reading files in NOR FLASH and storage medium - Google Patents

Method and device for storing and reading files in NOR FLASH and storage medium Download PDF

Info

Publication number
CN109857340B
CN109857340B CN201910035218.3A CN201910035218A CN109857340B CN 109857340 B CN109857340 B CN 109857340B CN 201910035218 A CN201910035218 A CN 201910035218A CN 109857340 B CN109857340 B CN 109857340B
Authority
CN
China
Prior art keywords
file
bch
stored
read
storing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201910035218.3A
Other languages
Chinese (zh)
Other versions
CN109857340A (en
Inventor
朱海明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
TP Link Technologies Co Ltd
Original Assignee
TP Link Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by TP Link Technologies Co Ltd filed Critical TP Link Technologies Co Ltd
Priority to CN201910035218.3A priority Critical patent/CN109857340B/en
Publication of CN109857340A publication Critical patent/CN109857340A/en
Application granted granted Critical
Publication of CN109857340B publication Critical patent/CN109857340B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method for storing and reading files in NOR FLASH, which comprises the following steps: when files need to be stored in the NOR FLASH, coding length information of the files to be stored according to a preset first BCH cyclic code, and coding content information of the files to be stored according to a preset second BCH cyclic code; storing the file to be stored according to the encoded file; when a file needs to be read in the NOR FLASH, decoding length information of the file to be read according to a preset third BCH cycle code, and decoding content information of the file to be read according to a preset fourth BCH cycle code; and acquiring the file to be read according to the decoded file. Correspondingly, the invention also discloses a device for storing and reading the files in the NOR FLASH and a computer readable storage medium. The technical scheme of the invention can solve the problem of bit flipping of the NOR FLASH, thereby improving the reliability of storing and reading the files in the NOR FLASH.

Description

Storage and reading method and device for files in NOR FLASH and storage medium
Technical Field
The invention relates to the technical field of data access, in particular to a method and a device for storing and reading files in NOR FLASH and a computer readable storage medium.
Background
While NOR FLASH is a non-volatile FLASH memory technology, NOR FLASH memory has been generally recognized as a relatively stable storage medium, recent research has found that NOR FLASH also has bit flipping problems, which are related to the chip vendor manufacturing process and the number of file accesses, while current NOR FLASH controller chips rarely support ECC checking, thus resulting in less reliability of file storage and reading in NOR FLASH.
Disclosure of Invention
The technical problem to be solved by the embodiments of the present invention is to provide a method and an apparatus for storing and reading a file in a NOR FLASH, and a computer-readable storage medium, which can solve the problem of bit flipping of the NOR FLASH, thereby improving the reliability of storing and reading the file in the NOR FLASH.
In order to solve the above technical problem, an embodiment of the present invention provides a method for storing and reading a file in a NOR FLASH, including:
when a file needs to be stored in the NOR FLASH, coding length information of the file to be stored according to a preset first BCH cyclic code, and coding content information of the file to be stored according to a preset second BCH cyclic code;
storing the file to be stored according to the encoded file;
when a file needs to be read in the NOR FLASH, decoding length information of the file to be read according to a preset third BCH cycle code, and decoding content information of the file to be read according to a preset fourth BCH cycle code; the third BCH cyclic code and the fourth BCH cyclic code are respectively cyclic codes used for coding length information and content information of the file to be read during storage;
acquiring the file to be read according to the decoded file;
the method encodes the length information of the file to be stored according to the first BCH cyclic code by the following steps:
adding a header field of X1 bytes to the file to be stored; the first X1 bytes of the header field are used for storing the actual length of the file to be stored, and X1> X1 is more than or equal to 1;
coding the length information of the file to be stored according to the first BCH cyclic code, and correspondingly obtaining a first BCH code;
the first BCH code is deposited in the last X1-X1 bytes of the header field.
Further, the method encodes the content information of the file to be stored according to the second BCH cyclic code by the following steps:
dividing the content data of the file to be stored into Y1 groups of content data according to each Y1 byte group; if the content data of the Y1 th group is less than Y1 bytes, zero padding is carried out, Y1 is more than or equal to 1, and Y1 is more than or equal to 1;
respectively coding each group of content data according to the second BCH cyclic codes to correspondingly obtain y1 second BCH codes;
and storing the y1 second BCH codes at the tail part of the file to be stored according to the coding sequence.
Further, the method decodes the length information of the file to be read according to the third BCH cyclic code by the following steps:
reading a preset header field of X2 bytes of the file to be read; wherein, X2> 1;
and decoding the header field according to the third BCH cyclic code, and correspondingly obtaining the length information of the file to be read.
Further, the method decodes the content information of the file to be read according to the fourth BCH cyclic code by the following steps:
dividing the content data of the file to be read into Y2 groups of content data according to preset Y2 bytes in one group according to the length information of the file to be read; if the content data of the Y2 th group is less than Y2 bytes, zero padding is carried out, Y2 is more than or equal to 1, and Y2 is more than or equal to 1;
reading y2 second BCH codes at the tail part of the file to be read;
splicing each group of content data and the second BCH code corresponding to the group of content data to correspondingly obtain y2 groups of spliced content data;
and decoding each group of spliced content data according to the fourth BCH cyclic code.
In order to solve the above technical problem, an embodiment of the present invention further provides a device for storing and reading a file in a NOR FLASH, including:
the file coding module is used for coding length information of a file to be stored according to a preset first BCH cyclic code and coding content information of the file to be stored according to a preset second BCH cyclic code when the file is required to be stored in the NOR FLASH;
the file storage module is used for storing the file to be stored according to the coded file;
the file decoding module is used for decoding the length information of the file to be read according to a preset third BCH cyclic code and decoding the content information of the file to be read according to a preset fourth BCH cyclic code when the file is required to be read in the NOR FLASH; the third BCH cyclic code and the fourth BCH cyclic code are respectively cyclic codes used for coding length information and content information of the file to be read during storage; and the number of the first and second groups,
the file reading module is used for acquiring the file to be read according to the decoded file;
the file encoding module specifically comprises:
a header field adding unit, configured to add a header field of X1 bytes to the file to be stored; the first X1 bytes of the header field are used for storing the actual length of the file to be stored, and X1> X1 is more than or equal to 1;
a length coding unit, configured to code length information of the file to be stored according to the first BCH cyclic code, and correspondingly obtain a first BCH code; and the number of the first and second groups,
a first BCH code storing unit for storing the first BCH code in last X1-X1 bytes of the header field.
Further, the file encoding module further comprises:
a first content dividing unit for dividing the content data of the file to be stored into Y1 groups of content data per Y1 bytes; wherein, if the content data of the Y1 th group is less than Y1 bytes, zero padding is carried out, Y1 is more than or equal to 1, and Y1 is more than or equal to 1;
a content encoding unit, configured to encode each set of content data according to the second BCH cyclic code, and accordingly obtain y1 second BCH codes; and the number of the first and second groups,
and the second BCH code storage unit is used for storing y1 second BCH codes at the tail part of the file to be stored according to the coding sequence.
An embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium includes a stored computer program; when the computer program runs, the device where the computer readable storage medium is located is controlled to execute any one of the methods for storing and reading files in the NOR FLASH.
The embodiment of the invention also provides a device for storing and reading files in NOR FLASH, which comprises a processor, a memory and a computer program which is stored in the memory and configured to be executed by the processor, wherein the processor realizes the method for storing and reading the files in the NOR FLASH when executing the computer program.
Compared with the prior art, the embodiment of the invention provides a method, a device and a computer readable storage medium for storing and reading files in NOR FLASH, when the files need to be stored in the NOR FLASH, the length information of the files to be stored is encoded according to a first BCH cyclic code, and the content information of the files to be stored is encoded according to a second BCH cyclic code, so that the files to be stored are stored according to the encoded files; when the file needs to be read in the NOR FLASH, the length information of the file to be read is decoded according to the third BCH cycle code, and the content information of the file to be read is decoded according to the fourth BCH cycle code, so that the file to be read is obtained according to the decoded file, the problem of bit flipping of the NOR FLASH caused by the manufacturing process and the access times can be solved, the NOR FLASH has automatic repair capability, and the reliability of storing and reading the file in the NOR FLASH is improved.
Drawings
FIG. 1 is a flow chart of a preferred embodiment of a method for storing and reading files in NOR FLASH according to the present invention;
FIG. 2 is a block diagram of a preferred embodiment of a file storing and reading apparatus in NOR FLASH according to the present invention;
fig. 3 is a block diagram of another preferred embodiment of the file storing and reading apparatus in NOR FLASH according to the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without any inventive step, are within the scope of the present invention.
Referring to fig. 1, it is a flowchart of a preferred embodiment of a method for storing and reading files in NOR FLASH according to the present invention, where the method includes steps S11 to S14:
step S11, when a file needs to be stored in the NOR FLASH, encoding length information of the file to be stored according to a preset first BCH cyclic code, and encoding content information of the file to be stored according to a preset second BCH cyclic code;
step S12, storing the file to be stored according to the coded file;
step S13, when a file needs to be read in the NOR FLASH, decoding the length information of the file to be read according to a preset third BCH cycle code, and decoding the content information of the file to be read according to a preset fourth BCH cycle code; the third BCH cyclic code and the fourth BCH cyclic code are respectively cyclic codes used for coding length information and content information of the file to be read during storage;
and step S14, acquiring the file to be read according to the decoded file.
The embodiment of the invention mainly comprises a storage file encoding stage and a reading file decoding stage, and specifically comprises the steps of firstly acquiring the actual length information of a file to be stored in the storage file encoding stage, encoding the actual length information of the file to be stored according to a preset first BCH cyclic code, then acquiring the content data information of the file to be stored, encoding the content data information of the file to be stored according to a preset second BCH cyclic code, and finally generating a corresponding encoded file according to the actual length of the file to be stored, the code corresponding to the length information, the content data and the code corresponding to the content information, so as to store the file to be stored according to the encoded file; in the file reading and decoding stage, firstly, a code corresponding to the length information of the file to be read is acquired, the length information of the file to be read is decoded according to a preset third BCH cycle code, then, a code corresponding to the content information of the file to be read is acquired, the content information of the file to be read is decoded according to a preset fourth BCH cycle code, and finally, a decoded file is organized according to the actual length information and the content data information of the file to be read, which are acquired by decoding, so that the file to be read is read according to the decoded file.
It can be understood that the third BCH cyclic code is consistent with the cyclic code used by the file to be read when the length information of the file is encoded in the storage encoding stage, the fourth BCH cyclic code is consistent with the cyclic code used by the file to be read when the content information of the file is encoded in the storage encoding stage, and the cyclic code used in the encoding stage is adopted to perform corresponding decoding in the decoding stage, so that the accuracy of the decoding result can be ensured.
It should be noted that, because the storage capacity of the NOR FLASH memory is small, the current products in the market generally do not exceed 4GB, so the maximum length of the file that the NOR FLASH can store is defined to be less than 4GB, that is, the maximum value of the actual length of the file to be stored is 2^32-1 bytes.
According to the method for storing and reading the file in the NOR FLASH, provided by the embodiment of the invention, the length information and the content information of the file to be stored are coded according to the BCH cyclic code when the file is stored in the NOR FLASH, the length information and the content information of the file to be read are decoded according to the BCH cyclic code when the file is read from the NOR FLASH, and through the coding and decoding processes, even if the original file is stored with bit flipping errors, the file can be automatically corrected in decoding calculation, and the file obtained after decoding is the file subjected to bit flipping correction, so that the bit flipping problem of the NOR FLASH caused by the manufacturing process and the access times is solved, the NOR FLASH has automatic repair capability, and the reliability of storing and reading the file in the NOR FLASH is improved.
In another preferred embodiment, the method encodes the length information of the file to be stored according to the first BCH cyclic code by:
adding a header field of X1 bytes to the file to be stored; the first X1 bytes of the header field are used for storing the actual length of the file to be stored, and X1> X1 is more than or equal to 1;
coding the length information of the file to be stored according to the first BCH cyclic code, and correspondingly obtaining a first BCH code;
the first BCH code is deposited in the last X1-X1 bytes of the header field.
Specifically, with reference to the foregoing embodiment, after acquiring the actual length information of the file to be stored, first add a header field of X1 bytes to the file to be stored, store the acquired actual length of the file to be stored in the first X1 bytes of X1 bytes, then encode the first X1 bytes according to a preset first BCH cyclic code, generate a corresponding first BCH code, and store the first BCH code in the last X1-X1 bytes of X1 bytes; the specific values of X1 and X1 can be set according to actual needs.
As an improvement of the above scheme, X1 is 7, X1 is 4, and the first BCH cyclic code is a BCH (56, 32) cyclic code.
Specifically, a header field of 7 bytes is added to the file to be stored, the actual length of the file to be stored obtained is stored in the first 4 bytes of the 7 bytes, 4-bit errors can be corrected according to the BCH cyclic code, that is, t is 4, k is 4 × 8 × 32, m can be obtained from 2^ m-1 ≧ 32 with minimum 6, r is n-k ≦ m × t, r is m × t, 6 × 4 × 24 is selected, the code length n is r + k 24+32 + 56 is obtained, and thus a non-native BCH (56, 32) code is obtained, that is, the first BCH cyclic code is a BCH (56, 32) cyclic code, the first 4 bytes are encoded according to the BCH (56, 32) cyclic code, the first BCH code of 3 bytes is generated, and the first byte is stored in the last 3 bytes.
It should be noted that the above specific parameters and the BCH cyclic code are set as a preferred embodiment, which can adjust the selection of the algorithm to an optimal state, and in practical applications, the same algorithm with slightly poor efficiency is used by increasing or decreasing the length of the added header field, correspondingly using other BCH cyclic codes for coding, and the like, all belong to the protection scope of the present invention, and the embodiment of the present invention is not limited specifically.
In a further preferred embodiment, the method encodes the content information of the file to be stored according to the second BCH cyclic code by:
dividing the content data of the file to be stored into Y1 groups of content data according to each Y1 byte group; if the content data of the Y1 th group is less than Y1 bytes, zero padding is carried out, Y1 is more than or equal to 1, and Y1 is more than or equal to 1;
respectively coding each group of content data according to the second BCH cyclic codes to correspondingly obtain y1 second BCH codes;
and storing the y1 second BCH codes at the tail part of the file to be stored according to the coding sequence.
Specifically, with reference to the foregoing embodiment, after content data information of a file to be stored is obtained, first, content data of the file to be stored is divided into one group of Y1 bytes, the file to be stored is divided into Y1 groups of content data, the last group, that is, the Y1 group of content data, is padded with zeros if Y1 bytes are not enough, then each group of content data is encoded according to a preset second BCH cyclic code, a second BCH code is generated for each group of content data, Y1 second BCH codes are correspondingly obtained, and Y1 second BCH codes are stored at the tail of the file to be stored according to an encoding sequence.
It should be noted that y1 sets of content data can be encoded according to the grouping number of the content data of the file to be stored, for example, each set of content data is sequentially encoded according to the order of the first set, the second set, · and the y1 set, so as to generate the first BCH, the second BCH, · · · · and the y1 second BCH codes correspondingly, and the generated first BCH, the second BCH, · · · and the y1 second BCH codes are sequentially arranged at the tail of the file to be stored.
As an improvement of the above scheme, Y1 is 512, and the second BCH cyclic code is a BCH (4148, 4096) cyclic code.
Specifically, the content data of the file to be stored is divided into one group of 512 bytes, the file to be stored is divided into y1 groups of content data, the last group, namely the y1 group of content data is supplemented with zero if the content data is not enough to 512 bytes, the BCH factor matching is carried out according to the principle that 4-bit errors can be corrected at most every 512 bytes, t is 4, k is 512 x 8 is 4096, m can be obtained from 2 x m-1 which is not less than 4096 and is at least 13, because r is n-k which is not more than m, the r is m, t is 13 x 52, the code length n is r + k is 52+4096 which is 4148, thereby selecting the BCH (4148, 4096) algorithm, namely the second BCH cyclic code is a BCH (4148, 416) cyclic code, and encoding is carried out on the content data of each group of corresponding BCH (48, 416) groups of content data to generate one second BCH (4148, 416) cyclic code, and correspondingly obtaining y1 second BCH codes, and storing the y1 second BCH codes at the tail part of the file to be stored according to the coding sequence.
It should be noted that the above specific parameters and the setting of the BCH cyclic code are a preferred embodiment, which can adjust the selection of the algorithm to the optimal state, and in practical applications, other algorithms with slightly poor efficiency may be replaced, for example, 1024 bytes + BCH (8304, 8192) cyclic codes are selected for encoding, which all belong to the protection scope of the present invention, and the embodiment of the present invention is not limited specifically.
In addition, the correction precision is at most 4 bits of bit flipping errors per 512 bytes, and most NOR FLASH application scenarios can be covered.
In another preferred embodiment, the method decodes the length information of the file to be read according to the third BCH cyclic code by:
reading a preset header field of X2 bytes of the file to be read; wherein, X2> 1;
and decoding the header field according to the third BCH cyclic code, and correspondingly obtaining the length information of the file to be read.
Specifically, with reference to the foregoing embodiment, first, a header field of X2 bytes preset in the file to be read is read to obtain an encoding corresponding to the length information of the file to be read, and then, the header field of X2 bytes is decoded according to a third BCH cyclic code preset in the file to be read, so as to obtain the length information of the file to be read.
It should be noted that the byte number X2 of the header field of the file to be read should be consistent with the byte number of the header field added by the file to be read in the storage encoding stage.
As an improvement of the above scheme, X2 is 7, and the third BCH cyclic code is a BCH (56, 32) cyclic code.
Specifically, a header field of a file to be read, which is set in advance and is 7 bytes, is read first, and a cyclic code used when the length information of the file to be read is encoded in a storage encoding stage corresponds to a BCH (56, 32) cyclic code, so that the third BCH cyclic code is a BCH (56, 32) cyclic code, and the header field of the file to be read is decoded according to the BCH (56, 32) cyclic code, so as to obtain the length information of the file to be read.
It should be noted that the above specific parameters and the BCH cyclic code are set as a preferred embodiment, which can adjust the selection of the algorithm to an optimal state, and in practical applications, the same algorithm with slightly poor efficiency is used by increasing or decreasing the length of the added header field, correspondingly using other BCH cyclic codes for decoding, and the like, all belong to the protection scope of the present invention, and the embodiment of the present invention is not limited specifically.
In another preferred embodiment, the method decodes the content information of the file to be read according to the fourth BCH cyclic code by:
dividing the content data of the file to be read into Y2 groups of content data according to preset Y2 bytes in one group according to the length information of the file to be read; if the content data of the Y2 th group is less than Y2 bytes, zero padding is carried out, Y2 is more than or equal to 1, and Y2 is more than or equal to 1;
reading y2 second BCH codes at the tail part of the file to be read;
splicing each group of content data and the second BCH code corresponding to the group of content data to correspondingly obtain y2 groups of spliced content data;
and decoding each group of spliced content data according to the fourth BCH cyclic code.
Specifically, with reference to the foregoing embodiment, firstly, according to length information of a to-be-read file obtained by decoding, content data of the to-be-read file is divided into Y2 byte groups, the to-be-read file is divided into Y2 group content data, the last group, that is, the Y2 th group content data, is zero-padded if Y2 bytes are not enough, then Y2 second BCH codes stored at the tail of the to-be-read file are read, each group of content data and the second BCH code corresponding to the group of content data are respectively spliced, Y2 group spliced content data are correspondingly obtained, and finally, each group of spliced content data is decoded according to a preset fourth BCH cyclic code, so as to obtain content data of the to-be-read file.
It should be noted that, when the content data of the file to be read is grouped, the number of bytes corresponding to each group of content data should be consistent with the number of bytes used when the file to be read is grouped in the storage encoding stage.
As an improvement of the above scheme, Y2 is 512, and the fourth BCH cyclic code is a BCH (4148, 4096) cyclic code.
Specifically, firstly, according to the length information of the file to be read, the content data of the file to be read is divided into 512 byte groups, the file to be read is divided into Y2 group content data, if the last group, that is, the Y2 group content data is not enough to Y2 bytes, zero padding is used, then, y2 second BCH codes stored at the tail part of the file to be read are read, each group of content data and the 7-byte second BCH codes corresponding to the group of content data are spliced respectively, the cyclic code used in the storage coding stage to code its content information corresponds to a BCH (4148, 4096) cyclic code, corresponding to the y2 sets of spliced-content data obtained, so that the fourth BCH cyclic code is a BCH (4148, 4096) cyclic code, each set of spliced content data is decoded separately according to the BCH (4148, 4096) cyclic code, thereby obtaining the content data of the file to be read.
For example, in the storage encoding stage, each group of 512-byte content data is encoded to generate a 7-byte BCH redundancy code, and the generated 7-byte BCH redundancy code is sequentially placed at the tail of the file, when decoding is required, the ith group of content data text [ i ] and the corresponding ith second BCH code BCH [ i ] are taken out, and then BCH [ i ] is placed at the tail of the text [ i ], so that the ith group of 512+7 ═ 519 spliced content data is formed, decoding calculation is performed on each group of spliced content data by using a BCH (4148, 4096) algorithm, a decoded result can be obtained, and each group of decoded results are directly and sequentially arranged to be combined into a file, which is the file to be read finally.
It should be noted that the above specific parameters and the setting of the BCH cyclic code are a preferred embodiment, which can adjust the selection of the algorithm to the optimal state, and in practical applications, other algorithms with slightly poor efficiency may be replaced, for example, 1024 bytes + BCH (8304, 8192) cyclic codes are selected for decoding, which all belong to the protection scope of the present invention, and the embodiment of the present invention is not limited specifically.
The embodiment of the present invention further provides a device for storing and reading a file in a NOR FLASH, which can implement all the processes of the method for storing and reading a file in a NOR FLASH described in any of the above embodiments, and the functions and the technical effects of the modules and units in the device are respectively the same as those of the method for storing and reading a file in a NOR FLASH described in the above embodiments, and are not described herein again.
Referring to fig. 2, it is a block diagram of a preferred embodiment of an apparatus for storing and reading files in NOR FLASH, which is provided in the present invention, and the apparatus includes:
the file encoding module 11 is configured to, when a file needs to be stored in the NOR FLASH, encode length information of the file to be stored according to a preset first BCH cyclic code, and encode content information of the file to be stored according to a preset second BCH cyclic code;
the file storage module 12 is used for storing the file to be stored according to the encoded file;
the file decoding module 13 is configured to, when a file needs to be read in the NOR FLASH, decode length information of the file to be read according to a preset third BCH cyclic code, and decode content information of the file to be read according to a preset fourth BCH cyclic code; the third BCH cyclic code and the fourth BCH cyclic code are respectively cyclic codes used for coding length information and content information of the file to be read during storage; and the number of the first and second groups,
and the file reading module 14 is configured to obtain the file to be read according to the decoded file.
Preferably, the file encoding module 11 specifically includes:
a header field adding unit, configured to add a header field of X1 bytes to the file to be stored; the first X1 bytes of the header field are used for storing the actual length of the file to be stored, and X1> X1 is more than or equal to 1;
a length coding unit, configured to code length information of the file to be stored according to the first BCH cyclic code, and correspondingly obtain a first BCH code; and the number of the first and second groups,
a first BCH code storing unit for storing the first BCH code in the last X1-X1 bytes of the header field.
Preferably, the file encoding module 11 further includes:
a first content dividing unit for dividing the content data of the file to be stored into Y1 groups of content data per Y1 bytes; if the content data of the Y1 th group is less than Y1 bytes, zero padding is carried out, Y1 is more than or equal to 1, and Y1 is more than or equal to 1;
a content encoding unit, configured to encode each set of content data according to the second BCH cyclic code, and accordingly obtain y1 second BCH codes; and the number of the first and second groups,
and the second BCH code storage unit is used for storing y1 second BCH codes at the tail part of the file to be stored according to the coding sequence.
Preferably, the file decoding module 13 specifically includes:
a header field reading unit, configured to read a header field of X2 bytes preset in the file to be read; wherein, X2> 1; and the number of the first and second groups,
and the length decoding unit is used for decoding the header field according to the third BCH cyclic code and correspondingly obtaining the length information of the file to be read.
Preferably, the file decoding module 13 further includes:
the second content dividing unit is used for dividing the content data of the file to be read into Y2 groups of content data according to preset Y2 bytes in one group according to the length information of the file to be read; if the content data of the Y2 th group is less than Y2 bytes, zero padding is carried out, Y2 is more than or equal to 1, and Y2 is more than or equal to 1;
a second BCH code reading unit, configured to read y2 second BCH codes at the tail of the file to be read;
a content splicing unit, configured to splice each set of content data and the second BCH code corresponding to the content data, so as to obtain y2 sets of spliced content data correspondingly; and the number of the first and second groups,
and a content decoding unit, configured to decode each group of spliced content data according to the fourth BCH cyclic code.
An embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium includes a stored computer program; when running, the computer program controls the device where the computer-readable storage medium is located to execute the method for storing and reading the file in the NOR FLASH according to any of the embodiments.
An embodiment of the present invention further provides a device for storing and reading files in NOR FLASH, and as shown in fig. 3, the device is a block diagram of another preferred embodiment of the device for storing and reading files in NOR FLASH, the device includes a processor 10, a memory 20, and a computer program stored in the memory 20 and configured to be executed by the processor 10, and the processor 10 implements the method for storing and reading files in NOR FLASH according to any of the above embodiments when executing the computer program.
Preferably, the computer program can be divided into one or more modules/units (e.g. computer program 1, computer program 2,) which are stored in the memory 20 and executed by the processor 10 to accomplish the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program in the apparatus.
The Processor 10 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc., the general purpose Processor may be a microprocessor, or the Processor 10 may be any conventional Processor, the Processor 10 is a control center of the apparatus, and various interfaces and lines are used to connect various parts of the apparatus.
The memory 20 mainly includes a program storage area that may store an operating system, an application program required for at least one function, and the like, and a data storage area that may store related data and the like. In addition, the memory 20 may be a high speed random access memory, a non-volatile memory such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card), and the like, or the memory 20 may be other volatile solid state memory devices.
It should be noted that the above-mentioned apparatus may include, but is not limited to, a processor and a memory, and those skilled in the art will understand that the structural block diagram in fig. 3 is only an example of the above-mentioned apparatus, and does not constitute a limitation of the apparatus, and may include more or less components than those shown, or combine some components, or different components.
To sum up, the length information and the content information of the file to be stored are encoded according to the BCH cyclic code when the file is stored in the NOR FLASH, and the length information and the content information of the file to be read are decoded according to the BCH cyclic code when the file is read from the NOR FLASH.
The above description is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, several modifications and variations can be made without departing from the technical principle of the present invention, and these modifications and variations should also be regarded as the protection scope of the present invention.

Claims (8)

1. A method for storing and reading files in NOR FLASH is characterized by comprising the following steps:
when a file needs to be stored in the NOR FLASH, coding length information of the file to be stored according to a preset first BCH cyclic code, and coding content information of the file to be stored according to a preset second BCH cyclic code;
storing the file to be stored according to the encoded file;
when a file needs to be read in the NOR FLASH, decoding length information of the file to be read according to a preset third BCH cyclic code, and decoding content information of the file to be read according to a preset fourth BCH cyclic code; the third BCH cyclic code and the fourth BCH cyclic code are respectively cyclic codes used for coding length information and content information of the file to be read during storage;
acquiring the file to be read according to the decoded file;
the method encodes the length information of the file to be stored according to the first BCH cyclic code by the following steps:
adding a header field of X1 bytes to the file to be stored; the first X1 bytes of the header field are used for storing the actual length of the file to be stored, and X1> X1 is more than or equal to 1;
coding the length information of the file to be stored according to the first BCH cyclic code, and correspondingly obtaining a first BCH code;
the first BCH code is deposited in the last X1-X1 bytes of the header field.
2. The method for storing and reading files in NOR FLASH of claim 1, wherein the method encodes the contents information of the files to be stored according to the second BCH cyclic code by:
dividing the content data of the file to be stored into Y1 groups of content data according to each Y1 byte group; if the content data of the Y1 th group is less than Y1 bytes, zero padding is carried out, Y1 is more than or equal to 1, and Y1 is more than or equal to 1;
respectively coding each group of content data according to the second BCH cyclic codes to correspondingly obtain y1 second BCH codes;
and storing the y1 second BCH codes at the tail part of the file to be stored according to the coding sequence.
3. The method for storing and reading files in NOR FLASH of claim 1, wherein the method decodes the length information of the file to be read according to the third BCH cyclic code by:
reading a preset header field of X2 bytes of the file to be read; wherein, X2> 1;
and decoding the header field according to the third BCH cyclic code, and correspondingly obtaining the length information of the file to be read.
4. The method for storing and reading files in NOR FLASH of claim 1 or 3, wherein the method decodes the content information of the file to be read according to the fourth BCH cyclic code by:
dividing the content data of the file to be read into Y2 groups of content data according to preset Y2 bytes in one group according to the length information of the file to be read; if the content data of the Y2 th group is less than Y2 bytes, zero padding is carried out, Y2 is more than or equal to 1, and Y2 is more than or equal to 1;
reading y2 second BCH codes at the tail part of the file to be read;
splicing each group of content data and the second BCH code corresponding to the group of content data to correspondingly obtain y2 groups of spliced content data;
and decoding each group of spliced content data according to the fourth BCH cyclic code.
5. An apparatus for storing and reading files in a NOR FLASH, comprising:
the file coding module is used for coding length information of a file to be stored according to a preset first BCH cyclic code and coding content information of the file to be stored according to a preset second BCH cyclic code when the file is required to be stored in the NOR FLASH;
the file storage module is used for storing the file to be stored according to the coded file;
the file decoding module is used for decoding the length information of the file to be read according to a preset third BCH cyclic code and decoding the content information of the file to be read according to a preset fourth BCH cyclic code when the file is required to be read in the NOR FLASH; the third BCH cyclic code and the fourth BCH cyclic code are respectively cyclic codes used for coding length information and content information of the file to be read during storage; and the number of the first and second groups,
the file reading module is used for acquiring the file to be read according to the decoded file;
the file encoding module specifically comprises:
a header field adding unit, configured to add a header field of X1 bytes to the file to be stored; the first X1 bytes of the header field are used for storing the actual length of the file to be stored, and X1> X1 is more than or equal to 1;
a length coding unit, configured to code length information of the file to be stored according to the first BCH cyclic code, and correspondingly obtain a first BCH code; and the number of the first and second groups,
a first BCH code storing unit for storing the first BCH code in last X1-X1 bytes of the header field.
6. The apparatus for storing and reading files in NOR FLASH of claim 5, wherein the file encoding module further comprises:
a first content dividing unit for dividing the content data of the file to be stored into Y1 groups of content data per Y1 bytes; if the content data of the Y1 th group is less than Y1 bytes, zero padding is carried out, Y1 is more than or equal to 1, and Y1 is more than or equal to 1;
a content encoding unit, configured to encode each set of content data according to the second BCH cyclic code, and accordingly obtain y1 second BCH codes; and the number of the first and second groups,
and the second BCH code storage unit is used for storing y1 second BCH codes at the tail part of the file to be stored according to the coding sequence.
7. A computer-readable storage medium, characterized in that the computer-readable storage medium comprises a stored computer program; wherein the computer program, when running, controls an apparatus in which the computer-readable storage medium is located to perform the method for storing and reading files in NOR FLASH of any of claims 1 to 4.
8. An apparatus for storing and reading files in NOR FLASH, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the method for storing and reading files in NOR FLASH according to any of claims 1-4.
CN201910035218.3A 2019-01-14 2019-01-14 Method and device for storing and reading files in NOR FLASH and storage medium Expired - Fee Related CN109857340B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910035218.3A CN109857340B (en) 2019-01-14 2019-01-14 Method and device for storing and reading files in NOR FLASH and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910035218.3A CN109857340B (en) 2019-01-14 2019-01-14 Method and device for storing and reading files in NOR FLASH and storage medium

Publications (2)

Publication Number Publication Date
CN109857340A CN109857340A (en) 2019-06-07
CN109857340B true CN109857340B (en) 2022-05-06

Family

ID=66894576

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910035218.3A Expired - Fee Related CN109857340B (en) 2019-01-14 2019-01-14 Method and device for storing and reading files in NOR FLASH and storage medium

Country Status (1)

Country Link
CN (1) CN109857340B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102823141A (en) * 2010-03-30 2012-12-12 国际商业机器公司 Two-level bch codes for solid state storage devices
CN104541253A (en) * 2012-09-26 2015-04-22 英特尔公司 Techniques associated with protecting system critical data written to non-volatile memory
CN105100820A (en) * 2015-08-18 2015-11-25 杭州士兰微电子股份有限公司 Digital media file encoding method, decoding method, encoding device and decoding device
CN106658034A (en) * 2016-12-05 2017-05-10 乐视控股(北京)有限公司 File storage and reading method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8433985B2 (en) * 2010-03-29 2013-04-30 Intel Corporation Error correction mechanisms for flash memories

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102823141A (en) * 2010-03-30 2012-12-12 国际商业机器公司 Two-level bch codes for solid state storage devices
CN104541253A (en) * 2012-09-26 2015-04-22 英特尔公司 Techniques associated with protecting system critical data written to non-volatile memory
CN105100820A (en) * 2015-08-18 2015-11-25 杭州士兰微电子股份有限公司 Digital media file encoding method, decoding method, encoding device and decoding device
CN106658034A (en) * 2016-12-05 2017-05-10 乐视控股(北京)有限公司 File storage and reading method and device

Also Published As

Publication number Publication date
CN109857340A (en) 2019-06-07

Similar Documents

Publication Publication Date Title
US8769374B2 (en) Multi-write endurance and error control coding of non-volatile memories
US8949687B2 (en) Memory device and memory system
US7900118B2 (en) Flash memory system and method for controlling the same
KR101686980B1 (en) Method of data storage in non-volatile memory
CN102017425B (en) System and method for performing concatenated error correction
US9075739B2 (en) Storage device
JP2015507409A (en) Multi-phase ECC encoding using algebraic codes
CN112486725B (en) Method and device for carrying out error correction coding on compressed data
US10355711B2 (en) Data processing method and system based on quasi-cyclic LDPC
US9858994B2 (en) Memory system with MLC memory cells and partial page compression or reduction
US20150149856A1 (en) Decoding with log likelihood ratios stored in a controller
CN111869111B (en) Generating and using reversible shortened bose-charderry-hokumq codewords
CN109785895B (en) ECC device and method for correcting multi-bit errors in NAND Flash
KR20190019728A (en) Error correction circuit, operating method thereof and data storage device incuding the same
CN109857340B (en) Method and device for storing and reading files in NOR FLASH and storage medium
CN109756231B (en) Cyclic shift processing device and method
CN210110352U (en) ECC device for correcting multi-bit errors in NAND Flash
KR102369313B1 (en) Error correction circuit, operating method thereof and data storage device incuding the same
KR20210057787A (en) Turbo product code decoding method, apparatus, decoder and computer recording medium
CN114078560B (en) Error correction decoding method of NAND flash memory chip, storage medium and SSD device
CN116302670A (en) Encoding and decoding method, encoder and decoder, chip, hard disk and communication system
CN113687976B (en) Coding and decoding method and device for DNA information storage
CN108170554B (en) NAND data coding method and device
US9160371B2 (en) Memory controller, storage device and memory control method
CN116662063B (en) Error correction configuration method, error correction method, system, equipment and medium for flash memory

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20220506

CF01 Termination of patent right due to non-payment of annual fee