WO2018094937A1 - Quick upgrade method for embedded software and embedded device - Google Patents

Quick upgrade method for embedded software and embedded device Download PDF

Info

Publication number
WO2018094937A1
WO2018094937A1 PCT/CN2017/078847 CN2017078847W WO2018094937A1 WO 2018094937 A1 WO2018094937 A1 WO 2018094937A1 CN 2017078847 W CN2017078847 W CN 2017078847W WO 2018094937 A1 WO2018094937 A1 WO 2018094937A1
Authority
WO
WIPO (PCT)
Prior art keywords
valid data
data block
unit
valid
data
Prior art date
Application number
PCT/CN2017/078847
Other languages
French (fr)
Chinese (zh)
Inventor
刘均
周宁杰
Original Assignee
深圳市元征软件开发有限公司
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 深圳市元征软件开发有限公司 filed Critical 深圳市元征软件开发有限公司
Publication of WO2018094937A1 publication Critical patent/WO2018094937A1/en

Links

Classifications

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

Definitions

  • the present invention relates to the field of embedded technologies, and in particular, to a method for quickly upgrading embedded software and an embedded device.
  • Embedded software is software based on embedded system design. It is a kind of computer software. It consists of programs and their documents. It can be subdivided into system software, supporting software and application software. It is an embedded system. An important part of. Embedded software is widely used in defense, industrial control, home, commercial, office, medical and other fields. For example, our common mobile phones, handheld computers, digital cameras, set-top boxes, MP3 players, etc. are all embedded products using traditional software technology. The result of intelligent transformation.
  • Embedded software can also be upgraded to add or adjust certain features to increase the versatility and usability of the software.
  • MCU Micro Control Unit
  • Bootstrap loader Bootloader
  • the main upgrade process is to delete the data of the original file. Delete in memory, and burn the data of the upgrade file into the memory. To upgrade the embedded software in this way, you need to burn the data of all the upgrade files into the memory. If the upgrade file is large, the upgrade will take a long time.
  • the embodiment of the invention discloses a method for quickly upgrading an embedded software and an embedded device, which can shorten the file writing time, so as to speed up the upgrading speed of the embedded software.
  • the first aspect of the present invention also discloses a method for quickly upgrading an embedded software and an embedded device.
  • the i is incremented by 1 to obtain a new i value, and it is determined whether the new i value is greater than N. If not, returning to perform the reading of the i th from the N valid data blocks. Steps of valid data blocks;
  • the method further includes:
  • the j-th data block is wiped from the memory unit Dividing, and writing the i-th valid data block to the memory unit, performing the step of adding 1 to the i to obtain a new i value, determining whether the new i value is greater than N, and The new i value is less than N ⁇ , and the step of reading the ith valid data block from the N valid data blocks is performed.
  • the method before the determining the valid data in the target upgrade file, the method further includes:
  • the determining the valid data in the target upgrade file, and dividing the valid data into N valid data blocks includes:
  • the size of the valid data block of any one of the N valid data blocks It is the same size as any one of the M data blocks.
  • the second aspect of the present invention also discloses an embedded device, including:
  • the processing unit is configured to determine valid data in the target upgrade file, and divide the valid data into N valid data blocks, where there is a correspondence between the N valid data blocks and the M data blocks.
  • M and the N are both positive integers;
  • a reading unit configured to read the i th valid data block from the N valid data blocks
  • a detecting unit configured to detect whether the i-th valid data block is the same as the j-th data block, the j-th data block is one of the M data blocks, and the i-th data a block corresponding to the jth data block, wherein the i and the j are both positive integers;
  • an operation unit configured to: when the i-th valid data block is the same as the j-th data block, add 1 to a new i value;
  • a determining unit configured to: when the computing unit adds 1 to the new i value, to determine whether the new i value is greater than N;
  • the reading unit is further configured to: when the determining unit determines that the result is negative, read the i th valid data block from the N valid data blocks;
  • the detecting unit is further configured to: when the i-th valid data block is different from the j-th data block, detecting whether all data in the i-th valid data block is all hexadecimal Number 0 to F in the same number
  • an erasing unit configured to: when all data in the i-th valid data block is composed of the same number in hexadecimal numbers 0 to F, the j-th data block is Memory unit erase;
  • the operation unit is further configured to: after the erasing unit erases the jth data block from the memory unit, add the i to 1 to obtain a new i value;
  • the determining unit is further configured to: when the computing unit adds 1 to the new i value, to determine whether the new value of i is greater than N;
  • the reading unit is further configured to: when the determining unit determines that the result is ⁇ , read a data block at the end of the upgrade file;
  • the erasing unit is further configured to erase the end data block of the original file from the memory unit; [0035] the writing unit is further used for the end data block of the upgrade file Write to the memory unit. [0036] In an alternative implementation,
  • the erasing unit is further configured to: when detecting that all data in the i-th valid data block is not completely composed of the same number in hexadecimal numbers 0 to F, the jth The data block is erased from the memory unit; [0038] the writing unit is further configured to: after the erasing unit erases the jth data block from the memory unit, Writing an i-th valid data block to the memory unit;
  • the operation unit is further configured to: after the writing unit writes the i th valid data block into the memory unit, add the i to 1 to obtain a new i value;
  • the determining unit is further configured to: when the computing unit adds the i to 1 to obtain a new value of i, determine whether the new value of i is greater than N;
  • the reading unit is further configured to: when the determining unit determines that the result is negative, read the i th valid data block from the N valid data blocks.
  • the reading unit is further configured to read a data block at the end of the target upgrade file, and obtain a size of the valid data from the last data block.
  • the processing unit determines valid data in the target upgrade file, and the manner of dividing the valid data into N valid data blocks is specifically:
  • the processing unit determines a valid number in the target upgrade file according to the size of the valid data and a preset position, and divides the valid data into N valid data blocks according to the size of the valid data. .
  • 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 embodiment of the present invention has the following advantages: only valid data in the upgrade file that is not completely composed of the same number of hexadecimal numbers 0 to F is written into the memory, in the upgrade file. The other data is not written into the memory, which can effectively shorten the writing time, speed up the upgrade of the embedded software, and solve the problem of the long time of the embedded software upgrade.
  • FIG. 1 is a schematic flowchart of a method for rapidly upgrading an embedded software according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of another method for quickly upgrading an 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 schematic diagram of a data storage according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of a file before and after upgrading according to an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of another embedded device according to an embodiment of the present invention.
  • FIG. An embodiment All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without making creative labor are within the scope of the present invention.
  • FIG. 1 is a schematic flowchart of a method for rapidly upgrading an embedded software according to an embodiment of the present invention. As shown in FIG. 1, the method for rapidly upgrading an embedded software includes the following steps.
  • the embedded device determines valid data obtained in the target upgrade file.
  • Embedded devices may include, but are not limited to: traditional industrial control and business management equipment, such as smart industrial equipment, point of sale (POS), automatic teller machine (ATM), integration Integrated circuit card (IC) card, etc.; home field devices, such as set-top boxes, digital TVs, network refrigerators, network air conditioners, and many other consumer and healthcare electronic devices; in addition, multimedia phones, pocket computers, handheld computers , car navigator, etc.
  • traditional industrial control and business management equipment such as smart industrial equipment, point of sale (POS), automatic teller machine (ATM), integration Integrated circuit card (IC) card, etc.
  • home field devices such as set-top boxes, digital TVs, network refrigerators, network air conditioners, and many other consumer and healthcare electronic devices
  • multimedia phones pocket computers, handheld computers , car navigator, etc.
  • the target upgrade file may also be referred to as an object file or an upgrade file, which is not distinguished in the embodiment of the present invention.
  • the valid data is defined by an embedded system or an embedded software that includes the valid data, where the valid data is distributed in a certain location of the target upgrade file, such as a starting position of the target upgrade file, or a middle Location; wherein, the target upgrade file is a file that needs to be upgraded in the above embedded software.
  • the target upgrade file is composed of three parts: valid data, invalid data, and last number
  • the end data is the data at the end of the target upgrade file.
  • the end data includes check digits, such as the previous "31 and 41"
  • the data also includes the size of the valid data, which may also be referred to as valid data. It is not distinguished in the embodiment of the present invention, such as the following four bytes "FF, 1C, FD, EF"; wherein, the invalid data is in addition to the valid data.
  • the data outside the end data as shown in Figure 4 and Figure 5, the partial data consisting of FF, which has been defined by the embedded system or the embedded software containing the data before the upgrade.
  • the embedded device divides the valid data into N valid data blocks, where the original file includes M data blocks, and there is a correspondence between the N valid data blocks and the M data blocks.
  • M and N are positive integers greater than or equal to 1.
  • the data block is a group or groups of records continuously arranged in sequence, and is a data unit for transferring between the main memory and the input device, the output device, or the external memory;
  • the original file may also be referred to as
  • the original file is a file stored in the memory of the embedded device.
  • the original file is replaced with the target upgrade file, and the data in the original file is completely or replaced with the data in the target upgrade file.
  • the definition or description is specifically defined or described in the following steps.
  • the embedded device reads the i th valid data block from the N valid data blocks.
  • the initial value of the above i is 1, and the first valid data block is read when the first reading is performed.
  • the embedded device detects whether the i-th valid data block is the same as the j-th data block, the j-th data block is one of M data blocks, and the i-th data block corresponds to the j-th data block. .
  • i and j are both positive integers, and both are greater than one.
  • 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.
  • detecting whether the i-th valid data block is identical to the j-th data block comprises: detecting whether the size and data of the i-th valid data block are the same as the size and data of the j-th data block.
  • the embedded device detects that the i-th valid data block is the same as the j-th data block, the step of performing i plus 1 to obtain a new i value is performed, that is, the j-th data is not to be The block is erased from the memory unit, and the i-th valid data block is not written to the memory.
  • the new i value (i ⁇ N) is returned, and the i-th reading is returned (notably, this ⁇ i is the new i value) valid data block; if the embedded device detects that the i-th valid data block is different from the j-th data block, then it is performed to detect whether all data in the i-th valid data block is full A step consisting of the same number in hexadecimal numbers 0 through F.
  • the embedded device detects whether all data in the i-th valid data block is composed of the same number in hexadecimal numbers 0 to F.
  • the embedded device detects whether all data in the i valid data blocks are all hexadecimal numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, The same number in A, B, C, D, and F.
  • the embedded device erases the jth data block from the memory unit.
  • the memory unit is a memory size occupied by storing one data block, and can be understood as a unit for storing one data block.
  • the above erasing of the jth data block from the memory unit can be understood as erasing the data in the jth data block from the memory unit.
  • the embedded device if the embedded device detects that all data in the i-th valid data block is composed of the same number in hexadecimal numbers 0 to F, the embedded device will use the j-th data.
  • the block is erased from the memory unit and the ith valid data block is not written to the memory unit. For example, if the valid data of the target upgrade file is the first 10 rows, there are 10 valid data blocks for each data block, and the data in the 6th to 10th rows of data blocks are all hexadecimal numbers 0. To a certain number of F, it is possible to make the data of the 6th to 10th data blocks all consist of 0, 1, 2, 3, 4 and 5.
  • the embedded device erases the jth data block from the memory unit, and the 6th to 10th data blocks are not written into the memory, that is, erased, but not written.
  • the data blocks of the first row to the fifth row are written to the memory cell after the embedded device erases the jth data block from the memory cell, as shown in FIG. 6.
  • the embedded device adds i to 1 to obtain a new i value.
  • i is a positive integer less than or equal to N before adding 1, and a new i value is obtained when 1 is added, the new i The value may be greater than N.
  • the embedded device determines whether the new value of i is greater than N.
  • the embedded device determines whether the new i value is greater than N, and if it is less than N, returns to step 103, that is, executing the embedded device to read the i th valid data from the N valid data blocks.
  • the embedded device reads the end data block of the upgrade file.
  • the embedded device erases the end data block of the original file from the memory unit, and writes the end data block of the upgrade file to the memory unit.
  • the last data block is a data block at the end of the target upgrade file, and the data block includes a check digit, such as the foregoing "31 and 41", and also includes the size of the valid data, which may also be called For the valid data, no distinction is made in the embodiment of the present invention, such as the following four bytes "FF, 1C, FD, EF".
  • the embedded device when it is determined that the new i value is greater than N ⁇ , the embedded device reads the end data block of the upgrade file, and erases the end data block of the original file from the memory unit, and the file is upgraded. The last data block is written to the memory unit, and after the step of writing the last data block to the memory unit, the writing of the target upgrade file is completed.
  • the embodiment of the present invention can determine valid data of the target upgrade file, and divide the valid data into N data blocks, if there are a (a ⁇ N) data blocks respectively. Same as a data block in the original file, the a valid data block is not written into the memory, and the corresponding original data block is not deleted; if the b valid data blocks are different from the original file, and b All data in any valid data block of the valid data block is composed of the same number in hexadecimal numbers 0 to F, then the corresponding original data block is erased from the memory, but the above b valid data The block is not written to memory, where a+b ⁇ N.
  • valid data in the upgrade file is determined, and valid data consisting of the same number of hexadecimal numbers 0 to F is not written into the memory, and invalid data is not written into the memory. It can reduce the data written in the memory, improve the writing efficiency, effectively shorten the writing time, thereby speeding up the upgrade speed of the embedded software, and solving the problem that the embedded software upgrade takes a long time.
  • FIG. 2 is a flow chart of another method for quickly upgrading embedded software according to an embodiment of the present invention. Schematic diagram, FIG. 2 is further optimized based on FIG. 1. As shown in FIG. 2, the method for quickly upgrading the embedded software includes the following steps.
  • the embedded device reads the end data block of the target upgrade file, and obtains the size of the valid data from the last data block.
  • the valid data is defined by an embedded system or an embedded software that includes the valid data, where the valid data is distributed in a certain location of the target upgrade file, such as a starting position of the target upgrade file, or a middle Location; wherein, the target upgrade file is a file that needs to be upgraded in the above embedded software.
  • the foregoing target upgrade file is composed of three parts: valid data, invalid data, and last data.
  • the end data is the data at the end of the target upgrade file.
  • the end data includes check digits, such as the previous "31 and 41", the data Also included is 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 the following four bytes "FF, 1C, FD, EF"; wherein, invalid data is in addition to valid data and the end Data outside the data, such as partial data consisting of FFs in Figures 4 and 5, which have been defined by the embedded system or embedded software containing the data prior to the upgrade.
  • the embedded device reads the end data block of the target upgrade file, and knows the size of the valid data from the last four bytes "FF, 1C, FD, EF" of the last data block.
  • the embedded device determines valid data in the target upgrade file according to the size of the valid data and the preset location.
  • the size of the valid data and the preset location determine valid data in the target upgrade file.
  • the preset position is the starting position of the valid data, and its setting is determined by the embedded system or embedded software containing the data.
  • the embedded device divides the valid data into N valid data blocks according to the size of the valid data.
  • the embedded device reads the i th valid data block from the N valid data blocks.
  • the embedded device detects whether the i-th valid data block is the same as the j-th data block, the j-th data block is one of M data blocks, and the i-th data block corresponds to the j-th data block. .
  • the embedded device detects whether all data in the i-th valid data block is composed of the same number in hexadecimal numbers 0 to F.
  • the embedded device erases the jth data block from the memory unit, and writes the i-th valid data block into the memory unit.
  • the embedded device detects that all data in the i-th valid data block is not completely composed of the same number in hexadecimal numbers 0 to F, the j-th data block is erased from the memory unit, and The i-th valid data block is written to the memory unit.
  • the embedded device erases the jth data block from the memory unit.
  • step 208 may refer to the step 106 of the embedded software rapid upgrade method described in FIG. 1 , which is not described in detail in the embodiment of the present invention.
  • the embedded device adds i to 1 to obtain a new value of i.
  • the embedded device determines whether the value of i is greater than N.
  • the embedded device reads the end data block of the upgrade file.
  • the embedded device erases the end data block of the original file from the memory unit, and writes the end data block of the upgrade file to the memory unit.
  • steps 209-212 may refer to steps 107-110 of the embedded software rapid upgrade method described in FIG. 1, which are not detailed in the embodiments of the present invention.
  • the embodiment of the present invention obtains valid data information from the end data block of the target upgrade file, determines valid data of the target upgrade file according to the information, and divides the valid data into N data blocks and N valid data.
  • a (a ⁇ N) data blocks are the same as a data block in the original file, the a valid data block is not written into the memory, and the corresponding original data block is not deleted;
  • b valid data blocks are different from the original file data, and all data in any valid data block in b (b ⁇ N) valid data blocks are all composed of the same number in hexadecimal numbers 0 to F , the corresponding original data block is erased from the memory, but the above b valid data blocks are not written into the memory; if all data in any valid data block of t (t ⁇ N) valid data blocks is not all ten When the hexadecimal numbers 0 to F are composed of the same number, the corresponding original data block is erased from the memory, and the above b valid
  • the processing unit 301 is configured to determine valid data in the target upgrade file, and divide the valid data into N valid data blocks, where the N valid data blocks and the M data blocks have a corresponding relationship.
  • the reading unit 302 is configured to read the i th valid data block from the N valid data blocks;
  • the detecting unit 303 is configured to detect whether the i-th valid data block is the same as the j-th data block, and the j-th data block is one of the M data blocks, the i-th data block and the j-th data block. Correspondingly, i and j are both positive integers; [0124] an operation unit 304, configured to: when the ith valid data block is the same as the jth data block, add i to 1 to obtain a new i value;
  • the determining unit 305 is configured to: when the computing unit 304 adds i to 1 to obtain a new value of i, determine whether the new value of i is greater than ⁇
  • the reading unit 302 is further configured to: when the determining unit 305 determines that the result is negative, read the i-th valid data block from the N valid data blocks.
  • the detecting unit 303 is further configured to: when the i-th valid data block is different from the j-th data block, detecting whether all data in the i-th valid data block is all hexadecimal 0 to F The same number in the middle;
  • the erasing unit 306 is configured to: when all the data in the i-th valid data block is composed of the same number in the hexadecimal numbers 0 to F, the j-th data block is wiped from the memory unit Save
  • the operation unit 304 is further configured to: after the erasing unit 306 erases the jth data block from the memory unit, add 1 to 1 to obtain a new value of i.
  • the determining unit 305 is further configured to: when the computing unit adds the above i to get a new i value, determine whether the new i value is greater than N.
  • the reading unit 302 is further configured to read the end data block of the upgrade file when the determining unit 305 determines that the result is ⁇ .
  • the above-mentioned erasing unit 306 is further configured to erase the end data block of the original file from the memory unit [0133]
  • the writing unit 307 writes the last data block for the above upgrade file into the above memory unit.
  • the above-mentioned erasing unit 306 is further configured to: when detecting that all data in the i-th valid data block is not completely composed of the same number in the hexadecimal numbers 0 to F, the j-th data block is from the memory Erase in the cell.
  • the writing unit 307 is further configured to write the i th valid data block to the memory unit after the erasing unit 306 erases the jth data block from the memory unit.
  • the operation unit 304 is further configured to add i to 1 to obtain a new value of i after the writing unit 307 writes the i-th valid data block to the memory unit.
  • the determining unit 305 is further configured to: when the computing unit 304 adds the above i to get a new i value, determine whether the new i value is greater than N.
  • the reading unit 302 is further configured to: when the determining unit 305 determines that the result is negative, read the i th valid data block from the N valid data blocks.
  • the reading unit 302 is further configured to read the end data block of the target upgrade file, and obtain the size of the valid data from the last data block.
  • the processing unit 301 determines a valid number in the target upgrade file according to the size of the valid data and a preset position, and divides the valid data into N valid data blocks according to the size of the valid data.
  • 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 reading unit 302 reads the end data block of the target upgrade file, and obtains the size of the valid data from the last data block.
  • the valid data is defined by an embedded system or an embedded software that includes the valid data, where the valid data is distributed in a certain location of the target upgrade file, such as a starting position of the target upgrade file, or a middle Location; wherein, the target upgrade file is a file that needs to be upgraded in the above embedded software.
  • the target upgrade file is composed of three parts: valid data, invalid data, and end data.
  • the end data is the data at the end of the target upgrade file.
  • the end data includes check digits, such as the previous "31 and 41", the data Still
  • the size of the valid data which may also be referred to as the length of the valid data, is not distinguished in the embodiment of the present invention, such as the following four bytes "FF, 1C, FD, EF"; wherein the invalid data is in addition to the valid data and the end Data outside the data, such as partial data consisting of FFs in Figures 4 and 5, which have been defined by the embedded system or embedded software containing the data prior to the upgrade.
  • the embedded device reads the end data block of the target upgrade file, and knows the size of the valid data from the last four bytes "FF, 1C, FD, EF" of the last data block.
  • the processing unit 301 determines valid data in the target upgrade file according to the size of the valid data and the preset position.
  • the size of the valid data and the preset location determine valid data in the target upgrade file.
  • the preset position is the starting position of the valid data, and its setting is determined by the embedded system or embedded software containing the data.
  • the processing unit 301 divides the valid data into N valid data blocks according to the size of the valid data.
  • the original file includes M data blocks, and there is a correspondence between the N valid data blocks and the M data blocks.
  • M and N are positive integers greater than or equal to 1.
  • the data block is a group or groups of records continuously arranged in sequence, and is a data unit for transmitting between the main memory and the input device, the output device, or the external memory;
  • the original file may also be referred to as
  • the original file is a file stored in the memory of the embedded device.
  • the original file is replaced with the target upgrade file, and the data in the original file is completely or replaced with the data in the target upgrade file.
  • the definition or description is specifically defined or described in the following steps.
  • the reading unit 302 reads the i-th valid data block from the N valid data blocks.
  • the initial value of the above i is 1, and the first valid number is read when the first reading is performed. According to the block.
  • the detecting unit 303 detects whether the i-th valid data block is the same as the j-th data block, and the j-th data block is one of M data blocks, the i-th data block and the j-th data block. correspond.
  • i and j are both positive integers, and both are greater than one.
  • 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.
  • detecting, by the detecting unit 303, whether the i-th valid data block and the j-th data block are the same include: detecting whether the size and data of the i-th valid data block are the same as the size and data of the j-th data block .
  • the detecting unit 303 detects that the i-th valid data block is the same as the j-th data block, the step of performing i plus 1 to obtain a new i value is performed, that is, the j-th data is not to be obtained.
  • the block is erased from the memory unit, and the i-th valid data block is not written to the memory.
  • the new i value (i ⁇ N) is returned, and the i-th reading is returned (notably, this Ii is a new i value) valid data block; if the detecting unit 303 detects that the i th valid data block is different from the jth data block, performing detection of whether all data in the i th valid data block is full A step consisting of the same number in hexadecimal numbers 0 through F.
  • the detecting unit 303 detects whether all data in the i-th valid data block is composed entirely of the same number in hexadecimal numbers 0 to F.
  • the detecting unit 303 detects whether all data in the i valid data blocks are all hexadecimal numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, The same number in A, B, C, D, and F.
  • the erase unit 306 erases the jth data block from the memory unit, and the write unit 307 writes the i-th valid data block to the memory unit.
  • the erasing unit 306 takes the j-th data block from the memory unit.
  • the erase, write unit 307 writes the ith valid data block to the memory unit.
  • the erase unit 306 erases the jth data block from the memory unit.
  • the memory unit is a memory size occupied by storing one data block, and can be understood as a unit for storing one data block.
  • the above erasing of the jth data block from the memory unit can be understood as erasing data in the jth data block from the memory unit.
  • the embedded device detects that all data in the i-th valid data block is composed of the same number in hexadecimal numbers 0 to F, the embedded device will use the j-th data.
  • the block is erased from the memory unit and the ith valid data block is not written to the memory unit. For example, if the valid data of the target upgrade file is the first 10 rows, there are 10 valid data blocks for each data block, and the data in the 6th to 10th rows of data blocks are all hexadecimal numbers 0.
  • the embedded device erases the jth data block from the memory unit, and the 6th to 10th data blocks are not written into the memory, that is, erased, but not written.
  • the data blocks of the first row to the fifth row are written to the memory cell after the embedded device erases the jth data block from the memory cell, as shown in FIG. 6.
  • the arithmetic unit 304 increments i by 1 to obtain a new value of i.
  • i is a positive integer less than or equal to N before adding 1, and a new i value is obtained when 1 is added, and the new i value may be greater than N.
  • the judging unit 305 judges whether or not the value of i is greater than N.
  • the determining unit 305 determines whether the new value of i is greater than N, and if it is less than N, returns to step 103, that is, executing the embedded device to read the ith effective data from the N valid data blocks. Step of the block; if greater than N, the reading unit 302 reads the end data block of the upgrade file.
  • the reading unit 302 reads the end data block of the upgrade file.
  • the erasing unit 306 erases the end data block of the original file from the memory unit, and the writing unit 307 writes the end data block of the upgrade file to the memory unit.
  • the last data block is a data block at the end of the target upgrade file, and the data block includes a check digit, such as the foregoing "31 and 41", and also includes the size of the valid data, which may also be called
  • the length of the valid data is not distinguished in the embodiment of the present invention, such as the following four bytes "FF, 1C, FD, EF".
  • the above erasing of the end data block of the original file from the memory unit can be understood as erasing the data of the end data block of the original file from the memory unit.
  • the reading unit 302 when it is determined that the new i value is greater than N ⁇ , the reading unit 302 reads the end data block of the upgrade file, and erases the last data block of the original file from the memory unit, and the upgrade file is upgraded. The end of the data block is written to the memory unit, and after the step of writing the end data block to the memory unit, the writing of the target upgrade file is completed. [0181] In short, the embodiment of the present invention obtains valid data information from the end data block of the target upgrade file, determines valid data of the target upgrade file according to the information, and divides the valid data into N data blocks and N valid data.
  • a (a ⁇ N) data blocks are the same as a data block in the original file, the a valid data block is not written into the memory, and the corresponding original data block is not deleted;
  • FIG. 7 is a schematic structural diagram of another embedded device according to an embodiment of the present invention. As shown in FIG. 7, the embedded device includes:
  • the input device 701, the output device 702, the processor 703, and the memory 704, and 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 specifically a USB interface, a keyboard, a mouse, or the like.
  • the output device 702 described above may specifically be a display screen or an indicator light.
  • the above memory 704 may be a high speed RAM memory or a non-volatile memory such as a disk memory.
  • the above memory 704 is used to store a set of program codes, and the input device 701, the output device 702, and the processor 703 are used to call the program code stored in the memory 704, and perform the following operations:
  • the processor 703 is configured to:
  • the original file is upgraded, and the original file includes M data blocks, including:
  • the processor 703 is further configured to:
  • the jth data block is erased from the memory unit, and The ith valid data block is written into the memory unit, and the i is incremented by 1 to obtain a new I. It is determined whether the new i value is greater than N. If not, the ith data of the N valid data blocks is read and executed. The steps of the block.
  • the foregoing processor 703 is further configured to: before determining valid data in the target upgrade file, the method further includes:
  • the foregoing processor 703 is further configured to:
  • [0200] determining valid data in the target upgrade file according to the size of the valid data and the preset position, and dividing the valid data into N valid data blocks according to the size of the valid data.
  • 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.

