Nor Flash erasing and upgrading method and device, computer equipment and storage medium

By determining the appropriate erase command based on the starting address and space size of the Nor Flash partition, and using appropriate erase blocks for data erasure and writing, the problem of low erasure and upgrade efficiency of Nor Flash is solved and space usage is improved. rate and equipment performance.

CN114138176BActive Publication Date: 2024-08-27ZHEJIANG DAHUA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111084814.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-16
Publication Date
2024-08-27
Estimated Expiration
2041-09-16

AI Technical Summary

Technical Problem

Nor Flash's writing and erasing speeds are low, causing its performance to suffer, and existing erasing methods are less efficient, resulting in wasted space and increased time consumption.

Method used

By determining the corresponding erase instructions according to the starting address and space size of the partition to be erased or upgraded according to the preset rules, using an appropriately sized erase block to erase and write data, and repeating the steps until completion, improving the erasure removal and upgrade efficiency.

Benefits of technology

It effectively improves the space usage and erasure and upgrade efficiency of Nor Flash, reduces time consumption and space waste, and improves the performance of the device.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114138176B
    Figure CN114138176B
Patent Text Reader

Abstract

The present application relates to the field of storage, and in particular to a method, device, computer equipment and storage medium for erasing and upgrading Nor Flash. The erasing method comprises: determining a corresponding erasing instruction according to a preset rule based on the alignment mode of the starting address and the space size of the partition to be erased; erasing data on the corresponding space of the partition to be erased based on the erasing instruction; and repeating the steps of determining the erasing instruction and erasing data until the partition to be erased completes data erasure. The present invention determines a corresponding erasing instruction according to a preset rule based on the alignment mode and the space size of the starting address of the partition to be erased, and erases data on the corresponding space of the partition to be erased, which can effectively improve the space utilization rate of Nor Flash and effectively improve the erasing efficiency of the partition to be erased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of storage, and in particular to a method and device for erasing and upgrading Nor Flash, a computer device, and a storage medium. Background Art

[0002] Nor Flash is one of the two main non-volatile memories on the market. The main feature of Nor Flash is on-chip execution, so that the application can run directly in the Flash memory without having to read the code into the system RAM, but its process is complex and the price is relatively expensive. Nor Flash has a high transmission efficiency and is very cost-effective at a small capacity of 1 to 4MB, but its low write and erase speed greatly affects its performance.

[0003] Generally, for Nor Flash, the erasing mode can be divided into 4k sector erasing, 32k erase block and 64k erase block. In the prior art of erasing Nor Flash, one of several erasing modes is usually selected, and such an erasing method is less efficient. Summary of the invention

[0004] Based on this, it is necessary to provide a Nor Flash erasing and upgrading method and device, computer equipment and storage medium to address the above technical problems.

[0005] In a first aspect, an embodiment of the present invention provides a method for erasing Nor Flash, comprising:

[0006] Based on the alignment mode and space size of the start address of the partition to be erased, a corresponding erase instruction is determined according to a preset rule;

[0007] Erasing data in a corresponding space of the partition to be erased based on the erase instruction;

[0008] Repeat the steps of determining the erase instruction and erasing the data until the data of the partition to be erased is completely erased.

[0009] In this embodiment, based on the alignment method of the starting address and the space size of the partition to be erased, the corresponding erase instruction is determined according to the preset rules, and data is erased for the corresponding space of the partition to be erased, which can effectively improve the Nor Flash space utilization rate and effectively improve the erasing efficiency of the partition to be erased.

[0010] In one embodiment, the step of determining the corresponding erase instruction according to a preset rule based on the alignment mode and space size of the start address of the partition to be erased includes:

[0011] If the space size of the partition to be erased is greater than or equal to the size of the erase block corresponding to the alignment mode of the start address of the partition to be erased, determining the corresponding erase instruction based on the size of the erase block;

