CN106648751B - Method for rapidly upgrading embedded software and embedded equipment - Google Patents

Method for rapidly upgrading embedded software and embedded equipment Download PDF

Info

Publication number
CN106648751B
CN106648751B CN201611046096.0A CN201611046096A CN106648751B CN 106648751 B CN106648751 B CN 106648751B CN 201611046096 A CN201611046096 A CN 201611046096A CN 106648751 B CN106648751 B CN 106648751B
Authority
CN
China
Prior art keywords
data block
data
unit
ith
effective
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.)
Active
Application number
CN201611046096.0A
Other languages
Chinese (zh)
Other versions
CN106648751A (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.)
Shenzhen Launch Software Co Ltd
Original Assignee
Shenzhen Launch Software 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 Shenzhen Launch Software Co Ltd filed Critical Shenzhen Launch Software Co Ltd
Priority to CN201611046096.0A priority Critical patent/CN106648751B/en
Priority to PCT/CN2017/078847 priority patent/WO2018094937A1/en
Publication of CN106648751A publication Critical patent/CN106648751A/en
Application granted granted Critical
Publication of CN106648751B publication Critical patent/CN106648751B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Abstract

The embodiment of the invention discloses a method for rapidly upgrading embedded software and embedded equipment, wherein the method comprises the following steps: determining effective data in a target upgrade file, and dividing the effective data into N effective data blocks; reading the ith effective data block, and detecting whether the effective data block is the same as the original data block; if the data blocks are the same, adding 1 to i to obtain a new value of i, judging whether the new value of i is larger than N, and if not, returning to the step of reading the ith data block; if not, detecting whether the data in the effective data block is composed of the same number in hexadecimal numbers, if so, erasing the original data block, adding 1 to i to obtain a new value i, judging whether the new value i is greater than N, and if not, returning to the step of reading the ith data block; and when the new value i is judged to be larger than N, reading the tail data block of the upgrade file and writing the tail data block into the memory. By adopting the invention, the writing time of the file can be shortened, thereby accelerating the upgrading speed of the embedded software.

Description