Abstract

Disclosed in embodiments of the present invention are a quick upgrade method for embedded software and an embedded device. The method comprises: determining valid data in a target upgrade file, and dividing the valid data into N valid data blocks; reading an i th valid data block, and detecting whether the valid data block is identical to an original data block; if they are identical, adding 1 to i to obtain a new value of i, and determining whether the new value of i is larger than N, if not, returning to perform the step of reading the i th valid data block; if they are not identical, detecting whether all data in the valid data block consist of the same number in hexadecimal format, if yes, erasing the original data block, adding 1 to i to obtain a new value of i, and determining whether the new value of i is larger than N, if not, returning to perform the step of reading the i th valid data block; and if it is determined that the new value of i is larger than N, reading an end data block of the upgrade file and writing the same into a memory. The present invention can shorten the writing time of a file, and thus accelerate the upgrade speed of embedded software.

Description

一种嵌入式软件快速升级的方法及嵌入式设备  Method for quickly upgrading embedded software and embedded device
[0001] 技术领域  [0001] Technical Field
[0002] 本发明涉及嵌入式技术领域, 特别涉及一种嵌入式软件快速升级的方法及嵌入 式设备。  [0002] The present invention relates to the field of embedded technologies, and in particular, to a method for quickly upgrading embedded software and an embedded device.
[0003] 背景技术 BACKGROUND
[0004] 嵌入式软件是基于嵌入式系统设计的软件, 它是计算机软件的一种, 由程序及 其文档组成, 可细分成系统软件、 支撑软件、 应用软件三类, 是嵌入式系统的 重要组成部分。 嵌入式软件广泛应用于国防、 工控、 家用、 商用、 办公、 医疗 等领域, 如我们常见的移动电话、 掌上电脑、 数码相机、 机顶盒、 MP3播放器等 都是用嵌入式软件技术对传统产品进行智能化改造的结果。  [0004] Embedded software is software based on embedded system design. It is a kind of computer software. It consists of programs and their documents. It can be subdivided into system software, supporting software and application software. It is an embedded system. An important part of. Embedded software is widely used in defense, industrial control, home, commercial, office, medical and other fields. For example, our common mobile phones, handheld computers, digital cameras, set-top boxes, MP3 players, etc. are all embedded products using traditional software technology. The result of intelligent transformation.
[0005] 在嵌入式软件幵发过程中, 可能会存在着未知的漏洞 bug, 用户在使用过程中 , 这些 bug有可能导致卡顿或闪退等问题, 需要升级软件来修复这些 bug; 此外 [0005] In the process of bursting embedded software, there may be unknown bugs. During the use of the user, these bugs may cause problems such as catastrophic or flashback. You need to upgrade the software to fix these bugs.
, 嵌入式软件也可以通过升级来增加或者调整某些功能, 从而加大软件的通用 性和可用性。 Embedded software can also be upgraded to add or adjust certain features to increase the versatility and usability of the software.
[0006] 目前许多微控制单元 (Micro Control Unit, MCU) 芯片, 一般都可以采用引导 装载程序 (Bootstrap loader, Bootloader) 的方法对嵌入式软件进行升级, 主要 的升级过程是将原文件的数据从内存中刪除, 并将升级文件的数据烧录到内存 中。 采用该方式升级嵌入式软件, 需要将所有升级文件的数据烧录到内存中, 若升级文件比较大吋, 升级所耗费的吋间也比较长。  [0006] At present, many Micro Control Unit (MCU) chips can generally be upgraded by using a Bootstrap loader (Bootloader) method. The main upgrade process is to delete the data of the original file. Delete in memory, and burn the data of the upgrade file into the memory. To upgrade the embedded software in this way, you need to burn the data of all the upgrade files into the memory. If the upgrade file is large, the upgrade will take a long time.
[0007] 发明内容 SUMMARY OF THE INVENTION
[0008] 本发明实施例公幵了一种嵌入式软件快速升级的方法及嵌入式设备, 能够缩短 文件的写入吋间, 以期加快嵌入式软件的升级速度。  [0008] The embodiment of the invention discloses a method for quickly upgrading an embedded software and an embedded device, which can shorten the file writing time, so as to speed up the upgrading speed of the embedded software.
[0009] 第一方面本发明实施例还公幵了一种嵌入式软件快速升级的方法及嵌入式设备[0009] The first aspect of the present invention also discloses a method for quickly upgrading an embedded software and an embedded device.
, 包括: , including:
[0010] 确定目标升级文件中的有效数据, 并将所述有效数据划分为 N个有效数据块, 所述 N个有效数据块与所述 M个数据块之间存在对应关系, 所述 M和所述 N均为 正整数; [0010] determining valid data in the target upgrade file, and dividing the valid data into N valid data blocks, where there is a correspondence between the N valid data blocks and the M data blocks, where the M and The N is Positive integer
[0011] 从所述 N个有效数据块中读取第 i个有效数据块, 检测所述第 i个有效数据块与 第 j个数据块是否相同, 所述第 j个数据块为所述 M个数据块中的一个, 所述第 i个 数据块与所述第 j个数据块对应, 所述 i和所述 j均为正整数;  [0011] reading the i-th valid data block from the N valid data blocks, detecting whether the i-th valid data block is the same as the j-th data block, and the j-th data block is the M One of the data blocks, the i-th data block corresponds to the j-th data block, and the i and the j are both positive integers;
[0012] 若相同, 则将所述 i加 1得到新的 i值, 判断所述新的 i值是否大于 N, 若否, 返回 执行所述从所述 N个有效数据块中读取第 i个有效数据块的步骤;  [0012] If they are the same, the i is incremented by 1 to obtain a new i value, and it is determined whether the new i value is greater than N. If not, returning to perform the reading of the i th from the N valid data blocks. Steps of valid data blocks;
[0013] 若不相同, 则检测所述第 i个有效数据块中的所有数据是否全由十六进制数 0至 F中的同一个数组成, 若是, 则将所述第 j个数据块从内存单元擦除, 执行所述将 所述 i加 1得到新的 i值, 判断所述新的 i值是否大于 N的步骤, 并当所述新的 i值小 于 N吋, 返回执行所述从所述 N个有效数据块中读取第 i个有效数据块的步骤; [0013] if not, detecting whether all data in the i-th valid data block is composed of the same number in hexadecimal numbers 0 to F, and if yes, the j-th data block Erasing from the memory unit, performing the step of adding 1 to the new i value, determining whether the new i value is greater than N, and returning to execute when the new i value is less than N吋The step of reading the i-th valid data block from the N valid data blocks;
[0014] 当判断所述新的 i值大于 N吋, 则读取所述升级文件的末尾数据块, 将所述原文 件的末尾数据块从所述内存单元中擦除, 并将所述升级文件的末尾数据块写入 所述内存单元。 [0014] when it is determined that the new i value is greater than N吋, reading the end data block of the upgrade file, erasing the end data block of the original file from the memory unit, and upgrading the The data block at the end of the file is written to the memory unit.
[0015] 在一个可选的实现方式中, 所述方法还包括:  [0015] In an optional implementation manner, the method further includes:
[0016] 若检测所述第 i个有效数据块中的所有数据不全由十六进制数 0至 F中的同一个 数组成, 则将所述第 j个数据块从所述内存单元中擦除, 并将所述第 i个有效数据 块写入所述内存单元, 执行所述将所述 i加 1得到新的 i值, 判断所述新的 i值是否 大于 N的步骤, 并当所述新的 i值小于 N吋, 返回执行所述从所述 N个有效数据块 中读取第 i个有效数据块的步骤。  [0016] if it is detected that all data in the i-th valid data block is not entirely composed of the same number in hexadecimal numbers 0 to F, the j-th data block is wiped from the memory unit Dividing, and writing the i-th valid data block to the memory unit, performing the step of adding 1 to the i to obtain a new i value, determining whether the new i value is greater than N, and The new i value is less than N吋, and the step of reading the ith valid data block from the N valid data blocks is performed.
[0017] 在一个可选的实现方式中, 所述确定目标升级文件中的有效数据之前, 所述方 法还包括:  [0017] In an optional implementation manner, before the determining the valid data in the target upgrade file, the method further includes:
[0018] 读取所述目标升级文件的末尾数据块, 从所述末尾数据块中获得所述有效数据 的大小。  [0018] reading a data block of the end of the target upgrade file, and obtaining a size of the valid data from the last data block.
[0019] 在一个可选的实现方式中, 所述确定目标升级文件中的有效数据, 并将所述有 效数据划分为 N个有效数据块包括:  [0019] In an optional implementation manner, the determining the valid data in the target upgrade file, and dividing the valid data into N valid data blocks includes:
[0020] 根据所述有效数据的大小和预设位置确定所述目标升级文件中的有效数据, 并 根据所述有效数据的大小将所述有效数据划分为 N个有效数据块。 [0020] determining valid data in the target upgrade file according to the size of the valid data and a preset location, and dividing the valid data into N valid data blocks according to the size of the valid data.
[0021] 在一个可选的实现方式中, 所述 N个有效数据块中的任一个有效数据块的大小 与所述 M个数据块中的任一个数据块的大小相同。 [0021] In an optional implementation manner, the size of the valid data block of any one of the N valid data blocks It is the same size as any one of the M data blocks.
[0022] 第二方面本发明实施例还公幵了一种嵌入式设备, 包括: [0022] The second aspect of the present invention also discloses an embedded device, including:
[0023] 处理单元用于确定目标升级文件中的有效数据, 将所述有效数据划分为 N个有 效数据块, 所述 N个有效数据块与所述 M个数据块之间存在对应关系, 所述 M和 所述 N均为正整数;  [0023] the processing unit is configured to determine valid data in the target upgrade file, and divide the valid data into N valid data blocks, where there is a correspondence between the N valid data blocks and the M data blocks. M and the N are both positive integers;
[0024] 读取单元, 用于从所述 N个有效数据块中读取第 i个有效数据块; [0024] a reading unit, configured to read the i th valid data block from the N valid data blocks;
[0025] 检测单元, 用于检测所述第 i个有效数据块与第 j个数据块是否相同, 所述第 j个 数据块为所述 M个数据块中的一个, 所述第 i个数据块与所述第 j个数据块对应, 所述 i和所述 j均为正整数; [0025] a detecting unit, configured to detect whether the i-th valid data block is the same as the j-th data block, the j-th data block is one of the M data blocks, and the i-th data a block corresponding to the jth data block, wherein the i and the j are both positive integers;
[0026] 运算单元, 用于当所述第 i个有效数据块与第 j个数据块相同吋, 将所述 i加 1得 到新的 i值; [0026] an operation unit, configured to: when the i-th valid data block is the same as the j-th data block, add 1 to a new i value;
[0027] 判断单元, 用于当所述运算单元将所述 i加 1得到新的 i值吋, 判断所述新的 i值 是否大于 N;  [0027] a determining unit, configured to: when the computing unit adds 1 to the new i value, to determine whether the new i value is greater than N;
[0028] 所述读取单元, 还用于当所述判断单元判断结果为否吋, 从所述 N个有效数据 块中读取第 i个有效数据块;  [0028] the reading unit is further configured to: when the determining unit determines that the result is negative, read the i th valid data block from the N valid data blocks;
[0029] 所述检测单元, 还用于当所述第 i个有效数据块与第 j个数据块不相同吋, 检测 所述第 i个有效数据块中的所有数据是否全由十六进制数 0至 F中的同一个数组成 [0029] the detecting unit is further configured to: when the i-th valid data block is different from the j-th data block, detecting whether all data in the i-th valid data block is all hexadecimal Number 0 to F in the same number
[0030] 擦除单元, 用于当所述第 i个有效数据块中的所有数据是否全由十六进制数 0至 F中的同一个数组成吋, 将所述第 j个数据块从内存单元擦除; [0030] an erasing unit, configured to: when all data in the i-th valid data block is composed of the same number in hexadecimal numbers 0 to F, the j-th data block is Memory unit erase;
[0031] 所述运算单元, 还用于在所述擦除单元将所述第 j个数据块从内存单元擦除之 后, 将所述 i加 1得到新的 i值;  [0031] the operation unit is further configured to: after the erasing unit erases the jth data block from the memory unit, add the i to 1 to obtain a new i value;
[0032] 所述判断单元, 还用于当所述运算单元将所述 i加 1得到新的 i值吋, 判断所述新 的 i值是否大于 N;  [0032] the determining unit is further configured to: when the computing unit adds 1 to the new i value, to determine whether the new value of i is greater than N;
[0033] 所述读取单元, 还用于当所述判断单元判断结果为是吋, 读取所述升级文件的 末尾数据块;  [0033] the reading unit is further configured to: when the determining unit determines that the result is 吋, read a data block at the end of the upgrade file;
[0034] 所述擦除单元, 还用于将所述原文件的末尾数据块从所述内存单元中擦除; [0035] 所述写入单元, 还用于所述升级文件的末尾数据块写入所述内存单元。 [0036] 在一个可选的实现方式中, [0034] the erasing unit is further configured to erase the end data block of the original file from the memory unit; [0035] the writing unit is further used for the end data block of the upgrade file Write to the memory unit. [0036] In an alternative implementation,
[0037] 所述擦除单元, 还用于当检测所述第 i个有效数据块中的所有数据不全由十六 进制数 0至 F中的同一个数组成吋, 将所述第 j个数据块从所述内存单元中擦除; [0038] 所述写入单元, 还用于在所述擦除单元将所述第 j个数据块从所述内存单元中 擦除之后, 将所述第 i个有效数据块写入所述内存单元;  [0037] the erasing unit is further configured to: when detecting that all data in the i-th valid data block is not completely composed of the same number in hexadecimal numbers 0 to F, the jth The data block is erased from the memory unit; [0038] the writing unit is further configured to: after the erasing unit erases the jth data block from the memory unit, Writing an i-th valid data block to the memory unit;
[0039] 所述运算单元, 还用于在所述写入单元将所述第 i个有效数据块写入所述内存 单元之后, 将所述 i加 1得到新的 i值; [0039] the operation unit is further configured to: after the writing unit writes the i th valid data block into the memory unit, add the i to 1 to obtain a new i value;
[0040] 所述判断单元, 还用于当所述运算单元将所述 i加 1得到新的 i值吋, 判断所述新 的 i值是否大于 N; [0040] the determining unit is further configured to: when the computing unit adds the i to 1 to obtain a new value of i, determine whether the new value of i is greater than N;
[0041] 所述读取单元, 还用于当所述判断单元判断结果为否吋, 从所述 N个有效数据 块中读取第 i个有效数据块。  [0041] The reading unit is further configured to: when the determining unit determines that the result is negative, read the i th valid data block from the N valid data blocks.
[0042] 在一个可选的实现方式中, [0042] In an alternative implementation,
[0043] 所述读取单元, 还用于读取所述目标升级文件的末尾数据块, 从所述末尾数据 块中获得所述有效数据的大小。  [0043] The reading unit is further configured to read a data block at the end of the target upgrade file, and obtain a size of the valid data from the last data block.
[0044] 在一个可选的实现方式中, 所述处理单元确定目标升级文件中的有效数据, 将 所述有效数据划分为 N个有效数据块的方式具体为: [0044] In an optional implementation manner, the processing unit determines valid data in the target upgrade file, and the manner of dividing the valid data into N valid data blocks is specifically:
[0045] 所述处理单元, 根据所述有效数据的大小和预设位置确定所述目标升级文件中 的有效数, 并根据所述有效数据的大小将所述有效数据划分为 N个有效数据块。 [0045] the processing unit determines a valid number in the target upgrade file according to the size of the valid data and a preset position, and divides the valid data into N valid data blocks according to the size of the valid data. .
[0046] 在一个可选的实现方式中, [0046] In an alternative implementation,
[0047] 所述 N个有效数据块中的任一个有效数据块的大小与所述 M个数据块中的任一 个数据块的大小相同。  [0047] 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.
[0048] 从以上技术方案可以看出, 本发明实施例具有以下优点: 只将升级文件中不全 由十六进制数 0至 F中的同一个数组成的有效数据写入内存, 升级文件中的其它 数据不写入内存, 可以有效地缩短写入的吋间, 加快嵌入式软件的升级速度, 解决嵌入式软件升级耗费吋间长的问题。  [0048] It can be seen from the above technical solution that the embodiment of the present invention has the following advantages: only valid data in the upgrade file that is not completely composed of the same number of hexadecimal numbers 0 to F is written into the memory, in the upgrade file. The other data is not written into the memory, which can effectively shorten the writing time, speed up the upgrade of the embedded software, and solve the problem of the long time of the embedded software upgrade.
[0049] 附图说明  BRIEF DESCRIPTION OF THE DRAWINGS
[0050] 为了更清楚地说明本发明实施例中的技术方案, 下面将对实施例描述中所需要 使用的附图作简要介绍, 显而易见地, 下面描述中的附图仅仅是本发明的一些 实施例, 对于本领域的普通技术人员来讲, 在不付出创造性劳动性的前提下, 还可以根据这些附图获得其他的附图。 [0050] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some of the present invention. For the embodiments, other drawings can be obtained from those skilled in the art without any inventive labor.
[0051] 图 1为本发明实施例公幵的一种嵌入式软件快速升级的方法的流程示意图; [0052] 图 2为本发明实施例公幵的另一种嵌入式软件快速升级的方法的流程示意图; [0053] 图 3为本发明实施例公幵的一种嵌入式设备的结构示意图;  1 is a schematic flowchart of a method for rapidly upgrading an embedded software according to an embodiment of the present invention; [0052] FIG. 2 is a schematic diagram of another method for quickly upgrading an embedded software according to an embodiment of the present invention; [0053] FIG. 3 is a schematic structural diagram of an embedded device according to an embodiment of the present invention;
[0054] 图 4为本发明实施例公幵的一种数据存储的示意图; 4 is a schematic diagram of a data storage according to an embodiment of the present invention;
[0055] 图 5为本发明实施例公幵的一种数据存储的示意图; 5 is a schematic diagram of a data storage according to an embodiment of the present invention;
[0056] 图 6为本发明实施例公幵的一种文件升级前后的示意图; 6 is a schematic diagram of a file before and after upgrading according to an embodiment of the present invention; [0056] FIG.
[0057] 图 7为本发明实施例公幵的另一种嵌入式设备的结构示意图。 7 is a schematic structural diagram of another embedded device according to an embodiment of the present invention.
[0058] 具体实施方式 DETAILED DESCRIPTION
[0059] 为了使本发明的目的、 技术方案和优点更加清楚, 下面将结合附图对本发明作 进一步地详细描述, 显然, 所描述的实施例仅仅是本发明一部份实施例, 而不 是全部的实施例。 基于本发明中的实施例, 本领域普通技术人员在没有做出创 造性劳动前提下所获得的所有其它实施例, 都属于本发明保护的范围。  The present invention will be further described in detail with reference to the accompanying drawings, in which FIG. An embodiment. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without making creative labor are within the scope of the present invention.
[0060] 请参阅图 1, 图 1是本发明实施例公幵的一种嵌入式软件快速升级的方法的流程 示意图, 如图 1所示, 该嵌入式软件快速升级的方法包括如下步骤。  Referring to FIG. 1, FIG. 1 is a schematic flowchart of a method for rapidly upgrading an embedded software according to an embodiment of the present invention. As shown in FIG. 1, the method for rapidly upgrading an embedded software includes the following steps.
[0061] 101、 嵌入式设备确定目标升级文件中获的有效数据。  [0061] 101. The embedded device determines valid data obtained in the target upgrade file.
[0062] 嵌入式设备可以包括但不唯一限定: 传统的工业控制和商业管理领域设备, 如 智能工控设备、 销售终端 (Point of sale, POS) 、 自动取款机 (Automatic Teller Machine, ATM) 、 集成电路 (Integrated Circuit Card, IC) 卡等; 家庭领域设 备, 如机顶盒、 数字电视、 网络冰箱、 网络空调等众多消费类和医疗保健类电 子设备等; 此外还有在多媒体手机、 袖珍电脑、 掌上电脑、 车载导航器等。  [0062] Embedded devices may include, but are not limited to: traditional industrial control and business management equipment, such as smart industrial equipment, point of sale (POS), automatic teller machine (ATM), integration Integrated circuit card (IC) card, etc.; home field devices, such as set-top boxes, digital TVs, network refrigerators, network air conditioners, and many other consumer and healthcare electronic devices; in addition, multimedia phones, pocket computers, handheld computers , car navigator, etc.
[0063] 上述目标升级文件, 也可以称之为目标文件或升级文件, 本发明实施例中不作 区分。 [0063] The target upgrade file may also be referred to as an object file or an upgrade file, which is not distinguished in the embodiment of the present invention.
[0064] 可选的, 有效数据由嵌入式系统或包含该有效数据的嵌入式软件定义, 该有效 数据集中分布于目标升级文件的某个位置, 如目标升级文件的起始位置, 或中 间某个位置; 其中, 目标升级文件为上述嵌入式软件中需要升级的一个文件。  [0064] Optionally, the valid data is defined by an embedded system or an embedded software that includes the valid data, where the valid data is distributed in a certain location of the target upgrade file, such as a starting position of the target upgrade file, or a middle Location; wherein, the target upgrade file is a file that needs to be upgraded in the above embedded software.
[0065] 可选的, 上述目标升级文件由三个部分组成: 有效数据、 无效数据以及末尾数 据, 其中, 末尾数据为目标升级文件末端的数据, 举例来说, 请参阅图 6, 图 6 中的升级后的目标文件中, 末尾数据包括校验位, 如前面的" 31和 41", 该数据还 包括有效数据的大小, 也可称之为有效数据的, 本发明实施例中不作区分, 如 后面 4个字节 "FF, 1C, FD, EF"; 其中, 无效数据为除了有效数据和末尾数据 外的数据, 如图 4和图 5中的由 FF组成的部分数据, 该无效数据, 在升级之前, 已由嵌入式系统或包含该数据的嵌入式软件定义。 [0065] Optionally, the target upgrade file is composed of three parts: valid data, invalid data, and last number According to which, the end data is the data at the end of the target upgrade file. For example, refer to Figure 6, in the upgraded object file in Figure 6, the end data includes check digits, such as the previous "31 and 41", The data also includes the size of the valid data, which may also be referred to as valid data. It is not distinguished in the embodiment of the present invention, such as the following four bytes "FF, 1C, FD, EF"; wherein, the invalid data is in addition to the valid data. And the data outside the end data, as shown in Figure 4 and Figure 5, the partial data consisting of FF, which has been defined by the embedded system or the embedded software containing the data before the upgrade.
[0066] 102、 嵌入式设备将有效数据划分为 N个有效数据块, 其中, 原文件包括 M个数 据块, N个有效数据块与 M个数据块之间存在对应关系。  [0066] 102. The embedded device divides the valid data into N valid data blocks, where the original file includes M data blocks, and there is a correspondence between the N valid data blocks and the M data blocks.
[0067] 其中, M和 N是大于等于 1的正整数。  Wherein M and N are positive integers greater than or equal to 1.
[0068] 其中, 数据块是一组或几组按顺序连续排列在一起的记录, 是主存储器与输入 设备、 输出设备或外存储器之间进行传输的数据单位; 上述原文件也可称之为 原始文件, 是存储在嵌入式设备的内存中的文件, 本次升级, 就是将原文件替 换成目标升级文件, 即将原文件中的数据完全或部门替换成目标升级文件中的 数据, 该数据的限定或描述, 在后面的步骤中进行具体限定或描述。  [0068] wherein, the data block is a group or groups of records continuously arranged in sequence, and is a data unit for transferring between the main memory and the input device, the output device, or the external memory; the original file may also be referred to as The original file is a file stored in the memory of the embedded device. In this upgrade, the original file is replaced with the target upgrade file, and the data in the original file is completely or replaced with the data in the target upgrade file. The definition or description is specifically defined or described in the following steps.
[0069] 上述对应关系, 可以分三种情况进行讨论:  [0069] The above correspondence can be discussed in three cases:
[0070] 首先, 若 M>N, 则上述 N个有效数据块与原文件 M个数据块中的 N个数据块相 对应。  [0070] First, if M>N, the N valid data blocks correspond to N data blocks in the M data blocks of the original file.
[0071] 其次, 若 M=N, 则上述 N个有效数据块与原文件 M个数据块一一对应。  [0071] Next, if M=N, the N valid data blocks are in one-to-one correspondence with the original file M data blocks.
[0072] 最后, 若 M<N, 由于嵌入式软件进行升级, 实际改动的范围不大, 因此, 目标 升级文件中的有效数据的大小较小, 即出现 M<N的可能性不大。  [0072] Finally, if M<N, due to the upgrade of the embedded software, the actual modification range is not large. Therefore, the size of the valid data in the target upgrade file is small, that is, the possibility of M<N is not large.
[0073] 103、 嵌入式设备从 N个有效数据块中读取第 i个有效数据块。 [0073] 103. The embedded device reads the i th valid data block from the N valid data blocks.
[0074] 本发明实施例中, 上述 i的初始值为 1, 第一次读取的吋候, 读取第 1个有效数 据块。 In the embodiment of the present invention, the initial value of the above i is 1, and the first valid data block is read when the first reading is performed.
[0075] 104、 嵌入式设备检测第 i个有效数据块与第 j个数据块是否相同, 第 j个数据块 为 M个数据块中的一个, 第 i个数据块与第 j个数据块对应。  [0075] 104. The embedded device detects whether the i-th valid data block is the same as the j-th data block, the j-th data block is one of M data blocks, and the i-th data block corresponds to the j-th data block. .
[0076] 其中, 上述 i和 j均为正整数, 且均大于 1。 [0076] wherein, i and j are both positive integers, and both are greater than one.
[0077] 可选的, N个有效数据块中的任一个有效数据块的大小与 M个数据块中的任一 个数据块的大小相同。 [0078] 可选的, 检测第 i个有效数据块与第 j个数据块是否相同包括: 检测第 i个有效数 据块的大小和数据与第 j个数据块的大小和数据是否相同。 [0077] 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. [0078] Optionally, detecting whether the i-th valid data block is identical to the j-th data block comprises: detecting whether the size and data of the i-th valid data block are the same as the size and data of the j-th data block.
[0079] 本发明实施例中, 若嵌入式设备检测第 i个有效数据块与第 j个数据块相同吋, 则执行 i加 1得到新的 i值的步骤, 即不会将第 j个数据块从内存单元中擦除, 也不 会将第 i个有效数据块写入内存, 将 i加 1得到新的 i值 (i<N) 后, 返回读取第 i ( 值得注意的是, 此吋的 i为新的 i值) 个有效数据块; 若嵌入式设备检测第 i个有效 数据块与第 j个数据块不相同吋, 则执行检测第 i个有效数据块中的所有数据是否 全由十六进制数 0至 F中的同一个数组成的步骤。  [0079] In the embodiment of the present invention, if the embedded device detects that the i-th valid data block is the same as the j-th data block, the step of performing i plus 1 to obtain a new i value is performed, that is, the j-th data is not to be The block is erased from the memory unit, and the i-th valid data block is not written to the memory. After i is incremented by 1, the new i value (i<N) is returned, and the i-th reading is returned (notably, this吋i is the new i value) valid data block; if the embedded device detects that the i-th valid data block is different from the j-th data block, then it is performed to detect whether all data in the i-th valid data block is full A step consisting of the same number in hexadecimal numbers 0 through F.
[0080] 105、 嵌入式设备检测第 i个有效数据块中的所有数据是否全由十六进制数 0至 F 中的同一个数组成。  [0080] 105. The embedded device detects whether all data in the i-th valid data block is composed of the same number in hexadecimal numbers 0 to F.
[0081] 本发明实施例中, 嵌入式设备检测 i个有效数据块中的所有数据是否全由十六 进制数 0、 1、 2、 3、 4、 5、 6、 7、 8、 9、 A、 B、 C、 D和 F中的同一个数组成。  [0081] In the embodiment of the present invention, the embedded device detects whether all data in the i valid data blocks are all hexadecimal numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, The same number in A, B, C, D, and F.
[0082] 106、 嵌入式设备将第 j个数据块从内存单元中擦除。 [0082] 106. The embedded device erases the jth data block from the memory unit.
[0083] 其中, 上述内存单元为存储一个数据块吋所占用的内存大小, 可以理解为存储 一个数据块的单元。  [0083] wherein, the memory unit is a memory size occupied by storing one data block, and can be understood as a unit for storing one data block.
[0084] 上述将第 j个数据块从内存单元中擦除可以理解为将第 j个数据块中的数据从内 存单元中擦除。  [0084] The above erasing of the jth data block from the memory unit can be understood as erasing the data in the jth data block from the memory unit.
[0085] 本发明实施例中, 若嵌入式设备检测第 i个有效数据块中的所有数据全由十六 进制数 0至 F中的同一个数组成, 则嵌入式设备将第 j个数据块从内存单元中擦除 , 而第 i个有效数据块并不写入该内存单元中。 举例来说, 若目标升级文件的有 效数据为前 10行, 每行为一个数据块, 即有 10个有效数据块, 且第 6至第 10行数 据块中的数据全由十六进制数 0至 F中的某一个数组成, 不妨令第 6至第 10行数据 块的数据分别全由 0、 1、 2、 3、 4和 5组成。 那么, 嵌入式设备将第 j个数据块从 内存单元中擦除后, 而第 6至第 10行数据块并不写入内存, 即擦除, 但不写入。 而第 1行至第 5行的数据块, 在嵌入式设备将第 j个数据块从内存单元中擦除后, 写入该内存单元, 请参阅图 6。  In the embodiment of the present invention, if the embedded device detects that all data in the i-th valid data block is composed of the same number in hexadecimal numbers 0 to F, the embedded device will use the j-th data. The block is erased from the memory unit and the ith valid data block is not written to the memory unit. For example, if the valid data of the target upgrade file is the first 10 rows, there are 10 valid data blocks for each data block, and the data in the 6th to 10th rows of data blocks are all hexadecimal numbers 0. To a certain number of F, it is possible to make the data of the 6th to 10th data blocks all consist of 0, 1, 2, 3, 4 and 5. Then, the embedded device erases the jth data block from the memory unit, and the 6th to 10th data blocks are not written into the memory, that is, erased, but not written. The data blocks of the first row to the fifth row are written to the memory cell after the embedded device erases the jth data block from the memory cell, as shown in FIG. 6.
[0086] 107、 嵌入式设备将 i加 1得到新的 i值。  [0086] 107. The embedded device adds i to 1 to obtain a new i value.
[0087] 其中, i在加 1之前, 是小于等于 N的一个正整数, 当加 1后得到新的 i值, 新的 i 值可能大于 N。 [0087] wherein, i is a positive integer less than or equal to N before adding 1, and a new i value is obtained when 1 is added, the new i The value may be greater than N.
[0088] 108、 嵌入式设备判断新的 i值是否大于 N。  [0088] 108. The embedded device determines whether the new value of i is greater than N.
[0089] 本发明实施例中, 嵌入式设备判断新的 i值是否大于 N, 若小于 N, 则返回执行 步骤 103, 即执行嵌入式设备从 N个有效数据块中读取第 i个有效数据块的步骤; 若大于 N, 则执行读取升级文件的末尾数据块的步骤。  In the embodiment of the present invention, the embedded device determines whether the new i value is greater than N, and if it is less than N, returns to step 103, that is, executing the embedded device to read the i th valid data from the N valid data blocks. The step of the block; if greater than N, the step of reading the end data block of the upgrade file is performed.
[0090] 109、 嵌入式设备读取升级文件的末尾数据块。  [0090] 109. The embedded device reads the end data block of the upgrade file.
[0091] 110、 嵌入式设备将原文件的末尾数据块从内存单元中擦除, 并将升级文件的 末尾数据块写入内存单元。  [0091] 110. The embedded device erases the end data block of the original file from the memory unit, and writes the end data block of the upgrade file to the memory unit.
[0092] 其中, 上述末尾数据块为目标升级文件末尾的一个数据块, 在该数据块中, 包 含了校验位, 如前面的" 31和 41", 还包括有效数据的大小, 也可称之为有效数据 的, 本发明实施例中不作区分, 如后面 4个字节 "FF, 1C, FD, EF"。 [0092] wherein, the last data block is a data block at the end of the target upgrade file, and the data block includes a check digit, such as the foregoing "31 and 41", and also includes the size of the valid data, which may also be called For the valid data, no distinction is made in the embodiment of the present invention, such as the following four bytes "FF, 1C, FD, EF".
[0093] 上述将原文件的末尾数据块从内存单元中擦除可以理解为将原文件的末尾数据 块的数据从内存单元中擦除。 [0093] The above erasing the end data block of the original file from the memory unit can be understood as erasing the data of the end data block of the original file from the memory unit.
[0094] 本发明实施例中, 当判断新的 i值大于 N吋, 嵌入式设备读取升级文件的末尾数 据块, 并将原文件的末尾数据块从内存单元中擦除, 将升级文件的末尾数据块 写入该内存单元, 完成末尾数据块写入内存单元的步骤后, 便完成了该目标升 级文件的写入。 [0094] In the embodiment of the present invention, when it is determined that the new i value is greater than N吋, the embedded device reads the end data block of the upgrade file, and erases the end data block of the original file from the memory unit, and the file is upgraded. The last data block is written to the memory unit, and after the step of writing the last data block to the memory unit, the writing of the target upgrade file is completed.
[0095] 简而言之, 本发明实施例可以确定目标升级文件的有效数据, 将有效数据划分 为 N个数据块, N个有效数据块中, 若有 a (a<N) 个数据块分别与原文件中的 a 个数据块相同, 则该 a个有效数据块不写入内存, 且对应的原数据块也不进行刪 除; 若 b个有效数据块与原文件的数据不相同, 且 b个有效数据块中任意一个有 效数据块中的所有数据全由十六进制数 0至 F中的同一个数组成, 则将对应的原 数据块从内存中擦除, 但上述 b个有效数据块不写入内存, 其中, a+b≤N。  [0095] In short, the embodiment of the present invention can determine valid data of the target upgrade file, and divide the valid data into N data blocks, if there are a (a<N) data blocks respectively. Same as a data block in the original file, the a valid data block is not written into the memory, and the corresponding original data block is not deleted; if the b valid data blocks are different from the original file, and b All data in any valid data block of the valid data block is composed of the same number in hexadecimal numbers 0 to F, then the corresponding original data block is erased from the memory, but the above b valid data The block is not written to memory, where a+b≤N.
[0096] 通过本发明实施例的方案, 确定升级文件中的有效数据, 将全由十六进制数 0 至 F中的同一个数组成的有效数据不写入内存, 无效数据不写入内存, 可以减少 写入内存的数据, 提升写入效率, 有效地缩短写入的吋间, 从而加快嵌入式软 件的升级速度, 解决嵌入式软件升级耗费吋间长的问题。  [0096] According to the solution of the embodiment of the present invention, valid data in the upgrade file is determined, and valid data consisting of the same number of hexadecimal numbers 0 to F is not written into the memory, and invalid data is not written into the memory. It can reduce the data written in the memory, improve the writing efficiency, effectively shorten the writing time, thereby speeding up the upgrade speed of the embedded software, and solving the problem that the embedded software upgrade takes a long time.
[0097] 请参阅图 2, 图 2是本发明实施例公幵的另一种嵌入式软件快速升级的方法的流 程示意图, 图 2是在图 1的基础上进一步优化得到的, 如图 2所示, 该嵌入式软件 快速升级的方法包括如下步骤。 Please refer to FIG. 2. FIG. 2 is a flow chart of another method for quickly upgrading embedded software according to an embodiment of the present invention. Schematic diagram, FIG. 2 is further optimized based on FIG. 1. As shown in FIG. 2, the method for quickly upgrading the embedded software includes the following steps.
[0098] 201、 嵌入式设备读取目标升级文件的末尾数据块, 从末尾数据块中获得有效 数据的大小。 [0098] 201. The embedded device reads the end data block of the target upgrade file, and obtains the size of the valid data from the last data block.
[0099] 可选的, 有效数据由嵌入式系统或包含该有效数据的嵌入式软件定义, 该有效 数据集中分布于目标升级文件的某个位置, 如目标升级文件的起始位置, 或中 间某个位置; 其中, 目标升级文件为上述嵌入式软件中需要升级的一个文件。  [0099] Optionally, the valid data is defined by an embedded system or an embedded software that includes the valid data, where the valid data is distributed in a certain location of the target upgrade file, such as a starting position of the target upgrade file, or a middle Location; wherein, the target upgrade file is a file that needs to be upgraded in the above embedded software.
[0100] 可选的, 上述目标升级文件由三个部分组成: 有效数据、 无效数据以及末尾数 据。 其中, 末尾数据为目标升级文件末端的数据, 举例来说, 请参阅图 6, 图 6 中的升级后的目标文件中, 末尾数据包括校验位, 如前面的" 31和 41", 该数据还 包括有效数据的大小, 也可称之为有效数据的, 本发明实施例中不作区分, 如 后面 4个字节 "FF, 1C, FD, EF"; 其中, 无效数据为除了有效数据和末尾数据 外的数据, 如图 4和图 5中的由 FF组成的部分数据, 该无效数据, 在升级之前, 已由嵌入式系统或包含该数据的嵌入式软件定义。  [0100] Optionally, the foregoing target upgrade file is composed of three parts: valid data, invalid data, and last data. The end data is the data at the end of the target upgrade file. For example, refer to Figure 6, in the upgraded object file in Figure 6, the end data includes check digits, such as the previous "31 and 41", the data Also included is 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 the following four bytes "FF, 1C, FD, EF"; wherein, invalid data is in addition to valid data and the end Data outside the data, such as partial data consisting of FFs in Figures 4 and 5, which have been defined by the embedded system or embedded software containing the data prior to the upgrade.
[0101] 本发明实施例中, 嵌入式设备读取目标升级文件的末尾数据块, 从末尾数据块 后面 4个字节 "FF, 1C, FD, EF"知道有效数据的大小。  [0101] In the embodiment of the present invention, the embedded device reads the end data block of the target upgrade file, and knows the size of the valid data from the last four bytes "FF, 1C, FD, EF" of the last data block.
[0102] 202、 嵌入式设备根据有效数据的大小和预设位置确定目标升级文件中的有效 数据。  [0102] 202. The embedded device determines valid data in the target upgrade file according to the size of the valid data and the preset location.
[0103] 本发明实施例中, 有效数据的大小和预设位置确定目标升级文件中的有效数据 [0103] In the embodiment of the present invention, the size of the valid data and the preset location determine valid data in the target upgrade file.
。 其中, 预设位置为有效数据的起始位置, 它的设定由嵌入式系统设定, 或包 含该数据的嵌入式软件确定。 . The preset position is the starting position of the valid data, and its setting is determined by the embedded system or embedded software containing the data.
[0104] 203、 嵌入式设备根据有效数据的大小将有效数据划分为 N个有效数据块。 [0104] 203. The embedded device divides the valid data into N valid data blocks according to the size of the valid data.
[0105] 204、 嵌入式设备从 N个有效数据块中读取第 i个有效数据块。 [0105] 204. The embedded device reads the i th valid data block from the N valid data blocks.
[0106] 205、 嵌入式设备检测第 i个有效数据块与第 j个数据块是否相同, 第 j个数据块 为 M个数据块中的一个, 第 i个数据块与第 j个数据块对应。 [0106] 205. The embedded device detects whether the i-th valid data block is the same as the j-th data block, the j-th data block is one of M data blocks, and the i-th data block corresponds to the j-th data block. .
[0107] 206、 嵌入式设备检测第 i个有效数据块中的所有数据是否全由十六进制数 0至 F 中的同一个数组成。 [0107] 206. The embedded device detects whether all data in the i-th valid data block is composed of the same number in hexadecimal numbers 0 to F.
[0108] 上述步骤 203-206的具体实施方式可参考图 1所描述的嵌入式软件快速升级方法 的步骤 102-105, 本发明实施例不再详述。 [0108] The specific implementation manner of the foregoing steps 203-206 can refer to the embedded software fast upgrade method described in FIG. Steps 102-105, which are not described in detail in the embodiments of the present invention.
[0109] 207、 嵌入式设备将第 j个数据块从内存单元擦除, 将第 i个有效数据块写入该内 存单元。 [0109] 207. The embedded device erases the jth data block from the memory unit, and writes the i-th valid data block into the memory unit.
[0110] 当嵌入式设备检测第 i个有效数据块中的所有数据不全由十六进制数 0至 F中的 同一个数组成吋, 则将第 j个数据块从内存单元擦除, 将第 i个有效数据块写入该 内存单元。  [0110] When the embedded device detects that all data in the i-th valid data block is not completely composed of the same number in hexadecimal numbers 0 to F, the j-th data block is erased from the memory unit, and The i-th valid data block is written to the memory unit.
[0111] 208、 嵌入式设备将第 j个数据块从内存单元中擦除。  [0111] 208. The embedded device erases the jth data block from the memory unit.
[0112] 上述步骤 208的具体实施方式可参考图 1所描述的嵌入式软件快速升级方法的步 骤 106, 本发明实施例不再详述。  [0112] The specific implementation of the foregoing step 208 may refer to the step 106 of the embedded software rapid upgrade method described in FIG. 1 , which is not described in detail in the embodiment of the present invention.
[0113] 209、 嵌入式设备将 i加 1得到新的 i值。 [0113] 209. The embedded device adds i to 1 to obtain a new value of i.
[0114] 210、 嵌入式设备判断 i值是否大于 N。 [0114] 210. The embedded device determines whether the value of i is greater than N.
[0115] 211、 嵌入式设备读取升级文件的末尾数据块。 [0115] 211. The embedded device reads the end data block of the upgrade file.
[0116] 212、 嵌入式设备将原文件的末尾数据块从内存单元中擦除, 并将升级文件的 末尾数据块写入内存单元。  [0116] 212. The embedded device erases the end data block of the original file from the memory unit, and writes the end data block of the upgrade file to the memory unit.
[0117] 上述步骤 209-212的具体实施方式可参考图 1所描述的嵌入式软件快速升级方法 的步骤 107-110, 本发明实施例不再详述。  [0117] The specific implementation manners of the foregoing steps 209-212 may refer to steps 107-110 of the embedded software rapid upgrade method described in FIG. 1, which are not detailed in the embodiments of the present invention.
[0118] 简而言之, 本发明实施例从目标升级文件的末尾数据块得到有效数据信息, 根 据该信息确定目标升级文件的有效数据, 将有效数据划分为 N个数据块, N个有 效数据块中, 若有 a (a<N) 个数据块分别与原文件中的 a个数据块相同, 则该 a 个有效数据块不写入内存, 且对应的原数据块也不进行刪除; 若 b个有效数据块 与原文件的数据不相同, 且 b (b<N) 个有效数据块中任意一个有效数据块中的 所有数据全由十六进制数 0至 F中的同一个数组成, 则将对应的原数据块从内存 中擦除, 但上述 b个有效数据块不写入内存; 若 t (t<N) 个有效数据块中任意一 个有效数据块中的所有数据不全由十六进制数 0至 F中的同一个数组成, 则将对 应的原数据块从内存中擦除, 且上述 b个有效数据块不写入内存, 其中, a+b+t= N。  [0118] In short, the embodiment of the present invention obtains valid data information from the end data block of the target upgrade file, determines valid data of the target upgrade file according to the information, and divides the valid data into N data blocks and N valid data. In the block, if a (a<N) data blocks are the same as a data block in the original file, the a valid data block is not written into the memory, and the corresponding original data block is not deleted; b valid data blocks are different from the original file data, and all data in any valid data block in b (b<N) valid data blocks are all composed of the same number in hexadecimal numbers 0 to F , the corresponding original data block is erased from the memory, but the above b valid data blocks are not written into the memory; if all data in any valid data block of t (t<N) valid data blocks is not all ten When the hexadecimal numbers 0 to F are composed of the same number, the corresponding original data block is erased from the memory, and the above b valid data blocks are not written into the memory, where a+b+t=N.
[0119] 通过本发明实施例的方案, 可以只将升级文件中不全由十六进制数 0至 F中的同 一个数组成的有效数据写入内存, 以及末尾数据块的数据写入内存, 而其它数 据不写入内存, 如无效数据和全由十六进制数 0至 F中的同一个数组成的有效数 据不写入内存, 可以有效地提升写入效率, 缩短写入的吋间, 加快嵌入式软件 的升级速度, 解决嵌入式软件升级耗费吋间长的问题。 [0119] With the solution of the embodiment of the present invention, only valid data that is not composed of the same number of hexadecimal numbers 0 to F in the upgrade file may be written into the memory, and data of the last data block is written into the memory. Other numbers According to the memory not written, such as invalid data and the same data consisting of the same number of hexadecimal numbers 0 to F are not written into the memory, which can effectively improve the writing efficiency, shorten the writing time, and speed up The upgrade speed of embedded software solves the problem of long time spent on embedded software upgrades.
[0120] 请参阅图 3, 图 3是本发明实施例公幵的一种嵌入式设备的结构示意图, 如图 3 所示, 该嵌入式设备包括:  Referring to FIG. 3, FIG. 3 is a schematic structural diagram of an embedded device according to an embodiment of the present invention. As shown in FIG. 3, the embedded device includes:
[0121] 处理单元 301, 用于确定目标升级文件中的有效数据, 将上述有效数据划分为 N 个有效数据块, 上述 N个有效数据块与上述 M个数据块之间存在对应关系, 上述[0121] The processing unit 301 is configured to determine valid data in the target upgrade file, and divide the valid data into N valid data blocks, where the N valid data blocks and the M data blocks have a corresponding relationship.
M和上述 N均为正整数。 M and the above N are both positive integers.
[0122] 读取单元 302, 用于从 N个有效数据块中读取第 i个有效数据块; [0122] The reading unit 302 is configured to read the i th valid data block from the N valid data blocks;
[0123] 检测单元 303, 用于检测第 i个有效数据块与第 j个数据块是否相同, 第 j个数据 块为 M个数据块中的一个, 第 i个数据块与第 j个数据块对应, i和 j均为正整数; [0124] 运算单元 304, 用于当第 i个有效数据块与第 j个数据块相同吋, 将 i加 1得到新的 i 值; [0123] The detecting unit 303 is configured to detect whether the i-th valid data block is the same as the j-th data block, and the j-th data block is one of the M data blocks, the i-th data block and the j-th data block. Correspondingly, i and j are both positive integers; [0124] an operation unit 304, configured to: when the ith valid data block is the same as the jth data block, add i to 1 to obtain a new i value;
[0125] 判断单元 305, 用于当运算单元 304将 i加 1得到新的 i值吋, 判断新的 i值是否大 于^  [0125] The determining unit 305 is configured to: when the computing unit 304 adds i to 1 to obtain a new value of i, determine whether the new value of i is greater than ^
[0126] 上述读取单元 302, 还用于当上述判断单元 305判断结果为否吋, 从上述 N个有 效数据块中读取第 i个有效数据块  [0126] The reading unit 302 is further configured to: when the determining unit 305 determines that the result is negative, read the i-th valid data block from the N valid data blocks.
[0127] 上述检测单元 303, 还用于当第 i个有效数据块与第 j个数据块不相同吋, 检测第 i个有效数据块中的所有数据是否全由十六进制数 0至 F中的同一个数组成; [0127] The detecting unit 303 is further configured to: when the i-th valid data block is different from the j-th data block, detecting whether all data in the i-th valid data block is all hexadecimal 0 to F The same number in the middle;
[0128] 擦除单元 306, 用于当第 i个有效数据块中的所有数据是否全由十六进制数 0至 F 中的同一个数组成吋, 将第 j个数据块从内存单元擦除; [0128] The erasing unit 306 is configured to: when all the data in the i-th valid data block is composed of the same number in the hexadecimal numbers 0 to F, the j-th data block is wiped from the memory unit Save
[0129] 上述运算单元 304, 还用于在上述擦除单元 306将上述第 j个数据块从内存单元 擦除之后, 将上述 i加 1得到新的 i值。 [0129] The operation unit 304 is further configured to: after the erasing unit 306 erases the jth data block from the memory unit, add 1 to 1 to obtain a new value of i.
[0130] 上述判断单元 305, 还用于当上述运算单元将上述 i加 1得到新的 i值吋, 判断上 述新的 i值是否大于 N。 [0130] The determining unit 305 is further configured to: when the computing unit adds the above i to get a new i value, determine whether the new i value is greater than N.
[0131] 上述读取单元 302, 还用于当上述判断单元 305判断结果为是吋, 读取上述升级 文件的末尾数据块。  The reading unit 302 is further configured to read the end data block of the upgrade file when the determining unit 305 determines that the result is 吋.
[0132] 上述擦除单元 306, 还用于将上述原文件的末尾数据块从上述内存单元中擦除 [0133] 写入单元 307, 用于上述升级文件的末尾数据块写入上述内存单元。 [0132] The above-mentioned erasing unit 306 is further configured to erase the end data block of the original file from the memory unit [0133] The writing unit 307 writes the last data block for the above upgrade file into the above memory unit.
[0134] 上述擦除单元 306, 还用于当检测第 i个有效数据块中的所有数据不全由十六进 制数 0至 F中的同一个数组成吋, 将第 j个数据块从内存单元中擦除。  [0134] The above-mentioned erasing unit 306 is further configured to: when detecting that all data in the i-th valid data block is not completely composed of the same number in the hexadecimal numbers 0 to F, the j-th data block is from the memory Erase in the cell.
[0135] 上述写入单元 307, 还用于在擦除单元 306将第 j个数据块从内存单元中擦除之 后, 将第 i个有效数据块写入内存单元。 [0135] The writing unit 307 is further configured to write the i th valid data block to the memory unit after the erasing unit 306 erases the jth data block from the memory unit.
[0136] 上述运算单元 304, 还用于在写入单元 307将第 i个有效数据块写入内存单元之 后, 将 i加 1得到新的 i值。 [0136] The operation unit 304 is further configured to add i to 1 to obtain a new value of i after the writing unit 307 writes the i-th valid data block to the memory unit.
[0137] 上述判断单元 305, 还用于当上述运算单元 304将上述 i加 1得到新的 i值吋, 判断 上述新的 i值是否大于 N。 [0137] The determining unit 305 is further configured to: when the computing unit 304 adds the above i to get a new i value, determine whether the new i value is greater than N.
[0138] 上述读取单元 302, 还用于当上述判断单元 305判断结果为否吋, 从上述 N个有 效数据块中读取第 i个有效数据块。 [0138] The reading unit 302 is further configured to: when the determining unit 305 determines that the result is negative, read the i th valid data block from the N valid data blocks.
[0139] 上述读取单元 302, 还用于读取目标升级文件的末尾数据块, 从末尾数据块中 获得有效数据的大小。 [0139] The reading unit 302 is further configured to read the end data block of the target upgrade file, and obtain the size of the valid data from the last data block.
[0140] 上述处理单元 301, 根据上述有效数据的大小和预设位置确定上述目标升级文 件中的有效数, 并根据上述有效数据的大小将上述有效数据划分为 N个有效数据 块。  [0140] The processing unit 301 determines a valid number in the target upgrade file according to the size of the valid data and a preset position, and divides the valid data into N valid data blocks according to the size of the valid data.
[0141] 其中, N个有效数据块中的任一个有效数据块的大小与 M个数据块中的任一个 数据块的大小相同。  [0141] 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.
[0142] 采用本嵌入式设备, 可以执行以下方法步骤: [0142] With the embedded device, the following method steps can be performed:
[0143] (1) 读取单元 302读取目标升级文件的末尾数据块, 从末尾数据块中获得有效 数据的大小。  [0143] (1) The reading unit 302 reads the end data block of the target upgrade file, and obtains the size of the valid data from the last data block.
[0144] 可选的, 有效数据由嵌入式系统或包含该有效数据的嵌入式软件定义, 该有效 数据集中分布于目标升级文件的某个位置, 如目标升级文件的起始位置, 或中 间某个位置; 其中, 目标升级文件为上述嵌入式软件中需要升级的一个文件。  [0144] Optionally, the valid data is defined by an embedded system or an embedded software that includes the valid data, where the valid data is distributed in a certain location of the target upgrade file, such as a starting position of the target upgrade file, or a middle Location; wherein, the target upgrade file is a file that needs to be upgraded in the above embedded software.
[0145] 可选的, 上述目标升级文件由三个部分组成: 有效数据、 无效数据以及末尾数 据。 其中, 末尾数据为目标升级文件末端的数据, 举例来说, 请参阅图 6, 图 6 中的升级后的目标文件中, 末尾数据包括校验位, 如前面的" 31和 41", 该数据还 包括有效数据的大小, 也可称之为有效数据的长度, 本发明实施例中不作区分 , 如后面 4个字节 "FF, 1C, FD, EF"; 其中, 无效数据为除了有效数据和末尾 数据外的数据, 如图 4和图 5中的由 FF组成的部分数据, 该无效数据, 在升级之 前, 已由嵌入式系统或包含该数据的嵌入式软件定义。 [0145] Optionally, the target upgrade file is composed of three parts: valid data, invalid data, and end data. The end data is the data at the end of the target upgrade file. For example, refer to Figure 6, in the upgraded object file in Figure 6, the end data includes check digits, such as the previous "31 and 41", the data Still The size of the valid data, which may also be referred to as the length of the valid data, is not distinguished in the embodiment of the present invention, such as the following four bytes "FF, 1C, FD, EF"; wherein the invalid data is in addition to the valid data and the end Data outside the data, such as partial data consisting of FFs in Figures 4 and 5, which have been defined by the embedded system or embedded software containing the data prior to the upgrade.
[0146] 本发明实施例中, 嵌入式设备读取目标升级文件的末尾数据块, 从末尾数据块 后面 4个字节 "FF, 1C, FD, EF"知道有效数据的大小。  [0146] In the embodiment of the present invention, the embedded device reads the end data block of the target upgrade file, and knows the size of the valid data from the last four bytes "FF, 1C, FD, EF" of the last data block.
[0147] (2) 处理单元 301根据有效数据的大小和预设位置确定目标升级文件中的有效 数据。  [0147] (2) The processing unit 301 determines valid data in the target upgrade file according to the size of the valid data and the preset position.
[0148] 本发明实施例中, 有效数据的大小和预设位置确定目标升级文件中的有效数据 。 其中, 预设位置为有效数据的起始位置, 它的设定由嵌入式系统设定, 或包 含该数据的嵌入式软件确定。  [0148] In the embodiment of the present invention, the size of the valid data and the preset location determine valid data in the target upgrade file. The preset position is the starting position of the valid data, and its setting is determined by the embedded system or embedded software containing the data.
[0149] (3) 处理单元 301根据有效数据的大小将有效数据划分为 N个有效数据块。 [0149] (3) The processing unit 301 divides the valid data into N valid data blocks according to the size of the valid data.
[0150] 其中, 原文件包括 M个数据块, N个有效数据块与 M个数据块之间存在对应关 系。 [0150] wherein the original file includes M data blocks, and there is a correspondence between the N valid data blocks and the M data blocks.
[0151] 其中, M和 N是大于等于 1的正整数。  Wherein M and N are positive integers greater than or equal to 1.
[0152] 其中, 数据块是一组或几组按顺序连续排列在一起的记录, 是主存储器与输入 设备、 输出设备或外存储器之间进行传输的数据单位; 上述原文件也可称之为 原始文件, 是存储在嵌入式设备的内存中的文件, 本次升级, 就是将原文件替 换成目标升级文件, 即将原文件中的数据完全或部门替换成目标升级文件中的 数据, 该数据的限定或描述, 在后面的步骤中进行具体限定或描述。  [0152] wherein the data block is a group or groups of records continuously arranged in sequence, and is a data unit for transmitting between the main memory and the input device, the output device, or the external memory; the original file may also be referred to as The original file is a file stored in the memory of the embedded device. In this upgrade, the original file is replaced with the target upgrade file, and the data in the original file is completely or replaced with the data in the target upgrade file. The definition or description is specifically defined or described in the following steps.
[0153] 上述对应关系, 可以分三种情况进行讨论:  [0153] The above correspondence can be discussed in three cases:
[0154] 首先, 若 M>N, 则上述 N个有效数据块与原文件 M个数据块中的 N个数据块相 对应。  [0154] First, if M>N, the N valid data blocks correspond to N data blocks in the M data blocks of the original file.
[0155] 其次, 若 M=N, 则上述 N个有效数据块与原文件 M个数据块一一对应。  [0155] Next, if M=N, the N valid data blocks are in one-to-one correspondence with the original file M data blocks.
[0156] 最后, 若 M<N, 由于嵌入式软件进行升级, 实际改动的范围不大, 因此, 目标 升级文件中的有效数据的大小较小, 即出现 M<N的可能性不大。  [0156] Finally, if M<N, due to the upgrade of the embedded software, the actual modification scope is not large. Therefore, the size of the valid data in the target upgrade file is small, that is, the possibility of M<N is not large.
[0157] (4) 读取单元 302从 N个有效数据块中读取第 i个有效数据块。 [0157] (4) The reading unit 302 reads the i-th valid data block from the N valid data blocks.
[0158] 本发明实施例中, 上述 i的初始值为 1, 第一次读取的吋候, 读取第 1个有效数 据块。 [0158] In the embodiment of the present invention, the initial value of the above i is 1, and the first valid number is read when the first reading is performed. According to the block.
[0159] (5) 检测单元 303检测第 i个有效数据块与第 j个数据块是否相同, 第 j个数据块 为 M个数据块中的一个, 第 i个数据块与第 j个数据块对应。  [0159] (5) The detecting unit 303 detects whether the i-th valid data block is the same as the j-th data block, and the j-th data block is one of M data blocks, the i-th data block and the j-th data block. correspond.
[0160] 其中, 上述 i和 j均为正整数, 且均大于 1。 [0160] wherein, i and j are both positive integers, and both are greater than one.
[0161] 可选的, N个有效数据块中的任一个有效数据块的大小与 M个数据块中的任一 个数据块的大小相同。  [0161] 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.
[0162] 可选的, 检测单元 303检测第 i个有效数据块与第 j个数据块是否相同包括: 检测 第 i个有效数据块的大小和数据与第 j个数据块的大小和数据是否相同。  [0162] Optionally, detecting, by the detecting unit 303, whether the i-th valid data block and the j-th data block are the same include: detecting whether the size and data of the i-th valid data block are the same as the size and data of the j-th data block .
[0163] 本发明实施例中, 若检测单元 303检测第 i个有效数据块与第 j个数据块相同吋, 则执行 i加 1得到新的 i值的步骤, 即不会将第 j个数据块从内存单元中擦除, 也不 会将第 i个有效数据块写入内存, 将 i加 1得到新的 i值 (i<N) 后, 返回读取第 i ( 值得注意的是, 此吋的 i为新的 i值) 个有效数据块; 若检测单元 303检测第 i个有 效数据块与第 j个数据块不相同吋, 则执行检测第 i个有效数据块中的所有数据是 否全由十六进制数 0至 F中的同一个数组成的步骤。  [0163] In the embodiment of the present invention, if the detecting unit 303 detects that the i-th valid data block is the same as the j-th data block, the step of performing i plus 1 to obtain a new i value is performed, that is, the j-th data is not to be obtained. The block is erased from the memory unit, and the i-th valid data block is not written to the memory. After i is incremented by 1, the new i value (i<N) is returned, and the i-th reading is returned (notably, this Ii is a new i value) valid data block; if the detecting unit 303 detects that the i th valid data block is different from the jth data block, performing detection of whether all data in the i th valid data block is full A step consisting of the same number in hexadecimal numbers 0 through F.
[0164] (6) 检测单元 303检测第 i个有效数据块中的所有数据是否全由十六进制数 0至 F中的同一个数组成。  [0164] (6) The detecting unit 303 detects whether all data in the i-th valid data block is composed entirely of the same number in hexadecimal numbers 0 to F.
[0165] 本发明实施例中, 检测单元 303检测 i个有效数据块中的所有数据是否全由十六 进制数 0、 1、 2、 3、 4、 5、 6、 7、 8、 9、 A、 B、 C、 D和 F中的同一个数组成。  [0165] In the embodiment of the present invention, the detecting unit 303 detects whether all data in the i valid data blocks are all hexadecimal numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, The same number in A, B, C, D, and F.
[0166] (7) 擦除单元 306将第 j个数据块从内存单元擦除, 写入单元 307将第 i个有效数 据块写入该内存单元。 [0166] (7) The erase unit 306 erases the jth data block from the memory unit, and the write unit 307 writes the i-th valid data block to the memory unit.
[0167] 当检测单元 303检测第 i个有效数据块中的所有数据不全由十六进制数 0至 F中的 同一个数组成吋, 则擦除单元 306将第 j个数据块从内存单元擦除, 写入单元 307 将第 i个有效数据块写入该内存单元。  [0167] When the detecting unit 303 detects that all the data in the i-th valid data block is not entirely composed of the same number in the hexadecimal numbers 0 to F, the erasing unit 306 takes the j-th data block from the memory unit. The erase, write unit 307 writes the ith valid data block to the memory unit.
[0168] (8) 擦除单元 306将第 j个数据块从内存单元中擦除。  [0168] (8) The erase unit 306 erases the jth data block from the memory unit.
[0169] 其中, 上述内存单元为存储一个数据块吋所占用的内存大小, 可以理解为存储 一个数据块的单元。  [0169] wherein, the memory unit is a memory size occupied by storing one data block, and can be understood as a unit for storing one data block.
[0170] 上述将第 j个数据块从内存单元中擦除可以理解为将第 j个数据块中的数据从内 存单元中擦除。 [0171] 本发明实施例中, 若嵌入式设备检测第 i个有效数据块中的所有数据全由十六 进制数 0至 F中的同一个数组成, 则嵌入式设备将第 j个数据块从内存单元中擦除 , 而第 i个有效数据块并不写入该内存单元中。 举例来说, 若目标升级文件的有 效数据为前 10行, 每行为一个数据块, 即有 10个有效数据块, 且第 6至第 10行数 据块中的数据全由十六进制数 0至 F中的某一个数组成, 不妨令第 6至第 10行数据 块的数据分别全由 0、 1、 2、 3、 4和 5组成。 那么, 嵌入式设备将第 j个数据块从 内存单元中擦除后, 而第 6至第 10行数据块并不写入内存, 即擦除, 但不写入。 而第 1行至第 5行的数据块, 在嵌入式设备将第 j个数据块从内存单元中擦除后, 写入该内存单元, 请参阅图 6。 [0170] The above erasing of the jth data block from the memory unit can be understood as erasing data in the jth data block from the memory unit. [0171] In the embodiment of the present invention, if the embedded device detects that all data in the i-th valid data block is composed of the same number in hexadecimal numbers 0 to F, the embedded device will use the j-th data. The block is erased from the memory unit and the ith valid data block is not written to the memory unit. For example, if the valid data of the target upgrade file is the first 10 rows, there are 10 valid data blocks for each data block, and the data in the 6th to 10th rows of data blocks are all hexadecimal numbers 0. To a certain number of F, it is possible to make the data of the 6th to 10th data blocks all consist of 0, 1, 2, 3, 4 and 5. Then, the embedded device erases the jth data block from the memory unit, and the 6th to 10th data blocks are not written into the memory, that is, erased, but not written. The data blocks of the first row to the fifth row are written to the memory cell after the embedded device erases the jth data block from the memory cell, as shown in FIG. 6.
[0172] (9) 运算单元 304将 i加 1得到新的 i值。  [0172] (9) The arithmetic unit 304 increments i by 1 to obtain a new value of i.
[0173] 其中, i在加 1之前, 是小于等于 N的一个正整数, 当加 1后得到新的 i值, 新的 i 值可能大于 N。  [0173] wherein, i is a positive integer less than or equal to N before adding 1, and a new i value is obtained when 1 is added, and the new i value may be greater than N.
[0174] (10) 判断单元 305判断 i值是否大于 N。 [0174] (10) The judging unit 305 judges whether or not the value of i is greater than N.
[0175] 本发明实施例中, 判断单元 305判断新的 i值是否大于 N, 若小于 N, 则返回执行 步骤 103, 即执行嵌入式设备从 N个有效数据块中读取第 i个有效数据块的步骤; 若大于 N, 则读取单元 302读取升级文件的末尾数据块的步骤。  In the embodiment of the present invention, the determining unit 305 determines whether the new value of i is greater than N, and if it is less than N, returns to step 103, that is, executing the embedded device to read the ith effective data from the N valid data blocks. Step of the block; if greater than N, the reading unit 302 reads the end data block of the upgrade file.
[0176] (11) 读取单元 302读取升级文件的末尾数据块。  [0176] (11) The reading unit 302 reads the end data block of the upgrade file.
[0177] (12) 擦除单元 306将原文件的末尾数据块从内存单元中擦除, 写入单元 307将 升级文件的末尾数据块写入内存单元。  [0177] (12) The erasing unit 306 erases the end data block of the original file from the memory unit, and the writing unit 307 writes the end data block of the upgrade file to the memory unit.
[0178] 其中, 上述末尾数据块为目标升级文件末尾的一个数据块, 在该数据块中, 包 含了校验位, 如前面的" 31和 41", 还包括有效数据的大小, 也可称之为有效数据 的长度, 本发明实施例中不作区分, 如后面 4个字节 "FF, 1C, FD, EF"。 [0178] wherein, the last data block is a data block at the end of the target upgrade file, and the data block includes a check digit, such as the foregoing "31 and 41", and also includes the size of the valid data, which may also be called The length of the valid data is not distinguished in the embodiment of the present invention, such as the following four bytes "FF, 1C, FD, EF".
[0179] 上述将原文件的末尾数据块从内存单元中擦除可以理解为将原文件的末尾数据 块的数据从内存单元中擦除。 [0179] The above erasing of the end data block of the original file from the memory unit can be understood as erasing the data of the end data block of the original file from the memory unit.
[0180] 本发明实施例中, 当判断新的 i值大于 N吋, 读取单元 302读取升级文件的末尾 数据块, 并将原文件的末尾数据块从内存单元中擦除, 将升级文件的末尾数据 块写入该内存单元, 完成末尾数据块写入内存单元的步骤后, 便完成了该目标 升级文件的写入。 [0181] 简而言之, 本发明实施例从目标升级文件的末尾数据块得到有效数据信息, 根 据该信息确定目标升级文件的有效数据, 将有效数据划分为 N个数据块, N个有 效数据块中, 若有 a (a<N) 个数据块分别与原文件中的 a个数据块相同, 则该 a 个有效数据块不写入内存, 且对应的原数据块也不进行刪除; 若 b个有效数据块 与原文件的数据不相同, 且 b (b<N) 个有效数据块中任意一个有效数据块中的 所有数据全由十六进制数 0至 F中的同一个数组成, 则将对应的原数据块从内存 中擦除, 但上述 b个有效数据块不写入内存; 若 t (t<N) 个有效数据块中任意一 个有效数据块中的所有数据不全由十六进制数 0至 F中的同一个数组成, 则将对 应的原数据块从内存中擦除, 且上述 b个有效数据块不写入内存, 其中, a+b+t= N。 [0180] In the embodiment of the present invention, when it is determined that the new i value is greater than N吋, the reading unit 302 reads the end data block of the upgrade file, and erases the last data block of the original file from the memory unit, and the upgrade file is upgraded. The end of the data block is written to the memory unit, and after the step of writing the end data block to the memory unit, the writing of the target upgrade file is completed. [0181] In short, the embodiment of the present invention obtains valid data information from the end data block of the target upgrade file, determines valid data of the target upgrade file according to the information, and divides the valid data into N data blocks and N valid data. In the block, if a (a<N) data blocks are the same as a data block in the original file, the a valid data block is not written into the memory, and the corresponding original data block is not deleted; b valid data blocks are different from the original file data, and all data in any valid data block in b (b<N) valid data blocks are all composed of the same number in hexadecimal numbers 0 to F , the corresponding original data block is erased from the memory, but the above b valid data blocks are not written into the memory; if all data in any valid data block of t (t<N) valid data blocks is not all ten When the hexadecimal numbers 0 to F are composed of the same number, the corresponding original data block is erased from the memory, and the above b valid data blocks are not written into the memory, where a+b+t=N.
[0182] 通过本发明实施例的方案, 可以只将升级文件中不全由十六进制数 0至 F中的同 一个数组成的有效数据写入内存, 以及末尾数据块的数据写入内存, 而其它数 据不写入内存, 如无效数据和全由十六进制数 0至 F中的同一个数组成的有效数 据不写入内存, 可以有效地提升写入效率, 缩短写入的吋间, 加快嵌入式软件 的升级速度, 解决嵌入式软件升级耗费吋间长的问题。  [0182] According to the solution of the embodiment of the present invention, only valid data that is not composed of the same number of hexadecimal numbers 0 to F in the upgrade file may be written into the memory, and data of the last data block is written into the memory. Other data is not written to the memory. For example, invalid data and valid data consisting of the same number in hexadecimal numbers 0 to F are not written into the memory, which can effectively improve the writing efficiency and shorten the writing time. , speed up the upgrade of embedded software, and solve the problem of long-term cost of embedded software upgrades.
[0183] 请参阅图 7, 图 7是本发明实施例公幵的另一种嵌入式设备的结构示意图, 如图 7所示, 该嵌入式包括:  Please refer to FIG. 7. FIG. 7 is a schematic structural diagram of another embedded device according to an embodiment of the present invention. As shown in FIG. 7, the embedded device includes:
[0184] 输入装置 701、 输出装置 702、 处理器 703和存储器 704, 上述通信输入 701、 输 出装置 702、 处理器 703和存储器 704通过总线 705连接。  [0184] The input device 701, the output device 702, the processor 703, and the memory 704, and the communication input 701, the output device 702, the processor 703, and the memory 704 are connected by a bus 705.
[0185] 其中, 上述输入装置 701具体可为 USB接口、 键盘或鼠标等。  [0185] The input device 701 may be specifically a USB interface, a keyboard, a mouse, or the like.
[0186] 上述输出装置 702具体可为显示屏或指示灯。  [0186] The output device 702 described above may specifically be a display screen or an indicator light.
[0187] 上述存储器 704可以是高速 RAM存储器, 也可为非易失存储器 (non-volatile memory) , 例如磁盘存储器。 上述存储器 704用于存储一组程序代码, 上述输入 装置 701、 输出装置 702和处理器 703用于调用存储器 704中存储的程序代码, 执 行如下操作:  [0187] The above memory 704 may be a high speed RAM memory or a non-volatile memory such as a disk memory. The above memory 704 is used to store a set of program codes, and the input device 701, the output device 702, and the processor 703 are used to call the program code stored in the memory 704, and perform the following operations:
[0188] 上述处理器 703, 用于:  [0188] The processor 703 is configured to:
[0189] 对原文件进行升级, 上述原文件包括 M个数据块, 包括:  [0189] The original file is upgraded, and the original file includes M data blocks, including:
[0190] 确定目标升级文件中的有效数据, 并将有效数据划分为 N个有效数据块, N个 有效数据块与 M个数据块之间存在对应关系, M和 N均为正整数; [0190] determining valid data in the target upgrade file, and dividing the valid data into N valid data blocks, N There is a correspondence between valid data blocks and M data blocks, and M and N are positive integers;
[0191] 从 N个有效数据块中读取第 i个有效数据块, 检测第 i个有效数据块与第 j个数据 块是否相同, 第 j个数据块为 M个数据块中的一个, 第 i个数据块与第 j个数据块对 应, i和 j均为正整数; [0191] reading the i-th valid data block from the N valid data blocks, detecting whether the i-th valid data block is the same as the j-th data block, and the j-th data block is one of M data blocks, i data blocks correspond to the jth data block, and i and j are positive integers;
[0192] 若相同, 则将 i加 1得到新的 i值, 判断新的 i值是否大于 N, 若否, 返回执行从 N 个有效数据块中读取第 i个有效数据块的步骤;  [0192] If they are the same, add i to 1 to obtain a new value of i, determine whether the new value of i is greater than N, and if not, return to perform the step of reading the i-th valid data block from the N valid data blocks;
[0193] 若不相同, 则检测第 i个有效数据块中的所有数据是否全由十六进制数 0至 F中 的同一个数组成, 若是, 则将第 j个数据块从内存单元擦除, 执行将 i加 1得到新 的 i值, 判断新的 i值是否大于 N的步骤, 并当新的 i值小于 N吋, 返回执行从 N个 有效数据块中读取第 i个有效数据块的步骤; [0193] If not, detecting whether all data in the i-th valid data block is composed of the same number in hexadecimal numbers 0 to F, and if so, wiping the j-th data block from the memory unit Except, the step of adding i to 1 to obtain a new i value, judging whether the new i value is greater than N, and returning the execution of the i th valid data from the N valid data blocks when the new i value is less than N吋Block step
[0194] 当判断新的 i值大于 N吋, 则读取升级文件的末尾数据块, 将原文件的末尾数据 块从内存单元中擦除, 并将升级文件的末尾数据块写入内存单元。 [0194] When it is judged that the new i value is greater than N吋, the end data block of the upgrade file is read, the end data block of the original file is erased from the memory unit, and the end data block of the upgrade file is written into the memory unit.
[0195] 可选的, 上述处理器 703, 还用于: [0195] Optionally, the processor 703 is further configured to:
[0196] 若检测上述第 i个有效数据块中的所有数据不全由十六进制数 0至 F中的同一个 数组成, 则将上述第 j个数据块从内存单元中擦除, 并将上述第 i个有效数据块写 入上述内存单元, 将上述 i加 1得到新的 I 判断上述新的 i值是否大于 N, 若否 , 返回执行读取上述 N个有效数据块的第 i个数据块的步骤。  [0196] if it is detected that all data in the ith valid data block is not completely composed of the same number in hexadecimal numbers 0 to F, the jth data block is erased from the memory unit, and The ith valid data block is written into the memory unit, and the i is incremented by 1 to obtain a new I. It is determined whether the new i value is greater than N. If not, the ith data of the N valid data blocks is read and executed. The steps of the block.
[0197] 可选的, 上述处理器 703, 还用于: 在确定目标升级文件中的有效数据之前, 还包括:  [0197] Optionally, the foregoing processor 703 is further configured to: before determining valid data in the target upgrade file, the method further includes:
[0198] 读取上述目标升级文件的末尾数据块, 从上述末尾数据块中获得上述有效数据 的大小。  [0198] reading the last data block of the target upgrade file, and obtaining the size of the valid data from the last data block.
[0199] 可选的, 上述处理器 703, 还用于:  [0199] Optionally, the foregoing processor 703 is further configured to:
[0200] 根据上述有效数据的大小和预设位置确定上述目标升级文件中的有效数据, 并 根据上述有效数据的大小将上述有效数据划分为 N个有效数据块。  [0200] determining valid data in the target upgrade file according to the size of the valid data and the preset position, and dividing the valid data into N valid data blocks according to the size of the valid data.
[0201] 其中, 上述 N个有效数据块中的任一个有效数据块的大小与上述 M个数据块中 的任一个数据块的大小相同。  [0201] 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.
[0202] 通过本发明实施例的方案, 可以只将升级文件中不全由十六进制数 0至 F中的同 一个数组成的有效数据写入内存, 以及末尾数据块的数据写入内存, 而其它数 据不写入内存, 如无效数据和全由十六进制数 0至 F中的同一个数组成的有效数 据不写入内存, 可以有效地提升写入效率, 缩短写入的吋间, 加快嵌入式软件 的升级速度, 解决嵌入式软件升级耗费吋间长的问题。 [0202] According to the solution of the embodiment of the present invention, only valid data that is not composed of the same number of hexadecimal numbers 0 to F in the upgrade file may be written into the memory, and data of the last data block is written into the memory. Other numbers According to the memory not written, such as invalid data and the same data consisting of the same number of hexadecimal numbers 0 to F are not written into the memory, which can effectively improve the writing efficiency, shorten the writing time, and speed up The upgrade speed of embedded software solves the problem of long time spent on embedded software upgrades.
尽管结合具体特征及其实施例对本发明进行了描述, 显而易见的, 在不脱离本 发明的精神和范围的情况下, 可对其进行各种修改和组合。 相应地, 本说明书 和附图仅仅是所附权利要求所界定的本发明的示例性说明, 且视为已覆盖本发 明范围内的任意和所有修改、 变化、 组合或等同物。 显然, 本领域的技术人员 可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。 这样, 倘若 本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内, 则本 发明也意图包含这些改动和变型在内。  While the invention has been described in terms of the specific embodiments and embodiments thereof, it will be understood that various modifications and combinations may be made without departing from the spirit and scope of the invention. Accordingly, the description and drawings are to be regarded as It is apparent that those skilled in the art can make various modifications and variations to the invention without departing from the spirit and scope of the invention. Thus, it is intended that the present invention cover the modifications and modifications of the invention
技术问题 technical problem
问题的解决方案 Problem solution
发明的有益效果 Advantageous effects of the invention

