Disclosure of Invention
The embodiment of the application provides a firmware upgrading method, a device, computer equipment and a storage medium, which can save storage space while ensuring the stability and reliability of firmware upgrading, thereby reducing cost.
In a first aspect, an embodiment of the present application provides a firmware upgrade method, applied to an embedded device, where the embedded device includes a flash memory, and the flash memory includes a check partition, a functional partition, and an upgrade partition, and the method includes:
Establishing connection with a server, acquiring new firmware from the server, and writing first target data, second target data and third target data contained in the new firmware into the check partition, the functional partition and the upgrade partition respectively, wherein the new firmware is used for carrying out firmware upgrade on the embedded equipment;
If the embedded equipment is restarted when the firmware is upgraded, judging whether the first target data is abnormal when being written into the check partition or not through a boot loader of the embedded equipment;
If no abnormality occurs when the first target data is written into the check partition, judging whether the third target data is abnormal when the third target data is written into the upgrade partition through the boot loader;
If the third target data is abnormal when being written into the upgrading partition, judging whether the functional partition has backed up the third target data or not through the boot loader;
if the functional partition has backed up the third target data, carrying out data recovery on the upgrading partition according to the backed up third target data in the functional partition;
And returning to the step of establishing connection with the server and acquiring new firmware from the server.
In the firmware upgrading method provided in the embodiment of the present application, if no abnormality occurs when the first target data is written into the check partition, the check partition stores the first data identifier of the third target data, and the judging, by the boot loader, whether the abnormality occurs when the third target data is written into the upgrade partition includes:
acquiring a first current data identifier corresponding to first current data in the upgrading partition through the boot loader;
If the first current data identifier is consistent with the first data identifier, determining that the third target data is written into the ascending partition without abnormality or
If the first current data identifier is inconsistent with the first data identifier, determining that the third target data is abnormal when being written into the upgrading partition.
In the firmware upgrading method provided by the embodiment of the present application, the step of determining, by the boot loader, whether the functional partition has backed up the third target data includes:
acquiring a second current data identifier corresponding to second current data in the functional partition;
If the second current data identification is consistent with the first data identification, determining that the functional partition has backed up the third target data, or
And if the second current data identifier is inconsistent with the first data identifier, determining that the functional partition does not backup the third target data.
In the firmware upgrading method provided by the embodiment of the present application, after the determining that the functional partition does not backup the third target data, the method further includes:
And returning to the step of establishing connection with the server and acquiring new firmware from the server.
In the firmware upgrading method provided by the embodiment of the present application, if no abnormality occurs when the first target data is written into the check partition, the check partition further stores a second data identifier corresponding to the second target data, and the method further includes:
if the third target data is written into the ascending partition and is not abnormal, acquiring a third current data identifier corresponding to third current data in the functional partition through the boot loader;
If the third current data identifier is inconsistent with the second data identifier, determining that the second target data is abnormal when being written into the functional partition;
And returning to the step of establishing connection with the server and acquiring new firmware from the server.
In the firmware upgrading method provided by the embodiment of the present application, the determining, by the boot loader of the embedded device, whether an exception occurs when the first target data is written into the check partition includes:
Reading fourth current data in the check partition through the boot loader;
If the fourth current data is in the preset format, determining that no abnormality occurs when the first target data is written into the check partition;
if the fourth current data is not in the preset format, determining that the first target data is abnormal when being written into the check partition.
The firmware upgrading method provided by the embodiment of the application further comprises the following steps:
and if the first target data is abnormal when being written into the check partition, returning to the step of establishing connection with the server and acquiring new firmware from the server.
In a second aspect, an embodiment of the present application further provides a firmware upgrade apparatus, which is applied to an embedded device, where the embedded device includes a flash memory, and the flash memory includes a check partition, a functional partition, and an upgrade partition, and the apparatus includes:
the system comprises an acquisition module, a verification partition, a function partition and an upgrade partition, wherein the acquisition module is used for establishing connection with a server, acquiring new firmware from the server, and writing first target data, second target data and third target data contained in the new firmware into the verification partition, the function partition and the upgrade partition respectively, wherein the new firmware is used for carrying out firmware upgrade on the embedded equipment;
The first judging module is used for judging whether the first target data is abnormal when being written into the check partition through a boot loader of the embedded equipment if the embedded equipment is restarted when the firmware is upgraded;
the second judging module is used for judging whether the first target data is abnormal when being written into the upgrading partition or not through the boot loader if the first target data is not abnormal when being written into the verifying partition;
The third judging module is used for judging whether the functional partition has backed up the third target data through the boot loader if the third target data is abnormal when being written into the upgrading partition;
And the recovery module is used for carrying out data recovery on the upgrading partition according to the backed-up third target data in the functional partition if the functional partition has backed-up the third target data, and returning to the acquisition module and executing the function of the acquisition module.
In a third aspect, an embodiment of the present application further provides a computer device, including a memory, a processor and a computer program stored on the memory and executable on the processor, where the processor implements the steps of the method according to the first aspect described above when the processor executes the computer program.
In a fourth aspect, embodiments of the present application also provide a storage medium having a computer program stored thereon, wherein the computer program when executed by a processor implements the steps of the method according to the first aspect described above.
The embodiment of the application provides a firmware upgrading method, a device, computer equipment and a storage medium, wherein the upgrading method comprises the steps of establishing connection with a server, acquiring new firmware from the server, writing first target data, second target data and third target data contained in the new firmware into a check partition, a functional partition and an upgrading partition of an embedded device respectively, wherein the new firmware is used for carrying out firmware upgrading on the embedded device, if the embedded device is restarted when the firmware is upgraded, no abnormality occurs when the first target data is written into the check partition, and abnormality occurs when the third target data is written into the upgrading partition, and if the third target data is backed up by the functional partition, carrying out data recovery on the upgrading partition according to the third target data backed up by the functional partition, and returning to execute the steps of establishing connection with the server and acquiring the new firmware from the server. According to the application, the upgrading partition is backed up through the functional partition without additional storage space, so that the possibility of upgrading damage is effectively reduced, the use of the storage space is saved, and the cost is further reduced.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to fall within the scope of the application.
The embodiment of the application provides a firmware upgrading method, a firmware upgrading device, computer equipment and a storage medium. Specifically, the present embodiment provides a firmware upgrade method applicable to a firmware upgrade apparatus that may be integrated in a computer device.
Referring to fig. 1, fig. 1 shows a flowchart of a firmware upgrade method described in an embodiment of the present application, where the firmware upgrade method is applied to an embedded device, the embedded device includes a flash memory, the flash memory includes a check partition, a functional partition, and an upgrade partition, and the method mainly includes steps 101 to 105, which are described as follows:
For easy understanding, the partition design and the writing design of each partition in the upgrading process provided by the application will be described in detail first.
Referring to fig. 2, fig. 2 is a schematic diagram of a flash partition design according to an embodiment of the present application, which may mainly include a partition that is not modified, an upgrade partition, a functional partition, and a check partition. The partitions which are not modified frequently may include a U-Boot partition, a configuration file partition, a product information partition and the like. The upgrade partition stores a complete upgrade system, including a kernel, files necessary for running a root file system, and files necessary for all firmware upgrades. The functional partition stores a functional system, including all programs and related files, that fulfill the product requirements. And checking the partition, and storing an MD5 (MessageDigestAlgorithmMD, message digest algorithm) value calculated according to the upgrading partition and an MD5 value calculated according to the functional partition, wherein the MD5 value and the MD5 value are used for judging whether the upgrading partition or the functional partition is damaged in the U-Boot.
It will be readily appreciated that the root file system may be split into two parts at release, a first part comprising the files necessary to run the root file system and all the files necessary for firmware upgrade (upgrade system), and a second part comprising all the programs and related files to fulfill the product requirements (functional system). The kernel and the upgrade system are combined together as an upgrade partition when the boot media is made. The U-Boot obtains the size of the kernel by reading the kernel compression header information and the like, so as to calculate the starting address of the upgrade partition, and the starting address is provided for the kernel to construct an MTD (Memory TechnologeDevicec, memory technology device) partition. The functional system is independently stored in a functional partition, the upgrading partition is loaded after the kernel is started, and then whether the functional partition is loaded is determined according to command line parameters transmitted by the U-Boot. If a functional partition is loaded, the functional systems in the loaded functional partition are somehow merged with the upgrade systems in the loaded upgrade partition and then run the programs of the relevant functions of the product requirements. If the functional partition is not loaded, the automatic upgrade software in the upgrade partition is run, and the automatic networking upgrade resumes the firmware.
Referring to fig. 3, fig. 3 shows a schematic diagram of a writing process of each partition in a normal upgrade process, firstly, downloading new firmware from a cloud, then writing a check partition of the new firmware into a check partition (step 1) of a flash (flash), then writing an upgrade partition of the new firmware into a functional partition of the flash as a backup of the upgrade partition (step 2), then writing an upgrade partition of the new firmware into an upgrade partition of the flash (step 3), and then writing a functional partition of the new firmware into a functional partition of the flash (step 4), thereby completing the upgrade.
It should be appreciated that in order to backup the contents of an upgrade partition using a functional partition during an upgrade, the upgrade partition and the functional partition must be kept uniform in size. Or the data content of the upgrade partition can be compressed and backed up to the functional partition under the condition that the upgrade partition is too large and the functional partition is more idle. The compression can be performed when the new firmware is manufactured, so that the file size of the transmitted new firmware can be reduced, and the computing overhead of the compressed file can be saved at the equipment end.
Specifically, before writing the upgrade partition of the new firmware into the upgrade partition of the flash, writing the upgrade partition of the new firmware into the functional partition of the flash for backup, so that if step2 is abnormal, the state before upgrade can be ensured to be maintained in the upgrade partition, and if step3 is abnormal, the content of the upgrade partition of the new firmware backed up in the functional partition in the flash can be used for recovering the content of the upgrade partition in the flash, so that the correct kernel, files necessary for running the root file system and files necessary for upgrading all the firmware are ensured to be always stored in the upgrade partition.
It is noted that for partitions that are not frequently modified, each partition in the new firmware may be marked as new firmware is released to determine whether it needs to be erased. In addition, compared with upgrading partitions and functional partitions, the partitions which are not modified frequently are small in size, high in erasing speed and not easy to cause abnormality. When erasing, erasing is performed according to the data blocks, and when the contents of each data block are compared, the erasing is not needed, so that the erasing speed is increased, and the possibility of occurrence of abnormality is reduced.
According to the partition design provided by the embodiment of the application, the root file system is split into the upgrade partition and the functional partition, then the product function is realized by simply combining the partitions, the partition writing sequence in the upgrade process is skillfully designed, the functional partition is utilized to store the data backup of the upgrade partition, and no extra flash memory space is needed to be added for backup, so that the storage space is saved, and meanwhile, the upgrade recovery system can be started under the condition that the data is damaged due to abnormal power failure in any step in the upgrade process.
And 101, establishing connection with a server, acquiring new firmware from the server, and writing first target data, second target data and third target data contained in the new firmware into a check partition, a functional partition and an upgrade partition respectively, wherein the new firmware is used for upgrading the firmware of the embedded equipment.
The first target data are data in a verification partition in the new firmware, the second target data are data in a functional service in the new firmware, the third target data are data in an upgrade partition in the new firmware, and the sequence of writing the first target data, the second target data and the third target data into the flash memory is strictly written according to the sequence. If no abnormality occurs in the writing process, the upgrading is successful.
Step 102, if the embedded device is restarted when the firmware is upgraded, judging whether an abnormality occurs when the first target data is written into the check partition through a boot loader of the embedded device, if so, executing step 101, and if not, executing step 103.
The Bootloader is a Bootloader commonly used in embedded systems, and the Bootloader is a small section of program executed before the operation system runs, through which, we can initialize hardware devices and build a mapping table of memory space, thereby building a proper software and hardware environment, and preparing for finally calling the kernel of the operation system. The main running task of the BootLoader is to read the kernel image from the hard disk into the RAM, and then jump to the entry point of the kernel to run, i.e. start to start the operating system. The system typically starts executing at address 0x00000000 at power up or reset, and what is typically arranged at this address is the BootLoader program of the system.
As can be seen from the above, the upgrade partition of the flash memory of the embedded device stores the files necessary for running the root file system and the files necessary for upgrading all the firmware, so that it is necessary to ensure that the content stored in the upgrade partition always maintains an operable state, that is, stores correct data before update or correct data after update.
After the upgrade is successful, the embedded device may be restarted automatically, at this time, it may be determined by the boot loader of the embedded device that no exception occurs when the first target data is written into the check partition, and step 103 is executed. If the embedded device is abnormally powered off in the upgrade process, for example, when the power supply is suddenly powered off and the like are encountered, the boot loader judges whether the first target data writing check partition is abnormal or not when the embedded device is restarted, if not, the first target data writing check partition can be considered to be not abnormal, then step 103 is executed, whether the third target data is normally written into the upgrade partition is continuously judged, if the boot loader judges that the first target data writing check partition is abnormal, the upgrade partition can be considered to not be subjected to the write operation, further, the correct data before the upgrade is stored in the upgrade partition, namely, the content stored in the upgrade partition is kept in an operable state, then the execution step 101 is returned to be executed, namely, connection is established again with the server, new firmware is acquired from the server, and firmware upgrade is carried out again.
Specifically, step 102 may mainly include reading, by the boot loader, fourth current data in the check partition, if the fourth current data is in a preset format, determining that no abnormality occurs when the first target data is written into the check partition, and if the fourth current data is not in the preset format, determining that an abnormality occurs when the first target data is written into the check partition.
The check partition stores data identifiers of the upgrade partition and the functional partition, for example, stores an MD5 value calculated according to data of the upgrade partition and the functional partition, the MD5 value is a hexadecimal number string with a certain length, and whether the first target data is abnormal when written into the check partition can be determined by reading current data in the check partition and judging the format of the current data in the check partition.
It is easy to understand that, in the process of writing data, that is, in the process of erasing, if an abnormal power failure occurs in the process of erasing, the length of the current data of the check partition will not conform to the actual length, so it can be determined whether an abnormality occurs when the first target data is written into the check partition by determining whether the length of the current data conforms to the preset length.
For example, if the second target data is "hsolngffbkop-phnnm, i [", the MD5 value calculated from the second target data is "C9A8B387E5CDAF F", the third target data is "gyighuojniojio", and the MD5 value calculated from the third target data is "12111ACCA8B2E394", it can be determined whether or not an abnormality occurs when the first target data is written into the parity partition by determining whether or not the current data of the parity partition is two sixteen bytes of data.
Step 103, judging whether the third target data is abnormal when being written into the upgrade partition through the boot loader, if so, executing step 104, and if not, executing step 101.
It is easy to understand that the check partition in the new firmware stores the first data identifier of the third target data and the second data identifier of the second target data, if the first target data is written into the check partition and is not abnormal, the current check partition stores the first data identifier, and step 103 mainly may include obtaining, by the boot loader, the first current data identifier corresponding to the first current data in the upgrade partition, if the first current data identifier is consistent with the first data identifier, determining that the third target data is not abnormal when being written into the upgrade partition, or if the first current data identifier is inconsistent with the first data identifier, determining that the third target data is abnormal when being written into the upgrade partition.
The first data identifier may be an MD5 value calculated according to the third target data, the second data identifier may be an MD5 value calculated according to the second target data, and similarly, the first current data identifier may also be an MD5 value calculated according to the first current data. Or the first data identifier may be a version number of the third target data, the version number may be carried at the tail of the third target data, and similarly, the first current data identifier may also be a version number carried at the tail of the first current data, if the writing of the third target data into the upgrade partition is completed, the version number obtained by the U-Boot should be consistent with the first data identifier, and if the writing of the third target data into the upgrade partition is not completed or the writing of the third target data into the upgrade partition is not completed, the version number obtained by the U-Boot should be inconsistent with the first data identifier.
It is easy to understand that if the first current data identifier is consistent with the first data identifier, it may be considered that the third target data has been successfully written into the upgrade partition, and at this time, a new complete upgrade system is stored in the upgrade partition, and then step 101 may be directly executed in a return manner, that is, the firmware is obtained by re-networking, so as to perform firmware upgrade again. If the first current data identifier is inconsistent with the first data identifier, it may be considered that the third target data is not successfully written into the upgrade partition, and at this time, it needs to be determined whether to power off when writing or power off when not writing, that is, step 104 is executed.
Step 104, judging whether the functional partition has backed up the third target data or not through the boot loader, if yes, executing step 105, and if not, executing step 101.
Specifically, step 104 may include obtaining a second current data identifier corresponding to the second current data in the functional partition, determining that the functional partition has backed up the third target data if the second current data identifier is consistent with the first data identifier, or determining that the functional partition has not backed up the third target data if the second current data identifier is inconsistent with the first data identifier.
It is easy to understand that the check partition in the new firmware stores the first data identifier of the third target data and the second data identifier of the second target data, and if the first target data written into the check partition is not abnormal, the current check partition stores the first data identifier. If the functional partition is backed up with the third target data, the second current data identifier corresponding to the second current data in the functional partition should be consistent with the first data identifier, and if the functional partition is not backed up with the third target data, the second current data identifier corresponding to the second current data in the functional partition is inconsistent with the first data identifier.
In the above-mentioned manner, under normal conditions, the writing sequence of the data is that the third target data is backed up in the functional partition first, and then the third target data is written into the upgrade partition. Therefore, if it is determined that the functional partition does not backup the third target data, it may be considered that the upgrade partition further stores correct data before the update, that is, the operation-enabled state is maintained, and the process may directly return to step 101, and establish connection with the server again and update again. If it is determined that the functional partition is backed up with the third target data, it can be considered that abnormal power failure occurs when the third target data is written into the upgrade partition, and at this time, the upgrade partition does not store correct data before update or correct data after update, and in a subsequent step, the upgrade partition is restored according to the third target data backed up by the functional partition, and then is re-networked and re-updated.
In some embodiments, if no abnormality occurs when the first target data is written into the check partition, the check partition further stores a second data identifier corresponding to the second target data, and the method may further include obtaining, by the bootloader, a third current data identifier corresponding to third current data in the functional partition if no abnormality occurs when the third target data is written into the ascending partition; if the third current data identifier is inconsistent with the second data identifier, determining that the second target data is abnormal when being written into the functional partition, and returning to execute the step 101.
Specifically, the second data identifier may be an MD5 value calculated according to the second target data, and similarly, the third current data identifier may also be an MD5 value calculated according to the third current data. Or the second data identifier may be a version number of the second target data, the version number may be carried at the tail of the second target data, and similarly, the third current data identifier may also be a version number carried at the tail of the third current data, if the writing function partition of the second target data is completed, the version number obtained by the U-Boot should be consistent with the second data identifier, and if the writing function partition of the second target data is not completed or the writing function partition is not completed, the version number obtained by the U-Boot should be inconsistent with the second data identifier. If the third current data identifier is inconsistent with the second data identifier, it can be considered that an abnormality occurs when the second target data is written into the functional partition, and at this time, the updated correct data is stored in the upgrade partition, and then the process returns to execute step 101, and new firmware is obtained by re-networking, and firmware upgrade is performed again.
It is easy to understand that if the third current data identifier is consistent with the second identifier, it may be determined that the firmware has been upgraded.
Step 105, recovering the data of the upgrade partition according to the third target data backed up in the functional partition, and returning to execute step 101.
Specifically, after the data recovery is performed on the upgrade partition according to the third target data backed up by the functional partition, the upgrade partition stores updated correct data, that is, the upgrade partition is in an executable state, and then the new firmware can be downloaded in a reconnection manner so as to perform firmware upgrade again.
It is easy to understand that when the third target data backed up in the functional partition is used for recovering the data of the upgrade partition, the data blocks can be erased and written, and when the content of each data block is compared with the content of each data block, the erasing and writing are not needed, so that the erasing and writing speed is increased.
Specifically, referring to fig. 4, fig. 4 shows an abnormal situation and a processing manner in the firmware upgrading process, where an upgrade recovery mode is to re-establish a connection with a server and download new firmware to re-upgrade the firmware. As shown in fig. 4, when the upgrade partition is damaged and the functional partition is backed up, the upgrade recovery mode is started after the upgrade partition is recovered by using the functional partition. When the functional partition is damaged or the check partition is damaged, the upgrade recovery mode is directly started. Therefore, when the upgrade partition keeps an operable state, the upgrade partition is connected with the server and firmware upgrade is carried out again, and data of the upgrade partition is not required to be backed up by extra storage space, so that the use of the storage space is saved, and the cost is reduced.
According to the firmware upgrading method provided by the embodiment of the application, the connection is established with the server, the new firmware is acquired from the server, the first target data, the second target data and the third target data contained in the new firmware are respectively written into the check partition, the functional partition and the upgrading partition of the embedded equipment, the new firmware is used for upgrading the firmware of the embedded equipment, if the embedded equipment is restarted when the firmware is upgraded, no abnormality occurs when the first target data is written into the check partition, the abnormality occurs when the third target data is written into the upgrading partition, and whether the functional partition has backed up the third target data or not, the data recovery is carried out on the upgrading partition according to the third target data backed up by the functional partition, and the step of establishing connection with the server and acquiring the new firmware from the server is executed is returned, so that the upgrading partition is backed up through the functional partition without additional storage space, the use of the storage space is saved while the possibility of upgrading damage is effectively reduced, and the cost is reduced.
In order to facilitate better implementation of the firmware upgrading method of the embodiment of the application, the embodiment of the application also provides a firmware upgrading device.
Having described in detail the method embodiments of the present application above, and in connection with fig. 5-6, the apparatus embodiments of the present application will be described in detail, it being understood that the apparatus embodiments correspond to the method embodiments, and similar descriptions can be made with reference to the method embodiments.
Fig. 5 is a schematic structural diagram of a firmware upgrade apparatus 10 according to an embodiment of the present application, the firmware upgrade apparatus 10 is applied to an embedded device including a flash memory including a parity partition, a function partition, and an upgrade partition, and the firmware upgrade apparatus 10 may include:
the obtaining module 11 is configured to establish a connection with a server, obtain new firmware from the server, and write first target data, second target data, and third target data included in the new firmware into a check partition, a functional partition, and an upgrade partition, respectively, where the new firmware is used to upgrade firmware of the embedded device;
A first judging module 12, configured to judge, if the embedded device is restarted when the firmware is upgraded, whether an abnormality occurs when the first target data is written into the check partition through a boot loader of the embedded device;
The second judging module 13 is configured to judge, by using the bootloader, whether an abnormality occurs when the third target data is written into the upgrade partition if the first target data is not abnormal when the first target data is written into the upgrade partition;
A third judging module 14, configured to judge, by the boot loader, whether the functional partition has backed up the third target data if an abnormality occurs when the third target data is written into the upgrade partition;
And the recovery module 15 is used for recovering the data of the upgrade partition according to the backed-up third target data in the functional partition if the functional partition has backed-up the third target data, and returning to the acquisition module and executing the function of the acquisition module.
In some embodiments, if no exception occurs when the first target data is written into the check partition, the check partition stores the first data identifier of the third target data, and the second judging module 13 may be specifically configured to obtain, by the bootloader, the first current data identifier corresponding to the first current data in the upgrade partition, determine that no exception occurs when the third target data is written into the upgrade partition if the first current data identifier is consistent with the first data identifier, or determine that an exception occurs when the third target data is written into the upgrade partition if the first current data identifier is inconsistent with the first data identifier.
Further, the third judging module 14 may be mainly configured to obtain a second current data identifier corresponding to the second current data in the functional partition, determine that the functional partition has backed up the third target data if the second current data identifier is consistent with the first data identifier, or determine that the functional partition has not backed up the third target data if the second current data identifier is inconsistent with the first data identifier.
In some embodiments, after the third determination module 14 determines that the functional partition is not backing up the third target data, it may also be used to return to the acquisition module and perform the functions of the acquisition module.
Further, if no abnormality occurs when the first target data is written into the check partition, the check partition further stores a second data identifier corresponding to the second target data, and the firmware upgrading device 10 may further include a determining module configured to obtain, through the boot loader, a third current data identifier corresponding to the third current data in the functional partition if no abnormality occurs when the third target data is written into the upgrade partition, determine that an abnormality occurs when the second target data is written into the functional partition if the third current data identifier is inconsistent with the second data identifier, and return to perform the steps of establishing connection with the server and obtaining new firmware from the server.
In some embodiments, the first determining module 12 may be specifically configured to read the fourth current data in the check partition through the bootloader, determine that no exception occurs when the first target data is written into the check partition if the fourth current data is in a preset format, and determine that an exception occurs when the first target data is written into the check partition if the fourth current data is not in the preset format.
Further, the first judging module 12 may be further specifically configured to return to the obtaining module 11 to execute the function of the obtaining module 11 if an abnormality occurs when the first target data is written into the check partition.
It should be noted that, the functions of each module in the firmware upgrading apparatus 10 in the embodiment of the present application may be correspondingly referred to the specific implementation manner in each method embodiment, and are not repeated herein.
The respective modules in the firmware upgrade apparatus described above may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In the firmware upgrading apparatus 10 provided in this embodiment of the present application, a connection is established between the obtaining module 11 and a server, and a new firmware is obtained from the server, and first target data, second target data, and third target data included in the new firmware are written into a check partition, a functional partition, and an upgrade partition of an embedded device, respectively, where the new firmware is used to upgrade the firmware of the embedded device, if the embedded device is restarted during firmware upgrade, the first judging module 12 judges whether an abnormality occurs when the first target data is written into the check partition, if no abnormality occurs when the first target data is written into the check partition, the second judging module 13 judges whether an abnormality occurs when the third target data is written into the upgrade partition, if an abnormality occurs when the third target data is written into the upgrade partition, the third judging module 14 judges whether the functional partition has backed up the third target data, if the functional partition has backed up the third target data, the recovering module 15 recovers the upgrade partition according to the third target data that has been backed up in the functional partition, and returns to the obtaining module 11. According to the application, the upgrading partition is backed up through the functional partition without additional storage space, so that the possibility of upgrading damage is effectively reduced, the use of the storage space is saved, and the cost is further reduced.
In addition, the embodiment of the application also provides a computer device which can be an embedded device, and the embedded device can be a terminal device such as a notebook computer, a personal computer (PC, personalComputer), a personal digital assistant (PersonalDigitalAssistant, PDA) and the like. Fig. 6 is a schematic structural diagram of a computer device according to an embodiment of the present application. The computer device 2000 includes a processor 2001 having one or more processing cores, a memory 2002 having one or more computer readable storage media, and a computer program stored on the memory 2002 and executable on the processor. The processor 2001 is electrically connected to the memory 2002. It will be appreciated by those skilled in the art that the computer device structure shown in the figures is not limiting of the computer device and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components.
Processor 2001 is a control center of computer device 2000, and connects various portions of the entire computer device 2000 using various interfaces and lines, performing various functions of computer device 2000 and processing data by running or loading software programs and/or modules stored in memory 2002, and invoking data stored in memory 2002, thereby performing overall monitoring of computer device 2000.
In an embodiment of the present application, the processor 2001 in the computer device 2000 loads instructions corresponding to the processes of one or more application programs into the memory 2002 according to the following steps, and the processor 2001 executes the application programs stored in the memory 2002, thereby implementing various functions:
The method comprises the steps of establishing connection with a server, obtaining new firmware from the server, writing first target data, second target data and third target data contained in the new firmware into a check partition, a functional partition and an upgrade partition respectively, enabling the new firmware to be used for upgrading firmware of the embedded equipment, judging whether the first target data is abnormal when the first target data is written into the check partition through a boot loader of the embedded equipment when the firmware is upgraded, judging whether the third target data is abnormal when the third target data is written into the upgrade partition through the boot loader when the first target data is not abnormal when the first target data is written into the check partition, judging whether the third target data is backed up through the boot loader when the third target data is abnormal when the third target data is written into the upgrade partition, recovering the data of the upgrade partition according to the third target data backed up in the functional partition if the third target data is backed up, returning to execute connection with the server, and obtaining the new firmware from the server.
The specific implementation of each operation above may be referred to the previous embodiments, and will not be described herein.
Optionally, as shown in FIG. 6, the computer device 2000 further includes a touch display 2003, a radio frequency circuit 2004, an audio circuit 2005, an input unit 2006, and a power supply 2007. The processor 2001 is electrically connected to the touch display 2003, the rf circuit 2004, the audio circuit 2005, the input unit 2006, and the power supply 2007, respectively. It will be appreciated by those skilled in the art that the computer device structure shown in FIG. 6 is not limiting of the computer device and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components.
The touch display 2003 may be used to display a graphical user interface and to receive operating instructions generated by a user acting on the graphical user interface. The touch display 2003 may include a display panel and a touch panel. Wherein the display panel may be used to display information entered by a user or provided to a user as well as various graphical user interfaces of a computer device, which may be composed of graphics, text, icons, video, and any combination thereof. Alternatively, the display panel may be configured in the form of a liquid crystal display (LCD, liquidCrystalDisplay), an organic light emitting diode (OLED, organicLight-EmittingDiode), or the like. The touch panel may be used to collect touch operations on or near the user (such as operations on or near the touch panel by the user using any suitable object or accessory such as a finger, stylus, etc.), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Alternatively, the touch panel may include two parts, a touch detection device and a touch controller. The touch controller receives touch information from the touch detection device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 2001, and can receive and execute commands sent by the processor 2001. The touch panel may overlay the display panel, and upon detection of a touch operation thereon or thereabout, the touch panel is passed to the processor 2001 to determine the type of touch event, and the processor 2001 then provides a corresponding visual output on the display panel depending on the type of touch event. In the embodiment of the present application, the touch panel and the display panel may be integrated into the touch display screen 2003 to implement input and output functions. In some embodiments, however, the touch panel and the touch panel may be implemented as two separate components to perform the input and output functions. I.e. the touch display 2003 may also implement an input function as part of the input unit 2006.
The radio frequency circuitry 2004 may be used to transceive radio frequency signals to establish wireless communications with a network device or other computer device via wireless communications.
Audio circuitry 2005 may be used to provide an audio interface between a user and a computer device through speakers, microphones, and so forth. The audio circuit 2005 may convert received audio data into an electrical signal, transmit the electrical signal to a speaker, and convert the electrical signal to a sound signal for output by the speaker, while the microphone converts the collected sound signal into an electrical signal, receives the electrical signal from the audio circuit 2005, converts the electrical signal into audio data, processes the audio data with the output processor 2001, and sends the audio data to another computer device, for example, via the radio frequency circuit 2004, or outputs the audio data to the memory 2002 for further processing. Audio circuit 2005 may also include an ear bud jack to provide communication of a peripheral headset with a computer device.
The input unit 2006 may be used to receive input numbers, character information, or user characteristic information (e.g., fingerprint, iris, facial information, etc.), as well as to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control.
A power supply 2007 is used to power the various components of the computer device 2000. Alternatively, the power supply 2007 may be logically connected to the processor 2001 through a power management system, so as to perform functions of managing charging, discharging, and power consumption management through the power management system. Power supply 2007 may also include one or more of any components, such as a dc or ac power supply, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, etc.
Although not shown in fig. 6, the computer device 2000 may further include a camera, a sensor, a wireless fidelity module, a bluetooth module, etc., which will not be described herein.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and for parts of one embodiment that are not described in detail, reference may be made to related descriptions of other embodiments.
It can be seen from the foregoing that, in the computer device provided in this embodiment, a connection is established between the computer device and a server, and a new firmware is obtained from the server, and first target data, second target data, and third target data included in the new firmware are written into a check partition, a functional partition, and an upgrade partition, respectively, where the new firmware is used to upgrade the embedded device, if the embedded device is restarted when the firmware is upgraded, the embedded device determines whether an abnormality occurs when the first target data is written into the check partition, if no abnormality occurs when the first target data is written into the check partition, the bootstrap loader determines whether an abnormality occurs when the third target data is written into the upgrade partition, if an abnormality occurs when the third target data is written into the upgrade partition, the bootstrap loader determines whether the functional partition has backed up the third target data, if the functional partition has backed up the third target data, and performs data recovery on the upgrade partition according to the third target data backed up in the functional partition, and returns to the step of establishing a connection with the server, and obtaining the new firmware from the server, thereby effectively reducing the possibility of damage and saving the storage space.
Those of ordinary skill in the art will appreciate that all or a portion of the steps of the various methods of the above embodiments may be performed by instructions, or by instructions controlling associated hardware, which may be stored in a computer-readable storage medium and loaded and executed by a processor.
To this end, an embodiment of the present application provides a computer readable storage medium having stored therein a plurality of computer programs that can be loaded by a processor to perform the steps of any of the firmware upgrade methods provided by the embodiments of the present application. For example, the computer program may perform the steps of:
establishing connection with a server, acquiring new firmware from the server, and writing first target data, second target data and third target data contained in the new firmware into a check partition, a functional partition and an upgrade partition respectively, wherein the new firmware is used for carrying out firmware upgrade on the embedded equipment;
if the embedded device is restarted when the firmware is upgraded, judging whether the first target data is abnormal when being written into the check partition through a boot loader of the embedded device;
if no abnormality occurs when the first target data is written into the check partition, judging whether the third target data is written into the upgrade partition through the boot loader;
If the third target data is abnormal when being written into the upgrade partition, judging whether the functional partition has backed up the third target data or not through the boot loader;
If the functional partition has backed up the third target data, carrying out data recovery on the upgrading partition according to the third target data backed up in the functional partition;
and returning to the step of establishing connection with the server and acquiring new firmware from the server.
The specific implementation of each operation above may be referred to the previous embodiments, and will not be described herein.
The storage medium may include read-only memory (ROM, readOnlyMemory), random access memory (RAM, randomAccessMemory), magnetic or optical disk, and the like.
The steps in any firmware upgrading method provided by the embodiment of the present application can be executed by the computer program stored in the storage medium, so that the beneficial effects that any firmware upgrading method provided by the embodiment of the present application can be achieved, and detailed descriptions of the previous embodiments are omitted.
The foregoing describes in detail a firmware upgrading method, apparatus, storage medium and computer device provided in the embodiments of the present application, and specific examples are set forth herein to illustrate the principles and implementations of the present application, and the above description of the embodiments is only for aiding in understanding the method and core concept of the present application, and meanwhile, for those skilled in the art, according to the concept of the present application, there are variations in the specific implementations and application ranges, so that the disclosure should not be construed as limiting the scope of the present application.