Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
To make the objects, technical solutions and advantages of the present application more clear, the following description is made by way of specific embodiments with reference to the accompanying drawings.
Referring to fig. 1, it shows a flowchart of an implementation of the method for remotely upgrading a device provided in the embodiment of the present application, which is detailed as follows:
s101: judging whether the target equipment needs to be upgraded or not according to the total packet header information of the upgrade packet; the total packet header information comprises sub-packet information of at least one sub-file; the sub-packet information includes a file size and an offset address of a sub-file in the upgrade packet.
Specifically, the execution subject of this embodiment is an upgradable target device.
When the upgrade package is manufactured, header processing is carried out on the upgrade package, and the size and version information of each subfile in the upgrade package, the size and version information of the upgrade package, the offset address of each subfile in the whole upgrade package and the like are counted. And storing the size and version information of each subfile in the upgrade package, the size and version information of the upgrade package, the offset address of each subfile in the whole upgrade package and the like as the total package header information of the upgrade package to the start position of the upgrade package.
In an embodiment of the present application, the total packet header information further includes an upgrade packet identifier, software version information, and hardware version information; fig. 2 shows a complete flowchart of the remote upgrade of the device provided in this embodiment, and as shown in fig. 2, before S101, the remote upgrade method of the device provided in this embodiment further includes:
when an upgrade order is monitored, judging whether an upgrade package is the upgrade package of the target equipment or not based on an upgrade package identifier in the upgrade order;
and if the upgrade package is the upgrade package of the target equipment, acquiring the total package header information of the upgrade package.
The specific implementation process of S101 includes:
and judging whether the target equipment needs to be upgraded or not based on the software version information and the hardware version information.
In this embodiment, after updating the upgrade package, the server sends an upgrade command to the target device, after monitoring the upgrade command, the target device determines whether the upgrade package is consistent with the identifier of the target device according to the upgrade package identifier carried in the upgrade command, if so, it determines that the upgrade package meets the upgrade condition, acquires and analyzes the total package header information of the upgrade package through the http \ https protocol, and then stores the total package header information into the local storage space. If not, ending the upgrading process.
TABLE 1
Specifically, data included in the total packet header information is shown in table 1, the total packet header information includes an upgrade packet identifier, a header information total length, software version information, hardware version information, other information, a subfile number, an upgrade packet protocol version number and reserved bits, and the sub-packet information includes an upgrade packet type, a subfile name, an MD5 value, an offset address of the subfile in the whole upgrade packet, a file size, and software version information.
As shown in fig. 2, after the total header information is obtained, the target device respectively determines whether software version information stored in the local storage space of the target device is consistent with software version information in the total header information, and whether hardware version information stored in the local storage space of the target device is consistent with hardware version information in the total header information; if the software version information stored in the local storage space by the target device is inconsistent with the software version information in the total header information, and the hardware version information stored in the local storage space by the target device is consistent with the hardware version information in the total header information, judging that the target device needs to be upgraded; otherwise, the target device is judged not to need to be upgraded, and the upgrading process is ended.
In one possible embodiment, the sub-packet information includes a sub-file name and sub-packet version information;
before S102, the method for remotely upgrading a device according to this embodiment further includes:
S102A: and if the sub-package version information of the sub-file corresponding to the same sub-file name in the local storage space is not consistent with the sub-package version information in the upgrading packet, executing the step of judging whether the file size corresponding to the sub-file is larger than the temporary storage space of the target device.
In one possible embodiment, the subpacket version information includes a subpacket version number and an MD5 value; the specific implementation process of S102A further includes:
and if the sub-packet version number of the sub-file corresponding to the same sub-file name in the local storage space is inconsistent with the sub-packet version number in the upgrade package, and the MD5 value of the sub-file in the local storage space is inconsistent with the MD5 value in the upgrade package, executing the step of judging whether the file size corresponding to the sub-file is larger than the temporary storage space of the target equipment.
In this embodiment, as shown in fig. 2, after determining that the upgrade package meets the upgrade condition, the target device sequentially downloads and upgrades each subfile in the upgrade package. Before downloading and upgrading the subfiles, firstly judging whether the number of the subfiles to be upgraded in the upgrade package is greater than zero, and if not, ending the upgrade process; if the sub-package version number of the sub-file corresponding to the same sub-file name in the local storage space is inconsistent with the sub-package version number in the upgrade package, and if the MD5 value of the sub-file in the local storage space is inconsistent with the MD5 value in the upgrade package, the sub-file is judged not to be downloaded. For the sub-files not downloaded, steps S102 to S104 are performed.
As shown in fig. 2, if the sub-packet version number of the sub-file corresponding to the same sub-file name in the local storage space is consistent with the sub-packet version number in the upgrade package, or the MD5 value of the sub-file in the local storage space is consistent with the MD5 value in the upgrade package, it is determined that the sub-file is downloaded, the number of the sub-file to be upgraded in the upgrade package is reduced by one, and the step of determining the number of the sub-file to be upgraded is returned to and repeatedly executed.
S102: if the target equipment needs to be upgraded, judging whether the file size corresponding to each subfile in the upgrade package is larger than the temporary storage space of the target equipment or not; and if the file size corresponding to the subfile is larger than the temporary storage space, downloading the subfile to the temporary storage space in a segmented manner based on the offset address of the subfile and the size of the temporary storage space, replacing the original file corresponding to the current file segment in the local storage space by adopting the current file segment downloaded to the temporary storage space before downloading the next file segment, and deleting the current file segment in the temporary storage space.
In this embodiment, the temporary storage space may be an unoccupied space of a local storage space in the target device, or may be a memory of the target device. As shown in fig. 2, if the file size corresponding to the subfile is larger than the temporary storage space, the subfile in the upgrade package is downloaded from the server in a segmented manner, and after the file is stored in the temporary storage space in a segmented manner each time, the original file of the storage address corresponding to the file segment in the local storage space is replaced by the file segment, and after the file segment is written in the local storage space, the file segment in the temporary storage space is deleted.
In a possible embodiment, the specific implementation flow of S102 includes:
step 1: determining the offset address of the current file segment in the subfile in the upgrade package based on the offset address of the subfile in the upgrade package and the address range of the file segment of the subfile downloaded last time in the upgrade package;
step 2: determining the address range of the current file segment in the subfile in the upgrade package based on the offset address of the current file segment in the subfile in the upgrade package and the size of the temporary storage space;
and step 3: sending a file segmentation downloading request to a server, wherein the file segmentation downloading request is used for indicating the server to send the file segmentation corresponding to the subfile in the upgrade package to the target device based on the address range of the current file segmentation of the subfile in the upgrade package;
and 4, step 4: and storing the file segments of the sub-file downloaded at the current time into the temporary storage space, and repeatedly executing the steps 1 to 4 until the end address of the file segment of the sub-file downloaded at the current time is the same as the end address of the sub-file.
Specifically, after the file segment of the sub file downloaded at the current time is saved in the temporary storage space instep 4, the address range of the file segment in the local storage space is determined based on the address range of the file segment of the sub file downloaded at the current time, the file segment of the sub file downloaded at the current time is adopted to replace the original file at the corresponding address range, and then the file segment downloaded at the current time in the temporary storage space is deleted to reserve a space for downloading the next file segment.
In an embodiment, after determining whether the file size corresponding to the sub-file is larger than the temporary storage space of the target device, the method provided in this embodiment further includes:
and if the file size of the subfile is not larger than the temporary storage space of the target equipment, downloading the subfile to the temporary storage space based on the offset address and the file size of the subfile.
Specifically, if the file size corresponding to the subfile is smaller than the temporary storage space in the target device, the address range of the subfile in the upgrade package is determined according to the offset address and the file size of the subfile in the upgrade package, a subfile downloading request is sent to the server, the server sends the subfile of the address range in the upgrade package to the target device according to the subfile downloading request, the target device acquires the subfile and stores the subfile in the temporary storage space, then the original file at the address range corresponding to the subfile in the local storage space is replaced by the subfile in the temporary storage space, and the subfile in the temporary storage space is deleted after the subfile is written into the local storage space.
S104: and upgrading the target equipment based on the subfile.
In a possible embodiment, the specific implementation flow of S104 includes:
calculating the sum of the sizes of the file segments written into the local storage space by the subfile;
and if the sum of the sizes of the file segments written into the local storage space by the subfile is equal to the file size of the subfile, judging that the subfile passes the integrity check, and upgrading the target equipment based on the subfile.
In this embodiment, as shown in fig. 2, after downloading the complete subfile, the integrity of the subfile is verified, and only after the integrity verification is passed, the target device can be upgraded based on the subfile, otherwise, the temporary file that is temporarily stored needs to be deleted, and the method returns to the step of determining the number of the subfiles to be upgraded in the upgrade package, and repeatedly executes the subsequent processes.
Specifically, if the subfile is completely stored in the local storage space at one time, the target device may calculate an MD5 value for the stored subfile, then determine whether the MD5 value of the subfile in the upgrade package is consistent with the calculated MD5 value, and if so, prove that the subfile passes integrity verification.
If the subfile segment is stored in the local storage space, the target device can calculate the sum of the sizes of the file segments written in the local storage space by the subfile; and if the sum of the sizes of the file segments written into the local storage space by the subfile is equal to the file size of the subfile, the subfile is proved to pass the integrity verification.
According to the embodiment, the integrity of the subfiles written into the local storage space is verified, so that the problem of failed upgrading caused by incomplete downloading of the subfiles and upgrading can be avoided.
In this embodiment, the upgrade package may be a compressed upgrade package or an uncompressed upgrade package. When the upgrade package is a compressed upgrade package, the specific implementation process of S104 includes:
and if the subfile passes the integrity check, decompressing the subfile, and storing the decompressed subfile to a corresponding storage address of the subfile in a local storage space. And then upgrading the target equipment based on the decompressed subfile, and deleting the compressed upgrade package of the subfile in the local storage space after upgrading.
Specifically, as shown in fig. 2, after the upgrading operation of the subfiles is completed, the number of the subfiles to be upgraded in the upgrade package is reduced by one, the step of judging the number of the subfiles to be upgraded is returned, the subsequent process is repeated until the number of the subfiles to be upgraded is equal to zero, and the upgrading process is ended.
Specifically, after upgrading of a subfile of the upgrade package is completed, the original sub-packet information in the local storage space is replaced by the current sub-packet information of the subfile. After the whole upgrade package is upgraded, the current total package head information of the upgrade package replaces the total package head information in the local storage space so as to wait for the verification of the upgrade package version in the next upgrade.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
In the following, embodiments of the apparatus of the present application are provided, and for details which are not described in detail therein, reference may be made to the corresponding method embodiments described above.
Fig. 3 shows a schematic structural diagram of an apparatus remote upgrade device provided in an embodiment of the present application, and for convenience of description, only parts related to the embodiment of the present application are shown, which are detailed as follows:
as shown in fig. 3, the deviceremote upgrade apparatus 100 includes:
theupgrade determining module 110 is configured to determine whether the target device needs to be upgraded according to total packet header information of an upgrade packet, where the total packet header information includes sub-packet information of at least one sub-file; the sub-package information comprises the file size and the offset address of the sub-file in the upgrading package;
thesegment downloading module 120 is configured to, if the target device needs to be upgraded, determine, for each subfile in the upgrade package, whether a file size corresponding to the subfile is larger than a temporary storage space of the target device; if the file size corresponding to the subfile is larger than the temporary storage space, downloading the subfile to the temporary storage space in a segmented manner based on the offset address of the subfile and the size of the temporary storage space, replacing an original file corresponding to the current file segment in the local storage space by the current file segment downloaded to the temporary storage space before downloading the next file segment, and deleting the current file segment in the temporary storage space;
and theupgrading module 130 is configured to upgrade the target device based on the subfile.
In one possible embodiment, thesegment download module 120 comprises:
step 1: determining the offset address of the current file segment in the subfile in the upgrade package based on the offset address of the subfile in the upgrade package and the address range of the file segment of the subfile downloaded last time in the upgrade package;
step 2: determining the address range of the current file segment in the subfile in the upgrade package based on the offset address of the current file segment in the subfile in the upgrade package and the size of the temporary storage space;
and 3, step 3: sending a file segmentation downloading request to a server, wherein the file segmentation downloading request is used for indicating the server to send the file segmentation corresponding to the subfile in the upgrade package to the target device based on the address range of the current file segmentation of the subfile in the upgrade package;
and 4, step 4: and storing the file segments of the sub file downloaded at the current time into the temporary storage space, and repeatedly executing the steps 1 to 4 until the ending address of the file segments of the sub file downloaded at the current time is the same as the ending address of the sub file.
In one possible embodiment, the sub-packet information includes a sub-file name and sub-packet version information; the deviceremote upgrade apparatus 100 further includes:
and the version information judging module is used for executing the step of judging whether the file size corresponding to the subfile is larger than the temporary storage space of the target equipment or not if the sub-package version information of the subfile corresponding to the same subfile name in the local storage space is inconsistent with the sub-package version information in the upgrading packet.
In one possible embodiment, the subpacket version information includes a subpacket version number and an MD5 value; the version information judgment module specifically comprises:
and if the sub-packet version number of the sub-file corresponding to the same sub-file name in the local storage space is inconsistent with the sub-packet version number of the upgrading packet, and the MD5 value of the sub-file in the local storage space is inconsistent with the MD5 value of the upgrading packet, executing the step of judging whether the file size corresponding to the sub-file is larger than the temporary storage space of the target equipment.
In one possible embodiment, the total header information further includes an upgrade package identifier, software version information, and hardware version information; the deviceremote upgrade apparatus 100 further comprises an identification verification module for:
when an upgrade order is monitored, judging whether an upgrade package is the upgrade package of the target equipment or not based on an upgrade package identifier in the upgrade order;
if the upgrade package is the upgrade package of the target equipment, acquiring the total package header information of the upgrade package;
theupgrade determining module 110 includes:
and judging whether the target equipment needs to be upgraded or not based on the software version information and the hardware version information.
The deviceremote upgrade apparatus 100 further includes:
and the subfile downloading module is used for downloading the subfile to the temporary storage space based on the offset address and the file size of the subfile if the file size of the subfile is not larger than the temporary storage space of the target equipment.
The remote upgrading device of equipment that this application embodiment provided can solve the problem that the upgrading package size can't be upgraded when being greater than the space of keeping in of equipment through downloading the subfile segmentation to the space of keeping in to improve upgrading efficiency.
Fig. 4 is a schematic diagram of a terminal provided in an embodiment of the present application. As shown in fig. 4, theterminal 4 of this embodiment includes: aprocessor 40, amemory 41 and acomputer program 42 stored in saidmemory 41 and executable on saidprocessor 40. Theprocessor 40 implements the steps in the above-described embodiments of the device remote upgrade method, such as steps 101 to 103 shown in fig. 1, when executing thecomputer program 42. Alternatively, theprocessor 40, when executing thecomputer program 42, implements the functions of the modules/units in the above-mentioned device embodiments, such as the functions of themodules 110 to 130 shown in fig. 3.
Illustratively, thecomputer program 42 may be partitioned into one or more modules/units, which are stored in thememory 41 and executed by theprocessor 40 to implement the scheme provided herein. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of thecomputer program 42 in theterminal 4. For example, thecomputer program 42 may be divided into themodules 110 to 130 shown in fig. 3.
Theterminal 4 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. Theterminal 4 may include, but is not limited to, aprocessor 40, amemory 41. Those skilled in the art will appreciate that fig. 4 is only an example of aterminal 4 and does not constitute a limitation ofterminal 4 and may include more or less components than those shown, or some components in combination, or different components, for example, the terminal may also include input output devices, network access devices, buses, etc.
TheProcessor 40 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Thememory 41 may be an internal storage unit of theterminal 4, such as a hard disk or a memory of theterminal 4. Thememory 41 may also be an external storage device of theterminal 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, provided on theterminal 4. Further, thememory 41 may also include both an internal storage unit and an external storage device of theterminal 4. Thememory 41 is used for storing the computer program and other programs and data required by the terminal. Thememory 41 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal and method may be implemented in other ways. For example, the above-described apparatus/terminal embodiments are merely illustrative, and for example, the division of the modules or units is only one type of logical function division, and other division manners may exist in actual implementation, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit may be implemented in the form of hardware, or may also be implemented in the form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method according to the embodiments described above may also be implemented by a computer program, which may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the steps of the embodiments of the method for remotely upgrading devices may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U.S. disk, removable hard disk, magnetic diskette, optical disk, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), electrical carrier wave signal, telecommunications signal, and software distribution medium, etc. It should be noted that the computer readable medium may contain other components which may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media which may not include electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
Furthermore, features of the embodiments shown in the drawings of the present application or of the various embodiments mentioned in the present description are not necessarily to be understood as embodiments independent of each other. Rather, each feature described in one example of one embodiment can be combined with one or more other desired features from other embodiments to yield yet further embodiments, which are not described in text or with reference to the accompanying drawings.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.