Claims

权利要求书 Claim
[权利要求 1] 一种嵌入式软件快速升级的方法, 其特征在于, 所述方法用于对原文 件进行升级, 所述原文件包括 M个数据块, 所述方法包括: 确定目标升级文件中的有效数据, 并将所述有效数据划分为 N个有效 数据块, 所述 N个有效数据块与所述 M个数据块之间存在对应关系, 所述 M和所述 N均为正整数;  [Claim 1] A method for rapidly upgrading an embedded software, wherein the method is used to upgrade an original file, where the original file includes M data blocks, and the method includes: determining a target upgrade file The valid data is divided into N valid data blocks, and the N valid data blocks and the M data blocks have a corresponding relationship, and the M and the N are positive integers;
从所述 N个有效数据块中读取第 i个有效数据块, 检测所述第 i个有效 数据块与第 j个数据块是否相同, 所述第 j个数据块为所述 M个数据块 中的一个, 所述第 i个数据块与所述第 j个数据块对应, 所述 i和所述 j 均为正整数;  Reading the i-th valid data block from the N valid data blocks, detecting whether the i-th valid data block is the same as the j-th data block, and the j-th data block is the M data block And the i-th data block corresponds to the j-th data block, and the i and the j are both positive integers;
若相同, 则将所述 i加 1得到新的 i值, 判断所述新的 i值是否大于 N, 若 否, 返回执行所述从所述 N个有效数据块中读取第 i个有效数据块的步 骤;  If they are the same, the i is incremented by 1 to obtain a new i value, and it is determined whether the new i value is greater than N. If not, returning to perform the reading of the i th valid data from the N valid data blocks. Block step
若不相同, 则检测所述第 i个有效数据块中的所有数据是否全由十六 进制数 0至 F中的同一个数组成, 若是, 则将所述第 j个数据块从内存 单元擦除, 执行所述将所述 i加 1得到新的 i值, 判断所述新的 i值是否 大于 N的步骤, 并当所述新的 i值小于 N吋, 返回执行所述从所述 N个 有效数据块中读取第 i个有效数据块的步骤;  If not, detecting whether all data in the i-th valid data block is composed of the same number in hexadecimal numbers 0 to F, and if so, the j-th data block is from the memory unit Erasing, performing the step of adding 1 to i to obtain a new i value, determining whether the new i value is greater than N, and returning execution of the slave from when the new i value is less than N吋The step of reading the i th valid data block in the N valid data blocks;
当判断所述新的 i值大于 N吋, 则读取所述升级文件的末尾数据块, 将 所述原文件的末尾数据块从所述内存单元中擦除, 并将所述升级文件 的末尾数据块写入所述内存单元。  When it is determined that the new i value is greater than N吋, reading the end data block of the upgrade file, erasing the end data block of the original file from the memory unit, and ending the upgrade file A data block is written to the memory unit.
[权利要求 2] 根据权利要求 1所述方法, 其特征在于, 所述方法还包括: [Claim 2] The method according to claim 1, wherein the method further comprises:
若检测所述第 i个有效数据块中的所有数据不全由十六进制数 0至 F中 的同一个数组成, 则将所述第 j个数据块从所述内存单元中擦除, 并 将所述第 i个有效数据块写入所述内存单元, 执行所述将所述 i加 1得到 新的 i值, 判断所述新的 i值是否大于 N的步骤, 并当所述新的 i值小于 N吋, 返回执行所述从所述 N个有效数据块中读取第 i个有效数据块的 If it is detected that all data in the i-th valid data block is not entirely composed of the same number in hexadecimal numbers 0 to F, the j-th data block is erased from the memory unit, and Writing the ith valid data block into the memory unit, performing the step of adding 1 to the new i value, determining whether the new i value is greater than N, and when the new If the value of i is less than N吋, returning to perform the reading of the i th valid data block from the N valid data blocks
[权利要求 3] 根据权利要求 1所述方法, 其特征在于, 所述确定目标升级文件中的 有效数据之前, 所述方法还包括: [Claim 3] The method according to claim 1, wherein before the determining the valid data in the target upgrade file, the method further includes:
读取所述目标升级文件的末尾数据块, 从所述末尾数据块中获得所述 有效数据的大小。  Reading the last data block of the target upgrade file, and obtaining the size of the valid data from the last data block.
[权利要求 4] 根据权利要求 3所述方法, 其特征在于, 所述确定目标升级文件中的 有效数据, 并将所述有效数据划分为 N个有效数据块包括: 根据所述有效数据的大小和预设位置确定所述目标升级文件中的有效 数据, 并根据所述有效数据的大小将所述有效数据划分为 N个有效数 据块。 [Claim 4] The method according to claim 3, wherein: determining the valid data in the target upgrade file, and dividing the valid data into N valid data blocks comprises: according to the size of the valid data Determining valid data in the target upgrade file with a preset location, and dividing the valid data into N valid data blocks according to the size of the valid data.
[权利要求 5] 根据权利要求 1至 4任意一项所述方法, 其特征在于, [Claim 5] The method according to any one of claims 1 to 4, characterized in that
所述 N个有效数据块中的任一个有效数据块的大小与所述 M个数据块 中的任一个数据块的大小相同。  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] —种嵌入式设备, 其特征在于, 包括: [Claim 6] An embedded device, comprising:
处理单元用于确定目标升级文件中的有效数据, 将所述有效数据划分 为 N个有效数据块, 所述 N个有效数据块与所述 M个数据块之间存在 对应关系, 所述 M和所述 N均为正整数;  The processing unit is configured to determine valid data in the target upgrade file, and divide the valid data into N valid data blocks, where there is a correspondence between the N valid data blocks and the M data blocks, where the M and The N is a positive integer;
读取单元, 用于从所述 N个有效数据块中读取第 i个有效数据块; 检测单元, 用于检测所述第 i个有效数据块与第 j个数据块是否相同, 所述第 j个数据块为所述 M个数据块中的一个, 所述第 i个数据块与所 述第 j个数据块对应, 所述 i和所述 j均为正整数; 运算单元, 用于当所述第 i个有效数据块与第 j个数据块相同吋, 将所 述 i加 1得到新的 i值;  a reading unit, configured to read an i th valid data block from the N valid data blocks, and a detecting unit, configured to detect whether the i th valid data block and the j th data block are the same, The j data blocks are one of the M data blocks, the i-th data block corresponds to the j-th data block, and the i and the j are both positive integers; The i-th valid data block is the same as the j-th data block, and the i is incremented by 1 to obtain a new i value;
判断单元, 用于当所述运算单元将所述 i加 1得到新的 i值吋, 判断所述 新的 i值是否大于 N; a determining unit, configured to: when the computing unit adds 1 to the i to obtain a new i value, determining the Whether the new i value is greater than N;
所述读取单元, 还用于当所述判断单元判断结果为否吋, 从所述 N个 有效数据块中读取第 i个有效数据块;  The reading unit is further configured to: when the determining unit determines that the result is negative, read the i th valid data block from the N valid data blocks;
所述检测单元, 还用于当所述第 i个有效数据块与第 j个数据块不相同 吋, 检测所述第 i个有效数据块中的所有数据是否全由十六进制数 0至 F中的同一个数组成;  The detecting unit is further configured to: when the i-th valid data block is different from the j-th data block, detecting whether all data in the i-th valid data block is all from a hexadecimal number 0 to The same number in F;
擦除单元, 用于当所述第 i个有效数据块中的所有数据是否全由十六 进制数 0至 F中的同一个数组成吋, 将所述第 j个数据块从内存单元擦 除;  An erasing unit, configured to: when all data in the i-th valid data block is composed of the same number in hexadecimal numbers 0 to F, wipe the j-th data block from the memory unit Save
所述运算单元, 还用于在所述擦除单元将所述第 j个数据块从内存单 元擦除之后, 将所述 i加 1得到新的 i值;  The operation unit is further configured to: after the erasing unit erases the jth data block from the memory unit, add the i to 1 to obtain a new i value;
所述判断单元, 还用于当所述运算单元将所述 i加 1得到新的 i值吋, 判 断所述新的 i值是否大于 N;  The determining unit is further configured to: when the computing unit adds the i to 1 to obtain a new i value, determine whether the new i value is greater than N;
所述读取单元, 还用于当所述判断单元判断结果为是吋, 读取所述升 级文件的末尾数据块;  The reading unit is further configured to: when the determining unit determines that the result is 吋, read a data block at the end of the upgrade file;
所述擦除单元, 还用于将所述原文件的末尾数据块从所述内存单元中 擦除;  The erasing unit is further configured to erase the end data block of the original file from the memory unit;
写入单元, 用于所述升级文件的末尾数据块写入所述内存单元。  a write unit, the end data block for the upgrade file is written to the memory unit.
[权利要求 7] 根据权利要求 6所述设备, 其特征在于, [Claim 7] The apparatus according to claim 6, wherein
所述擦除单元, 还用于当检测所述第 i个有效数据块中的所有数据不 全由十六进制数 0至 F中的同一个数组成吋, 将所述第 j个数据块从所 述内存单元中擦除; 所述写入单元, 还用于在所述擦除单元将所述第 j个数据块从所述内 存单元中擦除之后, 将所述第 i个有效数据块写入所述内存单元; 所述运算单元, 还用于在所述写入单元将所述第 i个有效数据块写入 所述内存单元之后, 将所述 i加 1得到新的 i值;  The erasing unit is further configured to: when detecting that all data in the i-th valid data block is not completely composed of the same number in hexadecimal numbers 0 to F, the j-th data block is The writing unit is further configured to: after the erasing unit erases the jth data block from the memory unit, the i-th valid data block Writing to the memory unit; the operation unit is further configured to: after the writing unit writes the i-th valid data block into the memory unit, add the i to 1 to obtain a new i value;
所述判断单元, 还用于当所述运算单元将所述 i加 1得到新的 i值吋, 判 断所述新的 i值是否大于 N; The determining unit is further configured to: when the computing unit adds 1 to the i to obtain a new i value, Whether the new i value is greater than N;
所述读取单元, 还用于当所述判断单元判断结果为否吋, 从所述 N个 有效数据块中读取第 i个有效数据块。  The reading unit is further configured to: when the determining unit determines that the result is negative, read the i th valid data block from the N valid data blocks.
[权利要求 8] 根据权利要求 6所述设备, 其特征在于, [Claim 8] The apparatus according to claim 6, wherein
所述读取单元, 还用于读取所述目标升级文件的末尾数据块, 从所述 末尾数据块中获得所述有效数据的大小。  The reading unit is further configured to read a data block of the end of the target upgrade file, and obtain a size of the valid data from the last data block.
[权利要求 9] 根据权利要求 8所述设备, 其特征在于, 所述处理单元确定目标升级 文件中的有效数据, 将所述有效数据划分为 N个有效数据块的方式具 体为: [Claim 9] The device according to claim 8, wherein the processing unit determines valid data in the target upgrade file, and the manner in which the valid data is divided into N valid data blocks is:
所述处理单元, 根据所述有效数据的大小和预设位置确定所述目标升 级文件中的有效数, 并根据所述有效数据的大小将所述有效数据划分 为 N个有效数据块。  The processing unit determines a valid number in the target upgrade file according to the size of the valid data and a preset position, and divides the valid data into N valid data blocks according to the size of the valid data.
[权利要求 10] 根据权利要求 6至 9任意一项所述设备, 其特征在于, [Claim 10] The apparatus according to any one of claims 6 to 9, characterized in that
所述 N个有效数据块中的任一个有效数据块的大小与所述 M个数据块 中的任一个数据块的大小相同。  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.
PCT/CN2017/078847 2016-11-22 2017-03-30 Quick upgrade method for embedded software and embedded device WO2018094937A1 (en)

