CN114296770A - Differential upgrading method, device, equipment and readable storage medium - Google Patents

Differential upgrading method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN114296770A
CN114296770A CN202111577749.9A CN202111577749A CN114296770A CN 114296770 A CN114296770 A CN 114296770A CN 202111577749 A CN202111577749 A CN 202111577749A CN 114296770 A CN114296770 A CN 114296770A
Authority
CN
China
Prior art keywords
file
partition
upgrading
upgrade
directory
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111577749.9A
Other languages
Chinese (zh)
Inventor
孙凡晴
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ecovacs Commercial Robotics Co Ltd
Original Assignee
Ecovacs Commercial Robotics Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ecovacs Commercial Robotics Co Ltd filed Critical Ecovacs Commercial Robotics Co Ltd
Priority to CN202111577749.9A priority Critical patent/CN114296770A/en
Publication of CN114296770A publication Critical patent/CN114296770A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

When the upgrade is needed, the linux terminal enters a recovery partition to start an upgrade mode, a user partition and a system partition are mounted to the recovery partition in the upgrade mode, and then a system file in the system partition is upgraded by using a differential package in the user partition. By adopting the scheme, the linux terminal is upgraded in a differential upgrading mode, so that the upgrading efficiency is high, the consumed flow is small, and the stability is high. And moreover, the occupation of the internal control space in the upgrading process is greatly reduced.

Description