Method for rapidly upgrading embedded software and embedded equipment
Technical Field
The invention relates to the technical field of embedded type, in particular to a method for quickly upgrading embedded type software and embedded type equipment.
Background
The embedded software is designed based on an embedded system, is one kind of computer software, consists of programs and documents thereof, can be subdivided into three types of system software, support software and application software, and is an important component of the embedded system. The embedded software is widely applied to the fields of national defense, industrial control, household, business, office, medical treatment and the like, and for example, common mobile phones, palm computers, digital cameras, set top boxes, MP3 players and the like are the results of intelligent modification of traditional products by using the embedded software technology.
In the development process of embedded software, unknown bug bugs may exist, and in the use process of users, the bugs may cause problems such as blocking or flash backing and the like, and software needs to be upgraded to repair the bugs; in addition, the embedded software can also add or adjust certain functions through upgrading, so that the universality and the usability of the software are increased.
At present, many Micro Control Unit (MCU) chips can generally adopt a Bootloader (Bootloader) method to upgrade embedded software, and the main upgrading process is to delete data of an original file from a memory and burn the data of an upgraded file into the memory. When the embedded software is upgraded by adopting the method, the data of all the upgrade files need to be burnt into the memory, and if the upgrade files are large, the time consumed by upgrading is long.
Disclosure of Invention
The embodiment of the invention discloses a method for rapidly upgrading embedded software and embedded equipment, which can shorten the writing time of a file so as to accelerate the upgrading speed of the embedded software.
The first aspect of the present invention also discloses a method for quickly upgrading embedded software and an embedded device, including:
determining effective data in a target upgrade file, and dividing the effective data into N effective data blocks, wherein corresponding relations exist between the N effective data blocks and the M data blocks, and M and N are positive integers;
reading an ith effective data block from the N effective data blocks, and detecting whether the ith effective data block is the same as a jth data block, wherein the jth data block is one of the M data blocks, the ith data block corresponds to the jth data block, and i and j are positive integers;
if the data blocks are the same, adding 1 to the i to obtain a new value of i, judging whether the new value of i is larger than N, if not, returning to the step of reading the ith effective data block from the N effective data blocks;
if not, detecting whether all data in the ith effective data block consist of the same number in hexadecimal numbers 0 to F, if so, erasing the jth data block from a memory unit, executing the step of adding 1 to the i to obtain a new i value, judging whether the new i value is larger than N, and returning to execute the step of reading the ith effective data block from the N effective data blocks when the new i value is smaller than N;
and when the new value i is judged to be larger than N, reading the tail data block of the upgrade file, erasing the tail data block of the original file from the memory unit, and writing the tail data block of the upgrade file into the memory unit.
In an optional implementation, the method further includes:
if it is detected that all data in the ith valid data block do not completely consist of the same number from 0 to F in hexadecimal numbers, erasing the jth data block from the memory unit, writing the ith valid data block into the memory unit, executing the step of adding 1 to the i to obtain a new i value, judging whether the new i value is greater than N, and returning to execute the step of reading the ith valid data block from the N valid data blocks when the new i value is less than N.
In an optional implementation manner, before determining valid data in the target upgrade file, the method further includes:
and reading an end data block of the target upgrade file, and obtaining the size of the effective data from the end data block.
In an optional implementation manner, the determining valid data in the target upgrade file, and dividing the valid data into N valid data blocks includes:
and determining effective data in the target upgrade file according to the size and the preset position of the effective data, and dividing the effective data into N effective data blocks according to the size of the effective data.
In an optional implementation, a size of any one of the N valid data blocks is the same as a size of any one of the M data blocks.
Second aspect the embodiment of the present invention also discloses an embedded device, including:
the processing unit is used for determining effective data in a target upgrade file and dividing the effective data into N effective data blocks, wherein corresponding relations exist between the N effective data blocks and the M data blocks, and M and N are positive integers;
a reading unit, configured to read an ith valid data block from the N valid data blocks;
a detecting unit, configured to detect whether the ith valid data block is the same as a jth data block, where the jth data block is one of the M data blocks, the ith data block corresponds to the jth data block, and i and j are positive integers;
the operation unit is used for adding 1 to the i to obtain a new i value when the ith effective data block is the same as the jth data block;
the judging unit is used for judging whether a new value i is larger than N or not when the arithmetic unit adds 1 to the i to obtain the new value i;
the reading unit is further configured to read the ith valid data block from the N valid data blocks when the judgment result of the judging unit is negative;
the detection unit is further configured to detect whether all data in the ith valid data block consists of the same number of hexadecimal numbers 0 to F when the ith valid data block is different from the jth data block;
an erasing unit, configured to erase the jth data block from the memory unit when all data in the ith valid data block consists of the same number of hexadecimal numbers 0 to F;
the operation unit is further configured to add 1 to i to obtain a new value of i after the erasing unit erases the jth data block from the memory unit;
the judging unit is further used for judging whether a new value i is larger than N or not when the arithmetic unit adds 1 to the i to obtain the new value i;
the reading unit is further configured to read the last data block of the upgrade file when the judgment result of the judging unit is yes;
the erasing unit is further configured to erase the last data block of the original file from the memory unit;
the write-in unit is further configured to write the last data block of the upgrade file into the memory unit.
In an alternative implementation form of the present invention,
the erasing unit is further configured to erase the jth data block from the memory unit when it is detected that all data in the ith valid data block do not all consist of the same number of hexadecimal numbers 0 to F;
the writing unit is further configured to write the ith valid data block into the memory unit after the erasing unit erases the jth data block from the memory unit;
the operation unit is further configured to add 1 to i to obtain a new value of i after the writing unit writes the ith valid data block into the memory unit;
the judging unit is further used for judging whether a new value i is larger than N or not when the arithmetic unit adds 1 to the i to obtain the new value i;
the reading unit is further configured to read the ith valid data block from the N valid data blocks when the determination result of the determining unit is negative.
In an alternative implementation form of the present invention,
the reading unit is further configured to read an end data block of the target upgrade file, and obtain the size of the valid data from the end data block.
In an optional implementation manner, the processing unit determines valid data in a target upgrade file, and a manner of dividing the valid data into N valid data blocks specifically is:
and the processing unit determines the effective number in the target upgrading file according to the size and the preset position of the effective data and divides the effective data into N effective data blocks according to the size of the effective data.
In an alternative implementation form of the present invention,
the size of any one of the N valid data blocks is the same as the size of any one of the M data blocks.
According to the technical scheme, the embodiment of the invention has the following advantages: only the effective data which is not completely composed of the same number of hexadecimal numbers 0 to F in the upgrade file is written into the memory, and other data in the upgrade file is not written into the memory, so that the writing time can be effectively shortened, the upgrade speed of the embedded software is accelerated, and the problem of long time consumption of the upgrade of the embedded software is solved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is a schematic flowchart of a method for rapidly upgrading embedded software according to an embodiment of the present invention;
FIG. 2 is a schematic flowchart of another method for rapidly upgrading embedded software according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an embedded device according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a data storage according to an embodiment of the present invention;
FIG. 5 is a diagram illustrating a data storage according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a file before and after being upgraded according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of another embedded device disclosed in the embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, 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 making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a schematic flowchart of a method for quickly upgrading embedded software according to an embodiment of the present invention, and as shown in fig. 1, the method for quickly upgrading embedded software includes the following steps.
101. And the embedded equipment determines the effective data obtained from the target upgrading file.
Embedded devices may include, but are not limited to: conventional industrial control and commercial management field devices, such as intelligent industrial control devices, Point of sale (POS), Automatic Teller Machines (ATM), Integrated Circuit (IC) cards, and the like; household field equipment, such as a set top box, a digital television, a network refrigerator, a network air conditioner and other consumer and health care electronic equipment; in addition, the system is also applied to multimedia mobile phones, pocket computers, palm computers, vehicle-mounted navigators and the like.
The target upgrade file may also be referred to as a target file or an upgrade file, which is not distinguished in the embodiment of the present invention.
Optionally, the valid data is defined by an embedded system or embedded software containing the valid data, and the valid data is centrally distributed at a certain position of the target upgrade file, such as an initial position of the target upgrade file, or a certain position in the middle; the target upgrading file is a file which needs to be upgraded in the embedded software.
Optionally, the target upgrade file is composed of three parts: for example, referring to fig. 6, in the upgraded target file in fig. 6, the last data includes check bits, such as "31" and "41" in the foregoing, and the data further includes the size of the valid data, which may also be referred to as valid data, which is not distinguished in the embodiment of the present invention, such as "FF, 1C, FD, EF" in the following 4 bytes; the invalid data is data other than the valid data and the last data, such as the partial data composed of FF in fig. 4 and 5, and is defined by the embedded system or the embedded software containing the data before the upgrade.
102. The embedded device divides the effective data into N effective data blocks, wherein the original file comprises M data blocks, and corresponding relations exist between the N effective data blocks and the M data blocks.
Wherein M and N are positive integers of 1 or more.
The data block is a group or a plurality of groups of records which are continuously arranged together in sequence and is a data unit transmitted between the main memory and the input equipment, the output equipment or the external memory; the original file can also be called as an original file and is a file stored in a memory of the embedded device, and the upgrading is to replace the original file with a target upgrading file, that is, to replace the data in the original file completely or by departments with the data in the target upgrading file, wherein the data is defined or described in detail in the following steps.
The above correspondence relationship can be discussed in three cases:
first, if M > N, the N valid data blocks correspond to N data blocks of M data blocks of the original file.
And secondly, if M is equal to N, the N effective data blocks correspond to M data blocks of the original file one by one.
Finally, if M < N, the actual modification range is not large because the embedded software is upgraded, and therefore the size of the valid data in the target upgrade file is small, that is, the possibility that M < N occurs is not high.
103. The embedded device reads the ith valid data block from the N valid data blocks.
In the embodiment of the present invention, the initial value of i is 1, and the 1 st valid data block is read when the first reading is performed.
104. The embedded device detects whether the ith effective data block is the same as the jth data block, wherein the jth data block is one of the M data blocks, and the ith data block corresponds to the jth data block.
Wherein i and j are positive integers and are both greater than 1.
Optionally, the size of any one of the N valid data blocks is the same as the size of any one of the M data blocks.
Optionally, detecting whether the ith valid data block and the jth data block are the same includes: and detecting whether the size and data of the ith valid data block are the same as those of the jth data block.
In the embodiment of the present invention, if the embedded device detects that the ith valid data block is the same as the jth data block, the step of adding 1 to i to obtain a new i value is executed, that is, the jth data block is not erased from the memory unit, nor is the ith valid data block written into the memory, and after adding 1 to i to obtain a new i value (i < N), the step of reading the ith (it is noted that i at this time is a new i value) valid data block is returned; and if the embedded equipment detects that the ith effective data block is different from the jth data block, executing a step of detecting whether all data in the ith effective data block consists of the same number of hexadecimal numbers 0 to F.
105. The embedded device detects whether all data in the ith valid data block consists of the same number from 0 to F in hexadecimal number.
In the embodiment of the present invention, the embedded device detects whether all data in the i valid data blocks are composed of the same number of hexadecimal numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D and F.
106. And the embedded equipment erases the jth data block from the memory unit.
The memory unit is a memory size occupied when one data block is stored, and can be understood as a unit for storing one data block.
The above-mentioned erasing the jth data block from the memory unit can be understood as erasing the data in the jth data block from the memory unit.
In the embodiment of the present invention, if the embedded device detects that all data in the ith valid data block is composed of the same number of hexadecimal numbers 0 to F, the embedded device erases the jth data block from the memory unit, and the ith valid data block is not written into the memory unit. For example, if the valid data of the target upgrade file is the first 10 rows, each row is one data block, that is, there are 10 valid data blocks, and the data in the data blocks of the rows 6 to 10 are all composed of one of hexadecimal numbers 0 to F, it is not required that the data in the data blocks of the rows 6 to 10 are all composed of 0, 1, 2, 3, 4, and 5, respectively. Then, the embedded device erases the jth data block from the memory unit, and the data blocks in rows 6 to 10 are not written into the memory, i.e., erased but not written. The data blocks in the rows 1 to 5 are written into the memory unit after the embedded device erases the jth data block from the memory unit, please refer to fig. 6.
107. And the embedded device adds 1 to i to obtain a new value of i.
Wherein, i is a positive integer less than or equal to N before adding 1, and a new value of i is obtained after adding 1, and the new value of i may be greater than N.
108. The embedded device determines whether the new value of i is greater than N.
In the embodiment of the present invention, the embedded device determines whether the new value i is greater than N, and if the new value i is less than N, the execution returns to step 103, that is, the step of the embedded device reading the ith valid data block from the N valid data blocks is executed; and if the number of the upgrade files is larger than N, executing a step of reading the tail data block of the upgrade files.
109. And the embedded equipment reads the tail data block of the upgrade file.
110. And the embedded equipment erases the tail data block of the original file from the memory unit and writes the tail data block of the upgrade file into the memory unit.
The last data block is a data block at the end of the target upgrade file, and the data block includes check bits, such as "31" and "41" in the foregoing, and also includes the size of valid data, which may also be referred to as valid data.
The erasing of the last data block of the original file from the memory unit may be understood as erasing the data of the last data block of the original file from the memory unit.
In the embodiment of the invention, when the new value i is judged to be larger than N, the embedded device reads the tail data block of the upgrade file, erases the tail data block of the original file from the memory unit, writes the tail data block of the upgrade file into the memory unit, and completes the writing of the target upgrade file after completing the step of writing the tail data block into the memory unit.
In short, the embodiment of the present invention may determine valid data of a target upgrade file, and divide the valid data into N data blocks, where, if a (a < N) data blocks are respectively the same as a data blocks in an original file, the a valid data blocks are not written into a memory, and corresponding original data blocks are not deleted; if the b effective data blocks are different from the data of the original file, and all the data in any one effective data block in the b effective data blocks are composed of the same number from 0 to F in hexadecimal number, the corresponding original data block is erased from the memory, but the b effective data blocks are not written into the memory, wherein a + b is less than or equal to N.
According to the scheme of the embodiment of the invention, the effective data in the upgrade file is determined, the effective data consisting of the same number from 0 to F in hexadecimal number is not written into the memory, and the invalid data is not written into the memory, so that the data written into the memory can be reduced, the writing efficiency is improved, and the writing time is effectively shortened, thereby accelerating the upgrade speed of the embedded software and solving the problem of long time consumption of the upgrade of the embedded software.
Referring to fig. 2, fig. 2 is a schematic flowchart of another method for rapidly upgrading embedded software according to an embodiment of the present invention, and fig. 2 is further optimized based on fig. 1, as shown in fig. 2, the method for rapidly upgrading embedded software includes the following steps.
201. And the embedded equipment reads the tail data block of the target upgrading file and obtains the size of the effective data from the tail data block.
Optionally, the valid data is defined by an embedded system or embedded software containing the valid data, and the valid data is centrally distributed at a certain position of the target upgrade file, such as an initial position of the target upgrade file, or a certain position in the middle; the target upgrading file is a file which needs to be upgraded in the embedded software.
Optionally, the target upgrade file is composed of three parts: valid data, invalid data, and end data. For example, referring to fig. 6, in the upgraded target file in fig. 6, the last data includes check bits, such as "31" and "41" in the foregoing, and the data further includes the size of valid data, which may also be referred to as valid data, which is not distinguished in the embodiment of the present invention, such as "FF, 1C, FD, EF" in the following 4 bytes; the invalid data is data other than the valid data and the last data, such as the partial data composed of FF in fig. 4 and 5, and is defined by the embedded system or the embedded software containing the data before the upgrade.
In the embodiment of the invention, the embedded equipment reads the tail data block of the target upgrade file, and the size of effective data is known from the rear 4 bytes 'FF, 1C, FD, EF' of the tail data block.
202. And the embedded equipment determines the effective data in the target upgrading file according to the size and the preset position of the effective data.
In the embodiment of the invention, the size and the preset position of the effective data determine the effective data in the target upgrading file. The preset position is the initial position of valid data, and the setting of the preset position is set by an embedded system or embedded software containing the data.
203. The embedded device divides the effective data into N effective data blocks according to the size of the effective data.
204. The embedded device reads the ith valid data block from the N valid data blocks.
205. The embedded device detects whether the ith effective data block is the same as the jth data block, wherein the jth data block is one of the M data blocks, and the ith data block corresponds to the jth data block.
206. The embedded device detects whether all data in the ith valid data block consists of the same number from 0 to F in hexadecimal number.
The above-mentioned specific implementation of step 203-.
207. The embedded device erases the jth data block from the memory unit and writes the ith valid data block into the memory unit.
And when the embedded equipment detects that all data in the ith effective data block do not consist of the same number of hexadecimal numbers from 0 to F, erasing the jth data block from the memory unit, and writing the ith effective data block into the memory unit.
208. And the embedded equipment erases the jth data block from the memory unit.
The above-mentioned specific implementation of step 208 may refer to step 106 of the embedded software rapid upgrade method described in fig. 1, and the embodiment of the present invention is not described in detail.
209. And the embedded device adds 1 to i to obtain a new value of i.
210. The embedded device judges whether the value i is larger than N.
211. And the embedded equipment reads the tail data block of the upgrade file.
212. And the embedded equipment erases the tail data block of the original file from the memory unit and writes the tail data block of the upgrade file into the memory unit.
The above-mentioned specific implementation of step 209-.
In short, in the embodiment of the present invention, valid data information is obtained from a last data block of a target upgrade file, valid data of the target upgrade file is determined according to the information, the valid data is divided into N data blocks, and in the N valid data blocks, if a (a < N) data blocks are respectively the same as a data blocks in an original file, the a valid data blocks are not written into a memory, and corresponding original data blocks are not deleted; if the b effective data blocks are different from the data of the original file, and all the data in any one effective data block in the b (b < N) effective data blocks are all composed of the same number from 0 hexadecimal number to F, the corresponding original data block is erased from the memory, but the b effective data blocks are not written into the memory; if all data in any one of the t (t < N) valid data blocks do not consist of the same number from 0 to F in hexadecimal number, the corresponding original data block is erased from the memory, and the b valid data blocks are not written into the memory, wherein a + b + t is N.
Through the scheme of the embodiment of the invention, only the effective data which is not completely composed of the same number from 0 to F in hexadecimal number in the upgrade file can be written into the memory, and the data of the tail data block is written into the memory, while other data, such as the ineffective data and the effective data which is completely composed of the same number from 0 to F in hexadecimal number, are not written into the memory, so that the write-in efficiency can be effectively improved, the write-in time can be shortened, the upgrade speed of the embedded software can be accelerated, and the problem that the time consumed by the upgrade of the embedded software is long can be solved.
Referring to fig. 3, fig. 3 is a schematic structural diagram of an embedded device according to an embodiment of the present invention, and as shown in fig. 3, the embedded device includes:
the processing unit 301 is configured to determine valid data in a target upgrade file, and divide the valid data into N valid data blocks, where the N valid data blocks have a correspondence with the M data blocks, and M and N are positive integers.
A reading unit 302, configured to read an ith valid data block from the N valid data blocks;
a detecting unit 303, configured to detect whether an ith valid data block is the same as a jth data block, where the jth data block is one of M data blocks, the ith data block corresponds to the jth data block, and i and j are positive integers;
an operation unit 304, configured to add 1 to i to obtain a new value of i when the ith valid data block is the same as the jth data block;
a judging unit 305, configured to judge whether the new value of i is greater than N when the arithmetic unit 304 adds 1 to i to obtain the new value of i.
The reading unit 302 is further configured to read an i-th valid data block from the N valid data blocks when the determination result of the determining unit 305 is negative
The detecting unit 303 is further configured to detect whether all data in the ith valid data block is composed of the same number of hexadecimal numbers 0 to F when the ith valid data block is different from the jth data block;
an erasing unit 306, configured to erase the jth data block from the memory unit when all data in the ith valid data block consists of the same number of hexadecimal numbers 0 to F;
the operation unit 304 is further configured to add 1 to i to obtain a new value of i after the erasing unit 306 erases the jth data block from the memory unit.
The determining unit 305 is further configured to determine whether the new value of i is greater than N when the computing unit adds 1 to i to obtain a new value of i.
The reading unit 302 is further configured to read the last data block of the upgrade file when the determination result of the determining unit 305 is yes.
The erasing unit 306 is further configured to erase the last data block of the original file from the memory unit.
A writing unit 307, configured to write the last data block of the upgrade file into the memory unit.
The erasing unit 306 is further configured to erase the jth data block from the memory unit when it is detected that all data in the ith valid data block do not consist of the same number of hexadecimal numbers 0 to F.
The writing unit 307 is further configured to write the i-th valid data block into the memory unit after the erasing unit 306 erases the j-th data block from the memory unit.
The operation unit 304 is further configured to add 1 to i to obtain a new value of i after the writing unit 307 writes the ith valid data block into the memory unit.
The determining unit 305 is further configured to determine whether the new value of i is greater than N when the computing unit 304 adds 1 to i to obtain a new value of i.
The reading unit 302 is further configured to read an i-th valid data block from the N valid data blocks when the determining unit 305 determines that the result is negative.
The reading unit 302 is further configured to read an end data block of the target upgrade file, and obtain the size of valid data from the end data block.
The processing unit 301 determines the valid number in the target upgrade file according to the size and the preset position of the valid data, and divides the valid data into N valid data blocks according to the size of the valid data.
Wherein the size of any one of the N valid data blocks is the same as the size of any one of the M data blocks.
The embedded equipment can execute the following method steps:
(1) the reading unit 302 reads the last data block of the target upgrade file, and obtains the size of valid data from the last data block.
Optionally, the valid data is defined by an embedded system or embedded software containing the valid data, and the valid data is centrally distributed at a certain position of the target upgrade file, such as an initial position of the target upgrade file, or a certain position in the middle; the target upgrading file is a file which needs to be upgraded in the embedded software.
Optionally, the target upgrade file is composed of three parts: valid data, invalid data, and end data. For example, referring to fig. 6, in the upgraded target file in fig. 6, the last data includes check bits, such as "31" and "41" in the foregoing, and the data further includes the size of valid data, which may also be referred to as the length of the valid data, which is not distinguished in the embodiment of the present invention, such as "FF, 1C, FD, EF" in the following 4 bytes; the invalid data is data other than the valid data and the last data, such as the partial data composed of FF in fig. 4 and 5, and is defined by the embedded system or the embedded software containing the data before the upgrade.
In the embodiment of the invention, the embedded equipment reads the tail data block of the target upgrade file, and the size of effective data is known from the rear 4 bytes 'FF, 1C, FD, EF' of the tail data block.
(2) The processing unit 301 determines valid data in the target upgrade file according to the size and the preset position of the valid data.
In the embodiment of the invention, the size and the preset position of the effective data determine the effective data in the target upgrading file. The preset position is the initial position of valid data, and the setting of the preset position is set by an embedded system or embedded software containing the data.
(3) The processing unit 301 divides the valid data into N valid data blocks according to the size of the valid data.
The original file comprises M data blocks, and corresponding relations exist between the N effective data blocks and the M data blocks.
Wherein M and N are positive integers of 1 or more.
The data block is a group or a plurality of groups of records which are continuously arranged together in sequence and is a data unit transmitted between the main memory and the input equipment, the output equipment or the external memory; the original file can also be called as an original file and is a file stored in a memory of the embedded device, and the upgrading is to replace the original file with a target upgrading file, that is, to replace the data in the original file completely or by departments with the data in the target upgrading file, wherein the data is defined or described in detail in the following steps.
The above correspondence relationship can be discussed in three cases:
first, if M > N, the N valid data blocks correspond to N data blocks of M data blocks of the original file.
And secondly, if M is equal to N, the N effective data blocks correspond to M data blocks of the original file one by one.
Finally, if M < N, the actual modification range is not large because the embedded software is upgraded, and therefore the size of the valid data in the target upgrade file is small, that is, the possibility that M < N occurs is not high.
(4) The reading unit 302 reads an ith valid data block from the N valid data blocks.
In the embodiment of the present invention, the initial value of i is 1, and the 1 st valid data block is read when the first reading is performed.
(5) The detecting unit 303 detects whether an ith valid data block is the same as a jth data block, where the jth data block is one of M data blocks, and the ith data block corresponds to the jth data block.
Wherein i and j are positive integers and are both greater than 1.
Optionally, the size of any one of the N valid data blocks is the same as the size of any one of the M data blocks.
Optionally, the detecting unit 303 detects whether the ith valid data block and the jth data block are the same, including: and detecting whether the size and data of the ith valid data block are the same as those of the jth data block.
In the embodiment of the present invention, if the detecting unit 303 detects that the ith valid data block is the same as the jth data block, the step of adding 1 to i to obtain a new i value is executed, that is, the jth data block is not erased from the memory unit, nor the ith valid data block is written into the memory, and after adding 1 to i to obtain a new i value (i < N), the step of reading the ith (it is noted that i at this time is a new i value) valid data block is returned; if the detection unit 303 detects that the ith valid data block is not the same as the jth data block, a step of detecting whether all data in the ith valid data block is composed of the same number of hexadecimal numbers 0 to F is performed.
(6) The detection unit 303 detects whether all data in the ith valid data block are composed of the same number of hexadecimal numbers 0 to F.
In the embodiment of the present invention, the detecting unit 303 detects whether all data in the i valid data blocks are composed of the same number of hexadecimal numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D and F.
(7) The erase unit 306 erases the jth data block from the memory unit, and the write unit 307 writes the ith valid data block into the memory unit.
When the detecting unit 303 detects that all data in the ith valid data block do not consist of the same number of hexadecimal numbers 0 to F, the erasing unit 306 erases the jth data block from the memory unit, and the writing unit 307 writes the ith valid data block into the memory unit.
(8) The erase unit 306 erases the jth data block from the memory cells.
The memory unit is a memory size occupied when one data block is stored, and can be understood as a unit for storing one data block.
The above-mentioned erasing the jth data block from the memory unit can be understood as erasing the data in the jth data block from the memory unit.
In the embodiment of the present invention, if the embedded device detects that all data in the ith valid data block is composed of the same number of hexadecimal numbers 0 to F, the embedded device erases the jth data block from the memory unit, and the ith valid data block is not written into the memory unit. For example, if the valid data of the target upgrade file is the first 10 rows, each row is one data block, that is, there are 10 valid data blocks, and the data in the data blocks of the rows 6 to 10 are all composed of one of hexadecimal numbers 0 to F, it is not required that the data in the data blocks of the rows 6 to 10 are all composed of 0, 1, 2, 3, 4, and 5, respectively. Then, the embedded device erases the jth data block from the memory unit, and the data blocks in rows 6 to 10 are not written into the memory, i.e., erased but not written. The data blocks in the rows 1 to 5 are written into the memory unit after the embedded device erases the jth data block from the memory unit, please refer to fig. 6.
(9) The arithmetic unit 304 adds 1 to i to obtain a new value of i.
Wherein, i is a positive integer less than or equal to N before adding 1, and a new value of i is obtained after adding 1, and the new value of i may be greater than N.
(10) The judgment unit 305 judges whether the value of i is larger than N.
In this embodiment of the present invention, the determining unit 305 determines whether the new value i is greater than N, and if the new value i is less than N, the step returns to the executing step 103, that is, the step of the embedded device reading the ith valid data block from the N valid data blocks is executed; and if the number is larger than N, the reading unit 302 reads the last data block of the upgrade file.
(11) The reading unit 302 reads an end data block of the upgrade file.
(12) The erasing unit 306 erases the last data block of the original file from the memory unit, and the writing unit 307 writes the last data block of the upgrade file into the memory unit.
The last data block is a data block at the end of the target upgrade file, and the data block includes check bits, such as "31" and "41" in the foregoing, and also includes the size of valid data, which may also be referred to as the length of the valid data.
The erasing of the last data block of the original file from the memory unit may be understood as erasing the data of the last data block of the original file from the memory unit.
In the embodiment of the present invention, when it is determined that the new value i is greater than N, the reading unit 302 reads the last data block of the upgrade file, erases the last data block of the original file from the memory unit, writes the last data block of the upgrade file into the memory unit, and completes writing of the target upgrade file after the step of writing the last data block into the memory unit is completed.
In short, in the embodiment of the present invention, valid data information is obtained from a last data block of a target upgrade file, valid data of the target upgrade file is determined according to the information, the valid data is divided into N data blocks, and in the N valid data blocks, if a (a < N) data blocks are respectively the same as a data blocks in an original file, the a valid data blocks are not written into a memory, and corresponding original data blocks are not deleted; if the b effective data blocks are different from the data of the original file, and all the data in any one effective data block in the b (b < N) effective data blocks are all composed of the same number from 0 hexadecimal number to F, the corresponding original data block is erased from the memory, but the b effective data blocks are not written into the memory; if all data in any one of the t (t < N) valid data blocks do not consist of the same number from 0 to F in hexadecimal number, the corresponding original data block is erased from the memory, and the b valid data blocks are not written into the memory, wherein a + b + t is N.
Through the scheme of the embodiment of the invention, only the effective data which is not completely composed of the same number from 0 to F in hexadecimal number in the upgrade file can be written into the memory, and the data of the tail data block is written into the memory, while other data, such as the ineffective data and the effective data which is completely composed of the same number from 0 to F in hexadecimal number, are not written into the memory, so that the write-in efficiency can be effectively improved, the write-in time can be shortened, the upgrade speed of the embedded software can be accelerated, and the problem that the time consumed by the upgrade of the embedded software is long can be solved.
Referring to fig. 7, fig. 7 is a schematic structural diagram of another embedded device according to an embodiment of the present invention, and as shown in fig. 7, the embedded device includes:
an input device 701, an output device 702, a processor 703 and a memory 704, wherein the communication input 701, the output device 702, the processor 703 and the memory 704 are connected by a bus 705.
The input device 701 may be a USB interface, a keyboard, a mouse, or the like.
The output device 702 may be a display screen or an indicator light.
The memory 704 may be a high-speed RAM memory, or may be a non-volatile memory (non-volatile memory), such as a magnetic disk memory. The memory 704 is used for storing a set of program codes, and the input device 701, the output device 702 and the processor 703 are used for calling the program codes stored in the memory 704 to execute the following operations:
the processor 703 is configured to:
upgrading an original file, wherein the original file comprises M data blocks, and the method comprises the following steps:
determining effective data in a target upgrade file, and dividing the effective data into N effective data blocks, wherein the N effective data blocks and the M data blocks have corresponding relations, and M and N are positive integers;
reading an ith effective data block from the N effective data blocks, and detecting whether the ith effective data block is the same as a jth data block, wherein the jth data block is one of the M data blocks, the ith data block corresponds to the jth data block, and i and j are positive integers;
if the data blocks are the same, adding 1 to i to obtain a new value of i, judging whether the new value of i is larger than N, if not, returning to the step of reading the ith effective data block from the N effective data blocks;
if not, detecting whether all data in the ith effective data block consists of the same number of hexadecimal numbers 0 to F, if so, erasing the jth data block from the memory unit, executing a step of adding 1 to i to obtain a new value i, judging whether the new value i is greater than N, and returning to execute the step of reading the ith effective data block from the N effective data blocks when the new value i is less than N;
and when the new value i is judged to be larger than N, reading the tail data block of the upgrade file, erasing the tail data block of the original file from the memory unit, and writing the tail data block of the upgrade file into the memory unit.
Optionally, the processor 703 is further configured to:
and if detecting that all data in the ith valid data block do not consist of the same number in hexadecimal numbers 0 to F, erasing the jth data block from a memory unit, writing the ith valid data block into the memory unit, adding 1 to the i to obtain a new i value, judging whether the new i value is greater than N, and if not, returning to the step of reading the ith data block of the N valid data blocks.
Optionally, the processor 703 is further configured to: before determining valid data in the target upgrade file, the method further comprises:
and reading the tail data block of the target upgrade file, and obtaining the size of the effective data from the tail data block.
Optionally, the processor 703 is further configured to:
and determining effective data in the target upgrade file according to the size and the preset position of the effective data, and dividing the effective data into N effective data blocks according to the size of the effective data.
Wherein a size of any one of the N valid data blocks is the same as a size of any one of the M data blocks.
Through the scheme of the embodiment of the invention, only the effective data which is not completely composed of the same number from 0 to F in hexadecimal number in the upgrade file can be written into the memory, and the data of the tail data block is written into the memory, while other data, such as the ineffective data and the effective data which is completely composed of the same number from 0 to F in hexadecimal number, are not written into the memory, so that the write-in efficiency can be effectively improved, the write-in time can be shortened, the upgrade speed of the embedded software can be accelerated, and the problem that the time consumed by the upgrade of the embedded software is long can be solved.
While the invention has been described in conjunction with specific features and embodiments thereof, it will be evident that various modifications and combinations can be made thereto without departing from the spirit and scope of the invention. Accordingly, the specification and figures are merely exemplary of the invention as defined in the appended claims and are intended to cover any and all modifications, variations, combinations, or equivalents within the scope of the invention. It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (10)