Applications Claiming Priority (2)

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

Publications (1)

Publication Number Publication Date
WO2018094937A1 true WO2018094937A1 (en) 2018-05-31

Family

ID=58811820

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/078847 WO2018094937A1 (en) 2016-11-22 2017-03-30 Quick upgrade method for embedded software and embedded device

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 (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2009107000A2 (en) * 2008-02-29 2009-09-03 Schlumberger Canada Limited Method, system and apparatus for remote software upgrade of an embedded device
CN102662700A (en) * 2012-03-28 2012-09-12 广东欧珀移动通信有限公司 Method for releasing and upgrading embedded software edition
CN102929669A (en) * 2012-10-29 2013-02-13 北京开元智信通软件有限公司 Embedded software upgrading method, system and device

Family Cites Families (5)

* 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
CN101290571B (en) * 2007-04-16 2011-01-12 阮建辉 Method for creating file being dynamically loaded and performed
CN101334734B (en) * 2007-06-27 2012-01-11 北京中电华大电子设计有限责任公司 Method for electric communication card dynamically downloading patch program
CN101937340B (en) * 2009-06-29 2014-11-05 中兴通讯股份有限公司 Method and device for dynamically updating and controlling software by using patches
TWI557744B (en) * 2015-01-27 2016-11-11 緯創資通股份有限公司 Data storing method and embedded system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2009107000A2 (en) * 2008-02-29 2009-09-03 Schlumberger Canada Limited Method, system and apparatus for remote software upgrade of an embedded device
CN102662700A (en) * 2012-03-28 2012-09-12 广东欧珀移动通信有限公司 Method for releasing and upgrading embedded software edition
CN102929669A (en) * 2012-10-29 2013-02-13 北京开元智信通软件有限公司 Embedded software upgrading method, system and device

Also Published As

Publication number Publication date
CN106648751B (en) 2020-04-21
CN106648751A (en) 2017-05-10

Similar Documents

Publication Publication Date Title
CN107239392B (en) Test method, test device, test terminal and storage medium
US9804832B2 (en) Method, apparatus, and communication device for updating firmware
US9176865B2 (en) Data writing method, memory controller, and memory storage device
CN103999060A (en) Solid-state storage management
TWI607448B (en) Data writing method, memory control circuit unit and mempry storage apparatus
KR20120063829A (en) Method of data processing for non-volatile memory
CN104699622A (en) Data storage device and data erasing method thereof
CN109240870A (en) A kind of solid state hard disk Fault Locating Method and relevant apparatus
CN107391038B (en) Data writing method of data storage type flash memory, flash memory and storage medium
KR20100088210A (en) Apparatus and method for downloadin contents using movinand in portable terminal
CN109445691B (en) Method and device for improving FTL algorithm development and verification efficiency
WO2016155387A1 (en) Plug-in management method and device based on mobile terminal
CN114942863A (en) Cascade snapshot processing method, device and equipment and storage medium
CN111143240B (en) Image storage method, system and terminal equipment
CN100440383C (en) External storing performance testing method and apparatus
CN103577344A (en) Data writing method, memory controller and memory storage device
WO2018094937A1 (en) Quick upgrade method for embedded software and embedded device
CN109104481B (en) File integrity detection method, file integrity detection device and terminal equipment
WO2020113421A1 (en) Method for mounting file system, terminal device, and storage medium
CN111090397A (en) Data deduplication method, system, equipment and computer readable storage medium
CN110058938B (en) Memory processing method and device, electronic equipment and readable medium
WO2023060893A1 (en) Storage space management method and apparatus, and device and storage medium
CN102819514B (en) Data reading method and device for storage medium
CN111880743B (en) Data storage method, device, equipment and storage medium
TWI569201B (en) Controlling method, memory controller and data transmission system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17874379

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 04.09.2019)

122 Ep: pct application non-entry in european phase

Ref document number: 17874379

Country of ref document: EP

Kind code of ref document: A1