WO2020082984A1 - 一种固件升级方法、装置及终端 - Google Patents

一种固件升级方法、装置及终端 Download PDF

Info

Publication number
WO2020082984A1
WO2020082984A1 PCT/CN2019/108397 CN2019108397W WO2020082984A1 WO 2020082984 A1 WO2020082984 A1 WO 2020082984A1 CN 2019108397 W CN2019108397 W CN 2019108397W WO 2020082984 A1 WO2020082984 A1 WO 2020082984A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
firmware version
data block
upgrade
block
Prior art date
Application number
PCT/CN2019/108397
Other languages
English (en)
French (fr)
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 WO2020082984A1 publication Critical patent/WO2020082984A1/zh
Priority to US17/140,847 priority Critical patent/US11531535B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/654Updates using techniques specially adapted for alterable solid state memories, e.g. for EEPROM or flash memories
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis
    • G06F8/433Dependency analysis; Data or control flow analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • G06F8/63Image based installation; Cloning; Build to order
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/658Incremental updates; Differential updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Definitions

  • the present application relates to the field of Internet of Things terminal technology, and in particular, to a firmware upgrade method, device, and terminal.
  • the Internet of Things is a network that extends and expands on the basis of the Internet, and its user end extends to any item and item for information exchange and communication.
  • the collected data of the Internet of Things terminal is obtained through the Internet of Things platform, and the obtained data is provided to each specific Internet of Things service, such as vehicle management, retail management, logistics management, etc.
  • the Internet of Things platform manages the Internet of Things terminals, and the thin device on the end of the Internet of Things is one of the key devices for the management of the Internet of Things terminal.
  • the differential upgrade method is: generate a differential upgrade package from the old firmware version 1 and the new firmware version 2 in the IoT end-side thin device, and then download the differential upgrade package to the flash memory of the IoT-side thin device Then, run the upgrade program on the thin device on the IoT side, and upgrade the old firmware version 1 to the new firmware version 2 through the differential upgrade package.
  • the differential upgrade method can achieve the firmware upgrade of the IoT end-side thin device
  • the firmware upgrade process needs to be compared with the old firmware version image by using the differential upgrade package to obtain the new firmware version image and store it on the IoT end-side thin device. Flash memory, and then replace the image of the new firmware version with the image of the old firmware version to complete the upgrade.
  • the flash memory of the thin device on the Internet of Things side needs to make a full mirror backup of the image of the old firmware version, so the flash space resource is large during the upgrade process.
  • This application provides a firmware upgrade method, device, and terminal to solve the problem of using a flash memory space resource during the firmware upgrade process of the thin device of the Internet of Things using the differential upgrade method in the conventional technology.
  • the present application provides a firmware upgrade method, the method includes: sequentially acquiring first upgrade data and operation instructions in each data block of a block differential upgrade package, the first upgrade data being a new firmware version Compared with the data of the old firmware version image, the operation instruction is used to instruct to obtain the second upgrade data according to the data in the old firmware version image. Converting the first data indicated in the operation instruction into the second upgrade data in the old firmware version image according to the operation instruction. When the first data does not exist in the old firmware version image, the first upgrade data and the second upgrade data are controlled to cover the data area to be upgraded in the old firmware version image.
  • the first upgrade data cannot be obtained by any data conversion in the image of the old firmware version.
  • the second upgrade data is obtained by converting data (eg, first data) in the image of the old firmware version.
  • the first upgrade data and the second upgrade data constitute the difference data of the new firmware version image and the old firmware version image.
  • the first data is any data whose dependency in the old firmware version image is not 0, and the dependency is used to indicate that the first data is required for conversion to the second upgrade data The number of times, wherein each time the second upgrade data is generated, the dependency of the first data is updated.
  • the first data indicated by the operation instruction is converted into second upgrade data in the old firmware version image according to the operation instruction in the differential upgrade package, and the old firmware version image is based on the first upgrade data and the second upgrade data Complete the upgrade to the new firmware version image.
  • the entire upgrade process does not need to generate a new firmware version image, and there is no need to reserve storage space for the new firmware version image; and the block differential upgrade package uses the operation instructions to replace some or all of the data in the traditional differential upgrade package. , Which further reduces the flash memory overhead of the storage block differential upgrade package, thereby making the flash memory space resource consumption small during the upgrade process.
  • the first data indicated in the operation instruction is converted into the second upgrade data in the old firmware version image according to the operation instruction Including: acquiring a field range of the first data corresponding to the operation instruction indication; determining the first data from the old firmware version image according to the field range; according to the conversion path in the operation instruction Converting the first data to the second upgrade data in the old firmware version image.
  • the first data is converted into the old firmware version image according to the conversion path in the operation instruction
  • the second upgrade data includes: determining a backup area in the old firmware version image, the backup area being a data area corresponding to the data to be deleted in the old firmware version image; converting the first data Copy to the backup area; convert the first data to the second upgrade data in the backup area according to the conversion path.
  • the method further includes: if the first data exists in the data area to be upgraded, the first upgrade data Put in the backup area.
  • the fourth possible implementation manner of the first aspect further includes: if the first data exists in the data area to be upgraded, put the first data Into the backup area.
  • the present application provides a firmware upgrade method, the method includes: obtaining an initial differential upgrade package according to the difference data of the new firmware version image and the old firmware version image; splitting the new firmware version image into the first A first data block of a preset length, where the first data block is any data block after the image split of the new firmware version; according to the data area of the initial differential upgrade package corresponding to the first data block Splitting the initial differential upgrade package to obtain a second data block, the second data block being any data block after the initial differential upgrade package is split; determining the second data block to the old firmware The degree of dependency of each original data block in the version image; updating the second data block according to the degree of dependency to obtain a block differential upgrade package.
  • the updating of the second data block includes: Part or all of the data is replaced with an operation instruction, and the operation instruction is used to instruct to generate data in the second data block that is replaced with the operation instruction according to the original data block.
  • the initial differential upgrade package is first divided into blocks, and then part or all of the data in the initial differential upgrade package data block obtained by the division is replaced by operation instructions, thereby reducing the differential upgrade package to Flash. take up space.
  • the initial differential upgrade package is split according to the data area of the initial differential upgrade package corresponding to the generated first data block to obtain the second
  • the data block includes: determining that each first data block corresponds to a field range of the initial differential upgrade package; using the last address of each field range as a splitting point of the initial differential upgrade package, splitting the initial Differential upgrade package.
  • the determining the degree of dependence of the second data block on each original data block in the old firmware version image includes: : If part or all of the data in the second data block can be obtained according to the original data block, the dependency of the original data block is updated; wherein, the data in the second data block can pass through one or more Obtain the original data block.
  • the updating the second data block according to the degree of dependency includes: determining to obtain the Operation instructions corresponding to part or all of the data in the second data block, the operation instructions include one or more of the following: translate the original data block to a specified field position, and perform data in a preset area of the original data block Delete and transform the original data block according to the specified path; add the operation instruction to the second data block and delete the part or all of the data.
  • a fourth possible implementation manner of the second aspect it further includes: each time the second data block is updated, updating the dependency of the original data block.
  • the present application provides a firmware upgrade apparatus, the apparatus includes: an acquisition module for sequentially acquiring first upgrade data and operation instructions in each data block of a block differential upgrade package, the first upgrade The data is data added by the new firmware version image compared to the old firmware version image, and the first upgrade data cannot be obtained through the old firmware version image; the operation instruction is used to instruct to obtain based on the data in the old firmware version image
  • the second upgrade data, the first upgrade data and the second upgrade data constitute the difference data of the new firmware version image and the old firmware version image;
  • a data conversion module is used to convert the operation instruction
  • the indicated first data is converted into the second upgrade data in the old firmware version image according to the operation instruction, and the first data is any data whose dependency is not 0 in the old firmware version image,
  • the degree of dependence is converted into the second upgrade data by indicating the number of times that the first data is required, wherein the first update data is updated every time the second upgrade data is generated A data dependency; an upgrade module, configured to control the difference data to cover the data area to
  • the data conversion module includes: an obtaining unit configured to obtain a field range of the first data corresponding to the operation instruction indication; a determining unit, It is used to determine the first data from the old firmware version image according to the field range; a data conversion unit is used to convert the first data in the old firmware version image according to the conversion path in the operation instruction The data is converted into the second upgrade data.
  • the data conversion unit includes: a determination subunit for determining a backup area in the old firmware version image ,
  • the backup area is a data area corresponding to the data to be deleted in the image of the old firmware version;
  • a data translation subunit used to copy the first data to the backup area;
  • a data conversion subunit used to Convert the first data into second upgrade data in the backup area according to the conversion path.
  • the method further includes: a first data backup unit, configured to: if the first data exists in the data area to be upgraded , Put the first upgrade data into the backup area.
  • a fourth possible implementation manner of the third aspect it further includes: a second data backup unit, used if the first data exists in the data area to be upgraded , Put the first data into the backup area.
  • the present application provides a firmware upgrade apparatus, characterized in that the apparatus includes: an acquisition module configured to obtain an initial differential upgrade package according to the difference data between the new firmware version image and the old firmware version image; A sub-module for splitting the new firmware version image into a first data block of a first preset length, the first data block being any data block after the new firmware version image is split; second A splitting module, configured to split the initial differential upgrade package according to the data area of the initial differential upgrade package corresponding to the first data block to obtain a second data block, the second data block is the Any data block after the initial differential upgrade package is split; a determination module is used to determine the degree of dependence of the second data block on each original data block in the old firmware version image; an update module is used according to the Updating the second data block by dependency to obtain a block differential upgrade package, the updating the second data block includes: replacing part or all of the data in the second data block with an operation instruction, the operation The command for instructing to generate the original data block is replaced with the second data operation instruction
  • the second splitting module includes: a first determining unit configured to determine that each first data block corresponds to the initial differential upgrade A field range of the package; a splitting unit, configured to use the last address of each field range as a splitting point of the initial differential upgrade package to split the initial differential upgrade package.
  • the determination module includes: a first dependency update unit, configured to obtain Part or all of the data in the second data block updates the dependency of the original data block; wherein, the data in the second data block can be obtained by one or more of the original data blocks.
  • the update module includes: a third determining unit, configured to determine to obtain an update according to the second data block update Dependency and dependency attribute of the third data block when describing the first data block, the dependency attribute includes one or more of the following: deletion, translation, and transformation; an instruction generation unit, which is used according to the dependency Generating an operation instruction with the dependency attribute, wherein each time the operation instruction is generated according to the third data block, the dependency of the third data block is decreased by 1; an update unit is used to add the operation instruction to The second data block and delete data associated with the third data block, and the data associated with the third data block is data obtained according to the operation instruction and the third data block.
  • the method further includes: a second dependency update unit, configured to update the second data block after each update of the second data block Describe the dependence of the original data block.
  • the present application provides a terminal, including: a processor; a memory for storing computer-executable instructions; when the processor executes the computer-executable instructions, the first aspect and the first aspect described above are performed.
  • the in-situ differential upgrade is completed according to the obtained block differential upgrade package and the old firmware version image, and a new firmware version image is obtained.
  • the present application provides a terminal, including: a processor; a memory for storing computer-executable instructions; when the processor executes the computer-executable instructions, the second aspect and the second aspect described above are performed.
  • a block differential upgrade package is generated according to the new firmware version image and the old firmware version image.
  • the present application provides a computer storage medium containing computer-readable instructions, which are executed by one or more processors to implement the first aspect and any one of the first aspects Possible methods of implementation.
  • the present application provides a computer storage medium containing computer-readable instructions, which are executed by one or more processors to implement the foregoing second aspect and any of the second aspects Possible methods of implementation.
  • Figure 1 is a schematic diagram of the differential upgrade method in the conventional technology
  • FIG. 2 is a schematic flowchart of a firmware upgrade method provided by an embodiment of the present application.
  • FIG. 3 is a schematic diagram of adding a block identifier to a data block according to an embodiment of the present application
  • FIG. 4 is a schematic diagram of an initial differential upgrade package after splitting provided by an embodiment of the present application.
  • FIG. 5 is a schematic flowchart of another firmware upgrade method provided by an embodiment of the present application.
  • FIG. 6 is a schematic diagram of a firmware upgrading apparatus provided by an embodiment of the present application.
  • FIG. 7 is a schematic diagram of another firmware upgrading apparatus provided by an embodiment of the present application.
  • FIG. 8 is a schematic structural diagram of a terminal according to an embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of another terminal provided by an embodiment of the present application.
  • the terminal that generates the differential upgrade package is a PC production terminal
  • the terminal that performs in-place differential upgrade according to the differential upgrade package is a thin device on the Internet of Things side.
  • the PC production side stores the current old firmware version image of the thin device on the IoT side and the new firmware version image that needs to be updated.
  • a block differential upgrade package is generated from the old firmware version image and the new firmware version image.
  • the PC production side will generate the The block differential upgrade package is uploaded to the server.
  • the thin device of the Internet of Things needs to upgrade the firmware version, download the block differential upgrade package from the server, according to the block differential upgrade package and the old firmware version image in the current device, to achieve the in-situ differential upgrade, the Internet of Things side
  • the old firmware version of the thin device is upgraded to the new firmware version.
  • FIG. 2 is a schematic flowchart of a firmware upgrade method provided by an embodiment of the present application.
  • the firmware upgrade method includes:
  • the production end compares the new firmware version image with the old firmware version image, determines the difference data between the new firmware version image and the new firmware version image, and generates an initial differential upgrade package based on the difference data.
  • the currently generated differential upgrade package is the same as the traditional differential upgrade package.
  • the data carried in the differential upgrade package only represents the difference between the new firmware version image and the old firmware version image.
  • the initial differential upgrade package can be Obtain the new firmware version image based on the internal difference data and the old firmware version image.
  • the difference data carried in the initial differential upgrade package generated in S101 can characterize the difference between the new firmware version image and the old firmware version image, there may be two different types of difference data, one of which is the new firmware version
  • the data added by the image compared to the image of the old firmware version cannot be obtained based on the data in the image of the old firmware version.
  • the other difference data is also the data that the new firmware version image adds to the old firmware version image, but it can be obtained by converting the data in the old firmware version image. If the type of the difference data carried in the initial differential upgrade package is the latter, the part corresponding to the type of data in the differential upgrade package can be replaced with an operation instruction, thereby reducing the data length of the initial differential upgrade package.
  • the new firmware version image is split according to a preset length, the new firmware version image is split into multiple first data blocks, and the first data block is the new firmware version Any data block after splitting.
  • the preset length of the split new firmware version image can be set according to actual needs, for example, it can be set to 2M, 4M, 8M, 16M, etc. The specific split length depends on the length of the new firmware version image This embodiment is not specifically limited.
  • a block identifier is added to each first data block, and the block identifier is used to determine the sequence relationship of each first data block in the new firmware version image.
  • the new firmware version image is split from the image file header position.
  • the first data block corresponding to the image file header position is added with a block identifier 1, indicating that the first data block is in a new The location of the file header in the firmware version image, correspondingly adding block identifiers 2, 3 ... n to each subsequent first data block in sequence, and the first data block corresponding to block identifier n is the end of the file in the new firmware version image position.
  • the image of the new firmware version is split.
  • the above splitting of the new firmware image is a split of equal length, and the length of each first data block is the same.
  • the data corresponding to the initial differential upgrade package generated by each first data block may be different.
  • the length of the image of the new firmware version is 100M, and the image of the new firmware version is split according to the preset length of 10M, which is divided into 10 first data blocks.
  • the initial differential upgrade package is 20M, corresponding to 10 first data blocks, and the initial differential upgrade package needs to be split into 10 blocks.
  • the data of the first data block generated in the initial differential upgrade package may be 3M, so if the initial differential upgrade package is split into equal lengths, the data block after the initial differential upgrade package is split cannot correspond to the first data block. Therefore, in this embodiment, the initial differential upgrade package is split according to the data area of the initial differential upgrade package corresponding to the first data block to obtain a second data block, where the second data block is any one after the initial differential upgrade package is split data block.
  • a block identifier is also added to each second data block, and the allocation rule of the added block identifier is the same as that of the first data block, ensuring that the generated block identifier is 1.
  • the block identifier of the second data block corresponding to the first data block is also 1.
  • the block identifier of the first data block sequentially determine the field range corresponding to each first data block generated in the initial differential upgrade package, and use the last address of each field range as the split point of the initial differential upgrade package,
  • the initial differential upgrade package is split into multiple second data blocks.
  • the length of the new firmware version image is 100M
  • the new firmware version image is split according to a preset length of 10M to obtain 10 first data blocks with a length of 10M.
  • the initial differential upgrade package is 20M, and the field range corresponding to the first first data block to the tenth first data block in the initial differential upgrade package is 0-3M, 3M-4M, 4M-7M, 7M-9M, 9M- 9.5M, 9.5M-11M, 11-13M, 13M-17M, 17M-19M, 19M-20M.
  • the length of the data area corresponding to the initial differential upgrade package corresponding to the first data block is 3M, 1M, 3M, 2M, 0.5M, 1.5M, 2M, 4M, 2M, 1M. Therefore, after the initial differential upgrade package is split, the length of the second data block according to the block identifier is 3M, 1M, 3M, 2M, 0.5M, 1.5M, 2M, 4M, 2M, 1M.
  • S104 Determine the dependence of the second data block on each original data block in the old firmware version image.
  • the initial differential upgrade package After the initial differential upgrade package is split, it is determined whether obtaining part or all of the data in the second data block depends on the original data block in the image of the old firmware version, where the length of the original data block cannot be determined.
  • the length of the original data block is 1M at this time.
  • Part of the data in the second second data block can be obtained by converting the two original data blocks with the field range of 2M-3M and 5M-7M in the image of the old firmware version.
  • the length of the original data block is uncertain, and the dependence degree of the same original data block is also different.
  • the original data block with the field range of 2M-3M in the above old firmware version image needs to be used twice, so the dependency is 2.
  • the original data block with the field range of 5M-7M is used once, and the dependency is 1. If the original data block with the field range of 2M-3M in the old firmware version image will be used again in the future, the dependency of the original data block is increased by 1 until all the second data blocks are determined.
  • the operation instruction includes: shifting the original data block to the specified field position, at this time part of the second data block Or all the data is only the data corresponding to a certain original data block, which is only obtained by translation. Delete the data in the preset area of the original data block. At this time, part or all of the data in the second data block needs to be deleted according to part of the data in an original data block, and then the remaining data is spliced to obtain the second data block. . Transform the original data block according to the specified path. At this time, part or all of the data in the second data block needs to be obtained by changing according to the data in the original data block.
  • all or part of the data in the second data block is deleted and replaced with the operation instruction.
  • the dependence of the original data block will change, so the dependence of each original data block needs to be updated.
  • the length of the first second data block is 3M
  • 2M of the data can be obtained by data conversion according to the original data block with the field range of 5M-7M in the image of the old firmware version
  • the first The corresponding 2M data in the second data block is deleted
  • the addition instruction is that the deleted 2M data can be obtained by data conversion according to the original data block with a field range of 5M-7M in the image of the old firmware version.
  • the length of the second data block is changed from 3M to close to 1M, so that the amount of data in the differential upgrade package becomes smaller, but it does not affect subsequent upgrades.
  • the firmware upgrade method provided in this embodiment first divides the initial differential upgrade package into blocks, and then replaces part or all of the data in the initial differential upgrade package data block obtained by the division with operation instructions. Furthermore, the space occupied by the Flash by the differential upgrade package is reduced.
  • a block differential upgrade package is generated, and this application also provides another firmware upgrade method, which is used to upgrade according to the block differential after the terminal device obtains the block differential upgrade package
  • the package upgrades the firmware, upgrading the old firmware version in the terminal device to the new firmware version.
  • FIG. 5 is another firmware upgrade method provided by an embodiment of the present application.
  • the firmware upgrade method includes:
  • S201 Acquire the first upgrade data and operation instructions in each data block of the block differential upgrade package in sequence.
  • the block differential upgrade package generated in the above embodiment updates each block in the block differential upgrade package, so that the amount of data in the block differential upgrade becomes smaller, but at least it is guaranteed that the terminal can use the differential upgrade package to complete Normal firmware upgrade.
  • the first upgrade data exists in the data block in the block differential upgrade package, it means that the first upgrade data is first the data of the new firmware version image compared to the old firmware version image. Secondly, the first upgrade data is that the old firmware version cannot pass the old firmware version.
  • the data in the image is obtained by any operation.
  • the operation instruction is used to indicate that the second upgrade data can be obtained according to the data in the old firmware version image.
  • the data block in the initial state block differential upgrade package should contain both the first upgrade data and the second upgrade data, but The second upgrade data can be obtained according to the data in the image of the old firmware version, so the second upgrade data is replaced with the operation instruction.
  • the first upgrade data and the second upgrade data constitute the difference data of the new firmware version image and the old firmware version image
  • the new firmware version image can be obtained according to the difference data and the old firmware version image.
  • S202 Convert the first data to the second upgrade data in the old firmware version image according to the operation instruction.
  • the first data is any data whose dependency degree in the old firmware version image is not 0, and the dependency degree is used to indicate the number of times the first data is required to be converted into the second upgrade data. For example, if the second upgrade data in the data blocks of the three block differential upgrade packages are converted and need to use a first data, then the dependence of the first data is 3.
  • the first data is determined from the old firmware version image according to the field range, and the first data is converted into the second upgrade data in the old firmware version image according to the conversion path in the operation instruction.
  • a backup area is determined in the old firmware version image.
  • the backup area is a data area corresponding to the data to be deleted in the old firmware version image.
  • the specific data to be deleted is the old firmware version image compared to the new firmware Data that is not required for the version image, and this part of the data needs to be overwritten by the upgraded data. Copy the first data to the backup area, and convert the first data to the second upgrade data in the backup area according to the conversion path. Wherein, every time the second upgrade data is generated, the dependency of the first data needs to be updated.
  • one data block in the block differential upgrade package contains the first upgrade data of 1M and an operation instruction
  • the operation instruction is 6M of the data corresponding to the field range 5M-7M in the image of the old firmware version -6.5M data is deleted, and then the remaining two ends of data are spliced to obtain the second upgrade data, and then the second superior data is overwritten to the 5M-6.5M field range in the old firmware version image, and the first upgrade data is overwritten.
  • the firmware version mirrors the 6.5M-7.5M field range. At this time, you need to delete the first data corresponding to the field range 5M-7M in the old firmware version image. However, if the first data has a dependency of 3, the first data will be used later, so it will be The first data is copied to the backup area for operation, so that the corresponding second upgrade data can be obtained, and the original first data structure will not be damaged.
  • S203 Control the first upgrade data and the second upgrade data to cover the data area to be upgraded in the old firmware version image.
  • the second upgrade data is generated in the backup area, and the second upgrade data can be directly translated to the designated field position in the old firmware version image, and the first upgrade data can also be extracted from the data block in the block differential upgrade package obtain. But first, it must be ensured that there is no first data in the data area to be upgraded to be covered by the first upgrade data and the second upgrade data. If the first data exists, after it is overwritten, subsequent upgrades cannot be guaranteed.
  • one data block in the block differential upgrade package contains 1M of the first upgrade data and an operation instruction.
  • the operation instruction is to translate and cover the data corresponding to the 3M-5M field range in the old firmware version image to The 10M-12M field range in the old firmware version image, and the first upgrade data of 1M overwrites the 12M-13M field range of the old firmware version image. Therefore, in this embodiment, the data corresponding to the field range 3M-5M in the old firmware version image is the second upgrade data, which is the data existing in the old firmware version image, but it corresponds to the 12M-13M field in the new firmware version image. range. However, if there is other first data in the 12M-13M field range of the old firmware version image, the direct shift will overwrite the other first data at this time.
  • the first data corresponding to the 3M-5M field range in the old firmware version image is first copied to the backup area, which can prevent the first data from being needed later, and the direct translation causes the firmware upgrade to not proceed smoothly.
  • the direct translation causes the firmware upgrade to not proceed smoothly.
  • it can be prevented that direct translation will overwrite other first data, resulting in the subsequent firmware upgrade not being able to proceed smoothly.
  • the dependency degree becomes 0 after this translation .
  • the field range of the backup area is the 60M-70M field range in the old firmware version image
  • the first data corresponding to the original 12M-13M field range of the old firmware version image can be shifted to the 60M-62M field range in the old firmware version image.
  • the second upgrade data is generated in the backup area, and it is determined that the first data does not exist in the data area to be upgraded in the old firmware version image corresponding to the first upgrade data and the second upgrade data, the first upgrade data and the 2.
  • the difference data composed of the upgrade data covers the data area to be upgraded, and completes some data upgrades in the image of the old firmware version. Until all the data areas to be upgraded in the old firmware version image are upgraded accordingly, the old firmware version image at this time smoothly becomes the new firmware version image, and the old firmware in the terminal is upgraded to the new firmware.
  • the firmware upgrade method provided in this embodiment converts the first data indicated by the operation instruction into the second upgrade data in the image of the old firmware version according to the operation instruction in the differential upgrade package, and according to the first upgrade data and The second upgrade data completes the operation of upgrading to the new firmware version image in the old firmware version image.
  • the entire upgrade process does not need to generate a new firmware version image, and there is no need to reserve storage space for the new firmware version image; and the block differential upgrade package uses the operation instructions to replace some or all of the data in the traditional differential upgrade package. , Which further reduces the flash memory overhead of the storage block differential upgrade package, thereby making the flash memory space resource consumption small during the upgrade process.
  • FIG. 6 is a schematic diagram of a firmware upgrading apparatus provided by an embodiment of the present application.
  • the firmware upgrading apparatus 30 includes: an obtaining module 301, a first splitting module 302, a second splitting module 303, a determining module 304 and an update Module 305.
  • the obtaining module 301 is used to obtain an initial differential upgrade package according to the difference data of the new firmware version image and the old firmware version image.
  • the first splitting module 302 is configured to split the new firmware version image into a first data block of a first preset length, and the first data block is any data block after the new firmware version image split.
  • the second splitting module 303 is configured to split the initial differential upgrade package to obtain a second data block according to the data area of the initial differential upgrade package corresponding to the first data block.
  • the second data block is the split of the initial differential upgrade package Any data block.
  • the determining module 304 is used to determine the dependence of the second data block on each original data block in the old firmware version image.
  • the update module 305 is used to update the second data block according to the degree of dependency to obtain a block differential upgrade package. Updating the second data block includes: replacing part or all of the data in the second data block with an operation instruction, and the operation instruction is used to indicate The data in the second data block that is replaced with the operation instruction is generated based on the original data block.
  • the second splitting module 303 includes: a first determining unit and a splitting unit.
  • the first determining unit is used to determine the field range of the initial differential upgrade package corresponding to each first data block.
  • the splitting unit is used to split the initial differential upgrade package by using the last address of each field range as the split point of the initial differential upgrade package.
  • the determining module 304 includes: a first dependency update unit for updating the dependency of the original data block if part or all of the data in the second data block can be obtained from the original data block; wherein, in the second data block Data can be obtained from one or more of the original data blocks.
  • the update module 305 includes: a second determination unit and an update unit.
  • the second determination unit is used to determine an operation instruction corresponding to some or all of the data in the second data block according to the original data block.
  • the operation instruction includes one or more of the following: shift the original data block to a specified field position, convert the original data block The data in the preset area of is deleted, the original data block is transformed according to a specified path; an update unit is used to add an operation instruction to the second data block and delete part or all of the data.
  • the firmware upgrading apparatus 30 provided by the embodiment of the present application further includes: a second dependency update unit, configured to update the dependency of the original data block every time a second data block is updated.
  • the firmware upgrading apparatus replaces part or all of the data in the initial differential upgrade package data block obtained by the block by operation instructions, thereby reducing the space occupied by the differential upgrade package for the Flash.
  • the firmware upgrading apparatus 40 includes: an acquisition module 401, a data conversion module 402, and an upgrade module 403.
  • the obtaining module 401 is used to sequentially obtain the first upgrade data and the operation instruction in each data block of the block differential upgrade package.
  • the first upgrade data is the data added by the new firmware version image compared to the old firmware version image, and the first upgrade data It cannot be obtained through the old firmware version image;
  • the operation instruction is used to instruct to obtain the second upgrade data according to the data in the old firmware version image, and the first upgrade data and the second upgrade data constitute the difference data between the new firmware version image and the old firmware version image.
  • the data conversion module 402 is used to convert the first data indicated in the operation instruction to the second upgrade data in the old firmware version image according to the operation instruction, and the first data is any data whose dependency is not 0 in the old firmware version image , The degree of dependence is used to indicate the number of times that the first data is required to be converted into the second upgrade data, where the dependency of the first data is updated every time the second upgrade data is generated.
  • the upgrade module 403 is configured to control the difference data to cover the data area to be upgraded when the first data does not exist in the data area to be upgraded in the old firmware version image.
  • the data conversion module includes: an acquisition unit, a determination unit, and a data conversion unit.
  • the obtaining unit is configured to obtain the field range of the first data corresponding to the operation instruction indication.
  • the determining unit is configured to determine the first data from the old firmware version image according to the field range.
  • the data conversion unit is configured to convert the first data to the second upgrade data in the image of the old firmware version according to the conversion path in the operation instruction.
  • the data conversion unit includes: a determination subunit, a data translation subunit, and a data conversion subunit.
  • the determination subunit is used to determine a backup area in the old firmware version image, and the backup area is a data area corresponding to the data to be deleted in the old firmware version image.
  • the data translation subunit is used to copy the first data to the backup area.
  • the data conversion subunit is used to convert the first data into the second upgrade data in the backup area according to the conversion path.
  • the firmware upgrading apparatus 40 provided by the embodiment of the present application further includes: a first data backup unit and a second data backup unit. among them:
  • the first data backup unit is configured to put the first upgraded data into the backup area if the first data exists in the data area to be upgraded.
  • the second data backup unit is configured to put the first data into the backup area if the first data exists in the data area to be upgraded.
  • the obtaining module 401 obtains the first upgrade data and the operation instruction, and the data conversion module 402 converts the first data indicated by the operation instruction into the second upgrade data in the old firmware version image, and the upgrade module 403 According to the first upgrade data and the second upgrade data, the operation of upgrading to the new firmware version image is completed in the old firmware version image.
  • the entire upgrade process does not need to generate a new firmware version image, and there is no need to reserve storage space for the new firmware version image; and the block differential upgrade package uses the operation instructions to replace some or all of the data in the traditional differential upgrade package. , Which further reduces the flash memory overhead of the storage block differential upgrade package, thereby making the flash memory space resource consumption small during the upgrade process.
  • FIG. 8 is a schematic structural diagram of a terminal according to an embodiment of the present application.
  • the terminal 50 includes: a processor 501, a memory 502 and a communication interface 503.
  • the memory 502 is used to store computer executable instructions.
  • the processor 501 executes the computer executable instructions, it performs the following operations:
  • the processor 501, the memory 502, and the communication interface 503 may be connected to each other through a bus; the bus may be divided into an address bus, a data bus, and a control bus. For ease of representation, only a thick line is used in FIG. 8, but it does not mean that there is only one bus or one type of bus.
  • the processor 501 may be a general-purpose processor, for example, a central processing unit (English: central processing unit, abbreviation: CPU), a network processor (English: network processor, abbreviation: NP), or a combination of CPU and NP.
  • the processor may also be a microprocessor (MCU).
  • the processor may also include a hardware chip.
  • the above-mentioned hardware chip may be an application specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof.
  • the above PLD may be a complex programmable logic device (CPLD), a field programmable logic gate array (FPGA), etc.
  • the memory 502 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read only memory (EEPROM), erasable and removable Programmable read only memory (EPROM), programmable read only memory (PROM), read only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
  • SRAM static random access memory
  • EEPROM electrically erasable programmable read only memory
  • EPROM erasable and removable Programmable read only memory
  • PROM programmable read only memory
  • ROM read only memory
  • magnetic memory magnetic memory
  • flash memory magnetic disk or optical disk.
  • the communication interface 503 is used for the terminal 50 to upload the generated block differential upgrade package to the server.
  • the communication interface includes a wired communication interface, and may also include a wireless communication interface.
  • the wired communication interface includes a PLC interface, and may also include an Ethernet interface.
  • the wireless communication interface may be a WLAN interface, a cellular network communication interface, or a combination thereof.
  • the terminal 50 may also include a power supply component for supplying power to various components of the PLC chip.
  • the power supply component may include a power management system and one or more power supplies.
  • the terminal 60 includes: a processor 601, a memory 602 and a communication interface 603.
  • the memory 602 is used to store computer executable instructions.
  • the processor 601 executes the computer executable instructions, it performs the following operations:
  • the first upgrade data is the data of the new firmware version image compared to the old firmware version image; the operation instruction is used to indicate that the old firmware
  • the data in the version image obtains the second upgrade data.
  • the processor 601, the memory 602, and the communication interface 603 may be connected to each other through a bus; the bus may be divided into an address bus, a data bus, and a control bus. For ease of representation, only a thick line is used in FIG. 9, but it does not mean that there is only one bus or one type of bus.
  • the processor 601 in the above embodiment may be a general-purpose processor, for example, a central processing unit (English: central processing unit, abbreviation: CPU), a network processor (English: network processor, abbreviation: NP), or a combination of CPU and NP.
  • the processor may also be a microprocessor (MCU).
  • the processor may also include a hardware chip.
  • the above-mentioned hardware chip may be an application specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof.
  • the above PLD may be a complex programmable logic device (CPLD), a field programmable logic gate array (FPGA), etc.
  • the memory 602 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read only memory (EEPROM), erasable and removable Programmable read only memory (EPROM), programmable read only memory (PROM), read only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
  • SRAM static random access memory
  • EEPROM electrically erasable programmable read only memory
  • EPROM erasable and removable Programmable read only memory
  • PROM programmable read only memory
  • ROM read only memory
  • magnetic memory magnetic memory
  • flash memory magnetic disk or optical disk.
  • the communication interface 603 is used by the terminal 60 to download the block differential upgrade package to update the firmware version.
  • the communication interface includes a wired communication interface, and may also include a wireless communication interface.
  • the wired communication interface includes a PLC interface, and may also include an Ethernet interface.
  • the wireless communication interface may be a WLAN interface, a cellular network communication interface, or a combination thereof.
  • the terminal 60 may also include a power supply component for providing power to various components of the PLC chip.
  • the power supply component may include a power management system and one or more power supplies.

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

