此应用程序的某些内容目前无法使用。
如果这种情况持续存在,请联系我们反馈与联系
1. (WO2019048933) METHOD AND APPARATUS FOR ERASING OR WRITING FLASH DATA
注:相关文本通过自动光符识别流程生成。凡涉及法律问题,请以 PDF 版本为准

METHOD AND APPARATUS FOR ERASING OR WRITING FLASH DATA

CROSS-REFERENCE TO RELATED APPLICATION

[0001] The present application claims priority to Chinese Patent Application No. 201710813896.5, filed on September 11, 2017, which is incorporated herein by reference in its entirety.

TECHNICAL FIELD

[0002] The present disclosure relates to the field of Flash technologies, and in particular, to a method and an apparatus for erasing or writing Flash data.

BACKGROUND

[0003] Erasing and writing of Flash data (that is, data stored or intended to be stored in Flash memory) are generally involved in an embedded device, e.g., updating a program on a Flash memory when writing configuration information and log information, system upgrade, or the like,

[0004] When Flash data is erased or written, if a program code has a defect, the Flash data might be erased by mistake or written into a Flash location that is not set in advance. This could cause severe problems such as destruction to data stored in the Flash memory and damage to a bootstrap program. In addition, increasingly more devices will be connected to the network along with the rapid development of network technologies. If some malicious programs attack an embedded device intentionally and modify the stored Flash data of the embedded device, problems such as destruction to data or a bootstrap program may also exist.

SUMMARY

[0005] The method and apparatus for erasing or writing data in a Flash memory provided in the present disclosure can set permissions for accessing a location in the Flash memory, thus preventing an illegal operation from tampering with the data in the Flash memory.

[0006] In accordance with some embodiments of the present disclosure, there is provided a method for erasing or writing data of a Flash memory. The method includes reading an instruction for erasing or writing the data, the instruction for erasing or writing the data carrying start address information and end address information of a Flash memory where an operation of the instruction is to occur. The method also includes querying whether the start address information and the end address information are in an address information table including one or more address ranges. The method further includes processing the instruction based on a result of the querying.

[0007] In accordance with some embodiments of the present disclosure, there is provided an apparatus for erasing or writing data of a Flash memory. The apparatus includes a reading unit configured to read an instruction for erasing or writing the data, the instruction for erasing or writing the data carrying start address information and end address information of a Flash memory where an operation of the instruction is to occur. The apparatus also includes a querying unit configured to query whether the start address information and the end address information are in an address information table including one or more address ranges. The apparatus further includes a processing unit configured to process the instruction based on a result of the querying by the query unit.

[0008] According to the method and apparatus for erasing or writing data of a Flash memory provided in embodiments of the present disclosure, when an operation of erasing or writing Flash data is initiated, start address information and end address information corresponding to a location in the Flash memory are carried in an erasing or writing instruction, and the start address information and the end address information are stored in an address information table. When the Flash data is to be erased and written, it is queried

whether the address information of the instruction is in the address information table. When the address information in the actual operation is in the address information table, the operation of erasing or writing data is executed. Otherwise, the erasing or writing operation is not executed. Compared with the conventional art, the present disclosure can set permissions for a location in a Flash memory, thus preventing an illegal operation from tampering with the data in the Flash memory.

BRIEF DESCRIPTION OF THE DRAWINGS

[0009] FIG. 1 is a flowchart of an exemplary method for erasing or writing Flash data according to some embodiments of the present disclosure;

[0010] FIG. 2 is another flowchart of an exemplary method for erasing or writing Flash data according to some embodiments of the present disclosure;

[0011] FIG. 3 is yet another flowchart of an exemplary method for erasing or writing Flash data according to some embodiments of the present disclosure;

[0012] FIG. 4 is a schematic diagram of an exemplary apparatus for erasing or writing Flash data according to some embodiments of the present disclosure; and

[0013] FIG. 5 is another schematic diagram of an exemplary apparatus for erasing or writing Flash data according to some embodiments of the present disclosure.

DETAILED DESCRIPTION