[0012] If the space size of the partition to be erased is smaller than the size of the erase block corresponding to the alignment method of the starting address of the partition to be erased, an erase block smaller than or equal to the space size of the partition to be erased is selected from large to small, and the corresponding erase instruction is determined based on the size of the erase block.

[0013] In one embodiment, when the space size of the partition to be erased is 0, it is determined that data erasure of the partition to be erased is completed.

[0014] In a second aspect, an embodiment of the present invention provides a method for upgrading Nor Flash, including:

[0015] Based on the alignment mode and space size of the start address of the partition to be upgraded, a corresponding erase instruction is determined according to a preset rule;

[0016] Based on the erasing instruction, data is erased from the corresponding space of the partition to be upgraded and corresponding upgrade data is written into the space;

[0017] Repeat the steps of determining the erase instruction, erasing the data, and writing the upgrade data until the partition to be upgraded is upgraded.

[0018] In this embodiment, based on the alignment method of the starting address of the partition to be upgraded and the space size, the corresponding erase instruction is determined according to the preset rules, and based on the erase instruction, the corresponding space of the partition to be upgraded is erased and the corresponding upgrade data is written, which can effectively improve the Nor Flash space utilization rate and effectively improve the erasing efficiency of the partition to be upgraded, thereby improving the upgrade efficiency of the Nor Flash.

[0019] In one embodiment, the step of determining the corresponding erase instruction according to a preset rule based on the alignment mode and space size of the start address of the partition to be upgraded includes:

[0020] If the space size of the partition to be upgraded is greater than or equal to the size of the erase block corresponding to the alignment mode of the start address of the partition to be upgraded, determining the corresponding erase instruction based on the size of the erase block;

[0021] If the space size of the partition to be upgraded is smaller than the size of the erase block corresponding to the alignment mode of the starting address of the partition to be upgraded, an erase block smaller than or equal to the space size of the partition to be upgraded is selected from large to small, and the corresponding erase instruction is determined based on the size of the erase block.

[0022] In one embodiment, when the space size of the partition to be upgraded is 0, it is determined that the partition to be upgraded has completed upgrading.

[0023] In a third aspect, an embodiment of the present invention provides a Nor Flash erasing device, comprising:

[0024] A determination module, used to determine a corresponding erase instruction according to a preset rule based on the alignment mode and space size of the start address of the partition to be erased obtained;

[0025] An erasing module, used for erasing data in a corresponding space of the partition to be erased based on the erasing instruction;

[0026] Repeat the steps of determining the erase instruction and erasing the data until the data of the partition to be erased is completely erased.

[0027] In a fourth aspect, an embodiment of the present invention provides a Nor Flash upgrade device, comprising:

[0028] A determination module, used to determine a corresponding erase instruction according to a preset rule based on the alignment mode and space size of the start address of the partition to be upgraded obtained;

[0029] An upgrade module, configured to erase data in a corresponding space of the partition to be upgraded and write corresponding upgrade data based on the erase instruction;

[0030] Repeat the steps of determining the erase instruction, erasing the data, and writing the upgrade data until the partition to be upgraded is upgraded.

[0031] In a fifth aspect, an embodiment of the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0032] Based on the alignment mode and space size of the start address of the partition to be erased, a corresponding erase instruction is determined according to a preset rule;

[0033] Erasing data in a corresponding space of the partition to be erased based on the erase instruction;

[0034] Repeat the steps of determining the erase instruction and erasing the data until the data of the partition to be erased is completely erased.

[0035] Based on the alignment mode and space size of the start address of the partition to be upgraded, a corresponding erase instruction is determined according to a preset rule;

[0036] Based on the erasing instruction, data is erased from the corresponding space of the partition to be upgraded and corresponding upgrade data is written into the space;

[0037] Repeat the steps of determining the erase instruction, erasing the data, and writing the upgrade data until the partition to be upgraded is upgraded.

[0038] In a sixth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the processor executes the computer program, the following steps are implemented:

[0039] Based on the alignment mode and space size of the start address of the partition to be erased, a corresponding erase instruction is determined according to a preset rule;