Differential upgrading method, device, equipment and readable storage medium
Technical Field
The present application relates to the field of Linux technologies, and in particular, to a differential upgrading method, apparatus, device, and readable storage medium.
Background
Currently, many electronic devices are equipped with linux systems, and such electronic devices are also called linux terminals. After leaving the factory, the Linux terminal may be upgraded for reasons such as bug repair, function addition, and the like.
The Linux terminal generally adopts a whole package upgrading mode to upgrade the system. In the upgrading process, the Linux terminal downloads the software of the latest version from the server and covers the software of the old version with the software of the latest version.
In the upgrading process, the Linux terminal is required to completely download the latest version of software to the local, and when the latest version of software is large, the downloading time is long, the upgrading efficiency is low, the flow consumption is large, and the stability is poor.
Disclosure of Invention
The embodiment of the application provides a differential upgrading method, a differential upgrading device and a readable storage medium, wherein the linux terminal is upgraded in a differential upgrading mode, and the upgrading method is high in upgrading efficiency, small in consumed flow and high in stability.
In a first aspect, an embodiment of the present application provides a differential upgrading method, which is applied to a linux terminal, and the method includes:
entering a recovery partition of the linux terminal to start an upgrading mode;
mounting a user partition and a system partition of the linux terminal to the recovery partition;
and upgrading the system file in the system partition by using the differential packet in the user partition.
In a second aspect, an embodiment of the present application provides a differential packet generation method, including:
the method comprises the steps of manufacturing a source file according to a first system file, and manufacturing a target file according to a second system file, wherein the second system file is obtained by upgrading the first system file, the directory of the source file comprises a first boot directory, a first OPT directory and a first OTA directory, and the directory of the target file comprises a second boot directory, a second OPT directory and a second OTA directory;
obtaining a first compressed packet according to the source file, and obtaining a second compressed packet according to the target file;
generating a differential packet according to the first compressed packet and the second compressed packet;
and sending a push request carrying the differential packet to a server.
In a third aspect, an embodiment of the present application provides a differential upgrading apparatus, where the apparatus is integrated on a linux terminal, and the apparatus includes:
the processing module is used for entering a recovery partition of the linux terminal to start an upgrading mode;
the mounting module is used for mounting the user partition and the system partition of the linux terminal to the recovery partition;
and the upgrading module is used for upgrading the system files in the system partition by using the differential packet in the user partition.
In a fourth aspect, an embodiment of the present application provides a differential packet generation apparatus, including:
the system comprises a making module, a generating module and a sending module, wherein the making module is used for making a source file according to a first system file and making a target file according to a second system file, the second system file is obtained by upgrading the first system file, the directory of the source file comprises a first boot directory, a first OPT directory and a first OTA directory, and the directory of the target file comprises a second boot directory, a second OPT directory and a second OTA directory;
the compression module is used for obtaining a first compression packet according to the source file and a second compression packet according to the target file;
a processing module, configured to generate a differential packet according to the first compressed packet and the second compressed packet;
and the sending module is used for sending a pushing request carrying the differential packet to a server.
In a fifth aspect, an embodiment of the present application provides an electronic device, where the electronic device is the linux terminal described above, and the electronic device includes: a processor, a memory and a computer program stored on the memory and executable on the processor, the processor when executing the computer program causing the electronic device to carry out the method according to the first aspect or the various possible implementations of the first aspect.
In a sixth aspect, an embodiment of the present application provides an electronic device, including: a processor, a memory and a computer program stored on the memory and executable on the processor, the processor executing the computer program to cause the electronic device to implement the method as described above in the second aspect or in various possible implementations of the second aspect.
In a seventh aspect, this application embodiment provides a computer-readable storage medium, in which computer instructions are stored, and when executed by a processor, the computer instructions are configured to implement the method according to the first aspect or each possible implementation manner of the first aspect.
In an eighth aspect, embodiments of the present application provide a computer-readable storage medium, in which computer instructions are stored, and when executed by a processor, the computer instructions are used to implement the method according to the second aspect or various possible implementation manners of the second aspect.
In a ninth aspect, embodiments of the present application provide a computer program product comprising a computer program, which when executed by a processor, implements the method according to the first aspect or the various possible implementations of the first aspect.
In a tenth aspect, embodiments of the present application provide a computer program product including a computer program, which when executed by a processor implements the method according to the second aspect or various possible implementations of the second aspect.
According to the differential upgrading method, the differential upgrading device, the linux terminal and the readable storage medium, when upgrading is needed, the linux terminal enters the recovery partition to start an upgrading mode, the user partition and the system partition are mounted to the recovery partition in the upgrading mode, and then the system file in the system partition is upgraded by using the differential package in the user partition. By adopting the scheme, the linux terminal is upgraded in a differential upgrading mode, so that the upgrading efficiency is high, the consumed flow is small, and the stability is high. And moreover, the occupation of the internal control space in the upgrading process is greatly reduced.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic diagram of an implementation environment of a differential upgrade method provided in an embodiment of the present application;
fig. 2 is a flowchart of a differential upgrade method provided in an embodiment of the present application;
fig. 3 is another flowchart of a differential upgrade method provided in an embodiment of the present application;
FIG. 4 is a detailed flowchart of step 313 in FIG. 3;
FIG. 5 is a detailed flowchart of step 310 in FIG. 3;
fig. 6 is a flowchart of a differential packet generation method according to an embodiment of the present application;
FIG. 7 is a detailed flowchart of step 603 in FIG. 6;
FIG. 8 is a flowchart of a whole package upgrade provided by an embodiment of the present application;
FIG. 9 is a schematic diagram of a differential upgrading apparatus according to an embodiment of the present disclosure;
fig. 10 is a schematic diagram of a differential packet generation apparatus according to an embodiment of the present application;
fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
With the rapid development of the technology, various terminal devices are widely used. Common terminal devices include Android-based (Android) terminal devices and linux-based terminal devices. Over-the-Air Technology (OTA) has also gained widespread interest for system upgrades. Because the complete upgrade package of the android system is very large, the system is upgraded in a differential upgrade mode. Through differential upgrading, the occupation of the memory can be reduced, the upgrading efficiency can be improved, and the like. In addition, in the differential upgrading process, the problem of insufficient memory and the like can be solved by adopting a mode of sequentially differentially upgrading a plurality of upgrading packets.
Generally, the complete upgrade package of the Linux terminal is relatively small, and is usually several megabits. Therefore, most linux terminals perform system upgrade in a whole package upgrade mode, that is, the linux terminals completely download the latest version of software to the local, and use the latest version of software to cover the old version of software.
However, the complete upgrade package for some linux terminals is large, such as a few G. Taking the size of the upgrade package as 7G as an example, it takes about 5 minutes to upload the complete upgrade package during local upgrade, and 5 minutes to upgrade. When the remote upgrade is performed, namely, the upgrade is performed based on the OTA, if the network is unstable, the upgrade fails if the server has not transmitted the upgrade package.
Obviously, when the upgrade package is large, if the whole package upgrade mode is adopted, the time consumption is long, the efficiency is low, and the stability is poor.
Based on this, the embodiment of the application provides a differential upgrading method, device, equipment and readable storage medium, and the linux terminal is upgraded in a differential upgrading mode, so that the upgrading efficiency is high, the consumed flow is small, and the stability is high.
Fig. 1 is a schematic diagram of an implementation environment of a differential upgrade method provided in an embodiment of the present application. Referring to fig. 1, the implementation environment includes a linux terminal 11, a server 12, and an electronic device 13. The Linux terminal 11 and the electronic device 13 establish network connection with the server 12 respectively. The operation and maintenance personnel create a difference packet through the electronic device 13, and send the difference packet to the server 12 by carrying the difference packet in a push request. After receiving the push request, the server 12 sends a push request carrying the differential packet to the linux terminal 11. The Linux terminal 11 uses the differential packet to upgrade a system file so as to implement system upgrade.
The Linux terminal 11 is a terminal device carrying the Ubuntu system on the Linux kernel, and its complete upgrade package is usually large, even larger than 1G, for example, 7G. The memory of the Linux terminal device 11 is partitioned into a plurality of partitions, such as an uboot partition, a boot partition, a misc partition, a recovery partition, a system (system) partition, and a user (userdata) partition. Wherein:
the uboot partition is used for storing a bootstrap program for starting the linux kernel;
the boot partition is used for storing a linux kernel;
the misc partition is used for storing control information and the like of the system entering a recovery mode and a normal mode;
the recovery partition is used for backing up and recovering the data of the normal partition;
the system partition is used for storing system files and the like of the Ubuntu system, and in the embodiment of the application, the system files in the system partition are mainly upgraded;
and the user partition is used for storing user data and the like.
It should be noted that, in the embodiment of the present application, the linux terminal may include more or fewer partitions, and the embodiment of the present application is not limited.
The server 12 may be hardware or software. When the server 12 is hardware, the server 12 is a single server or a distributed server cluster composed of a plurality of servers. When the server 12 is software, it may be a plurality of software modules or a single software module, and the embodiments of the present application are not limited.
The electronic device 13 is an electronic device of an operation and maintenance person, and may be a desktop computer, a server, a notebook computer, or the like. The electronic device creates a target file based on the new version of the system file, creates a source file based on the old version of the system file, creates a differential package based on the target file and the source file, and uploads the differential package to the server 12.
The differential upgrade method provided in the embodiment of the present application is described in detail below based on the implementation environment shown in fig. 1. For example, please refer to fig. 2, and fig. 2 is a flowchart of a differential upgrade method according to an embodiment of the present application. This embodiment is explained from the perspective of a linux terminal. The embodiment comprises the following steps:
201. and entering a recovery partition of the linux terminal to start an upgrading mode.
Illustratively, the linux terminal has an upgrade mode and a normal (normal) mode. Normally, the linux terminal device is in normal mode and operates in normal mode. When upgrading is needed, the linux terminal enters a recovery partition to start an upgrading mode.
For example, the misc partition is read in the linux terminal starting process, and if a reboot recovery (reboot recovery) instruction is read from the misc partition, the instruction is executed to enter the recovery partition to start the upgrade mode.
For another example, the linux terminal currently operates under the Ubuntu system and receives a reboot recovery instruction from the server. And then, the linux terminal executes the instruction to enter a recovery partition so as to start an upgrading mode.
202. And the linux terminal mounts the user partition and the system partition of the linux terminal to the recovery partition.
Illustratively, the recovery partition has a plurality of directories, and the linux terminal mounts the user partition to a certain directory of the recovery partition first, and then mounts the system partition to a certain directory of the user partition, such as an/opt directory. Thus, the linux terminal can operate the user partition and the system partition in the upgrade mode.
203. And the linux terminal utilizes the differential packet in the user partition to upgrade the system file in the system partition.
Illustratively, the differential package is typically written to the user partition, while the system files of the Ubuntu system are located in the system partition. After the Linux terminal mounts the user partition and the system partition to the recovery partition, the system file in the system partition can be upgraded by using the differential packet in the user partition.
It can be understood that the system files in the system partition are software packages of old versions, the differential package can reflect the difference between the software packages of the old versions and the software packages of the new versions, and the purpose of upgrading is to upgrade the system files in the system partition into the software packages of the new versions by using the differential package.
According to the differential upgrading method provided by the embodiment of the application, when upgrading is needed, the linux terminal enters the recovery partition to start the upgrading mode, the user partition and the system partition are mounted to the recovery partition in the upgrading mode, and then the system file in the system partition is upgraded by using the differential package in the user partition. By adopting the scheme, the linux terminal is upgraded in a differential upgrading mode, so that the upgrading efficiency is high, the consumed flow is small, and the stability is high. And moreover, the occupation of the internal control space in the upgrading process is greatly reduced.
Optionally, in the foregoing embodiment, before step 201, the linux terminal enters the Ubuntu system, and receives a push request from the server under the Ubuntu system, where the push request carries the differential packet.
And after receiving the push request, the Linux terminal writes the differential packet into the user partition under the Ubuntu system. For example, the differential packet is update. Also, the linux terminal creates a command file under a user partition creation command (command) file, for example, a/userdata/recovery directory, which is used to indicate a path of the differential packet. For example, the content of the command file is "- - -/update _ package ═ userdata/update. And then, the linux terminal writes the command file and a restart recovery (reboot recovery) instruction in the misc partition, wherein the reboot recovery instruction is used for indicating the linux terminal to enter the recovery partition.
By adopting the scheme, the linux terminal writes the differential packet into the user partition under the Ubuntu system and creates a command file to prepare for subsequent differential upgrading.
Similarly, if the recovery partition needs to be updated, the server also pushes a firmware update package to the linux terminal, where the firmware update package is, for example, update. If the recovery.img is packaged in the update.img, it indicates that the recovery partition needs to be upgraded, and if the recovery.img is not in the update.img, it indicates that the recovery partition does not need to be upgraded.
After receiving the firmware upgrade package under the Ubuntu system, the Linux terminal puts the component upgrade package under the user partition/userdata/directory. And the subsequent linux terminal executes a second upgrading command, namely the update binary program finishes upgrading the recovery partition.
Optionally, in the above embodiment, in a process that the linux terminal updates the system file in the system partition by using the differential packet in the user partition, a first update command is read from the recover partition, where the first update command is a binary program, and the binary program is also referred to as an update-binary program. Meanwhile, the linux terminal reads the misc partition to obtain a command file, wherein the command file is used for indicating the path of the differential packet. And the Linux terminal reads the differential packet according to the path and analyzes the differential packet to obtain a flashing script and an upgrading file. Among them, the flush script is also called (updatescript) script, and the script contains some operation commands. The upgrade includes newly added files, patch files, etc.
And finally, the linux terminal analyzes the flashing script by using the first upgrading command to obtain an operation command, and operates the upgrading file by using the operation command to upgrade the system file.
By adopting the scheme, the operation command is analyzed from the flash script by executing the update-binary system program in the upgrading process of the linux terminal, and the upgrading file is operated by utilizing the operation command, so that the upgrading of the system file is realized, and the speed is high.
Optionally, in the above embodiment, in the process that the linux terminal operates the upgrade file by using the operation command to upgrade the system file, operation modes corresponding to different operation commands are different.
For example, when the operation command is a copy command and the upgrade file is a newly added file, the linux terminal copies the newly added file by one copy and adds the newly added file obtained by copying to the system file.
For another example, when the operation command is a delete command and the upgrade file indicates a file to be deleted, the linux terminal deletes the file to be deleted from the system file. It can be understood that the system file includes a plurality of files, and if one of the plurality of files is a file to be generated indicated by the upgrade file, the linux terminal finds the file from the plurality of files and executes a delete command.
For another example, when the operation command is patching and the upgrade file is a patch file, the linux terminal modifies the system file according to the patch file. For example, the system file comprises a plurality of files, and one of the files needs to be modified, so that the linux terminal modifies the one of the files according to the modification of the patch file.
By adopting the scheme, the linux terminal operates the upgrading file according to different operation instructions to upgrade the system, and the method has high accuracy and high speed.
Optionally, in the above embodiment, the linux terminal uses the differential packet in the user partition to update the system file in the system partition. And after the upgrading is finished, the linux terminal unloads the directory of the system partition from the plurality of directories of the recovery partition. Thereafter, the misc partition is emptied. Finally, the differential packets in the user partition are made clear.
Illustratively, after successful upgrade, the linux terminal determines a directory for mounting the system partition from the plurality of directories of the recovery partition, and unloads the directory. The misc partition is then cleared first. After the misc partition is cleared, the differential packet in the user partition is cleared.
By adopting the scheme, the problem of equipment brick change caused by power failure in the upgrading process can be effectively avoided by orderly unloading the directory, emptying the miscc partition and clearing the differential packet, and the upgrading operation can be continuously completed after the power is re-electrified.
Fig. 3 is another flowchart of a differential upgrade method provided in an embodiment of the present application. In this embodiment, in the process of starting the linux terminal each time, the misc partition is read first, and whether a restart recovery instruction exists in the misc partition is judged, so as to determine whether to start the upgrade mode. The embodiment comprises the following steps:
301. and starting the linux terminal.
302. The linux terminal judges whether a restart recovery instruction exists in the misc partition, and if the restart recovery instruction exists in the misc partition, the step 303 is executed; if there is no restart recovery instruction in the misc partition, step 311 is performed.
Wherein, the restart recovery instruction is also called a reboot recovery instruction.
By adopting the scheme, the linux terminal can determine whether to enter the upgrading mode by reading the miscc partition when being started every time, the accuracy is high, the timeliness is strong, and the Ubuntu system of the linux terminal can be upgraded in time.
303. Enter recovery partition to initiate upgrade mode.
304. And mounting the user partition and the system partition of the linux terminal to the recovery partition.
305. Checking the differential packet, and if the checking is successful, executing step 306; if the verification fails, it indicates that the upgrade fails, and the linux terminal performs step 309.
Illustratively, the system file comprises a plurality of files, and if a certain file needs to be patched, the linux terminal determines the hash value of the old version of the file and the hash value of the new version of the file. If the two hash values are the same, the verification is successful; if the two hash values are different, it is described that the verification fails, and the reasons of the failure include cross-version and the like, which is not limited in the embodiment of the present application.
By adopting the scheme, the hash value of the file to be upgraded is checked in the upgrading process, so that the stability and reliability in the upgrading process are improved.
306. And upgrading the system files in the system partition by using the differential packet in the user partition.
Illustratively, the linux terminal reads a first upgrade command from the recovery partition, and analyzes a flush script in the differential packet by using the first upgrade command to obtain an operation command. And operating the upgrading file in the differential packet according to the operation command so as to upgrade the system file. The upgrade files include newly added files, patch files, and the like.
307. Judging whether abnormal power failure occurs in the upgrading process, if not, executing step 308; if an abnormal power outage occurs, step 310 is executed.
308. And the linux terminal unloads the directory of the system partition from the plurality of directories of the recovery partition. Thereafter, the misc partition is emptied. Finally, the differential packets in the user partition are made clear.
309. The linux terminal is restarted, and then step 302 is executed.
Illustratively, after the upgrade is successful, the linux terminal is restarted and enters the Ubuntu system.
310. And powering up the linux terminal again, and detecting whether to continue upgrading.
Illustratively, when power failure occurs in the upgrading process, after the linux terminal is powered off and powered on again, whether to continue upgrading or enter the Ubuntu system is determined according to the signature file in the differential packet, whether the differential packet is cleared, whether the misc partition is emptied, and the like.
311. And the linux terminal enters the Ubuntu system.
312. And reading a second upgrading command from the system partition under the Ubuntu system.
The second upgrade command is a binary program, which is also called an update binary program and is a binary program for upgrading a recovery partition. The parameters of the update binary program are ota/userdata/update.
313. And executing the second upgrading command to upgrade the recovery partition of the linux terminal.
It should be noted that, if the upgrade of the recovery partition is not considered, in step 302, if the linux terminal determines that there is no restart recovery instruction in the misc partition, the misuntu system is directly entered and operates under the Ubuntu system, and an update binary program does not need to be executed, that is, the recovery partition does not need to be upgraded.
By adopting the scheme, the purpose of upgrading recovery partitions is achieved.
Fig. 4 is a detailed flowchart of step 313 in fig. 3. Fig. 4 includes:
401. and the linux terminal executes a second upgrading command under the Ubuntu system.
The second upgrade command is a binary program, which is also called an update binary program and is a binary program for upgrading a recovery partition. The parameters of the update binary program are ota/userdata/update.
The update binary is compiled from a source file in the linux Software Development Kit (SDK) that is located under the external/rktoolkit directory in the SDK.
402. The linux terminal device detects whether data for updating the recovery partition exists in a firmware update package in the user partition by using a second update command, and if the data for updating the recovery partition exists in the firmware update package, step 403 is executed; if the firmware upgrade package does not contain data for upgrading the recovery partition, step 404 is executed.
Illustratively, when the linux terminal executes the second upgrade command, a detection function (checkFwdata) is called in the Ubuntu system, and the detection function is used to detect whether data for upgrading the recovery partition exists in the firmware upgrade package. Img, also called update. If the firmware upgrade package contains data for upgrading the recovery partition, the recovery. If the update.img does not have the packaged recovery.img, it indicates that the firmware upgrade package does not have data for upgrading recovery.
403. Writing data for upgrading the recovery partition into the recovery partition to upgrade the recovery partition.
And when the linux terminal detects that the data for upgrading the recovery partition exists in the firmware upgrading packet through the detection function, continuously executing the second upgrading command, calling a write-in function (writekFwdata), and writing the data for upgrading the recovery partition into the recovery partition.
404. Rebooting to enter upgrade mode.
And when the linux terminal detects that data for upgrading the recovery partition does not exist in the firmware upgrading packet, restarting to enter the recovery partition, namely entering an upgrading mode. And upgrading other partitions in the upgrading mode.
By adopting the scheme, when the data for upgrading the recovery partition exists in the firmware upgrading package, the recovery partition is upgraded under the Ubuntu system, and the purpose of timely upgrading the recovery partition is achieved.
Fig. 5 is a detailed flowchart of step 310 in fig. 3. Fig. 5 includes:
501. and after the power failure occurs in the upgrading process of the linux terminal, the linux terminal is electrified and started again.
502. The linux terminal detects whether a misc partition of the linux terminal is cleared and whether a differential packet in the user partition is cleared, and if the misc partition is not cleared and the differential packet in the user partition is not cleared, step 503 is executed; if the misc partition is empty but the differential packet in the user partition is not cleared, go to step 504; if the misc partition is cleared and the differential packet in the user partition is cleared, step 505 is performed.
For example, if the misc partition is not cleared and the differential packet in the user partition is not cleared, the linux terminal only updates part of the files in the system file, or the linux terminal completes the update but does not clear the misc partition and does not clear the differential packet.
503. The linux terminal detects whether only part of the files are upgraded, and if only part of the files are upgraded, the step 506 is executed; if the upgrade is completed for each file in the system files, step 509 is executed.
506. Enter recovery partition to initiate upgrade mode.
507. And determining the files which are not upgraded from the system files in the upgrading mode, and upgrading the files which are not upgraded.
508. And unloading the directory of the mounted system partition from the directory of the recovery partition, emptying the misc partition, and then clearing the differential packet.
509. The recovery partition is entered to initiate upgrade mode, followed by step 508.
Illustratively, the linux terminal skips the upgrading operation and directly carries out directory uninstallation, misc partition clearing and differential packet clearing.
504. Entering a Ubuntu system, and covering the old differential packet by using a new differential packet when the system is updated next time.
505. And entering a Ubuntu system, and directly writing the differential packet into the user partition when upgrading next time.
By adopting the scheme, whether the upgrade of all files is finished or not, whether the differential packet is cleared or not, whether the misc partition is emptied or not and the like are detected according to the signature files in the differential packet, whether the upgrade is continued or the Ubuntu system is entered is determined, and the problem of equipment side bricks caused by abnormal power failure in the upgrade process is avoided.
Next, how the electronic device of the operation and maintenance person generates the difference packet will be described in detail. For example, please refer to fig. 6, fig. 6 is a flowchart of a differential packet generation method according to an embodiment of the present application. The execution subject of the present embodiment is an electronic apparatus, and the present embodiment explains from the viewpoint of how the electronic apparatus generates the differential packet. The embodiment comprises the following steps:
601. and manufacturing a source file according to the first system file, and manufacturing a target file according to the second system file.
The second system file is obtained by upgrading the first system file, the directories of the source file comprise a first boot directory, a first OPT directory and a first OTA directory, and the directories of the target file comprise a second boot directory, a second OPT directory and a second OTA directory.
Illustratively, the formats of the first system file and the second system file do not include a boot directory, an OPT directory, and an OTA directory. The electronic equipment produces a source file and a target file according to the two files.
And storing the kernel mirror image under the boot directory, wherein the boot directory comprises a first boot directory and a second boot directory. The system files of the Ubuntu system are stored under the OPT directory, wherein the OPT directory comprises a first OPT directory and a second OPT directory. The OTA directory stores a binary program for differential upgrade, i.e., the first upgrade command described above.
602. And obtaining a first compressed packet according to the source file, and obtaining a second compressed packet according to the target file.
Illustratively, the electronic device compresses the first boot directory, the first OPT directory, and the first OTA directory of the target file to obtain a first compressed packet in a zip format. Similarly, the electronic device obtains a second compressed packet.
603. And generating a differential packet according to the first compressed packet and the second compressed packet.
Illustratively, the electronic device executes a python script to obtain a differential packet containing the signature file from the first compressed packet and the second compressed packet. The signature file is used for signature verification to ensure stability and reliability in the upgrading process.
Optionally, in the process of creating the differential packet, the electronic device compares the first OPT directory and the second OPT directory, generates a patch (patch) by using a bsdiff tool, determines a newly added file, a file to be deleted, and the like, and generates the differential packet including the signature file based on the files.
604. And sending a push request carrying the differential packet to a server.
By adopting the scheme, the electronic equipment generates the differential packet based on the first system file and the second system file and pushes the differential packet to the server, so that the aims of accurately generating the differential packet and pushing the differential packet to the server in time are fulfilled.
Fig. 7 is a detailed flowchart of step 603 in fig. 6. The embodiment comprises the following steps:
701. the first OPT directory and the second OPT directory are compared.
702. And generating a patch file.
Illustratively, the electronic device generates a patch file using the bsdiff tool based on the comparison.
703. And determining newly added files and files to be deleted according to the first OPT directory and the second OPT directory.
Wherein the newly added file exists in the second OPT directory but does not exist in the first OPT directory, and the file to be deleted exists in the first OPT directory but does not exist in the second OPT directory;
704. and generating a flashing script according to the patching command corresponding to the patch file, the copying command corresponding to the newly added file and the deleting command corresponding to the file to be deleted.
Illustratively, the electronic device records operation commands such as tagging, copying, deleting, etc. into a flash script (updatescript).
705. And generating the differential upgrade package according to the flashing script, the signature file and the newly added file.
Illustratively, the electronic device packages the flashing script, the signature file and the newly added file, thereby obtaining an upgrade package, which is a differential upgrade package.
It should be noted that the above steps 702 and 703 are not in strict sequence.
By adopting the scheme, the differential packet is generated by executing the python script command, so that the speed is high and the accuracy is high.
The differential upgrade method according to the embodiment of the present application will be described below by taking an example in which the complete upgrade package of the linux terminal is 7G and the size of the differential package is 100M.
Illustratively, if a full package upgrade is used, even a local inline upgrade, uploading the complete upgrade package takes approximately 5 minutes, and the upgrade takes 5 minutes. When the remote upgrade is performed, namely, the upgrade is performed based on the OTA, if the network is unstable, the upgrade fails if the server has not transmitted the upgrade package.
If a differential upgrading mode is adopted, the electronic equipment respectively produces a source file and a target file according to the system files of the new version and the old version, compares the OPT directories of the source file and the target file, executes a python script command to generate about 100M differential packages, and pushes the differential packages to the linux terminal through the server.
The Linux terminal receives the differential packet under the Ubuntu system, the differential packet is placed under the/userdata/directory of the user partition, a command file is created under the/userdata/recovery directory of the user partition, and the command file and a reboot recovery instruction are written into the misc partition. And then, executing a reboot recovery, and restarting the linux terminal and entering a recovery partition to start an upgrading mode. Since the difference packet is about 100M, the upgrade is completed quickly, for example, in about 3 seconds. Obviously, the differential upgrading mode has low flow consumption, high stability and high upgrading efficiency.
In the normal upgrading process, after abnormal power failure, the linux terminal is powered on and stays in the recovery partition, namely the machine changes bricks. In the embodiment of the application, a power-off prevention mechanism is added, so that even if power is off in the upgrading process, the linux terminal cannot stay in the recovery partition all the time, and finally enters the Ubuntu system. Therefore, the problem that the machine is changed into bricks due to abnormal power failure in the upgrading process can be effectively solved.
The above embodiments are all described in detail for differential upgrade. However, when the whole package is small or the network is stable, the linux terminal can be upgraded in a whole package coverage mode. For example, please refer to fig. 8. Fig. 8 is a flowchart of a whole package upgrade provided in an embodiment of the present application. This embodiment is explained from the perspective of a linux terminal. The embodiment comprises the following steps:
801. and starting the linux terminal to enter the Ubuntu system.
802. And the linux terminal executes the second upgrading command to analyze the firmware upgrading packet.
The second upgrade command is an update binary program, and the parameters of the binary program are as follows: ota/userdata/update. img, the firmware upgrade package is update.
803. The linux terminal judges whether data for updating the recovery partition exists in the firmware update package, and if the data for updating the recovery partition exists in the firmware update package, the step 804 is executed; if the firmware upgrade package does not contain data for upgrading the recovery partition, step 806 is performed.
805. And writing the data for upgrading the recovery partition into the recovery partition to complete the upgrading of the recovery partition. Thereafter, step 806 is performed.
806. Write command files and restart recovery instructions in the miscc partition.
Wherein the command file is used to indicate the location of the firmware upgrade package.
807. And restarting to enter a recovery partition to start the upgrading mode.
808. And determining the position of the firmware upgrading package according to the command file of the misc partition, and analyzing the firmware upgrading package to finish upgrading other partitions.
809. And after the firmware upgrade package is cleared and the miscc partition is cleared, restarting to enter the Ubuntu system.
The following are embodiments of the apparatus of the present application that may be used to perform embodiments of the method of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the embodiments of the method of the present application.
Fig. 9 is a schematic diagram of a differential upgrading apparatus according to an embodiment of the present application. The differential upgrade apparatus 900 includes: a processing module 91, a mounting module 92 and an upgrade module 93.
The processing module 91 is configured to enter a recovery partition of the linux terminal to start an upgrade mode;
a mounting module 92, configured to mount a user partition and a system partition of the linux terminal to the recovery partition;
and the upgrading module 93 is configured to upgrade the system file in the system partition by using the differential packet in the user partition.
In a possible implementation manner, the upgrade module 93 is configured to read a first upgrade command from the recovery partition; analyzing the differential packet to obtain a flashing script and an upgrading file; analyzing the flashing script by using the first upgrading command to obtain an operation command; and operating the upgrade file by using the operation command to upgrade the system file.
In a feasible implementation manner, when the upgrade module 93 operates the upgrade file by using the operation command to upgrade the system file, when the operation command is a copy command and the upgrade file is a new file, the new file is added to the system file; when the operation command is a deletion command and the upgrade file indicates a file to be deleted, deleting the file to be deleted from the system file; and when the operation command is patching and the upgrade file is a patch file, modifying the system file according to the patch file.
In a possible implementation manner, the processing module 91 is configured to read the misc partition of the linux terminal after the linux terminal is started; and when a restart recovery instruction exists in the miscc partition, executing the restart recovery instruction to enter a recovery partition and starting an upgrade mode, wherein the restart recovery instruction is used for indicating the linux terminal to enter the recovery partition.
In a possible implementation manner, the processing module 91 is further configured to enter the Ubuntu system when there is no restart recovery instruction in the misc partition; reading a second upgrading command from the system partition under the Ubuntu system; and executing the second upgrading command to upgrade the recovery partition of the linux terminal.
In a possible implementation manner, when the processing module 91 executes the second upgrade command to upgrade a recovery partition of the linux terminal, the processing module is configured to execute the second upgrade command to detect whether data for upgrading the recovery partition exists in a firmware upgrade package in the user partition; if the firmware upgrade package contains data for upgrading the recovery partition, writing the data for upgrading the recovery partition into the recovery partition so as to upgrade the recovery partition.
Referring to fig. 9, in a possible implementation manner, the differential upgrade apparatus 900 further includes: the receiving module 94, before the processing module 91 enters a recovery partition of the linux terminal to start the upgrade mode, is further configured to enter a Ubuntu system;
the receiving module 94 is configured to receive a push request from a server, where the push request carries the differential packet;
the processing module 91 is further configured to write the differential packet into the user partition under the Ubuntu system; creating a command file in the user partition, the command file indicating a path of the differential packet; and writing the command file and a restart recovery instruction in the misc partition of the linux terminal, wherein the restart recovery instruction is used for indicating the linux terminal to enter the recovery partition.
In a possible implementation manner, the processing module 91 is further configured to uninstall a directory of the system partition from the plurality of directories of the recovery partition after the upgrading module 93 upgrades the system file in the system partition by using the differential package in the user partition; emptying the misc partition of the linux terminal; clearing the differential packet in the user partition.
In a possible implementation manner, the processing module 91 is further configured to detect whether the misc partition of the linux terminal is cleared and whether the differential packet in the user partition is cleared after the linux terminal is powered off and powered on again; if the misc partition is not emptied and the differential packet in the user partition is not cleared, entering the upgrading mode; determining files which are not upgraded from the system files in the upgrading mode; and upgrading the unemplified file.
In a possible implementation, the processing module 91 is further configured to enter the Ubuntu system if the misc partition is cleared but the differential packet in the user partition is not cleared.
In a possible implementation manner, the processing module 91 is further configured to check the differential packet before the upgrading module 93 upgrades the system file in the system partition by using the differential packet in the user partition.
The differential upgrading device provided by the embodiment of the application can execute the actions of the linux terminal in the embodiment, the implementation principle and the technical effect are similar, and the implementation principle and the technical effect are not repeated.
Fig. 10 is a schematic diagram of a differential packet generation apparatus according to an embodiment of the present application. The differential packet generation apparatus 1000 includes: a production module 101, a compression module 102, a processing module 103 and a sending module 104.
The system comprises a making module 101, a first system file, a second system file and a third system file, wherein the making module is used for making a source file according to the first system file and making a target file according to the second system file, the second system file is obtained by upgrading the first system file, the directory of the source file comprises a first boot directory, a first OPT directory and a first OTA directory, and the directory of the target file comprises a second boot directory, a second OPT directory and a second OTA directory;
the compression module 102 is configured to obtain a first compression packet according to the source file and obtain a second compression packet according to the target file;
a processing module 103, configured to generate a differential packet according to the first compressed packet and the second compressed packet;
a sending module 104, configured to send a push request carrying the differential packet to a server.
In a feasible implementation manner, the processing module 103 is configured to determine a first file from the first OPT directory, determine a second file corresponding to the first file from the second OPT directory, and generate a patch file according to the first file and the second file; determining a newly added file and a file to be deleted according to the first OPT directory and the second OPT directory, wherein the newly added file exists in the second OPT directory but does not exist in the first OPT directory, and the file to be deleted exists in the first OPT directory but does not exist in the second OPT directory; generating a flashing script according to the patching command corresponding to the patch file, the copying command corresponding to the newly added file and the deleting command corresponding to the file to be deleted; and generating the differential upgrade package according to the flashing script, the signature file and the newly added file.
The differential packet generation apparatus provided in the embodiment of the present application can execute the actions of the electronic device in the above embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.
Fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 11, the electronic device 1100 is, for example, the linux terminal or the electronic device for generating the differential packet, and the electronic device 1100 includes:
a processor 1101 and a memory 1102;
the memory 1102 stores computer instructions;
the processor 1101 executes the computer instructions stored by the memory 1102, so that the processor 1101 executes the differential upgrade method as implemented by the linux terminal above; alternatively, the processor 1101 is caused to execute a differential packet generation method as implemented by the electronic device.
For a specific implementation process of the processor 1101, reference may be made to the above method embodiments, which implement similar principles and technical effects, and details of this embodiment are not described herein again.
Optionally, the electronic device 1100 further comprises a communication component 1103. The processor 1101, the memory 1102, and the communication unit 1103 may be connected by a bus 1104.
An embodiment of the present application further provides a computer-readable storage medium, in which computer instructions are stored, and when the computer instructions are executed by a processor, the computer instructions are used to implement the differential upgrade method implemented by the linux terminal or the differential packet generation method implemented by the electronic device.
An embodiment of the present application further provides a computer program product, where the computer program product includes a computer program, and when executed by a processor, the computer program implements the differential upgrade method implemented by the linux terminal or the differential packet generation method implemented by the electronic device.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (17)