[0014] In order to illustrate the objectives, technical solutions and advantages of the embodiments of the present disclosure, the technical solutions in the embodiments of the present disclosure will be described in the following with reference to the accompanying drawings of the embodiments of the present disclosure. It is apparent that the embodiments described herein are merely some of rather than all of the embodiments of the present disclosure. Based on the embodiments described herein, all other embodiments obtained by

those of ordinary skill in the art without creative efforts shall be encompassed in the protective scope of the present disclosure.

[0015] The present disclosure provides an exemplary method for erasing or writing Flash data. As shown in FIG. 1, the method can include steps SI 1, S13, and S14.

[0016] In step SI 1, an instruction for erasing or writing Flash data is read. The instruction may be requested by an authorized upper-level application that provides configuration information and log information, system upgrade, or the like to the Flash memory. The instruction for erasing or writing data located in a Flash memory carries start address information and end address information corresponding to a location in the Flash memory where the operation of the instruction is to occur.

[0017] In step SI 3, it is queried whether the start address information and the end address information of the instruction are in an address information table. The address information table includes start address information and end address information of one or more Flash address ranges allowing erasing or writing.

[0018] In step SI 4, according to the query result, the instruction for erasing or writing Flash data is executed or the execution of the instruction for erasing or writing Flash data is stopped.

[0019] Optionally, the step of executing the instruction for erasing or writing data for the Flash memory or stopping the execution of the instruction for erasing or writing data in the Flash memory according to the query result includes: executing the instruction for erasing or writing Flash data when the start address information and the end address information are in the address information table; and stopping executing the instruction for erasing or writing Flash data when the start address information and the end address information are not in the address information table.

[0020] Operations on a Flash memory include reading, writing, and erasing.

Operations such as configuration information, log information, and system upgrade in an embedded system generally involve writing and modifying data in the Flash memory.

Modifying the Flash data involves erasing the original data of the Flash memory before new data is written. When an upper-layer application needs to write or modify (erase first and then write) data in the Flash memory, the instruction request includes a start address information and an end address information of the Flash memory where the operation of the instruction is to occur is included in an instruction request. After the step of reading an instruction for erasing or writing Flash data, as shown in FIG. 2, the method can further include step SI 2.

[0021] In step SI 2, the start address information and the end address information provided in the instruction are stored in the address information table.

[0022] The method for erasing or writing Flash data provided in the present disclosure stores address range information (e.g., start address information and end address information) of a Flash memory to be operated by an upper-layer application. For example, the start address information and the end address information provided in the instruction can be stored into an address information table. The address information table allows storing multiple address ranges each having start address information and end address information. The address information in the address information table can also be added or deleted dynamically. The address information table can be as shown in the following table.


[0023] When attempting to erase or write data to the Flash memory, the address information table is queried to determine whether the start address information and the end address information provided in the instruction are in an address information table. If the information is in the address information table, an erasing or writing operation is executed. On the other hand, if the information is not in the address information table, it is indicated that an erasing or writing request is illegal, and the operation of erasing data or writing data is no longer executed.

[0024] While the address information table is set up as a whitelist that identifies address ranges within Flash memory that can be erased or written to, it is appreciated that the address information table could be set up as a blacklist that identifies address ranges that cannot be erased or written to. In the latter blacklist situation, upon receiving an instruction for erasing or writing data associated with an address range, the address information table could be updated to remove that address range from the list.

[0025] After the erasing or writing operation is executed, the start address information and the end address information may need to be removed. Optionally, as shown in FIG. 2, after the step of executing the instruction for erasing or writing Flash data in step SI 4, the method can further include step SI 5.

[0026] In step SI 5, the start address information and the end address information corresponding to the executed instruction are removed from the address information table.