[0040] Erasing data in a corresponding space of the partition to be erased based on the erase instruction;

[0041] Repeat the steps of determining the erase instruction and erasing the data until the data of the partition to be erased is completely erased.

[0042] Based on the alignment mode and space size of the start address of the partition to be upgraded, a corresponding erase instruction is determined according to a preset rule;

[0043] Based on the erasing instruction, data is erased from the corresponding space of the partition to be upgraded and corresponding upgrade data is written into the space;

[0044] Repeat the steps of determining the erase instruction, erasing the data, and writing the upgrade data until the partition to be upgraded is upgraded. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 An application environment diagram of a Nor Flash upgrade method in one embodiment;

[0046] Figure 2 A schematic diagram of an erasing method in the prior art;

[0047] Figure 3 A schematic diagram of a process of erasing a Nor Flash in one embodiment;

[0048] Figure 4 A schematic diagram of a flow chart of a method for determining an erase instruction in one embodiment;

[0049] Figure 5 is a flowchart of a method for erasing Nor Flash in an exemplary embodiment;

[0050] Figure 6 is a flowchart of a method for upgrading Nor Flash in another embodiment;

[0051] Figure 7 A schematic diagram of a flow chart of a method for determining an erase instruction in another embodiment;

[0052] Figure 8is a flowchart of a method for upgrading Nor Flash in another exemplary embodiment;

[0053] Fig. 9 Schematic diagram of the structure of a Nor Flash erasing device in one embodiment;

[0054] Fig.10 It is a structural schematic diagram of a Nor Flash upgrade device in one embodiment;

[0055] Fig.11 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0056] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0057] The present application provides a method for erasing Nor Flash, which can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The terminal 102 first determines the corresponding erasure instruction according to the preset rules based on the alignment mode of the starting address of the partition to be erased and the size of the space, and erases the data of the corresponding space of the partition to be erased; repeats the steps of determining the erasure instruction and data erasure until the partition to be erased completes the data erasure. The terminal 102 then sends the result of the data erasure to the server 104. Among them, the terminal 102 can be but is not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices, and the server 104 can be implemented with an independent server or a server cluster composed of multiple servers.

[0058] In the prior art, a method for erasing Nor Flash usually selects one of several erasing methods, and such an erasing method is relatively inefficient. Figure 2 The figure is a schematic diagram of an erasing method for erasing a partition in the prior art. Figure 2 The size of the partition to be erased in Nor Flash is 320k, and the actual size used by the software program in the partition to be erased is 257k. If the basic unit of the erase block is configured as 64k, and the size of the last erase block is 1K, then there is a waste of 63k space in the partition to be erased, and erasing 1K of space using a 64k erase block takes longer time than erasing other smaller blocks, resulting in lower Nor Flash erasure efficiency.

[0059] It should be noted that the programming principle of Nor Flash is that 1 can only be written as 0, but 0 cannot be written as 1. Therefore, before upgrading the Flash, the corresponding area must be erased, and the erasing process is the process of writing all bits to 1.

[0060] In one embodiment, if Figure 3 As shown, a method for erasing Nor Flash is provided, and the method is applied to Figure 1 The terminal in is used as an example to illustrate, including the following steps:

[0061] S202: determining a corresponding erase instruction according to a preset rule based on the alignment mode and space size of the start address of the partition to be erased obtained;

[0062] S204: Erasing data in a space corresponding to the partition to be erased based on the erase instruction;

[0063] S206: Repeat the steps of determining the erasing instruction and erasing data until the data of the partition to be erased is completely erased.

[0064] In this embodiment, based on the alignment method of the starting address and the space size of the partition to be erased, the corresponding erase instruction is determined according to the preset rules, and data is erased for the corresponding space of the partition to be erased, which can effectively improve the Nor Flash space utilization rate and effectively improve the erasing efficiency of the partition to be erased.

[0065] When erasing a partition to be erased, it is first necessary to extract the alignment mode and space size of the start address of the partition to be erased.