本申请实施例公开了一种固件升级方法、装置及终端,依次获取分块差分升级包每个数据块中的第一升级数据和操作指令,将第一数据按照操作指令在所述旧固件版本镜像中转换为所述第二升级数据,控制所述第一升级数据和所述第二升级数据覆盖所述旧固件版本镜像中的待升级数据区域。根据第一升级数据和第二升级数据在旧固件版本镜像中完成升级为新固件版本镜像的操作,整个升级过程无需额外生成新固件版本镜像,无需为新固件版本镜像预留存储空间。而且分块差分升级包相比传统的差分升级包利用操作指令替换了传统差分升级包中的部分或全部数据,进一步减小了存储分块差分升级包的闪存开销,进而使得升级过程中闪存空间资源占用小。

Description

一种固件升级方法、装置及终端 技术领域
本申请涉及物联网终端技术领域,尤其涉及一种固件升级方法、装置及终端。
背景技术
物联网是在互联网基础上延伸和扩展的网络,其用户端延伸扩展到了任何物品与物品之间进行信息交换和通信。在当前物联网服务中,通过物联网平台获取物联网终端的采集数据,并将获取的数据提供给各个具体的物联网服务,例如车辆管理、零售管理、物流管理等。物联网平台会对于物联网终端进行管理,而物联网端侧瘦设备则是物联网终端管理的关键设备之一。
随着物联网服务的升级,物联网端侧瘦设备也需要进行相应的固件升级,以提升对物联网终端的管理。传统技术中物联网端侧瘦设备的固件升级方法有很多种,包括:全镜像升级方法、压缩镜像升级方法和差分升级方法。其中,由于差分升级方法具有占用空间信号小,实现简单等优点,因此差分升级方法成为物联网端侧瘦设备最常用的固件升级方法之一。如图1所示,差分升级方法过程为:通过物联网端侧瘦设备中旧固件版本1和新固件版本2生成一个差分升级包,然后将差分升级包下载到物联网端侧瘦设备的闪存中,然后在物联网端侧瘦设备运行升级程序,通过差分升级包将旧固件版本1升级到新固件版本2。
差分升级方法虽然可以实现物联网端侧瘦设备的固件升级,但是固件升级过程中需要通过使用差分升级包与旧固件版本镜像进行比较,获取新固件版本的镜像存储到物联网端侧瘦设备的闪存中,然后将新固件版本的镜像替换旧固件版本镜像完成升级。在升级过程中,为了避免升级过程中断电等情况引起升级失败,物联网端侧瘦设备的闪存需要对旧固件版本的镜像做全镜像备份,因此在升级过程占用闪存空间资源大。
发明内容
本申请提供了一种固件升级方法、装置及终端,以解决传统技术中使用差分升级方法对物联网端瘦设备进行固件升级过程中,占用闪存空间资源大的问题。
第一方面,本申请提供了一种固件升级方法,所述方法包括:依次获取分块差分升级包每个数据块中的第一升级数据和操作指令,所述第一升级数据为新固件版本镜像相比旧固件版本镜像增加的数据,所述操作指令用于指示根据所述旧固件版本镜像中的数据获得所述第二升级数据。将所述操作指令中指示的第一数据按照所述操作指令在所述旧固件版本镜像中转换为所述第二升级数据。当所述旧固件版本镜像中不存在所述第一数据时,控制所述第一升级数据和所述第二升级数据覆盖所述旧固件版本镜像中的待升级数据区域。
所述第一升级数据无法通过所述旧固件版本镜像中的任意数据转换获得。所述第二升级数据是通过所述旧固件版本镜像中的数据(例如第一数据)转换获得的。所述 第一升级数据和所述第二升级数据组成所述新固件版本镜像和所述旧固件版本镜像的差异数据。
在一些实现方式中,所述第一数据为所述旧固件版本镜像中任一依赖度不为0的数据,所述依赖度用于指示转换为所述第二升级数据需要所述第一数据的次数,其中,每生成一个第二升级数据,更新所述第一数据的依赖度。
应理解的是,这里的“新固件版本镜像”不是在完成固件升级的这台计算机上额外生成的,只是指代目标镜像。
采用本实现方式,根据差分升级包中的操作指令在旧固件版本镜像中将操作指令指示的第一数据转换为第二升级数据,根据第一升级数据和第二升级数据在旧固件版本镜像中完成升级为新固件版本镜像的操作。整个升级过程无需额外生成新固件版本镜像,无需为新固件版本镜像预留存储空间;而且分块差分升级包相比传统的差分升级包利用操作指令替换了传统差分升级包中的部分或全部数据,进一步减小了存储分块差分升级包的闪存开销,进而使得升级过程中闪存空间资源占用小。
结合第一方面,在第一方面第一种可能的实现方式中,所述将操作指令中指示的第一数据按照所述操作指令在所述旧固件版本镜像中转换为所述第二升级数据,包括:获取所述操作指令指示对应的所述第一数据的字段范围;根据所述字段范围从所述旧固件版本镜像中确定所述第一数据;按照所述操作指令中的转换路径在所述旧固件版本镜像中将所述第一数据转换为所述第二升级数据。
结合第一方面第一种可能的实现方式,在第一方面第二种可能的实现方式中,所述按照操作指令中的转换路径在所述旧固件版本镜像中将所述第一数据转换为所述第二升级数据,包括:在所述旧固件版本镜像中确定一个备份区,所述备份区为所述旧固件版本镜像中的待删除的数据对应的数据区域;将所述第一数据复制到所述备份区;按照所述转换路径在所述备份区内将所述第一数据转换为第二升级数据。
结合第一方面第二种可能的实现方式,在第一方面第三种可能的实现方式中,还包括:如果所述待升级数据区域中存在所述第一数据,将所述第一升级数据放入所述备份区。
结合第一方面第二种可能的实现方式,在第一方面第四种可能的实现方式中,还包括:如果所述待升级数据区域中存在所述第一数据,将所述第一数据放入所述备份区。
第二方面,本申请提供了一种固件升级方法,所述方法包括:根据新固件版本镜像和旧固件版本镜像的差异数据获得初始差分升级包;将所述新固件版本镜像拆分为第一预设长度的第一数据块,所述第一数据块为所述新固件版本镜像拆分后的任一数据块;根据生成所述第一数据块对应的所述初始差分升级包的数据区域将所述初始差分升级包进行拆分获得第二数据块,所述第二数据块为所述初始差分升级包拆分后的任一数据块;确定所述第二数据块对所述旧固件版本镜像中每个原始数据块的依赖度;根据所述依赖度更新所述第二数据块,获得分块差分升级包,所述更新第二数据块包括:将所述第二数据块中的部分或全部数据更换为操作指令,所述操作指令用于指示根据所述原始数据块生成所述第二数据块中被更换为操作指令的数据。
采用本实现方式,首先将初始差分升级包进行分块,然后将分块获得的初始差分 升级包数据块中的部分或全部的数据通过操作指令进行替代,进而减小了差分升级包对Flash的占用空间。
结合第二方面,在第二方面第一种可能的实现方式中,所述根据生成第一数据块对应的所述初始差分升级包的数据区域将所述初始差分升级包进行拆分获得第二数据块,包括:确定每个所述第一数据块对应所述初始差分升级包的字段范围;将每个字段范围的末地址作为所述初始差分升级包的拆分点,拆分所述初始差分升级包。
结合第二方面第一种可能的实现方式,在第二方面第二种可能的实现方式中,所述确定第二数据块对所述旧固件版本镜像中每个原始数据块的依赖度,包括:如果根据所述原始数据块可以获得所述第二数据块中部分或全部数据,更新所述原始数据块的依赖度;其中,所述第二数据块中的数据可以通过一个或多个所述原始数据块获得。
结合第二方面第二种可能的实现方式,在第二方面第三种可能的实现方式中,所述根据依赖度更新所述第二数据块,包括:确定根据所述原始数据块获得所述第二数据块中部分或全部数据对应的操作指令,所述操作指令包括以下一种或多种:平移所述原始数据块到指定字段位置、将所述原始数据块的预设区域的数据进行删除、将所述原始数据块按照指定路径进行变换;将所述操作指令添加到所述第二数据块并删除所述部分或全部数据。
结合第二方面第三种可能的实现方式,在第二方面第四种可能的实现方式中,还包括:每更新完一个所述第二数据块,更新所述原始数据块的依赖度。
第三方面,本申请提供了一种固件升级装置,所述装置包括:获取模块,用于依次获取分块差分升级包每个数据块中的第一升级数据和操作指令,所述第一升级数据为新固件版本镜像相比旧固件版本镜像增加的数据,所述第一升级数据无法通过所述旧固件版本镜像获得;所述操作指令用于指示根据所述旧固件版本镜像中的数据获得所述第二升级数据,所述第一升级数据和所述第二升级数据组成所述新固件版本镜像和所述旧固件版本镜像的差异数据;数据转化模块,用于将所述操作指令中指示的第一数据按照所述操作指令在所述旧固件版本镜像中转换为所述第二升级数据,所述第一数据为所述旧固件版本镜像中任一依赖度不为0的数据,所述依赖度用指示转换为所述第二升级数据需要所述第一数据的次数,其中,每生成一个第二升级数据,更新所述第一数据的依赖度;升级模块,用于当所述旧固件版本镜像中的待升级数据区域中不存在所述第一数据时,控制所述差异数据覆盖所述待升级数据区域。
结合第三方面,在第三方面第一种可能的实现方式中,所述数据转化模块包括:获取单元,用于获取所述操作指令指示对应的所述第一数据的字段范围;确定单元,用于根据所述字段范围从所述旧固件版本镜像中确定所述第一数据;数据转换单元,用于按照所述操作指令中的转换路径在所述旧固件版本镜像中将所述第一数据转换为所述第二升级数据。
结合第三方面第一种可能的实现方式,在第三方面第二种可能的实现方式中,所述数据转换单元包括:确定子单元,用于在所述旧固件版本镜像中确定一个备份区,所述备份区为所述旧固件版本镜像中的待删除的数据对应的数据区域;数据平移子单元,用于将所述第一数据复制到所述备份区;数据转换子单元,用于按照所述转换路径在 所述备份区内将所述第一数据转换为第二升级数据。
结合第三方面第二种可能的实现方式,在第三方面第三种可能的实现方式中,还包括:第一数据备份单元,用于如果所述待升级数据区域中存在所述第一数据,将所述第一升级数据放入所述备份区。
结合第三方面第二种可能的实现方式,在第三方面第四种可能的实现方式中,还包括:第二数据备份单元,用于如果所述待升级数据区域中存在所述第一数据,将所述第一数据放入所述备份区。
第四方面,本申请提供了一种固件升级装置,其特征在于,所述装置包括:获取模块,用于根据新固件版本镜像和旧固件版本镜像的差异数据获得初始差分升级包;第一拆分模块,用于将所述新固件版本镜像拆分为第一预设长度的第一数据块,所述第一数据块为所述新固件版本镜像拆分后的任一数据块;第二拆分模块,用于根据生成所述第一数据块对应的所述初始差分升级包的数据区域将所述初始差分升级包进行拆分获得第二数据块,所述第二数据块为所述初始差分升级包拆分后的任一数据块;确定模块,用于确定所述第二数据块对所述旧固件版本镜像中每个原始数据块的依赖度;更新模块,用于根据所述依赖度更新所述第二数据块,获得分块差分升级包,所述更新第二数据块包括:将所述第二数据块中的部分或全部数据更换为操作指令,所述操作指令用于指示根据所述原始数据块生成所述第二数据块中被更换为操作指令的数据。
结合第四方面,在第四方面第一种可能的实现方式中,所述第二拆分模块,包括:第一确定单元,用于确定每个所述第一数据块对应所述初始差分升级包的字段范围;拆分单元,用于将每个字段范围的末地址作为所述初始差分升级包的拆分点,拆分所述初始差分升级包。
结合第四方面第一种可能的实现方式,在第四方面第二种可能的实现方式中,所述确定模块,包括:第一依赖度更新单元,用于如果根据所述原始数据块可以获得所述第二数据块中部分或全部数据,更新所述原始数据块的依赖度;其中,所述第二数据块中的数据可以通过一个或多个所述原始数据块获得。
结合第四方面第二种可能的实现方式,在第四方面第三种可能的实现方式中,所述更新模块,包括:第三确定单元,用于确定根据所述第二数据块更新获得所述第一数据块时对所述第三数据块的依赖度和依赖度属性,所述依赖属性包括以下一种或多种:删除、平移和变换;指令生成单元,用于根据所述依赖度和所述依赖度属性生成操作指令,其中,每次根据所述第三数据块生成操作指令后,所述第三数据块的依赖度减1;更新单元,用于将所述操作指令添加到所述第二数据块并删除与所述第三数据块相关联的数据,所述与所述第三数据块相关联的数据为根据所述操作指令和所述第三数据块获得的数据。
结合第四方面第三种可能的实现方式,在第四方面第四种可能的实现方式中,还包括:第二依赖度更新单元,用于每更新完一个所述第二数据块,更新所述原始数据块的依赖度。
第五方面,本申请提供了一种终端,包括:处理器;存储器,用于存储计算机可执 行指令;当所述处理器执行所述计算机可执行指令时,执行如前述第一方面及第一方面任一种可能的实现方式的方法,根据获取的分块差分升级包和旧固件版本镜像完成原地差分升级,获得新固件版本镜像。
第六方面,本申请提供了一种终端,包括:处理器;存储器,用于存储计算机可执行指令;当所述处理器执行所述计算机可执行指令时,执行如前述第二方面及第二方面任一种可能的实现方式的方法,根据新固件版本镜像和旧固件版本镜像生成分块差分升级包。
第七方面,本申请提供一种计算机存储介质,内含计算机可读指令,所述计算机可读指令在被一个或多个处理器执行后用于实现前述第一方面及第一方面任一种可能的实现方式的方法。
第八方面,本申请提供一种计算机存储介质,内含计算机可读指令,所述计算机可读指令在被一个或多个处理器执行后用于实现前述第二方面及第二方面任一种可能的实现方式的方法。
附图说明
为了更清楚地说明本申请的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为传统技术中差分升级方法的示意图;
图2为本申请实施例提供的一种固件升级方法的流程示意图;
图3为本申请实施例提供的一种为数据块添加块标识的示意图;
图4为本申请实施例提供的一种初始差分升级包拆分后的示意图;
图5为本申请实施例提供的另一种固件升级方法的流程示意图;
图6为本申请实施例提供的一种固件升级装置示意图;
图7为本申请实施例提供的另一种固件升级装置示意图;
图8为本申请实施例提供的一种终端的结构示意图;
图9为本申请实施例提供的另一种终端的结构示意图。
具体实施方式
为了使本技术领域的人员更好地理解本申请实施例中的技术方案,下面结合附图对本申请实施例中技术方案作进一步详细的说明。
为了能够更好的对本申请提供的技术方案进行说明,首先对本申请实施例中生成分块差分升级包和根据差分升级包进行原地差分升级的终端进行说明。本实施例中生成差分升级包的终端为PC制作端,根据差分升级包进行原地差分升级的终端为物联网端侧瘦设备。PC制作端中存储有物联网端侧瘦设备当前的旧固件版本镜像和需要更新的新固件版本镜像,通过旧固件版本镜像和新固件版本镜像生成分块差分升级包,PC制作端将生成的分块差分升级包上传到服务器。物联网端侧瘦设备需要进行固件版本升级时,从服务器中下载分块 差分升级包,根据分块差分升级包和当前设备中的旧固件版本镜像,实现原地差分升级,将物联网端侧瘦设备的旧固件版本升级为新固件版本。
图2为本本申请实施例提供的一种固件升级方法的流程示意图,参见图2,所述固件升级方法包括:
S101,根据新固件版本镜像和旧固件版本镜像的差异数据获得初始差分升级包。
本申请实施中制作端将新固件版本镜像和旧固件版本镜像进行进行比对,确定出新固件版本镜像与新固件版本镜像的差异数据,基于该差异数据生成初始差分升级包。也就是说,当前生成的差分升级包与传统中的差分升级包是一致的,该差分升级包中携带的数据仅表征新固件版本镜像和旧固件版本镜像之间的差异,初始差分升级包可以根据内部的差异数据和旧固件版本镜像获得新固件版本镜像。
S102,将新固件版本镜像拆分为第一预设长度的第一数据块。
在S101中生成的初始差分升级包中携带的差异数据虽然可以表征新固件版本镜像和旧固件版本镜像之间的差异,但是差异数据可能存在两种不同的类型,一种差异数据是新固件版本镜像相比旧固件版本镜像增加的数据,根据旧固件版本镜像中的数据也无法获得上述差异数据。另一种差异数据虽然也是新固件版本镜像相比旧固件版本镜像增加的数据,但是可以通过旧固件版本镜像中的数据进行转换获得。如果初始差分升级包中携带的差异数据类型为后者,则可以将差分升级包中对应该种类型数据的部分替换为操作指令,进而可以减小初始差分升级包的数据长度。
为此,本实施例在获得初始差分升级包之后,将新固件版本镜像按照预设长度进行拆分,将新固件版本镜像拆分为多个第一数据块,第一数据块为新固件版本进行拆分后的任一数据块。本实施例中拆分新固件版本镜像的预设长度可以根据实际需要进行设定,例如可以设定为2M、4M、8M、16M等等,具体拆分长度根据新固件版本镜像的长度而定,本实施例不做具体限定。
将新固件版本镜像拆分完毕后,为每个第一数据块添加块标识,所述块标识用于确定每个第一数据块在新固件版本镜像中的顺序关系。如图3所示,将新固件版本镜像从镜像文件头位置开始进行拆分,拆分后,将对应镜像文件头位置的第一数据块添加块标识1,表示该第一数据块是在新固件版本镜像中的文件头位置,相应的对后续每个第一数据块按照顺序依次添加块标识2、3…n,块标识为n对应的第一数据块为新固件版本镜像中的文件末端位置。
S103,根据生成第一数据块对应的初始差分升级包的数据区域将初始差分升级包进行拆分获得第二数据块。
在S102中对新固件版本镜像进行了拆分,为了实现对初始差分数据包中的差异数据进行分析,确定差异数据是否可以根据旧固件版本镜像中的数据进行转换获得。本实施例进一步将初始差分升级包进行拆分。
上述对新固件固件版本镜像的拆分是等长拆分,每个第一数据块的长度相同。但是通过初始差分升级包与旧固件版本生成新固件版本镜像时,生成每个第一数据块对应到初始差分升级包中的数据可能是不同的。例如,新固件版本镜像进行的长度是100M,按照预设长度为10M对新固件版本镜像进行拆分,则分为10个第一数据块。初始差分 升级包为20M,对应10个第一数据块,需要将初始差分升级包拆分为10个块。假设初始差分升级包中生成第一个数据块的数据可能为3M,因此如果将初始差分升级包等长拆分则无法将初始差分升级包拆分后的数据块与第一数据块相对应。因此本实施例中根据生成第一数据块对应的初始差分升级包的数据区域将初始差分升级包进行拆分获得第二数据块,其中第二数据块为初始差分升级包拆分后的任一数据块。相应的,对初始差分升级包进行拆分后,也对每个第二数据块添加块标识,添加块标识的分配规则与对第一数据块添加块标识的一致,保证生成块标识为1的第一数据块对应的第二数据块的块标识也为1。
具体地,按照第一数据块的块标识,依次确定初始差分升级包中生成每个第一数据块对应的字段范围,将每个字段范围的末地址作为初始差分升级包的拆分点,将初始差分升级包拆分为多个第二数据块。如图4所示,新固件版本镜像进行的长度是100M,按照预设长度为10M对新固件版本镜像进行拆分,获得10个长度为10M的第一数据块。初始差分升级包为20M,初始差分升级包中对应第一个第一数据块到第十个第一数据块的字段范围依次0-3M,3M-4M,4M-7M,7M-9M,9M-9.5M,9.5M-11M,11-13M,13M-17M,17M-19M,19M-20M。由上述可知,按照第一数据块的块标识,生成第一数据块对应初始差分升级包的数据区域的长度依次为3M,1M,3M,2M,0.5M,1.5M,2M,4M,2M,1M。因此,对初始差分升级包拆分后,第二数据块按照块标识对应的长度依次为3M,1M,3M,2M,0.5M,1.5M,2M,4M,2M,1M。
S104,确定第二数据块对旧固件版本镜像中每个原始数据块的依赖度。
将初始差分升级包拆分完毕后,确定获得第二数据块中的部分或全部数据是否依赖旧固件版本镜像中的原始数据块,其中,原始数据块的长度也是无法确定的。
如果根据第一个第二数据块中的部分数据可以通过旧固件版本镜像中字段范围为2M-3M的原始数据块转换获得,此时原始数据块的长度为1M。第二个第二数据块中的部分数据可以通过旧固件版本镜像中字段范围为2M-3M和5M-7M的两个原始数据块转换获得。由上述可知,原始数据块的长度是不确定的,而且同一个原始数据块的依赖程度也是不同的。
上述旧固件版本镜像中字段范围为2M-3M的原始数据块需要用到两次,因此依赖度为2。旧固件版本镜像中字段范围为5M-7M的原始数据块用到一次,依赖度为1。如果后续还会再次用到旧固件版本镜像中字段范围为2M-3M的原始数据块,则将该原始数据块的依赖度加1,直至所有的第二数据块确定完毕。
S105,根据依赖度更新第二数据块,获得分块差分升级包。
更新每个第二数据块之前,确定根据原始数据块获得第二数据块中部分或全部数据对应的操作指令,操作指令包括:平移原始数据块到指定字段位置,此时第二数据块中部分或全部数据只是某个原始数据块对应的数据,只是进行平移获得。将原始数据块的预设区域的数据进行删除,此时第二数据块中部分或全部数据需要根据某个原始数据块中的部分数据进行删除,然后将剩余的数据进行拼接获得第二数据块。将原始数据块按照指定路径进行变换,此时第二数据块中部分或全部数据需要根据原始数据块中的数据进行变化获得。
确定根据原始数据块获得第二数据块中的部分或全部数据的操作指令后,将二数据块中的全部或部分数据进行删除,替换为操作指令。每次更新完一个第二数据块,原始数据块的依赖度就会发生变化,因此需要对每个原始数据块的依赖度进行更新。
一个示意性实施例,如果第一个第二数据块的长度为3M,其中有2M的数据可以根据旧固件版本镜像中字段范围为5M-7M的原始数据块进行数据变换获得,则将该第二数据块中对应2M的数据删除,添加指令以只是删除的2M数据可以根据旧固件版本镜像中字段范围为5M-7M的原始数据块进行数据变换获得。此时该第二数据块的长度从3M变为接近1M,从而使得差分升级包中的数据量变小,但是不会影响后续升级。
由上述实施例可知,本实施例提供的固件升级方法,首先将初始差分升级包进行分块,然后将分块获得的初始差分升级包数据块中的部分或全部的数据通过操作指令进行替代,进而减小了差分升级包对Flash的占用空间。
对应上述实施例提供的固件升级方法生成了一个分块差分升级包,本申请还提供了另一种固件升级方法,用于当终端设备获取所述分块差分升级包后,根据分块差分升级包进行固件升级,将终端设备中的旧固件版本升级为新固件版本。
图5为本申请实施例提供的另一种固件升级方法,所述固件升级方法包括:
S201,依次获取分块差分升级包每个数据块中的第一升级数据和操作指令。
在上述实施例中生成的分块差分升级包,对分块差分升级包中每个分块进行了更新,以使得分块差分升级中的数据量变小,但至少保证终端使用差分升级包可以完成正常的固件升级。
其中分块差分升级包中的数据块如果存在第一升级数据,则说明第一升级数据首先是新固件版本镜像相比旧固件版本镜像增加的数据,其次第一升级数据是无法通过旧固件版本镜像中数据通过任何操作获得。而操作指令则是用于指示可以根据旧固件版本镜像中的数据获得所述第二升级数据,初始状态分块差分升级包中的数据块应该同时包含第一升级数据和第二升级数据,但是第二升级数据可以根据旧固件版本镜像中的数据获得,因此将第二升级数据用操作指令代替。其中,第一升级数据和第二升级数据组成了新固件版本镜像和旧固件版本镜像的差异数据,根据差异数据和旧固件版本镜像可以获得新固件版本镜像。
S202,将第一数据按照操作指令在旧固件版本镜像中转换为第二升级数据。
本实施例中,第一数据为旧固件版本镜像中任一依赖度不为0的数据,依赖度用指示转换为第二升级数据需要第一数据的次数。例如转换获得3个分块差分升级包数据块中的第二升级数据都需要用到一个第一数据,则该第一数据的依赖度为3。
为了获得第二升级数据,首先从操作指令中获取操作指令指示获得第二升级数据需要的第一数据在旧固件版本镜像中的字段范围。根据所述字段范围从旧固件版本镜像中确定第一数据,按照操作指令中的转换路径在旧固件版本镜像中将第一数据转换为第二升级数据。
由于根据第一数据转换获得第二升级数据是在旧固件版本镜像中完成,如果直接对第一数据进行操作,可能会破坏第一数据原有的数据结构和第一数据所在的字段位置。因此本实施例中,在旧固件版本镜像中确定一个备份区,备份区为旧固件版本镜 像中的待删除的数据对应的数据区域,具体的待删除的数据为旧固件版本镜像相比新固件版本镜像不需要的数据,该部分数据需要被升级数据覆盖。将第一数据复制到备份区,按照转换路径在备份区内将第一数据转换为第二升级数据。其中,每生成一个第二升级数据,需要更新第一数据的依赖度。
一个示意性实施例,分块差分升级包中的一个数据块包含1M的第一升级数据和一条操作指令,所述操作指令为将旧固件版本镜像中字段范围5M-7M对应的数据中的6M-6.5M的数据进行删除,然后将剩余的两端数据进行数据拼接获得第二升级数据,然后将第二上级数据覆盖旧固件版本镜像中5M-6.5M字段范围,将第一升级数据覆盖旧固件版本镜像6.5M-7.5M字段范围。此时首先需要对旧固件版本镜像中字段范围5M-7M对应的第一数据进行数据删除操作,但是如果该第一数据的依赖度为3,因此后续还会用到该第一数据,因此将该第一数据复制到备份区进行操作,既可以获得对应的第二升级数据,还不会对原始的第一数据结构造成破坏。
S203,控制所述第一升级数据和所述第二升级数据覆盖所述旧固件版本镜像中的待升级数据区域。
由上述可知,在备份区中生成第二升级数据,第二升级数据可以直接在旧固件版本镜像中进行平移到指定的字段位置,第一升级数据也可以从分块差分升级包中数据块中获得。但是首先要保证第一升级数据和第二升级数据待覆盖的待升级数据区域中不存在任何第一数据。如果存在第一数据,将其覆盖后,将不能保证后续的升级。
一个示意性实施例,分块差分升级包中的一个数据块包含1M的第一升级数据和一条操作指令,所述操作指令为将旧固件版本镜像中3M-5M字段范围对应的数据平移覆盖到旧固件版本镜像中10M-12M字段范围,并且将1M的第一升级数据覆盖旧固件版本镜像的12M-13M字段范围。因此本实施例中,旧固件版本镜像中字段范围3M-5M对应的数据即为第二升级数据,为旧固件版本镜像中存在的数据,只是对应到新固件版本镜像中是在12M-13M字段范围。但是如果旧固件版本镜像的12M-13M字段范围存在其他第一数据,此时直接平移会将覆盖其他第一数据。
因此本实施例中还是首先将旧固件版本镜像中3M-5M字段范围对应的第一数据先复制到备份区,这样既可以防止该第一数据后续还会需要,直接平移导致固件升级不能顺利进行。另一方面,可以防止直接平移会覆盖其他第一数据,导致后续固件升级无法顺利进行。
如果旧固件版本镜像的10M-12M字段范围中存在第一数据,且旧固件版本镜像中3M-5M字段范围对应的第一数据依赖度为1,则经过本次平移后依赖度即变为0。也可以将旧固件版本镜像的10M-12M字段范围对应的第一数据平移到备份区中保存,并且记录此时旧固件版本镜像的原10M-12M字段范围对应的第一数据当前的字段范围。例如备份区字段范围是旧固件版本镜像中60M-70M字段范围,则可以将旧固件版本镜像的原12M-13M字段范围对应的第一数据平移到旧固件版本镜像中60M-62M字段范围。
如果在备份区生成第二升级数据后,且确定出第一升级数据和第二升级数据对应的旧固件版本镜像中的待升级数据区域中不存在第一数据,直接将第一升级数据和第二升级数据组成的差异数据覆盖待升级数据区域,完成旧固件版本镜像中的部分数据 升级。直至对旧固件版本镜像中的所有待升级数据区域完成相应升级,此时的旧固件版本镜像顺利变为新固件版本镜像,终端中的旧固件升级为新固件。
由上述实施例可知,本实施例提供的固件升级方法,根据差分升级包中的操作指令在旧固件版本镜像中将操作指令指示的第一数据转换为第二升级数据,根据第一升级数据和第二升级数据在旧固件版本镜像中完成升级为新固件版本镜像的操作。整个升级过程无需额外生成新固件版本镜像,无需为新固件版本镜像预留存储空间;而且分块差分升级包相比传统的差分升级包利用操作指令替换了传统差分升级包中的部分或全部数据,进一步减小了存储分块差分升级包的闪存开销,进而使得升级过程中闪存空间资源占用小。
与上述实施例提供的一种固件升级方法相对应,本申请实施例还提供了一种固件升级装置。图6为本申请实施例提供的一种固件升级装置的示意图,参见图6,固件升级装置30包括:获取模块301、第一拆分模块302、第二拆分模块303、确定模块304和更新模块305。
获取模块301,用于根据新固件版本镜像和旧固件版本镜像的差异数据获得初始差分升级包。第一拆分模块302,用于将新固件版本镜像拆分为第一预设长度的第一数据块,第一数据块为新固件版本镜像拆分后的任一数据块。第二拆分模块303,用于根据生成第一数据块对应的初始差分升级包的数据区域将初始差分升级包进行拆分获得第二数据块,第二数据块为初始差分升级包拆分后的任一数据块。确定模块304,用于确定第二数据块对旧固件版本镜像中每个原始数据块的依赖度。更新模块305,用于根据依赖度更新第二数据块,获得分块差分升级包,更新第二数据块包括:将第二数据块中的部分或全部数据更换为操作指令,操作指令用于指示根据原始数据块生成第二数据块中被更换为操作指令的数据。
在一个示意性实施例中,第二拆分模块303,包括:第一确定单元和拆分单元。
第一确定单元,用于确定每个第一数据块对应初始差分升级包的字段范围。拆分单元,用于将每个字段范围的末地址作为初始差分升级包的拆分点,拆分初始差分升级包。
确定模块304,包括:第一依赖度更新单元,用于如果根据原始数据块可以获得第二数据块中部分或全部数据,更新原始数据块的依赖度;其中,所述第二数据块中的数据可以通过一个或多个所述原始数据块获得。
更新模块305,包括:第二确定单元和更新单元。
第二确定单元,用于确定根据原始数据块获得第二数据块中部分或全部数据对应的操作指令,操作指令包括以下一种或多种:平移原始数据块到指定字段位置、将原始数据块的预设区域的数据进行删除、将原始数据块按照指定路径进行变换;更新单元,用于将操作指令添加到第二数据块并删除所述部分或全部数据。
本申请实施例提供的固件升级装置30还包括:第二依赖度更新单元,用于每更新完一个第二数据块,更新原始数据块的依赖度。
本申请实施例提供的固件升级装置,将分块获得的初始差分升级包数据块中的部分或全部的数据通过操作指令进行替代,进而减小了差分升级包对Flash的占用空间。
与上述实施例提供的另一种固件升级方法相对应,本申请实施例还提供了另一种固件升级装置。图7为本申请实施例提供的另一种固件升级装置的示意图,参见图7,固件升级装置40包括:获取模块401、数据转化模块402和升级模块403。
获取模块401,用于依次获取分块差分升级包每个数据块中的第一升级数据和操作指令,第一升级数据为新固件版本镜像相比旧固件版本镜像增加的数据,第一升级数据无法通过旧固件版本镜像获得;操作指令用于指示根据旧固件版本镜像中的数据获得第二升级数据,第一升级数据和第二升级数据组成新固件版本镜像和旧固件版本镜像的差异数据。数据转化模块402,用于将操作指令中指示的第一数据按照操作指令在旧固件版本镜像中转换为第二升级数据,第一数据为旧固件版本镜像中任一依赖度不为0的数据,依赖度用指示转换为第二升级数据需要第一数据的次数,其中,每生成一个第二升级数据,更新第一数据的依赖度。升级模块403,用于当旧固件版本镜像中的待升级数据区域中不存在第一数据时,控制差异数据覆盖待升级数据区域。
在一个示意性实施例中,所述数据转化模块包括:获取单元、确定单元和数据转换单元。
获取单元,用于获取操作指令指示对应的第一数据的字段范围。确定单元,用于根据字段范围从旧固件版本镜像中确定第一数据。数据转换单元,用于按照操作指令中的转换路径在旧固件版本镜像中将第一数据转换为第二升级数据。
数据转换单元包括:确定子单元、数据平移子单元和数据转换子单元。
确定子单元,用于在旧固件版本镜像中确定一个备份区,备份区为旧固件版本镜像中的待删除的数据对应的数据区域。数据平移子单元,用于将第一数据复制到备份区。数据转换子单元,用于按照转换路径在备份区内将第一数据转换为第二升级数据。
本申请实施例提供的固件升级装置40还包括:第一数据备份单元和第二数据备份单元。其中:
第一数据备份单元,用于如果待升级数据区域中存在第一数据,将第一升级数据放入所述备份区。
第二数据备份单元,用于如果待升级数据区域中存在第一数据,将第一数据放入所述备份区。
本申请实施例提供的固件升级装置,获取模块401获得第一升级数据和操作指令,数据转化模块402在旧固件版本镜像中将操作指令指示的第一数据转换为第二升级数据,升级模块403根据第一升级数据和第二升级数据在旧固件版本镜像中完成升级为新固件版本镜像的操作。整个升级过程无需额外生成新固件版本镜像,无需为新固件版本镜像预留存储空间;而且分块差分升级包相比传统的差分升级包利用操作指令替换了传统差分升级包中的部分或全部数据,进一步减小了存储分块差分升级包的闪存开销,进而使得升级过程中闪存空间资源占用小。
图8为本申请实施例提供的一种终端的结构示意图。参见图8,终端50包括:处理器501、存储器502和通信接口503。
存储器502,用于存储计算机可执行指令,当处理器501执行所述计算机可执行指令时,执行以下操作:
根据新固件版本镜像和旧固件版本镜像的差异数据获得初始差分升级包。
将新固件版本镜像拆分为第一预设长度的第一数据块。
根据生成第一数据块对应的初始差分升级包的数据区域将初始差分升级包进行拆分获得第二数据块。
确定第二数据块对旧固件版本镜像中每个原始数据块的依赖度。
根据依赖度更新第二数据块,获得分块差分升级包。
处理器501、存储器502和通信接口503可以通过总线相互连接;总线可以分为地址总线、数据总线、控制总线等。为便于表示,图8中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
处理器501可以是通用处理器,例如,中央处理器(英文:central processing unit,缩写:CPU),网络处理器(英文:network processor,缩写:NP)或者CPU和NP的组合。处理器也可以是微处理器(MCU)。处理器还可以包括硬件芯片。上述硬件芯片可以是专用集成电路(ASIC),可编程逻辑器件(PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(CPLD),现场可编程逻辑门阵列(FPGA)等。
存储器502可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。
通信接口503用于终端50向服务器上传生成的分块差分升级包。所述通信接口包括有线通信接口,还可以包括无线通信接口。其中,有线通信接口包括PLC接口,还可以包括以太网接口。无线通信接口可以为WLAN接口,蜂窝网络通信接口或其组合等。
终端50还可以包括电源组件,用于为PLC芯片的各种组件提供电力。电源组件可以包括电源管理系统,一个或多个电源。
图9为本申请实施例提供的另一种终端的结构示意图。参见图9,终端60包括:处理器601、存储器602和通信接口603。
存储器602,用于存储计算机可执行指令,当处理器601执行所述计算机可执行指令时,执行以下操作:
依次获取分块差分升级包每个数据块中的第一升级数据和操作指令,第一升级数据为新固件版本镜像相比旧固件版本镜像增加的数据;操作指令用于指示根据所述旧固件版本镜像中的数据获得第二升级数据。
将第一数据按照操作指令在旧固件版本镜像中转换为第二升级数据,第一数据为所述旧固件版本镜像中的数据;
控制第一升级数据和第二升级数据覆盖所述旧固件版本镜像中的待升级数据区域。
处理器601、存储器602和通信接口603可以通过总线相互连接;总线可以分为地址总线、数据总线、控制总线等。为便于表示,图9中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
上述实施例中处理器601可以是通用处理器,例如,中央处理器(英文:central processing unit,缩写:CPU),网络处理器(英文:network processor,缩写:NP) 或者CPU和NP的组合。处理器也可以是微处理器(MCU)。处理器还可以包括硬件芯片。上述硬件芯片可以是专用集成电路(ASIC),可编程逻辑器件(PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(CPLD),现场可编程逻辑门阵列(FPGA)等。
存储器602可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。
通信接口603用于终端60下载分块差分升级包,实现固件版本更新。所述通信接口包括有线通信接口,还可以包括无线通信接口。其中,有线通信接口包括PLC接口,还可以包括以太网接口。无线通信接口可以为WLAN接口,蜂窝网络通信接口或其组合等。
终端60还可以包括电源组件,用于为PLC芯片的各种组件提供电力。电源组件可以包括电源管理系统,一个或多个电源。
需要说明的是,在本文中,诸如“第一”和“第二”等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
本申请说明书中各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置和终端实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
以上所述的本申请实施方式并不构成对本申请保护范围的限定。

Claims (22)

  1. 一种固件升级方法,其特征在于,所述方法包括:
    依次获取分块差分升级包每个数据块中的第一升级数据和操作指令,所述第一升级数据为新固件版本镜像相比旧固件版本镜像增加的数据;所述操作指令用于指示根据所述旧固件版本镜像中的数据获得第二升级数据;
    将第一数据按照所述操作指令在所述旧固件版本镜像中转换为所述第二升级数据,所述第一数据为所述旧固件版本镜像中的数据;
    控制所述第一升级数据和所述第二升级数据覆盖所述旧固件版本镜像中的待升级数据区域。
  2. 根据权利要求1所述的方法,其特征在于,所述将第一数据按照所述操作指令在所述旧固件版本镜像中转换为所述第二升级数据,包括:
    获取所述操作指令指示对应的所述第一数据的字段范围;
    根据所述字段范围从所述旧固件版本镜像中确定所述第一数据;
    按照所述操作指令中的转换路径在所述旧固件版本镜像中将所述第一数据转换为所述第二升级数据。
  3. 根据权利要求2所述的方法,其特征在于,所述按照操作指令中的转换路径在所述旧固件版本镜像中将所述第一数据转换为所述第二升级数据,包括:
    在所述旧固件版本镜像中确定一个备份区,所述备份区为所述旧固件版本镜像中的待删除的数据对应的数据区域;
    将所述第一数据复制到所述备份区;
    按照所述转换路径在所述备份区内将所述第一数据转换为第二升级数据。
  4. 根据权利要求3所述的方法,其特征在于,还包括:如果所述待升级数据区域中存在所述第一数据,将所述第一升级数据放入所述备份区。
  5. 根据权利要求3所述的方法,其特征在于,还包括:如果所述待升级数据区域中存在所述第一数据,将所述第一数据放入所述备份区。
  6. 一种固件升级方法,其特征在于,所述方法包括:
    根据新固件版本镜像和旧固件版本镜像的差异数据获得初始差分升级包;
    将所述新固件版本镜像拆分为第一预设长度的第一数据块,所述第一数据块为所述新固件版本镜像拆分后的任一数据块;
    根据生成所述第一数据块对应的所述初始差分升级包的数据区域将所述初始差分升级包进行拆分获得第二数据块,所述第二数据块为所述初始差分升级包拆分后的任一数据块;
    确定所述第二数据块对所述旧固件版本镜像中每个原始数据块的依赖度;
    根据所述依赖度更新所述第二数据块,获得分块差分升级包,所述更新第二数据块包括:将所述第二数据块中的部分或全部数据更换为操作指令,所述操作指令用于指示根据所述原始数据块生成所述第二数据块中被更换为操作指令的数据。
  7. 根据权利要求6所述的方法,其特征在于,所述根据生成第一数据块对应的所述初始差分升级包的数据区域将所述初始差分升级包进行拆分获得第二数据块,包括:
    确定每个所述第一数据块对应所述初始差分升级包的字段范围;
    将每个字段范围的末地址作为所述初始差分升级包的拆分点,拆分所述初始差分升级包。
  8. 根据权利要求7所述的方法,其特征在于,所述确定第二数据块对所述旧固件版本镜像中每个原始数据块的依赖度,包括:
    如果根据所述原始数据块可以获得所述第二数据块中部分或全部数据,更新所述原始数据块的依赖度;
    其中,所述第二数据块中的数据可以通过一个或多个所述原始数据块获得。
  9. 根据权利要求8所述的方法,其特征在于,所述根据依赖度更新所述第二数据块,包括:
    确定根据所述原始数据块获得所述第二数据块中部分或全部数据对应的操作指令,所述操作指令包括以下一种或多种:平移所述原始数据块到指定字段位置、将所述原始数据块的预设区域的数据进行删除、将所述原始数据块按照指定路径进行变换;
    将所述操作指令添加到所述第二数据块并删除所述部分或全部数据。
  10. 根据权利要求9所述的方法,其特征在于,还包括:每更新完一个所述第二数据块,更新所述原始数据块的依赖度。
  11. 一种固件升级装置,其特征在于,所述装置包括:
    获取模块,用于依次获取分块差分升级包每个数据块中的第一升级数据和操作指令,所述第一升级数据为新固件版本镜像相比旧固件版本镜像增加的数据;所述操作指令用于指示根据所述旧固件版本镜像中的数据获得第二升级数据;
    数据转化模块,用于将第一数据按照所述操作指令在所述旧固件版本镜像中转换为所述第二升级数据,所述第一数据为所述旧固件版本镜像中的数据;
    升级模块,控制所述第一升级数据和所述第二升级数据覆盖所述旧固件版本镜像中的待升级数据区域。
  12. 根据权利要求11所述的装置,其特征在于,所述数据转化模块具体用于:
    获取单元,用于获取所述操作指令指示对应的所述第一数据的字段范围;
    确定单元,用于根据所述字段范围从所述旧固件版本镜像中确定所述第一数据;
    数据转换单元,用于按照所述操作指令中的转换路径在所述旧固件版本镜像中将所述第一数据转换为所述第二升级数据。
  13. 根据权利要求12所述的装置,其特征在于,所述数据转化模块在按照所述操作指令中的转换路径在所述旧固件版本镜像中将所述第一数据转换为所述第二升级数据时具体用于:
    在所述旧固件版本镜像中确定一个备份区,所述备份区为所述旧固件版本镜像中的待删除的数据对应的数据区域;
    将所述第一数据复制到所述备份区;
    按照所述转换路径在所述备份区内将所述第一数据转换为第二升级数据。
  14. 根据权利要求13所述的装置,其特征在于,还包括:第一数据备份单元,用于如果所述待升级数据区域中存在所述第一数据,将所述第一升级数据放入所述备份区。
  15. 根据权利要求13所述的装置,其特征在于,还包括:第二数据备份单元,用于如果所述待升级数据区域中存在所述第一数据,将所述第一数据放入所述备份区。
  16. 一种固件升级装置,其特征在于,所述装置包括:
    获取模块,用于根据新固件版本镜像和旧固件版本镜像的差异数据获得初始差分升级包;
    第一拆分模块,用于将所述新固件版本镜像拆分为第一预设长度的第一数据块,所述第一数据块为所述新固件版本镜像拆分后的任一数据块;
    第二拆分模块,用于根据生成所述第一数据块对应的所述初始差分升级包的数据区域将所述初始差分升级包进行拆分获得第二数据块,所述第二数据块为所述初始差分升级包拆分后的任一数据块;
    确定模块,用于确定所述第二数据块对所述旧固件版本镜像中每个原始数据块的依赖度;
    更新模块,用于根据所述依赖度更新所述第二数据块,获得分块差分升级包,所述更新第二数据块包括:将所述第二数据块中的部分或全部数据更换为操作指令,所述操作指令用于指示根据所述原始数据块生成所述第二数据块中被更换为操作指令的数据。
  17. 根据权利要求16所述的装置,其特征在于,所述第二拆分模块具体用于:
    确定每个所述第一数据块对应所述初始差分升级包的字段范围;
    将每个字段范围的末地址作为所述初始差分升级包的拆分点,拆分所述初始差分升级包。
  18. 根据权利要求17所述的装置,其特征在于,所述确定模块具体用于:
    如果根据所述原始数据块可以获得所述第二数据块中部分或全部数据,更新所述原始数据块的依赖度;其中,所述第二数据块中的数据可以通过一个或多个所述原始数据块获得。
  19. 根据权利要求18所述的装置,其特征在于,所述更新模块具体用于:
    确定根据所述原始数据块获得所述第二数据块中部分或全部数据对应的操作指令,所述操作指令包括以下一种或多种:平移所述原始数据块到指定字段位置、将所述原始数据块的预设区域的数据进行删除、将所述原始数据块按照指定路径进行变换;
    将所述操作指令添加到所述第二数据块并删除所述部分或全部数据。
  20. 根据权利要求19所述的装置,其特征在于,还包括:第二依赖度更新单元,用于每更新完一个所述第二数据块,更新所述原始数据块的依赖度。
  21. 一种终端,其特征在于,包括:
    处理器;
    存储器,用于存储计算机可执行指令;
    当所述处理器执行所述计算机可执行指令时,执行如权利要求1-5任一项所述的方法,根据获取的分块差分升级包和旧固件版本镜像完成原地差分升级,获得新固件版本镜像。
  22. 一种终端,其特征在于,包括:
    处理器;
    存储器,用于存储计算机可执行指令;
    当所述处理器执行所述计算机可执行指令时,执行如权利要求6-10任一项所述的方法,根据新固件版本镜像和旧固件版本镜像生成分块差分升级包。
PCT/CN2019/108397 2018-10-25 2019-09-27 一种固件升级方法、装置及终端 WO2020082984A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US17/140,847 US11531535B2 (en) 2018-10-25 2021-01-04 Firmware upgrade method and apparatus, and terminal

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811247582.8A CN111104149A (zh) 2018-10-25 2018-10-25 一种固件升级方法、装置及终端
CN201811247582.8 2018-10-25

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/140,847 Continuation US11531535B2 (en) 2018-10-25 2021-01-04 Firmware upgrade method and apparatus, and terminal

Publications (1)

Publication Number Publication Date
WO2020082984A1 true WO2020082984A1 (zh) 2020-04-30

Family

ID=70330888

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/108397 WO2020082984A1 (zh) 2018-10-25 2019-09-27 一种固件升级方法、装置及终端

Country Status (3)

Country Link
US (1) US11531535B2 (zh)
CN (1) CN111104149A (zh)
WO (1) WO2020082984A1 (zh)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112181466A (zh) * 2020-09-08 2021-01-05 上海深聪半导体有限责任公司 一种语音空调固件云端升级方法及系统
CN112230975A (zh) * 2020-09-30 2021-01-15 厦门汉印电子技术有限公司 一种固件差分的升级方法、装置及设备
CN112286565A (zh) * 2020-10-30 2021-01-29 浙江正泰中自控制工程有限公司 一种基于存储容器的嵌入式系统差分升级方法
CN113590168A (zh) * 2021-07-29 2021-11-02 百度在线网络技术(北京)有限公司 嵌入式设备升级方法、装置、设备、介质及程序产品
CN113721966A (zh) * 2021-08-27 2021-11-30 杭州华橙软件技术有限公司 节点升级方法、装置、存储介质及电子装置
CN113805921A (zh) * 2021-09-26 2021-12-17 深圳威消保科技有限公司 一种固件远程升级方法及装置
WO2023051527A1 (en) * 2021-10-01 2023-04-06 International Business Machines Corporation Transformation of data from legacy architecture to updated architecture

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111651186B (zh) * 2020-05-29 2023-10-03 歌尔科技有限公司 耳机及其程序升级方法、控制装置和可读存储介质
CN111770169B (zh) * 2020-06-29 2023-05-09 百度在线网络技术(北京)有限公司 设备固件升级的方法、装置、设备以及存储介质
CN113867749A (zh) * 2020-06-30 2021-12-31 Oppo广东移动通信有限公司 数据升级的方法、电子设备及存储介质
CN112015458A (zh) * 2020-08-04 2020-12-01 上海艾拉比智能科技有限公司 设备升级方法、终端设备、电子设备和存储介质
CN112905221A (zh) * 2021-02-20 2021-06-04 百度在线网络技术(北京)有限公司 一种版本回退方法、装置、电子设备及存储介质
CN114567628B (zh) * 2022-02-28 2024-03-08 中汽创智科技有限公司 一种ota升级方法和装置
CN114416173B (zh) * 2022-03-28 2022-10-25 荣耀终端有限公司 版本切换方法和终端设备
CN116700739A (zh) * 2022-09-21 2023-09-05 荣耀终端有限公司 差分升级方法、装置、电子设备及可读存储介质
CN116521210B (zh) * 2023-04-18 2024-05-03 宁夏隆基宁光仪表股份有限公司 一种物联网水表固件差量升级的方法

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7975147B1 (en) * 2003-03-31 2011-07-05 Hewlett-Packard Development Company, L.P. Electronic device network supporting enciphering and deciphering and update generation in electronic devices
CN102722386A (zh) * 2012-05-28 2012-10-10 华为终端有限公司 生成无线固件升级包的方法和装置
CN103118198A (zh) * 2013-02-05 2013-05-22 惠州Tcl移动通信有限公司 移动终端的固件升级方法及系统
CN108279922A (zh) * 2018-01-03 2018-07-13 深圳市泰比特科技有限公司 差分文件生成方法、基于该差分文件的升级方法及系统

Family Cites Families (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0733531B2 (ja) * 1990-04-25 1995-04-12 日本鋼管株式会社 高炉々熱制御装置の支援システム
IL125846A0 (en) 1998-08-19 1999-04-11 Emony Incremental program update
JP3863118B2 (ja) * 2002-04-01 2006-12-27 松下電器産業株式会社 受信装置、印刷装置およびファームウェア更新システム
JP2004152136A (ja) * 2002-10-31 2004-05-27 Matsushita Electric Ind Co Ltd データ更新システム、データ更新システムの差分データ生成装置及びプログラム、並びに更新後ファイル復元装置及びプログラム
US20050223372A1 (en) * 2004-04-01 2005-10-06 Borchers Gregory E Methods and systems for firmware download configuration
US7587433B2 (en) 2004-06-01 2009-09-08 Red Bend Ltd. Method and system for in-place updating content stored in a storage device
US7904518B2 (en) * 2005-02-15 2011-03-08 Gytheion Networks Llc Apparatus and method for analyzing and filtering email and for providing web related services
CN1658574A (zh) * 2005-03-23 2005-08-24 港湾网络有限公司 网络设备自动更新方法及系统
US8752044B2 (en) * 2006-07-27 2014-06-10 Qualcomm Incorporated User experience and dependency management in a mobile device
US20080172584A1 (en) 2007-01-11 2008-07-17 Red Bend Ltd. Method and system for in-place updating content stored in a storage device
US7802129B2 (en) * 2007-10-17 2010-09-21 Hewlett-Packard Development Company, L.P. Mobile handset employing efficient backup and recovery of blocks during update
US8869134B2 (en) * 2008-04-07 2014-10-21 Google Inc. Updating firmware on mobile electronice devices
JP5113699B2 (ja) * 2008-09-24 2013-01-09 株式会社日立ソリューションズ ファームウェア更新システム、及び更新イメージ生成・配布サーバ装置
JP5342302B2 (ja) * 2009-03-30 2013-11-13 株式会社日立ソリューションズ ファームウェア更新システム、ファームウェア配信サーバ、及びプログラム
JP5346253B2 (ja) * 2009-08-24 2013-11-20 株式会社日立ソリューションズ ファームウェア更新システム、及び情報機器、並びにプログラム
CN102609328B (zh) * 2012-01-29 2015-04-15 华为终端有限公司 系统差分升级方法和装置、移动终端
CN103473099B (zh) * 2013-09-13 2017-02-01 惠州Tcl移动通信有限公司 一种移动终端的软件升级方法和系统
CN104932909A (zh) 2014-03-17 2015-09-23 中兴通讯股份有限公司 一种终端软件升级方法及装置
KR102261815B1 (ko) * 2014-10-30 2021-06-07 삼성전자주식회사 펌웨어 업데이트 시간을 줄일 수 있는 데이터 저장 장치, 및 이를 포함하는 데이터 처리 시스템
US9940287B2 (en) * 2015-03-27 2018-04-10 Intel Corporation Pooled memory address translation
US20160291967A1 (en) * 2015-03-30 2016-10-06 Konica Minolta Laboratory U.S.A., Inc. Method and system for updating firmware
CN104991790B (zh) 2015-06-09 2018-05-25 北京奇虎科技有限公司 一种文件的升级发布方法和装置
US10162622B2 (en) * 2016-02-26 2018-12-25 Ayla Networks, Inc. Local over the air update of an embedded system
CN108228224B (zh) * 2017-12-21 2021-11-30 杭州中天微系统有限公司 一种嵌入式系统差分升级的方法及装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7975147B1 (en) * 2003-03-31 2011-07-05 Hewlett-Packard Development Company, L.P. Electronic device network supporting enciphering and deciphering and update generation in electronic devices
CN102722386A (zh) * 2012-05-28 2012-10-10 华为终端有限公司 生成无线固件升级包的方法和装置
CN103118198A (zh) * 2013-02-05 2013-05-22 惠州Tcl移动通信有限公司 移动终端的固件升级方法及系统
CN108279922A (zh) * 2018-01-03 2018-07-13 深圳市泰比特科技有限公司 差分文件生成方法、基于该差分文件的升级方法及系统

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112181466A (zh) * 2020-09-08 2021-01-05 上海深聪半导体有限责任公司 一种语音空调固件云端升级方法及系统
CN112181466B (zh) * 2020-09-08 2024-04-16 深聪半导体(江苏)有限公司 一种语音空调固件云端升级方法及系统
CN112230975A (zh) * 2020-09-30 2021-01-15 厦门汉印电子技术有限公司 一种固件差分的升级方法、装置及设备
CN112286565A (zh) * 2020-10-30 2021-01-29 浙江正泰中自控制工程有限公司 一种基于存储容器的嵌入式系统差分升级方法
CN112286565B (zh) * 2020-10-30 2023-03-10 浙江正泰中自控制工程有限公司 一种基于存储容器的嵌入式系统差分升级方法
CN113590168A (zh) * 2021-07-29 2021-11-02 百度在线网络技术(北京)有限公司 嵌入式设备升级方法、装置、设备、介质及程序产品
CN113590168B (zh) * 2021-07-29 2024-03-01 百度在线网络技术(北京)有限公司 嵌入式设备升级方法、装置、设备、介质及程序产品
CN113721966A (zh) * 2021-08-27 2021-11-30 杭州华橙软件技术有限公司 节点升级方法、装置、存储介质及电子装置
CN113721966B (zh) * 2021-08-27 2024-03-29 杭州华橙软件技术有限公司 节点升级方法、装置、存储介质及电子装置
CN113805921A (zh) * 2021-09-26 2021-12-17 深圳威消保科技有限公司 一种固件远程升级方法及装置
CN113805921B (zh) * 2021-09-26 2023-10-24 深圳威消保科技有限公司 一种固件远程升级方法及装置
WO2023051527A1 (en) * 2021-10-01 2023-04-06 International Business Machines Corporation Transformation of data from legacy architecture to updated architecture

Also Published As

Publication number Publication date
CN111104149A (zh) 2020-05-05
US11531535B2 (en) 2022-12-20
US20210124573A1 (en) 2021-04-29

Similar Documents

Publication Publication Date Title
WO2020082984A1 (zh) 一种固件升级方法、装置及终端
CN105511911B (zh) 系统固件升级包的生成方法及装置
JP2017117446A (ja) 動的なデータ差分生成および配送
CN111857777B (zh) 基于双芯智能电表的系统更新方法、装置和计算机设备
TWI775616B (zh) 差分包產生方法,差分包產生設備,更新方法,及嵌入式系統
CN108829431A (zh) iOS应用程序的更新方法、装置、设备及存储介质
CN110333876A (zh) 一种数据清除方法及控制设备
CN113504918A (zh) 设备树配置优化方法、装置、计算机设备和存储介质
US9588884B2 (en) Systems and methods for in-place reorganization of device storage
US20230385334A1 (en) Method and Apparatus for Preparing Image on Cloud Platform, and Device and Storage Medium
CN116991758A (zh) 一种空间布局的更新方法、装置、设备及介质
CN114138558A (zh) 一种对象存储方法、装置、电子设备和存储介质
CN113377770A (zh) 一种数据处理方法和装置
CN104063377A (zh) 信息处理方法和使用其的电子设备
CN111176705B (zh) 特征库的升级方法及装置
CN112395339A (zh) 系统间数据准入校验方法、装置、计算机设备和存储介质
WO2017036197A1 (zh) 一种网元模型管理方法及装置
CN109614383B (zh) 数据复制方法、装置、电子设备及存储介质
CN113986312B (zh) 软件升级方法、装置、电子设备及计算机可读存储介质
CN107861739A (zh) ReactNative应用调整方法、客户端及系统
CN114610366A (zh) 一种差分包升级方法、系统、智能电子设备和存储介质
CN113656100A (zh) 接口切换方法、装置、电子装置及计算机程序产品
CN109558375B (zh) 一种优化的文件存储方法、存储介质、设备及系统
CN115269530A (zh) 数据同步方法、电子设备及计算机可读存储介质
US10437802B2 (en) Single IO operation integer-value database

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: 19875729

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19875729

Country of ref document: EP

Kind code of ref document: A1