1. A method for rapidly upgrading embedded software is characterized in that the method is used for upgrading an original file, the original file comprises M data blocks, and the method comprises the following steps:
determining effective data in a target upgrade file, and dividing the effective data into N effective data blocks, wherein corresponding relations exist between the N effective data blocks and the M data blocks, and M and N are positive integers;
reading an ith effective data block from the N effective data blocks, and detecting whether the ith effective data block is the same as a jth data block, wherein the jth data block is one of the M data blocks, the ith data block corresponds to the jth data block, and i and j are positive integers;
if the data blocks are the same, adding 1 to the i to obtain a new value of i, judging whether the new value of i is larger than N, if not, returning to the step of reading the ith effective data block from the N effective data blocks;
if not, detecting whether all data in the ith effective data block consist of the same number in hexadecimal numbers 0 to F, if so, erasing the jth data block from a memory unit, executing the step of adding 1 to the i to obtain a new i value, judging whether the new i value is larger than N, and returning to execute the step of reading the ith effective data block from the N effective data blocks when the new i value is smaller than N;
and when the new value i is judged to be larger than N, reading the tail data block of the upgrade file, erasing the tail data block of the original file from the memory unit, and writing the tail data block of the upgrade file into the memory unit.
2. The method of claim 1, further comprising:
if it is detected that all data in the ith valid data block do not completely consist of the same number from 0 to F in hexadecimal numbers, erasing the jth data block from the memory unit, writing the ith valid data block into the memory unit, executing the step of adding 1 to the i to obtain a new i value, judging whether the new i value is greater than N, and returning to execute the step of reading the ith valid data block from the N valid data blocks when the new i value is less than N.
3. The method of claim 1, wherein before determining valid data in the target upgrade file, the method further comprises:
and reading an end data block of the target upgrade file, and obtaining the size of the effective data from the end data block.
4. The method of claim 3, wherein the determining valid data in the target upgrade file and dividing the valid data into N valid data blocks comprises:
and determining effective data in the target upgrade file according to the size and the preset position of the effective data, and dividing the effective data into N effective data blocks according to the size of the effective data.
5. The method according to any one of claims 1 to 4,
the size of any one of the N valid data blocks is the same as the size of any one of the M data blocks.
6. An embedded device, comprising:
the processing unit is used for determining effective data in a target upgrade file and dividing the effective data into N effective data blocks, the original file comprises M data blocks, corresponding relations exist between the N effective data blocks and the M data blocks, and M and N are positive integers;
a reading unit, configured to read an ith valid data block from the N valid data blocks;
a detecting unit, configured to detect whether the ith valid data block is the same as a jth data block, where the jth data block is one of the M data blocks, the ith data block corresponds to the jth data block, and i and j are positive integers;
the operation unit is used for adding 1 to the i to obtain a new i value when the ith effective data block is the same as the jth data block;
the judging unit is used for judging whether a new value i is larger than N or not when the arithmetic unit adds 1 to the i to obtain the new value i;
the reading unit is further configured to read the ith valid data block from the N valid data blocks when the judgment result of the judging unit is negative;
the detection unit is further configured to detect whether all data in the ith valid data block consists of the same number of hexadecimal numbers 0 to F when the ith valid data block is different from the jth data block;
an erasing unit, configured to erase the jth data block from the memory unit when all data in the ith valid data block consists of the same number of hexadecimal numbers 0 to F;
the operation unit is further configured to add 1 to i to obtain a new value of i after the erasing unit erases the jth data block from the memory unit;
the judging unit is further used for judging whether a new value i is larger than N or not when the arithmetic unit adds 1 to the i to obtain the new value i;
the reading unit is further configured to read the last data block of the upgrade file when the judgment result of the judging unit is yes;
the erasing unit is further used for erasing a tail data block of the original file from the memory unit;
and the writing unit is used for writing the tail data block of the upgrade file into the memory unit.
7. The apparatus of claim 6,
the erasing unit is further configured to erase the jth data block from the memory unit when it is detected that all data in the ith valid data block do not all consist of the same number of hexadecimal numbers 0 to F;
the writing unit is further configured to write the ith valid data block into the memory unit after the erasing unit erases the jth data block from the memory unit;
the operation unit is further configured to add 1 to i to obtain a new value of i after the writing unit writes the ith valid data block into the memory unit;
the judging unit is further used for judging whether a new value i is larger than N or not when the arithmetic unit adds 1 to the i to obtain the new value i;
the reading unit is further configured to read the ith valid data block from the N valid data blocks when the determination result of the determining unit is negative.
8. The apparatus of claim 6,
the reading unit is further configured to read an end data block of the target upgrade file, and obtain the size of the valid data from the end data block.
9. The device according to claim 8, wherein the processing unit determines valid data in the target upgrade file, and the dividing the valid data into N valid data blocks is specifically performed by:
and the processing unit determines the effective number in the target upgrading file according to the size and the preset position of the effective data and divides the effective data into N effective data blocks according to the size of the effective data.
10. The apparatus according to any one of claims 6 to 9,
the size of any one of the N valid data blocks is the same as the size of any one of the M data blocks.
CN201611046096.0A 2016-11-22 2016-11-22 Method for rapidly upgrading embedded software and embedded equipment Active CN106648751B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201611046096.0A CN106648751B (en) 2016-11-22 2016-11-22 Method for rapidly upgrading embedded software and embedded equipment
PCT/CN2017/078847 WO2018094937A1 (en) 2016-11-22 2017-03-30 Quick upgrade method for embedded software and embedded device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611046096.0A CN106648751B (en) 2016-11-22 2016-11-22 Method for rapidly upgrading embedded software and embedded equipment