[0066] In one embodiment, the method of determining the corresponding erase instruction according to a preset rule based on the alignment mode and space size of the start address of the partition to be erased is as follows: Figure 4 As shown, the following steps are included:

[0067] S302: If the space size of the partition to be erased is greater than or equal to the size of the erase block corresponding to the alignment mode of the start address of the partition to be erased, determine a corresponding erase instruction based on the size of the erase block;

[0068] S304: If the space size of the partition to be erased is smaller than the size of the erase block corresponding to the alignment method of the starting address of the partition to be erased, select erase blocks that are smaller than or equal to the space size of the partition to be erased from large to small, and determine the corresponding erase instruction based on the size of the erase block.

[0069] To avoid data erasure anomalies, the size of the erase block needs to correspond to the alignment of the start address of the partition to be erased. For example, when the alignment of the start address of the partition to be erased is 64K, a 64K erase block is preferably used. It is understandable that when the alignment of the start address of the partition to be erased is 64K, a 32K erase block or a 4K erase block can also be used, but the erasure efficiency is low.

[0070] When the space of the partition to be erased meets the requirements, that is, when the space size of the partition to be erased is greater than or equal to the size of the erase block corresponding to the alignment mode of the starting address of the partition to be erased, the erase instruction corresponding to the alignment mode of the starting address of the partition to be erased is preferentially selected for erasing, because the larger the erase block, the higher the erasing efficiency.

[0071] In the case where the space of the partition to be erased does not meet the requirements, that is, the space size of the partition to be erased is smaller than the size of the erase block corresponding to the alignment mode of the starting address of the partition to be erased, usually in the final stage of erasing the partition to be erased, an erase block smaller than or equal to the space size of the partition to be erased is selected from large to small, because the larger the erase block, the higher its erasing efficiency. In view of this situation, the prior art still uses the same size erase block for erasing, which will result in erasing redundant space, causing waste of Nor Flash space, and taking longer erasing time. Therefore, this method can effectively improve the space utilization rate of Nor Flash and the erasing efficiency of Nor Flash.

[0072] In an exemplary embodiment, three erase instructions include an erase block of 4K, an erase block of 32K, and an erase block of 64K, respectively. Figure 5 This is the erase flow chart of Nor Flash, such as Figure 5As shown, first obtain the alignment mode and space size of the starting address of the partition to be erased, and judge whether the space size is 0. If not, judge whether the starting address is 64K aligned. If it is 64K aligned, judge whether the space size of the partition to be upgraded is greater than or equal to 32K and less than 64K. If so, perform 32K erasure on the corresponding space of the partition to be upgraded and write 32K upgrade data, and at the same time increase the starting address by 32K, and subtract 32K from the space size; if not, judge whether the space size of the partition to be upgraded is less than 32K. If so, perform 4K erasure on the corresponding space of the partition to be erased, and at the same time increase the starting address by 4K, and subtract 4K from the space size. If the space of the partition to be upgraded is greater than or equal to 64K, Execute 64K erasure on the corresponding space, and increase the starting address by 64K, and reduce the space size by 64K; if the starting address is not 64K aligned, determine whether the starting address is 32K aligned, and if it is 32K aligned, determine whether the space size of the partition to be upgraded is less than 32K, and if so, execute 4K erasure on the corresponding space of the partition to be erased, and increase the starting address by 4K, and reduce the space size by 4K, and if the space of the partition to be upgraded is greater than or equal to 32K, execute 32K erasure on the corresponding space of the partition to be erased, and increase the starting address by 32K, and reduce the space size by 32K; if the starting address is not 32K aligned, execute 4K erasure on the corresponding space of the partition to be erased, and increase the starting address by 4K, and reduce the space size by 4K. Repeat the above steps until the space size of the partition to be erased is 0, and the erasure of the partition to be erased is completed.