[00271 For an illegal Flash operation, since the start address information and the end address information of the Flash memory that are to be written or erased are not stored in the address information table, the address information cannot be retrieved from the address information table to perform the illegal operation. Therefore, the erasing or writing operation cannot be executed on the Flash memory, and the Flash data cannot be modified, thus protecting the Flash data from being tampered with.

[0028] FIG. 3 shows a flowchart of an exemplary method for performing a writing operation on a Flash memory according to some embodiments of the present disclosure. In

step 301, an authorized upper-layer application initiates an operation of writing to a Flash memory, resulting in an instruction request. The instruction request includes start address information and end address information corresponding to a location in the Flash memory where the writing operation of the instruction is to occur. In step 302, the start address information and the end address information are stored in an address information table. In step 303, when Flash data is attempted to be written to the Flash memory via the instruction request, the address information table is queried to detennine whether address information of the instruction request is located in the address information table. If the address information of the instruction request is not in the address information table, the operation of writing data is no longer executed (e.g., step 306).

[0029] On the other hand, if the address information of the instruction request is in the address information table, in step 304, the data is written into the location of Flash memory corresponding to the start and end address information. After the Flash data is written, in step 305, the start address and the end address of the data written in the Flash memory are deleted from the address information table.

[0030] According to the method for erasing or writing Flash data provided in the present disclosure, when an operation of erasing or writing Flash data is initiated, an erasing or writing instruction carries start address information and end address information of a Flash memory for operation. The start address information and the end address information of the Flash memory for operation are stored in an address information table. When Flash data is erased and written, it is queried whether address information used for an actual operation is in the address information table. When the address information used for the actual operation is in the address information table, the operation of erasing or writing Flash is executed.

Otherwise, the erasing or writing operation is not executed. Compared with the conventional art, the present disclosure can set permissions for accessing an address of a Flash memory for operation, thus preventing an illegal operation from tampering with Flash data.

[0031] The embodiments of the present disclosure further provide an exemplary apparatus for erasing or writing Flash data. As shown in FIG. 4, the apparatus includes a reading unit 11 configured to read an instruction for erasing or writing Flash data. The instruction for erasing or writing Flash data carries start address information and end address information corresponding to a location in the Flash memory where the operation of the instruction is to occur.

[0032] The apparatus also includes a querying unit 13 configured to query whether the start address information and the end address information are in an address information table. The address information table includes one or more Flash memory address ranges including start address information and end address information for allowing erasing or writing.

[0033] The apparatus further includes a processing unit 14 configured to normally execute the instruction for erasing or writing Flash data or stop executing the instruction for erasing or writing Flash data according to the query result.

[0034] Optionally, the processing unit is configured to normally execute the instruction for erasing or writing Flash data when the start address information and the end address information are in the address information table. Optionally, the processing unit is configured to stop executing the instruction for erasing or writing Flash data when the start address information and the end address information are not in the address information table.

[0035] Optionally, as shown in FIG. 5, the apparatus can further include a storing unit 12 configured to, after reading unit 1 1 reads the instruction for erasing or writing Flash data, store in the address information table the start address information and the end address information provided in the instruction.

[0036] Optionally, as shown in FIG. 5, the apparatus can further include a removing unit 15 configured to, after processing unit 14 executes the instruction for erasing or writing Flash data, remove from the address information table the start address information and end address information.

[0037] According to the apparatus for erasing or writing Flash data provided in the present disclosure, when an operation of erasing or writing Flash data is initiated, an erasing or writing instruction carries start address information and end address information corresponding to a location in the a Flash memory where the operation of the instruction is to occur. The start address information and the end address information are stored in an address information table. When Flash data is requested to be erased and written, it is queried whether address information provided in the instruction is in the address information table. When the address information is in the address information table, the operation of erasing or writing Flash is executed. Otherwise, the erasing or writing operation is not executed.

Compared with the conventional art, the present disclosure can set permissions for one or more address ranges in a Flash memory to which an operation can occur, thus preventing an illegal operation from tampering the Flash data.

[0038] Those of ordinary skill in the art can understand that all or a part of processes in the method of the foregoing embodiments can be implemented by a computer program instructing relevant hardware. The program can be stored in a computer readable storage medium. When executed, the program can include processes of the embodiments of the foregoing methods. The storage medium can be a magnetic disk, an optical disc, a Readonly Memory (ROM), a Random Access Memory (RAM), or the like.

[0039] The above descriptions are merely specific implementation manners of the present disclosure, but the protective scope of the present disclosure is not limited to this. Variations or replacements that can be easily thought of by one of skill in the art within the technical scope disclosed in the present disclosure shall all be encompassed in the protective scope of the present disclosure. Therefore, the current protective scope of the present disclosure should be subject to the scope of the claims.