Publications (2)

Publication Number Publication Date
CN106648751A CN106648751A (en) 2017-05-10
CN106648751B true CN106648751B (en) 2020-04-21

Family

ID=58811820

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611046096.0A Active CN106648751B (en) 2016-11-22 2016-11-22 Method for rapidly upgrading embedded software and embedded equipment

Country Status (2)

Country Link
CN (1) CN106648751B (en)
WO (1) WO2018094937A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107577474B (en) * 2017-09-12 2020-07-10 海信视像科技股份有限公司 Processing method and device for upgrading file and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101211265A (en) * 2006-12-28 2008-07-02 英华达(上海)电子有限公司 Terminal embedded type system software update method and apparatus
CN101290571A (en) * 2007-04-16 2008-10-22 阮建辉 Method for creating file being dynamically loaded and performed
CN101334734A (en) * 2007-06-27 2008-12-31 北京中电华大电子设计有限责任公司 Scheme for electric communication card dynamically downloading patch program
CN101937340A (en) * 2009-06-29 2011-01-05 中兴通讯股份有限公司 Method and device for dynamically updating and controlling software by using patches

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090222497A1 (en) * 2008-02-29 2009-09-03 Schlumberger Technology Corp. Method, system and apparatus for remote software upgrade of an embedded device
CN102662700B (en) * 2012-03-28 2016-02-03 广东欧珀移动通信有限公司 A kind of issue of embedded software version and upgrade method
CN102929669B (en) * 2012-10-29 2016-11-16 北京开元智信通软件有限公司 A kind of embedded software upgrade method, system and device
TWI557744B (en) * 2015-01-27 2016-11-11 緯創資通股份有限公司 Data storing method and embedded system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101211265A (en) * 2006-12-28 2008-07-02 英华达(上海)电子有限公司 Terminal embedded type system software update method and apparatus
CN101290571A (en) * 2007-04-16 2008-10-22 阮建辉 Method for creating file being dynamically loaded and performed
CN101334734A (en) * 2007-06-27 2008-12-31 北京中电华大电子设计有限责任公司 Scheme for electric communication card dynamically downloading patch program
CN101937340A (en) * 2009-06-29 2011-01-05 中兴通讯股份有限公司 Method and device for dynamically updating and controlling software by using patches