[0073] It can be seen from the above exemplary embodiments that the method selects the erase block size according to the alignment mode of the start address of the partition to be erased and the space size, thereby effectively improving the space utilization rate of the Nor Flash and the erasing efficiency of the Nor Flash.

[0074] In another embodiment, if Figure 6 As shown, a Nor Flash upgrade method is provided, comprising the following steps:

[0075] S502: Based on the alignment mode and space size of the start address of the partition to be upgraded, a corresponding erase instruction is determined according to a preset rule;

[0076] S504: Erasing data in the corresponding space of the partition to be upgraded based on the erasing instruction and writing corresponding upgrade data;

[0077] S506: Repeat the steps of determining the erasing instruction, erasing the data, and writing the upgrade data until the partition to be upgraded is upgraded.

[0078] When upgrading the partition to be upgraded, it is first necessary to erase the data of the partition to be upgraded, and then write the upgrade data into the erased space, so as to realize the upgrade of the Nor Flash.

[0079] In this embodiment, the upgrade data maintains 4K alignment, and the last remaining upgrade data during the upgrade must be 4K, 32K, or 64K in size.

[0080] It can be understood that the erasing method used in this embodiment is the same as the erasing method of Nor Flash used in the above embodiment, and based on the technical effects of the above embodiment, the upgrade method proposed in this embodiment can improve the upgrade efficiency of Nor Flash.

[0081] Among them, based on the alignment mode and space size of the starting address of the partition to be upgraded, a method for determining the corresponding erase instruction according to a preset rule is performed, such as Figure 7 As shown, the following steps are included:

[0082] S602: If the space size of the partition to be upgraded is greater than or equal to the size of the erase block corresponding to the alignment mode of the start address of the partition to be upgraded, determine a corresponding erase instruction based on the size of the erase block;

[0083] S604: If the space size of the partition to be upgraded is smaller than the size of the erase block corresponding to the alignment method of the starting address of the partition to be upgraded, select erase blocks that are smaller than or equal to the space size of the partition to be upgraded from large to small, and determine the corresponding erase instruction based on the size of the erase block.

[0084] It can be understood that the erasing method used in this embodiment is the same as the erasing method of the Nor Flash used in the above embodiment, so its specific implementation scheme and technical effects are not described in detail.

[0085] In an exemplary embodiment, three erase instructions include an erase block of 4K, an erase block of 32K, and an erase block of 64K, respectively. Figure 8 The upgrade flow chart for Nor Flash is as follows: Figure 5As shown, first obtain the alignment mode and space size of the starting address of the partition to be upgraded, and judge whether the space size is 0. If not, judge whether the starting address is 64K aligned. If it is 64K aligned, judge whether the space size of the partition to be upgraded is greater than or equal to 32K and less than 64K. If so, perform 32K erasure on the corresponding space of the partition to be upgraded and write 32K upgrade data, and at the same time increase the starting address by 32K, and subtract 32K from the space size; if not, judge whether the space size of the partition to be upgraded is less than 32K. If so, perform 4K erasure on the corresponding space of the partition to be upgraded and write 4K upgrade data, and at the same time increase the starting address by 4K, and subtract 4K from the space size. If the space of the partition to be upgraded is greater than or equal to 64K, perform 64K erasure on the corresponding space of the partition to be upgraded and write 64K The upgrade data is written to the partition to be upgraded, and the starting address is increased by 64K, and the space size is reduced by 64K; if the starting address is not aligned with 64K, it is determined whether the starting address is aligned with 32K. If it is aligned with 32K, it is determined whether the space size of the partition to be upgraded is less than 32K. If it is, 4K is erased and 4K upgrade data is written to the corresponding space of the partition to be upgraded, and the starting address is increased by 4K, and the space size is reduced by 4K. If the space of the partition to be upgraded is greater than or equal to 32K, 32K is erased and 32K upgrade data is written to the corresponding space of the partition to be upgraded, and the starting address is increased by 32K, and the space size is reduced by 32K; if the starting address is not aligned with 32K, 4K is erased and 4K upgrade data is written to the corresponding space of the partition to be upgraded, and the starting address is increased by 4K, and the space size is reduced by 4K. Repeat the above steps until the space size of the partition to be upgraded is 0, and the erasure of the partition to be upgraded is completed.