1. A differential upgrading method is applied to a linux terminal, and comprises the following steps:
entering a recovery partition of the linux terminal to start an upgrading mode;
mounting a user partition and a system partition of the linux terminal to the recovery partition;
and upgrading the system file in the system partition by using the differential packet in the user partition.
2. The method of claim 1, wherein the upgrading the system file in the system partition using the differential package in the user partition comprises:
reading a first upgrading command from the recovery partition;
analyzing the differential packet to obtain a flashing script and an upgrading file;
analyzing the flashing script by using the first upgrading command to obtain an operation command;
and operating the upgrade file by using the operation command to upgrade the system file.
3. The method of claim 2, wherein the operating the upgrade file with the operation command to upgrade the system file comprises:
when the operation command is a copying command and the upgrade file is a newly added file, adding the newly added file in the system file;
when the operation command is a deletion command and the upgrade file indicates a file to be deleted, deleting the file to be deleted from the system file;
and when the operation command is patching and the upgrade file is a patch file, modifying the system file according to the patch file.
4. The method according to any one of claims 1 to 3, wherein the entering into the recovery partition of the linux terminal to start an upgrade mode comprises:
after the linux terminal is started, reading the misc partition of the linux terminal;
and when a restart recovery instruction exists in the miscc partition, executing the restart recovery instruction to enter a recovery partition and starting an upgrade mode, wherein the restart recovery instruction is used for indicating the linux terminal to enter the recovery partition.
5. The method of claim 4, further comprising:
entering an Ubuntu system when a restart recovery instruction does not exist in the misc partition;
reading a second upgrading command from the system partition under the Ubuntu system;
and executing the second upgrading command to upgrade the recovery partition of the linux terminal.
6. The method of claim 5, wherein the executing the second upgrade command to upgrade the recovery partition of the linux terminal comprises:
executing the second upgrade command to detect whether data for upgrading the recovery partition exists in a firmware upgrade package in the user partition;
if the firmware upgrade package contains data for upgrading the recovery partition, writing the data for upgrading the recovery partition into the recovery partition so as to upgrade the recovery partition.
7. The method according to any one of claims 1 to 3, wherein before entering a recovery partition of the linux terminal to start an upgrade mode, the method further comprises:
entering a Ubuntu system;
receiving a push request from a server, wherein the push request carries the differential packet;
writing the differential packet into the user partition under the Ubuntu system;
creating a command file in the user partition, the command file indicating a path of the differential packet;
and writing the command file and a restart recovery instruction in the misc partition of the linux terminal, wherein the restart recovery instruction is used for indicating the linux terminal to enter the recovery partition.
8. The method according to any one of claims 1-3, further comprising, after the upgrading the system file in the system partition with the difference package in the user partition:
unloading the directory of the system partition from the plurality of directories of the recovery partition;
emptying the misc partition of the linux terminal;
clearing the differential packet in the user partition.
9. The method according to any one of claims 1-3, further comprising:
when the linux terminal is powered off and powered on again, detecting whether the misc partition of the linux terminal is emptied and whether a differential packet in the user partition is cleared;
if the misc partition is not emptied and the differential packet in the user partition is not cleared, entering the upgrading mode;
determining files which are not upgraded from the system files in the upgrading mode;
and upgrading the unemplified file.
10. The method of claim 9, further comprising:
and if the misc partition is emptied but the differential packet in the user partition is not cleared, entering the Ubuntu system.
11. The method according to any one of claims 1-3, wherein before upgrading the system file in the system partition using the differencing packet in the user partition, further comprising:
and checking the differential packet.
12. A differential packet generation method applied to an electronic device, the method comprising:
the method comprises the steps of manufacturing a source file according to a first system file, and manufacturing a target file according to a second system file, wherein the second system file is obtained by upgrading the first system file, the directory of the source file comprises a first boot directory, a first OPT directory and a first OTA directory, and the directory of the target file comprises a second boot directory, a second OPT directory and a second OTA directory;
obtaining a first compressed packet according to the source file, and obtaining a second compressed packet according to the target file;
generating a differential packet according to the first compressed packet and the second compressed packet;
and sending a push request carrying the differential packet to a server.
13. The method of claim 12, wherein generating the differential packet from the first compressed packet and the second compressed packet comprises:
determining a first file from the first OPT directory, determining a second file corresponding to the first file from the second OPT directory, and generating a patch file according to the first file and the second file;
determining a newly added file and a file to be deleted according to the first OPT directory and the second OPT directory, wherein the newly added file exists in the second OPT directory but does not exist in the first OPT directory, and the file to be deleted exists in the first OPT directory but does not exist in the second OPT directory;
generating a flashing script according to the patching command corresponding to the patch file, the copying command corresponding to the newly added file and the deleting command corresponding to the file to be deleted;
and generating the differential upgrade package according to the flashing script, the signature file and the newly added file.
14. A differential upgrading apparatus integrated on a linux terminal, the apparatus comprising:
the processing module is used for entering a recovery partition of the linux terminal to start an upgrading mode;
the mounting module is used for mounting the user partition and the system partition of the linux terminal to the recovery partition;
and the upgrading module is used for upgrading the system files in the system partition by using the differential packet in the user partition.
15. A differential packet generation device, comprising:
the system comprises a making module, a generating module and a sending module, wherein the making module is used for making a source file according to a first system file and making a target file according to a second system file, the second system file is obtained by upgrading the first system file, the directory of the source file comprises a first boot directory, a first OPT directory and a first OTA directory, and the directory of the target file comprises a second boot directory, a second OPT directory and a second OTA directory;
the compression module is used for obtaining a first compression packet according to the source file and a second compression packet according to the target file;
a processing module, configured to generate a differential packet according to the first compressed packet and the second compressed packet;
and the sending module is used for sending a pushing request carrying the differential packet to a server.
16. An electronic device comprising a processor, a memory, and a computer program stored on the memory and executable on the processor, wherein execution of the computer program by the processor causes the electronic device to carry out the method of any one of claims 1 to 13.
17. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1 to 13.
CN202111577749.9A 2021-12-22 2021-12-22 Differential upgrading method, device, equipment and readable storage medium Pending CN114296770A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111577749.9A CN114296770A (en) 2021-12-22 2021-12-22 Differential upgrading method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111577749.9A CN114296770A (en) 2021-12-22 2021-12-22 Differential upgrading method, device, equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN114296770A true CN114296770A (en) 2022-04-08