Also Published As

Publication number Publication date
CN106648751A (en) 2017-05-10
WO2018094937A1 (en) 2018-05-31

Similar Documents

Publication Publication Date Title
US9176865B2 (en) Data writing method, memory controller, and memory storage device
US8296466B2 (en) System, controller, and method thereof for transmitting data stream
CN104714893A (en) Method and system for garbage collection scaling
CN110718264A (en) Method and device for testing information of solid state disk, computer equipment and storage medium
CN112445729B (en) Operation address determination method, PCIe system, electronic device and storage medium
CN110673789B (en) Metadata storage management method, device, equipment and storage medium of solid state disk
TW201519242A (en) Data writing method, memory storage device and memory controlling circuit unit
CN111209257B (en) File system fragmentation method and device
CN105224238B (en) Storage management method, memory storage apparatus and memorizer control circuit unit
CN114996173A (en) Method and device for managing write operation of storage equipment
CN106648751B (en) Method for rapidly upgrading embedded software and embedded equipment
KR102330394B1 (en) Method for operating controller and method for operating device including the same
CN111597009A (en) Application program display method and device and terminal equipment
CN111444117B (en) Method and device for realizing fragmentation of storage space, storage medium and electronic equipment
CN109298809A (en) A kind of touch action recognition methods, device and terminal device
CN111143240B (en) Image storage method, system and terminal equipment
CN110058938B (en) Memory processing method and device, electronic equipment and readable medium
CN105117168A (en) Information processing method and electronic equipment
US20120303879A1 (en) Memory Device and Method for Programming Flash Memory Utilizing Spare Blocks
CN113272785B (en) Method for mounting file system, terminal equipment and storage medium
CN110704139B (en) Icon classification method and device
CN109104481B (en) File integrity detection method, file integrity detection device and terminal equipment
CN111562983A (en) Memory optimization method and device, electronic equipment and storage medium
CN109885491B (en) Method for detecting existence of data overflow expression and terminal equipment
US9268554B2 (en) Controlling method, memory controller, and data transmission system

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