[0086] It can be seen from the above exemplary embodiments that this method selects the erase block size according to the alignment mode of the start address of the partition to be upgraded and the space size, thereby effectively improving the space utilization rate of the Nor Flash and the upgrade efficiency of the Nor Flash.

[0087] It should be understood that although the steps in the above flowchart are shown in sequence, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Figure 1-8 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0088] In one embodiment, if Fig. 9As shown, the present invention provides an erasing device for Nor Flash, the device comprising: a determination module 902, for determining a corresponding erasing instruction according to a preset rule based on the alignment mode of the start address of the partition to be erased and the space size; an erasing module 904, for erasing data on the corresponding space of the partition to be erased based on the erasing instruction; and repeating the steps of determining the erasing instruction and erasing data until the data of the partition to be erased is completely erased.

[0089] In one embodiment, the determination module is specifically used for: if the space size of the partition to be erased is greater than or equal to the size of the erase block corresponding to the alignment mode of the starting address of the partition to be erased, then determining the corresponding erase instruction based on the size of the erase block; if the space size of the partition to be erased is smaller than the size of the erase block corresponding to the alignment mode of the starting address of the partition to be erased, then selecting erase blocks that are smaller than or equal to the space size of the partition to be erased from large to small, and determining the corresponding erase instruction based on the size of the erase block; and erasing data in the corresponding space of the partition to be erased based on the erase instruction.

[0090] In one embodiment, when the space size of the partition to be erased is 0, it is determined that the partition to be erased completes data erasure.

[0091] For the specific definition of the erasing device of Nor Flash, please refer to the definition of the erasing method of Nor Flash mentioned above, which will not be repeated here. Each module in the above-mentioned erasing device of Nor Flash can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0092] In another embodiment, if Fig.10 As shown, the present invention provides an upgrade device for Nor Flash, the device comprising: a determination module 1002, used to determine a corresponding erase instruction according to a preset rule based on the alignment mode of the start address and the space size of the partition to be upgraded; an upgrade module 1004, used to erase data in the corresponding space of the partition to be upgraded based on the erase instruction and write corresponding upgrade data; and repeat the steps of determining the erase instruction, erasing data and writing upgrade data until the partition to be upgraded completes the upgrade.

[0093] In one embodiment, the determination module is specifically used for: if the space size of the partition to be upgraded is greater than or equal to the size of the erase block corresponding to the alignment mode of the starting address of the partition to be upgraded, then determining the corresponding erase instruction based on the size of the erase block; if the space size of the partition to be upgraded is smaller than the size of the erase block corresponding to the alignment mode of the starting address of the partition to be upgraded, then selecting erase blocks that are smaller than or equal to the space size of the partition to be upgraded from large to small, and determining the corresponding erase instruction based on the size of the erase block; and erasing data in the corresponding space of the partition to be upgraded based on the erase instruction.

[0094] In one embodiment, when the space size of the partition to be upgraded is 0, it is determined that the partition to be upgraded has completed upgrading.

[0095] The specific definition of the Nor Flash upgrade device can be found in the definition of the Nor Flash upgrade method above, which will not be repeated here. Each module in the above-mentioned Nor Flash upgrade device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0096] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.11 As shown. The computer device includes a processor, a memory and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store motion detection data. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, the steps in any of the above-mentioned Nor Flash erasing method or upgrade method embodiments are implemented.

[0097] Those skilled in the art will understand that Fig.11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0098] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps in any of the above-mentioned Nor Flash erasing method or upgrading method embodiments are implemented.

[0099] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in any of the above-mentioned Nor Flash erasing method or upgrading method embodiments are implemented.

[0100] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0101] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0102] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A method for erasing Nor Flash, characterized in that: include: Based on the alignment mode and space size of the start address of the partition to be erased, a corresponding erase instruction is determined according to a preset rule; Erasing data in a corresponding space of the partition to be erased based on the erase instruction; Repeat the steps of determining the erasing instruction and erasing the data until the data of the partition to be erased is completely erased; The step of determining the corresponding erase instruction according to a preset rule based on the alignment mode and space size of the start address of the partition to be erased comprises: If the space size of the partition to be erased is greater than or equal to the size of the erase block corresponding to the alignment mode of the start address of the partition to be erased, determining the corresponding erase instruction based on the size of the erase block; If the space size of the partition to be erased is smaller than the size of the erase block corresponding to the alignment method of the starting address of the partition to be erased, an erase block smaller than or equal to the space size of the partition to be erased is selected from large to small, and the corresponding erase instruction is determined based on the size of the erase block.

2. The method according to claim 1, characterized in that When the space size of the partition to be erased is 0, it is determined that data erasure of the partition to be erased is completed.

3. A Nor Flash upgrade method, characterized in that: include: Based on the alignment mode and space size of the start address of the partition to be upgraded, a corresponding erase instruction is determined according to a preset rule; Based on the erasing instruction, data is erased from the corresponding space of the partition to be upgraded and corresponding upgrade data is written into the space; Repeat the steps of determining the erase instruction, erasing the data, and writing the upgrade data until the partition to be upgraded is upgraded; The step of determining the corresponding erase instruction according to a preset rule based on the alignment mode and space size of the start address of the partition to be upgraded comprises: If the space size of the partition to be upgraded is greater than or equal to the size of the erase block corresponding to the alignment mode of the start address of the partition to be upgraded, determining the corresponding erase instruction based on the size of the erase block; If the space size of the partition to be upgraded is smaller than the size of the erase block corresponding to the alignment mode of the starting address of the partition to be upgraded, an erase block smaller than or equal to the space size of the partition to be upgraded is selected from large to small, and the corresponding erase instruction is determined based on the size of the erase block.

4. The method according to claim 3, characterized in that When the space size of the partition to be upgraded is 0, it is determined that the partition to be upgraded has completed upgrading.

5. A Nor Flash erasing device, characterized in that: include: A determination module, used to determine a corresponding erase instruction according to a preset rule based on the alignment mode and space size of the start address of the partition to be erased obtained; An erasing module, used for erasing data in a corresponding space of the partition to be erased based on the erasing instruction; Repeat the steps of determining the erasing instruction and erasing the data until the data of the partition to be erased is completely erased; The determination module is specifically used for: if the space size of the partition to be erased is greater than or equal to the size of the erase block corresponding to the alignment mode of the starting address of the partition to be erased, then determining the corresponding erase instruction based on the size of the erase block; if the space size of the partition to be erased is smaller than the size of the erase block corresponding to the alignment mode of the starting address of the partition to be erased, then selecting erase blocks that are smaller than or equal to the space size of the partition to be erased from large to small, and determining the corresponding erase instruction based on the size of the erase block.

6. A Nor Flash upgrade device, characterized in that: include: A determination module, used to determine a corresponding erase instruction according to a preset rule based on the alignment mode and space size of the start address of the partition to be upgraded obtained; An upgrade module, configured to erase data in a corresponding space of the partition to be upgraded and write corresponding upgrade data based on the erase instruction; Repeat the steps of determining the erase instruction, erasing the data, and writing the upgrade data until the partition to be upgraded is upgraded; The determination module is specifically used for: if the space size of the partition to be upgraded is greater than or equal to the size of the erase block corresponding to the alignment mode of the starting address of the partition to be upgraded, then determining the corresponding erase instruction based on the size of the erase block; if the space size of the partition to be upgraded is smaller than the size of the erase block corresponding to the alignment mode of the starting address of the partition to be upgraded, then selecting erase blocks that are smaller than or equal to the space size of the partition to be upgraded from large to small, and determining the corresponding erase instruction based on the size of the erase block.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.