Family

ID=80970616

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111577749.9A Pending CN114296770A (en) 2021-12-22 2021-12-22 Differential upgrading method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN114296770A (en)

Similar Documents

Publication Publication Date Title
CN109933348B (en) Method and device for updating Bootloader in electronic control unit
KR101143112B1 (en) Applying custom software image updates to non-volatile storage in a failsafe manner
US8196130B2 (en) Tri-phase boot process in electronic devices
US8539471B2 (en) Updating firmware of an electronic device
CN110597542B (en) Software automatic OTA (over the air) upgrading method and device and electronic equipment
US20110302572A1 (en) Embedded network device and firmware upgrading method
CN112416406B (en) Terminal equipment upgrading method, device, terminal equipment and medium
CN110825563B (en) System recovery method and device and electronic equipment
CN112612524A (en) Method, device and equipment for starting Linux system and storage medium
CN104918114A (en) Method and device for upgrading operation system
CN103106083B (en) A kind of loading method of firmware and device
CN111562934A (en) Software system upgrading method based on hot patch, terminal and storage medium
CN114116023A (en) Operating system starting method, operating system starting device, storage medium and computer program product
CN111782236A (en) System software upgrading method and device, storage medium and all-in-one machine equipment
CN106933604B (en) System upgrading method and device
CN114296770A (en) Differential upgrading method, device, equipment and readable storage medium
CN111338652B (en) Operating system mirror image manufacturing method, device, equipment and medium
CN115061704A (en) Firmware upgrading method and electronic equipment
CN114398087A (en) Method for improving running stability of single chip microcomputer after program updating and single chip microcomputer
CN113377425A (en) BMC firmware generation method and device, BMC starting method and device and storage medium
CN112667444A (en) System upgrading method, storage medium and terminal equipment
CN111190627A (en) System upgrading method and device
CN112631637B (en) OTA upgrading method, system, equipment and storage medium based on RTOS
CN116361817B (en) Protection method of ubi file system under Linux
CN113821234B (en) Operating system upgrade method, apparatus, storage medium, and computer program product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination