Firmware upgrading method and device, embedded device and storage medium
By using multi-layered verification and unique identification code checks during the firmware upgrade process, the system ensures that the received firmware upgrade file is undamaged and matches the data, thus solving the problem of device damage caused by firmware upgrade file transmission errors and improving the reliability and efficiency of the upgrade.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-31
- Publication Date
- 2026-03-24
AI Technical Summary
During firmware upgrades, firmware upgrade files may be damaged or corrupted during transmission, potentially leading to device damage. There is also the issue of upgrade files being mixed up between different chips.
After receiving the upgrade file package, the firmware upgrade file and its verification code are extracted. A multi-layer verification algorithm is used to determine whether the file has been corrupted during transmission. The unique identification code ensures that the file matches, and the upgrade is only performed if there are no errors and the file matches.
It effectively reduces the possibility of device damage during firmware upgrades, improves upgrade efficiency, and avoids the uncertainty caused by multiple receptions.
Smart Images

Figure CN115469903B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of firmware upgrade, in particular to a firmware upgrade method and device, an embedded device and a storage medium. BACKGROUND
[0002] Firmware is generally stored in an erasable programmable read-only memory, an electrically erasable programmable read-only memory or a FLASH chip in a device. Generally speaking, firmware refers to program code (or software) that performs the most basic and bottom-level work of a device and enables the device to run.
[0003] In order to solve some bugs and compatibility problems, or to comprehensively or selectively meet customer needs, more and more manufacturers improve product reliability and user experience through firmware upgrade.
[0004] At present, during firmware upgrade, firmware upgrade files usually need to go through communication transmission, medium caching and the like. However, in the process of communication transmission or medium caching, the content in the firmware upgrade file may be damaged due to transmission, or for different functional chips in an embedded system, the firmware upgrade file originally intended to be transmitted to chip A may be transmitted to chip B, thereby causing the chip to receive an abnormal upgrade file. The abnormal upgrade file is written into the device during firmware upgrade, which may cause the device to have the risk of upgrade damage. SUMMARY
[0005] Embodiments of the present application provide a firmware upgrade method, device, embedded device and storage medium to solve the problem that the current firmware upgrade method may damage the device where the firmware is located.
[0006] In a first aspect, embodiments of the present application provide a firmware upgrade method, comprising:
[0007] receiving an upgrade file package;
[0008] extracting a firmware upgrade file, a first check code corresponding to the firmware upgrade file and a second check code corresponding to the first check code from the upgrade file package;
[0009] determining whether the first check code is incorrect in the transmission process according to the second check code;
[0010] if it is determined that the first check code is not incorrect in the transmission process, determining whether the firmware upgrade file is incorrect in the transmission process according to the first check code;
[0011] if it is determined that the firmware upgrade file is not incorrect in the transmission process, determining whether the firmware upgrade file matches the firmware to be upgraded in the current chip according to a unique identification code in the firmware upgrade file;
[0012] If it is determined that the firmware upgrade file matches the firmware to be upgraded in the current chip, the firmware to be upgraded in the current chip is upgraded according to the firmware upgrade file.
[0013] In a possible implementation, the determining whether the first check code is incorrect in the transmission process according to the second check code comprises:
[0014] performing check calculation on the first check code according to a first preset check algorithm to obtain a third check code; the first preset check algorithm is the same as a first check algorithm used by a sender of the upgrade file package to calculate the second check code;
[0015] determining whether the third check code is the same as the second check code;
[0016] if the third check code is the same as the second check code, it is determined that the first check code is not incorrect in the transmission process;
[0017] if the third check code is not the same as the second check code, it is determined that the first check code is incorrect in the transmission process.
[0018] In a possible implementation, the determining whether the firmware upgrade file is incorrect in the transmission process according to the first check code comprises:
[0019] performing check calculation on the firmware upgrade file according to a second preset check algorithm to obtain a fourth check code; the second preset check algorithm is the same as a second check algorithm used by the sender of the upgrade file package to calculate the first check code;
[0020] determining whether the fourth check code is the same as the first check code;
[0021] if the fourth check code is the same as the first check code, it is determined that the firmware upgrade file is not incorrect in the transmission process;
[0022] if the fourth check code is not the same as the first check code, it is determined that the firmware upgrade file is incorrect in the transmission process.
[0023] In a possible implementation, the determining whether the firmware upgrade file matches the firmware to be upgraded in the current chip according to the unique identification code in the firmware upgrade file comprises:
[0024] determining whether the unique identification code in the firmware upgrade file is the same as a unique identification code in firmware source code corresponding to the firmware to be upgraded in the current chip;
[0025] If the unique identification code in the firmware upgrade file is identical to the unique identification code in the firmware source code corresponding to the firmware to be upgraded in the current chip, it is determined that the firmware upgrade file matches the firmware to be upgraded in the current chip.
[0026] If the unique identification code in the firmware upgrade file is not identical to the unique identification code in the firmware source code corresponding to the firmware to be upgraded in the current chip, it is determined that the firmware upgrade file does not match the firmware to be upgraded in the current chip.
[0027] In a possible implementation, the upgrade file package includes: a position mark code of the unique identification code in the firmware upgrade file; the position mark code and the first check code constitute a joint check code.
[0028] The extracting of the firmware upgrade file, the first check code corresponding to the firmware upgrade file, and the second check code corresponding to the first check code from the upgrade file package includes:
[0029] The extracting of the firmware upgrade file, the first check code corresponding to the firmware upgrade file, the position mark code, and the second check code corresponding to the joint check code from the upgrade file package includes:
[0030] The determining whether the first check code is incorrect in the transmission process according to the second check code includes:
[0031] The determining whether the joint check code is incorrect in the transmission process according to the second check code.
[0032] The determining whether the firmware upgrade file is incorrect in the transmission process according to the first check code if it is determined that the first check code is not incorrect in the transmission process includes:
[0033] The determining whether the firmware upgrade file is incorrect in the transmission process according to the first check code in the joint check code if it is determined that the joint check code is not incorrect in the transmission process.
[0034] The determining whether the firmware upgrade file matches the firmware to be upgraded in the current chip according to the unique identification code in the firmware upgrade file if it is determined that the firmware upgrade file is not incorrect in the transmission process includes:
[0035] The obtaining of the unique identification code in the firmware upgrade file according to the position mark code in the joint check code if it is determined that the firmware upgrade file is not incorrect in the transmission process.
[0036] The determining whether the firmware upgrade file matches the firmware to be upgraded in the current chip according to the obtained unique identification code.
[0037] In a possible implementation, the determining whether the joint check code is incorrect in the transmission process according to the second check code comprises:
[0038] performing check calculation on the joint check code according to a third preset check algorithm to obtain a fifth check code, wherein the third preset check algorithm is the same as a third check algorithm used by a sender of the upgrade file package to calculate the second check code;
[0039] determining whether the fifth check code is the same as the second check code;
[0040] if the fifth check code is the same as the second check code, determining that the joint check code is not incorrect in the transmission process;
[0041] if the fifth check code is not the same as the second check code, determining that the joint check code is incorrect in the transmission process.
[0042] In a possible implementation, after determining whether the first check code is incorrect in the transmission process according to the second check code, the method further comprises:
[0043] if it is determined that the first check code is incorrect in the transmission process, sending a prompt information to prompt that the upgrade file package is incorrect;
[0044] after determining whether the firmware upgrade file is incorrect in the transmission process according to the first check code, the method further comprises:
[0045] if it is determined that the firmware upgrade file is incorrect in the transmission process, sending a prompt information to prompt that the upgrade file package is incorrect;
[0046] after determining whether the firmware upgrade file matches the firmware to be upgraded in the current chip according to the unique identification code in the firmware upgrade file, the method further comprises:
[0047] if it is determined that the firmware upgrade file does not match the firmware to be upgraded in the current chip, sending a prompt information to prompt that the upgrade file package is incorrect.
[0048] In a second aspect, an embodiment of the present application provides a firmware upgrade device, comprising:
[0049] a receiving module configured to receive an upgrade file package;
[0050] an extracting module configured to extract a firmware upgrade file, a first check code corresponding to the firmware upgrade file, and a second check code corresponding to the first check code from the upgrade file package;
[0051] a first processing module configured to determine whether the first check code is incorrect in a transmission process according to the second check code;
[0052] a second processing module, configured to determine whether the firmware upgrade file is error-free in the transmission process according to the first check code if it is determined that the first check code is error-free in the transmission process;
[0053] a third processing module, configured to determine whether the firmware upgrade file matches the firmware to be upgraded in the current chip according to the unique identification code in the firmware upgrade file if it is determined that the firmware upgrade file is error-free in the transmission process;
[0054] an upgrading module, configured to upgrade the firmware to be upgraded in the current chip according to the firmware upgrade file if it is determined that the firmware upgrade file matches the firmware to be upgraded in the current chip.
[0055] In a third aspect, an embedded device is provided, which comprises a memory and a processor. The memory is configured to store a computer program. The processor is configured to invoke and run the computer program stored in the memory, and execute the steps of the method according to the first aspect or any possible implementation manner of the first aspect.
[0056] In a fourth aspect, a computer readable storage medium is provided, which stores a computer program. The computer program is executed by a processor to implement the steps of the method according to the first aspect or any possible implementation manner of the first aspect.
[0057] This invention provides a firmware upgrade method, apparatus, embedded device, and storage medium. Upon receiving an upgrade file package, the method first extracts the firmware upgrade file, a first verification code corresponding to the firmware upgrade file, and a second verification code corresponding to the first verification code from the upgrade file package. Then, it uses the second verification code to determine if the first verification code was corrupted during transmission. If the first verification code was not corrupted during transmission, it uses the first verification code to determine if the firmware upgrade file was corrupted during transmission. If the firmware upgrade file was also not corrupted during transmission, it uses a unique identifier in the firmware upgrade file to determine if it matches the firmware to be upgraded in the current chip. Finally, if the firmware upgrade file matches the firmware to be upgraded in the current chip, it upgrades the firmware to be upgraded in the current chip according to the firmware upgrade file. On the one hand, layer-by-layer verification ensures that the firmware upgrade file in the received upgrade file package is not damaged or corrupted. On the other hand, after confirming that an undamaged or corrupted firmware upgrade file has been received, the unique identifier in the firmware upgrade file ensures that only the matching firmware upgrade file is used to upgrade the firmware to be upgraded in the current chip, thereby effectively reducing the possibility of damaging the device containing the firmware during the firmware upgrade process. Moreover, this application avoids the uncertainty caused by receiving the upgrade file package once and then making subsequent judgments or upgrades, which is conducive to improving the efficiency of firmware upgrades. Attached Figure Description
[0058] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0059] Figure 1 This is a flowchart illustrating the implementation of the firmware upgrade method provided in this embodiment of the invention.
[0060] Figure 2 This is a flowchart illustrating the implementation of a firmware upgrade method according to another embodiment of the present invention;
[0061] Figure 3 This is a schematic diagram of the firmware upgrade device provided in an embodiment of the present invention;
[0062] Figure 4 This is a schematic diagram of an embedded device provided in an embodiment of the present invention. Detailed Implementation
[0063] In the following description, for purposes of explanation and not limitation, specific details are set forth such as particular architectures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application can be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known methods, devices, circuits, and
[0064] In order to make the objects, technical solutions and advantages of the present application clearer, the following will be described in conjunction with the accompanying drawings and specific embodiments.
[0065] Referring to Figure 1 which shows the implementation flowchart of the firmware upgrade method provided by the embodiments of the present application, and will be described in detail as follows:
[0066] In step 101, an upgrade file package is received.
[0067] The upgrade file package can be generated by a sender (such as an upgrade server, etc.) sending the upgrade file package. In the embodiments, the upgrade file package includes not only a firmware upgrade file, but also a check code for checking whether the firmware upgrade file is damaged or abnormal. Similarly, the upgrade server can also generate firmware source code corresponding to the current version of the firmware.
[0068] For different firmwares in an embedded system, such as inverter chip firmware and rectifier chip firmware in an uninterruptible power supply system, the upgrade server can set different identification codes for the different firmwares as unique identification codes of the corresponding firmwares, so as to distinguish the different firmwares.
[0069] For the same firmware, the upgrade server can write the unique identification code corresponding to the firmware in a preset addressable region of the firmware source code when generating the firmware source code. Similarly, the upgrade server can also write the unique identification code corresponding to the firmware in a preset addressable region of the firmware upgrade file when generating the firmware upgrade file.
[0070] The preset addressable region in the firmware source code and the firmware upgrade file is a fixed addressable region for filling the unique identification code of the firmware. When the firmware upgrade file is generated, the unique identification code can be found through addressable search.
[0071] In the embodiments, a fixed addressable region is set in the firmware source code and the firmware upgrade file to fill the unique identification code of the firmware, which is beneficial to distinguishing different firmware upgrade files during firmware upgrade, so as to avoid firmware confusion in the case of more chips in the embedded system.
[0072] In step 102, the firmware upgrade file, the first check code corresponding to the firmware upgrade file, and the second check code corresponding to the first check code are extracted from the upgrade file package.
[0073] As described above, in the embodiment, when the sender generates the upgrade file package, in addition to generating a firmware upgrade file, a check code for checking whether the firmware upgrade file is damaged or abnormal is also generated.
[0074] For example, after the firmware upgrade file is generated, the generated firmware upgrade file is checked by using a check algorithm to generate a check code A corresponding to the firmware upgrade file. On this basis, the generated check code A is checked by using the check algorithm to generate a check code B corresponding to the check code A. The check code A and the check code B can be arranged at the front end of the firmware upgrade file to form the upgrade file package.
[0075] Since the upgrade file package may be damaged or abnormal in the process from the sender sending the upgrade file package to the chip firmware receiving the upgrade file package, after the upgrade file package is received, the firmware upgrade file, the first check code corresponding to the firmware upgrade file, and the second check code corresponding to the first check code can be extracted from the upgrade file package, so as to check whether the received upgrade file package is damaged or abnormal.
[0076] The first check code corresponds to the check code A, and the second check code corresponds to the check code B. Since the upgrade file package may be damaged or abnormal in the transmission process, the received first check code may be the same as or different from the check code A generated by the sender, the received second check code may be the same as or different from the check code B generated by the sender, and on this basis, the received firmware upgrade file may be the same as or different from the firmware upgrade file generated by the sender. Accordingly, whether the received upgrade file package is damaged or abnormal can be checked.
[0077] For example, the check algorithm used by the sender when generating the check code A can be a message digest algorithm (Message Digest Algorithm MD5) or a cyclic redundancy check algorithm (Cyclic Redundancy Check, CRC), such as CRC32. The check algorithm used when generating the check code B can be a CRC or an accumulation sum check algorithm, such as CRC16. According to needs, the check algorithm for generating the check code A and the check algorithm for generating the check code B can be the same or different, which is not limited in the embodiment.
[0078] In step 103, whether the first check code is wrong in the transmission process is judged according to the second check code.
[0079] Optionally, judging whether the first check code is wrong in the transmission process according to the second check code can include:
[0080] According to the first preset check algorithm, the first check code is checked and calculated to obtain a third check code; the first preset check algorithm is the same as the first check algorithm used by the sender of the upgrade file package to calculate the second check code.
[0081] It is judged whether the third check code is the same as the second check code.
[0082] If the third check code is the same as the second check code, it is determined that the first check code is not wrong in the transmission process.
[0083] If the third check code is not the same as the second check code, it is determined that the first check code is wrong in the transmission process.
[0084] In the embodiment, the first preset check algorithm and the first check algorithm are the check algorithm used to generate the check code B in step 102. Since the sender uses the first check algorithm to check and calculate the generated check code A to obtain the check code B (i.e. the second check code), after receiving the first check code corresponding to the check code A, the first check code is also checked and calculated by using the first check algorithm to obtain the third check code. If the third check code is different from the second check code, it indicates that the received first check code has changed relative to the check code A generated by the sender, that is, the first check code is wrong in the transmission process; if the third check code is the same as the second check code, it indicates that the received first check code has not changed relative to the check code A generated by the sender, that is, the first check code is not wrong in the transmission process.
[0085] In step 104, if it is determined that the first check code is not wrong in the transmission process, it is judged according to the first check code whether the firmware upgrade file is wrong in the transmission process.
[0086] Optionally, judging whether the firmware upgrade file is wrong in the transmission process according to the first check code can include:
[0087] According to the second preset check algorithm, the firmware upgrade file is checked and calculated to obtain a fourth check code; the second preset check algorithm is the same as the second check algorithm used by the sender of the upgrade file package to calculate the first check code.
[0088] It is judged whether the fourth check code is the same as the first check code.
[0089] If the fourth check code is the same as the first check code, it is determined that the firmware upgrade file is not wrong in the transmission process.
[0090] If the fourth check code is not the same as the first check code, it is determined that the firmware upgrade file is wrong in the transmission process.
[0091] In the embodiment, the second preset check algorithm and the second check algorithm are the check algorithm used to generate the check code A in step 102. Since the sender uses the second check algorithm to perform check calculation on the generated firmware upgrade file to obtain the check code A (i.e. the first check code), after receiving the firmware upgrade file, the second check algorithm is also used to perform check calculation on the firmware upgrade file to obtain the fourth check code. If the fourth check code is different from the first check code, it indicates that the received firmware upgrade file has changed relative to the firmware upgrade file generated by the sender, i.e. the firmware upgrade file has an error in the transmission process; if the fourth check code is the same as the first check code, it indicates that the received firmware upgrade file has not changed relative to the firmware upgrade file generated by the sender, i.e. the firmware upgrade file has no error in the transmission process.
[0092] In the embodiment, in the case that it is determined that the first check code has no error in the transmission process, the first check code is further used to determine whether the firmware upgrade file has an error in the transmission process, so that the determination result is more accurate.
[0093] In step 105, if it is determined that the firmware upgrade file has no error in the transmission process, the unique identification code in the firmware upgrade file is used to determine whether the firmware upgrade file matches the firmware to be upgraded in the current chip.
[0094] Optionally, the unique identification code in the firmware upgrade file is used to determine whether the firmware upgrade file matches the firmware to be upgraded in the current chip, including:
[0095] determining whether the unique identification code in the firmware upgrade file is the same as the unique identification code in the firmware source code corresponding to the firmware to be upgraded in the current chip;
[0096] If the unique identification code in the firmware upgrade file is the same as the unique identification code in the firmware source code corresponding to the firmware to be upgraded in the current chip, it is determined that the firmware upgrade file matches the firmware to be upgraded in the current chip.
[0097] If the unique identification code in the firmware upgrade file is not the same as the unique identification code in the firmware source code corresponding to the firmware to be upgraded in the current chip, it is determined that the firmware upgrade file does not match the firmware to be upgraded in the current chip.
[0098] In the embodiment, the unique identification code stored in the firmware source code corresponding to the firmware upgrade file and the firmware to be upgraded in the current chip can be determined in advance, and then it is judged whether the unique identification code in the firmware upgrade file is consistent with the unique identification code in the firmware source code corresponding to the firmware to be upgraded in the current chip. When the two are consistent, it means that the firmware upgrade file is the firmware upgrade file corresponding to the firmware to be upgraded in the current chip, that is, it means that the firmware to be upgraded in the current chip can be upgraded by using the firmware upgrade file. If the two are not consistent, it means that the firmware upgrade file does not match the firmware to be upgraded in the current chip, and then upgrading the firmware to be upgraded in the current chip by using the firmware upgrade file may cause the device where the firmware is located to be damaged.
[0099] In step 106, if it is determined that the firmware upgrade file matches the firmware to be upgraded in the current chip, the firmware to be upgraded in the current chip is upgraded according to the firmware upgrade file.
[0100] Optionally, after judging whether the first check code is wrong in the transmission process according to the second check code, it can further include: if it is determined that the first check code is wrong in the transmission process, a prompt information is sent to prompt that the upgrade file package is wrong.
[0101] After judging whether the firmware upgrade file is wrong in the transmission process according to the first check code, it can further include: if it is determined that the firmware upgrade file is wrong in the transmission process, a prompt information is sent to prompt that the upgrade file package is wrong.
[0102] After judging whether the firmware upgrade file matches the firmware to be upgraded in the current chip according to the unique identification code in the firmware upgrade file, it can further include: if it is determined that the firmware upgrade file does not match the firmware to be upgraded in the current chip, a prompt information is sent to prompt that the upgrade file package is wrong.
[0103] In the embodiment, after extracting the firmware upgrade file, the first check code corresponding to the firmware upgrade file, and the second check code corresponding to the first check code from the upgrade file package, only when it is determined that the first check code and the firmware upgrade file are not wrong in the transmission, and the firmware upgrade file matches the firmware to be upgraded in the current chip, the firmware to be upgraded in the current chip is upgraded based on the received firmware upgrade file. If any of the above determinations is wrong, a prompt information is sent to prompt that the upgrade file package is wrong. This is further conducive to minimizing the possibility of damaging the device where the firmware is located during the firmware upgrade process.
[0104] Referring to Figure 2FIG. 2 shows a flow chart of the implementation of the firmware upgrade method provided by another embodiment of the present application. In the firmware upgrade method provided by another embodiment of the present application, the upgrade file package includes: a position mark code of the unique identification code in the firmware upgrade file. The position mark code and the first check code corresponding to the firmware upgrade file constitute a joint check code. The firmware upgrade method is described in detail as follows:
[0105] In step 201, the upgrade file package is received.
[0106] In step 202, the firmware upgrade file, the first check code corresponding to the firmware upgrade file, the position mark code, and the second check code corresponding to the joint check code are extracted from the upgrade file package.
[0107] In step 203, it is judged whether the joint check code is wrong in the transmission process according to the second check code.
[0108] In step 204, if it is judged that the joint check code is not wrong in the transmission process, it is judged whether the firmware upgrade file is wrong in the transmission process according to the first check code in the joint check code.
[0109] In step 205, if it is judged that the firmware upgrade file is not wrong in the transmission process, the position mark code in the joint check code is used to obtain the unique identification code in the firmware upgrade file; and it is judged whether the firmware upgrade file matches the firmware to be upgraded in the current chip according to the obtained unique identification code in the firmware upgrade file.
[0110] In step 206, if it is judged that the firmware upgrade file matches the firmware to be upgraded in the current chip, the firmware to be upgraded in the current chip is upgraded according to the firmware upgrade file.
[0111] Compared with the firmware upgrade method of steps 101 to 106, in this embodiment, when the upgrade file package is generated, not only the check code A corresponding to the firmware upgrade file and the check code B corresponding to the check code A are generated, but also the position mark code is generated, which is used to mark the addressable area in which the unique identification code is stored in the firmware upgrade file, so as to facilitate the subsequent obtaining of the unique identification code in the firmware upgrade file.
[0112] Adaptive, since the upgrade file package in the embodiment includes not only the firmware upgrade file, but also the check code A and the position mark code, in order to avoid the impact of the damage or error of the check code A and the position mark code in the transmission process on the firmware upgrade, a check calculation is performed on the joint check code composed of the check code A and the position mark code to generate a new check code B, so that the firmware upgrade file, the check code A corresponding to the firmware upgrade file, the position mark code, the joint check code composed of the position mark code and the check code A, and the new check code B corresponding to the joint check code are packaged into the upgrade file package and sent out. After receiving the upgrade file package, the receiver extracts the received firmware upgrade file, the received check code A (i.e. the first check code), the received position mark code, and the received new check code B (i.e. the second check code) from the upgrade file package, and then judges whether the received position mark code + the first check code is transmitted incorrectly according to the second check code; when the received position mark code + the first check code is not transmitted incorrectly, it is judged whether the received firmware upgrade file is transmitted incorrectly according to the first check code; when the received firmware upgrade file is not transmitted incorrectly, the unique identification code is accurately extracted from the firmware upgrade file according to the position mark code which is not transmitted incorrectly; finally, when the firmware upgrade file matches the firmware to be upgraded in the current chip according to the accurate unique identification code, the firmware upgrade is performed on the firmware to be upgraded in the current chip according to the firmware upgrade file which is not transmitted incorrectly. Thus, the possibility of damaging the device where the firmware is located in the firmware upgrade process is further reduced.
[0113] Optionally, judging whether the joint check code is transmitted incorrectly according to the second check code can include:
[0114] performing a check calculation on the joint check code according to a third preset check algorithm to obtain a fifth check code; the third preset check algorithm is the same as the third check algorithm used by the sender of the upgrade file package to calculate the second check code;
[0115] judging whether the fifth check code is the same as the second check code;
[0116] if the fifth check code is the same as the second check code, it is determined that the joint check code is not transmitted incorrectly in the transmission process;
[0117] if the fifth check code is not the same as the second check code, it is determined that the joint check code is transmitted incorrectly in the transmission process.
[0118] The embodiment is a specific process of judging whether the joint check code is wrong in the transmission process according to the second check code, which is similar to the specific process of judging whether the first check code is wrong in the transmission process according to the second check code in step 103. However, since the received upgrade file package includes the first check code and the position mark code corresponding to the firmware upgrade file in addition to the firmware upgrade file, the first check code and the position mark code need to be judged whether they are wrong in the transmission process. Therefore, the sender can perform check calculation on the joint check code composed of the check code A and the position mark code to generate a new check code B. Similarly, the receiver can perform check calculation again on the joint check code composed of the received check code A (i.e. the first check code) and the position mark code to obtain a fifth check code, and then judge whether the fifth check code is same as the received new check code B (i.e. the second check code) to judge whether the joint check code composed of the received check code A (i.e. the first check code) and the position mark code is wrong in the transmission process.
[0119] The embodiment of the application extracts the firmware upgrade file, the first check code corresponding to the firmware upgrade file and the second check code corresponding to the first check code from the upgrade file package after receiving the upgrade file package, judges whether the first check code is wrong in the transmission process according to the second check code, judges whether the firmware upgrade file is wrong in the transmission process according to the first check code in the case that the first check code is determined not to be wrong in the transmission process, judges whether the firmware upgrade file matches the firmware to be upgraded in the current chip according to the unique identification code in the firmware upgrade file in the case that the firmware upgrade file is determined not to be wrong in the transmission process, and upgrades the firmware to be upgraded in the current chip according to the firmware upgrade file in the case that the firmware upgrade file matches the firmware to be upgraded in the current chip. On the one hand, the firmware upgrade file in the received upgrade file package can be ensured not to be damaged or wrong through layer-by-layer check, and on the other hand, the unique identification code in the firmware upgrade file can be used to ensure that only the matched firmware upgrade file is used to upgrade the firmware to be upgraded in the current chip after it is determined that the received firmware upgrade file is not damaged or wrong, thereby effectively reducing the possibility that the device where the firmware is located is damaged in the firmware upgrade process. Moreover, the subsequent judgment or upgrade can be performed through once receiving the upgrade file package, thereby avoiding the uncertainty caused by multiple receiving and being beneficial to improving the firmware upgrade efficiency.
[0120] It should be understood that the size of the serial number of each step in the above embodiment does not mean the order of execution, the execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the application.
[0121] The following is a device embodiment of the application, and for details not described in detail, reference can be made to the corresponding method embodiments described above.
[0122] Figure 3 A structure diagram of the firmware upgrading device provided by the embodiment of the present application is shown, only parts related to the embodiment of the present application are shown for convenience of description, and the details are as follows:
[0123] As shown in Figure 3 The firmware upgrading device comprises a receiving module 31, an extracting module 32, a first processing module 33, a second processing module 34, a third processing module 35 and an upgrading module 36.
[0124] The receiving module 31 is used for receiving an upgrading file package;
[0125] The extracting module 32 is used for extracting a firmware upgrading file, a first check code corresponding to the firmware upgrading file and a second check code corresponding to the first check code from the upgrading file package;
[0126] The first processing module 33 is used for judging whether the first check code is wrong in a transmission process according to the second check code;
[0127] The second processing module 34 is used for judging whether the firmware upgrading file is wrong in the transmission process according to the first check code if it is judged that the first check code is not wrong in the transmission process;
[0128] The third processing module 35 is used for judging whether the firmware upgrading file matches the firmware to be upgraded in the current chip according to a unique identification code in the firmware upgrading file if it is judged that the firmware upgrading file is not wrong in the transmission process;
[0129] The upgrading module 36 is used for upgrading the firmware to be upgraded in the current chip according to the firmware upgrading file if it is judged that the firmware upgrading file matches the firmware to be upgraded in the current chip.
[0130] The embodiment of the present application firstly extracts the firmware upgrade file, the first check code corresponding to the firmware upgrade file and the second check code corresponding to the first check code from the upgrade file package after receiving the upgrade file package, then judges whether the first check code is wrong in the transmission process according to the second check code, judges whether the firmware upgrade file is wrong in the transmission process according to the first check code in the case that the first check code is not wrong in the transmission process, judges whether the firmware upgrade file matches the firmware to be upgraded in the current chip according to the unique identification code in the firmware upgrade file in the case that the firmware upgrade file is not wrong in the transmission process, and finally upgrades the firmware to be upgraded in the current chip according to the firmware upgrade file in the case that the firmware upgrade file matches the firmware to be upgraded in the current chip. On the one hand, the firmware upgrade file in the received upgrade file package can be ensured not to be damaged or wrong through layer-by-layer checking, and on the other hand, the unique identification code in the firmware upgrade file can be used to ensure that only the matched firmware upgrade file is used to upgrade the firmware to be upgraded in the current chip after it is determined that the received firmware upgrade file is not damaged or wrong, thereby effectively reducing the possibility that the device where the firmware is located is damaged in the firmware upgrade process. Moreover, the subsequent judgment or upgrade can be performed through once receiving the upgrade file package, thereby avoiding the uncertainty caused by multiple receptions and being beneficial to improving the firmware upgrade efficiency.
[0131] In a possible implementation, the first processing module 33 can be configured to:
[0132] perform check calculation on the first check code according to a first preset check algorithm to obtain a third check code; the first preset check algorithm is the same as a first check algorithm used by a sender of the upgrade file package to calculate the second check code.
[0133] determine whether the third check code is the same as the second check code.
[0134] if the third check code is the same as the second check code, it is determined that the first check code is not wrong in the transmission process.
[0135] if the third check code is not the same as the second check code, it is determined that the first check code is wrong in the transmission process.
[0136] In a possible implementation, the second processing module 34 can be configured to:
[0137] perform check calculation on the firmware upgrade file according to a second preset check algorithm to obtain a fourth check code; the second preset check algorithm is the same as a second check algorithm used by a sender of the upgrade file package to calculate the first check code.
[0138] determine whether the fourth check code is the same as the first check code.
[0139] If the fourth check code is the same as the first check code, it is determined that the firmware upgrade file is not error in the transmission process.
[0140] If the fourth check code is not the same as the first check code, it is determined that the firmware upgrade file is error in the transmission process.
[0141] In a possible implementation, the third processing module 35 can be configured to:
[0142] determine whether the unique identification code in the firmware upgrade file is the same as the unique identification code in the firmware source code corresponding to the firmware to be upgraded in the current chip.
[0143] If the unique identification code in the firmware upgrade file is the same as the unique identification code in the firmware source code corresponding to the firmware to be upgraded in the current chip, it is determined that the firmware upgrade file matches the firmware to be upgraded in the current chip.
[0144] If the unique identification code in the firmware upgrade file is not the same as the unique identification code in the firmware source code corresponding to the firmware to be upgraded in the current chip, it is determined that the firmware upgrade file does not match the firmware to be upgraded in the current chip.
[0145] In a possible implementation, the upgrade file package includes: a position mark code of the unique identification code in the firmware upgrade file; and the position mark code and the first check code constitute a joint check code.
[0146] The extraction module 32 can be configured to:
[0147] extract the firmware upgrade file, the first check code corresponding to the firmware upgrade file, the position mark code, and the second check code corresponding to the joint check code from the upgrade file package.
[0148] The first processing module 33 can be configured to:
[0149] determine whether the joint check code is error in the transmission process according to the second check code.
[0150] The second processing module 34 can be configured to:
[0151] If it is determined that the joint check code is not error in the transmission process, determine whether the firmware upgrade file is error in the transmission process according to the first check code in the joint check code.
[0152] The third processing module 35 can be configured to:
[0153] If it is determined that the firmware upgrade file is not error in the transmission process, obtain the unique identification code in the firmware upgrade file according to the position mark code in the joint check code.
[0154] determine whether the firmware upgrade file matches the firmware to be upgraded in the current chip according to the obtained unique identification code.
[0155] In a possible implementation, the first processing module 33 can be configured to:
[0156] perform a check calculation on the joint check code according to a third preset check algorithm to obtain a fifth check code; the third preset check algorithm is the same as a third check algorithm used by a sender of the upgrade file package to calculate the second check code.
[0157] determine whether the fifth check code is the same as the second check code.
[0158] If the fifth check code is the same as the second check code, it is determined that the joint check code is not erroneous in the transmission process.
[0159] If the fifth check code is not the same as the second check code, it is determined that the joint check code is erroneous in the transmission process.
[0160] In a possible implementation, the firmware upgrade device further includes a prompting module 37.
[0161] The prompting module 37 is configured to, if it is determined that the first check code is erroneous in the transmission process, send a prompt information to prompt that the upgrade file package is erroneous.
[0162] Alternatively, the prompting module 37 is configured to, if it is determined that the firmware upgrade file is erroneous in the transmission process, send a prompt information to prompt that the upgrade file package is erroneous.
[0163] Alternatively, the prompting module 37 is configured to, if it is determined that the firmware upgrade file does not match the firmware to be upgraded in the current chip, send a prompt information to prompt that the upgrade file package is erroneous.
[0164] Figure 4 is a schematic diagram of an embedded device provided by an embodiment of the present application. As shown in the figure, the embedded device 4 of the embodiment includes a processor 40, a memory 41, and a computer program 42 stored in the memory 41 and executable on the processor 40. The processor 40 implements the steps in each of the above firmware upgrade method embodiments when executing the computer program 42, for example, the steps 101 to 106 shown in the figure, or the steps 201 to 206 shown in the figure. Figure 4 Figure 1 Figure 2 Figure 3
[0165] For example, the computer program 42 can be divided into one or more modules / units, one or more of which are stored in the memory 41 and executed by the processor 40 to accomplish the present application. One or more modules / units can be a series of computer program instruction segments capable of accomplishing a specific function, which are used to describe the execution process of the computer program 42 in the embedded device 4. For example, the computer program 42 can be divided into Figure 3 The modules / units 31 to 37 shown.
[0166] The embedded device 4 can be a device constituting an uninterruptible power supply system or the like. The embedded device 4 can include, but is not limited to, the processor 40, the memory 41. Those skilled in the art can understand that the embedded device 4 can include more or less components than those shown, or combine certain components, or different components, for example, the embedded device can also include an input / output device, a network access device, a bus, etc. Figure 4 The embedded device 4 shown is merely an example and does not constitute a limitation on the embedded device 4, and can include more or less components than those shown, or combine certain components, or different components, for example, the embedded device can also include an input / output device, a network access device, a bus, etc.
[0167] The processor 40 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic components, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0168] The memory 41 can be an internal storage unit of the embedded device 4, such as a hard disk or a memory of the embedded device 4. The memory 41 can also be an external storage device of the embedded device 4, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the memory 41 can include both an internal storage unit and an external storage device of the embedded device 4. The memory 41 is used to store computer programs and other programs and data required by the embedded device. The memory 41 can also be used to temporarily store data that has been output or will be output.
[0169] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be realized in the form of hardware or software. In addition, the specific name of each functional unit and module is only for the convenience of mutual distinction, and does not limit the protection scope of the present application. The specific working process of the unit and module in the above system can refer to the corresponding process in the foregoing method embodiment, which will not be described here.
[0170] In the above embodiments, the description of each embodiment has its own emphasis, and the parts not described or recorded in detail in a certain embodiment can be referred to the related description of other embodiments.
[0171] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0172] In the embodiments provided by the present application, it should be understood that the disclosed devices / embedded devices and methods can be implemented in other ways. For example, the device / embedded device embodiments described above are only schematic. The division of modules or units is only a logical function division, and there can be another division in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or in other forms.
[0173] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0174] In addition, each function unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software function unit.
[0175] If the integrated module / unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above-mentioned embodiment methods can also be completed by a computer program instructing related hardware, and the computer program can be stored in a computer-readable storage medium. When the processor executes the computer program, the steps of each firmware upgrade method embodiment described above can be implemented. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or some intermediate forms, etc. The computer-readable medium can include any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content included in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.
[0176] The above embodiments are only used to illustrate the technical solutions of the present application, rather than limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements for some technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A firmware upgrade method, characterized in that, include: Receive the upgrade package; Extract the firmware upgrade file, the first verification code corresponding to the firmware upgrade file, and the second verification code corresponding to the first verification code from the upgrade file package; The second check code is used to determine whether the first check code was corrupted during transmission; If it is determined that the first verification code was not erroneous during transmission, then the firmware upgrade file is determined to be erroneous during transmission based on the first verification code. If it is determined that the firmware upgrade file was transmitted without error, then the unique identifier in the firmware upgrade file is used to determine whether the firmware upgrade file matches the firmware to be upgraded in the current chip. If it is determined that the firmware upgrade file matches the firmware to be upgraded in the current chip, then the firmware to be upgraded in the current chip is upgraded according to the firmware upgrade file; The step of determining whether the first check code was corrupted during transmission based on the second check code includes: The first verification code is verified and calculated according to the first preset verification algorithm to obtain the third verification code; the first preset verification algorithm is the same as the first verification algorithm used by the sender of the upgrade file package to calculate the second verification code. Determine whether the third check code is the same as the second check code; If the third verification code is the same as the second verification code, then it is determined that the first verification code did not have an error during transmission; If the third check code is different from the second check code, it is determined that the first check code was corrupted during transmission.
2. The firmware upgrade method according to claim 1, characterized in that, The step of determining whether the firmware upgrade file was corrupted during transmission based on the first verification code includes: The firmware upgrade file is verified and calculated according to the second preset verification algorithm to obtain the fourth verification code; the second preset verification algorithm is the same as the second verification algorithm used by the sender of the upgrade file package to calculate the first verification code. Determine whether the fourth check code is the same as the first check code; If the fourth verification code is the same as the first verification code, it is determined that the firmware upgrade file was transmitted without error. If the fourth verification code is different from the first verification code, it is determined that the firmware upgrade file has an error during transmission.
3. The firmware upgrade method according to claim 1, characterized in that, The step of determining whether the firmware upgrade file matches the firmware to be upgraded in the current chip based on the unique identifier in the firmware upgrade file includes: Determine whether the unique identifier in the firmware upgrade file is the same as the unique identifier in the firmware source code corresponding to the firmware to be upgraded in the current chip; If the unique identifier in the firmware upgrade file is the same as the unique identifier in the firmware source code corresponding to the firmware to be upgraded in the current chip, then the firmware upgrade file is determined to match the firmware to be upgraded in the current chip. If the unique identifier in the firmware upgrade file is different from the unique identifier in the firmware source code corresponding to the firmware to be upgraded in the current chip, then it is determined that the firmware upgrade file does not match the firmware to be upgraded in the current chip.
4. The firmware upgrade method according to claim 1, characterized in that, The upgrade file package includes: a location marker code of the unique identifier in the firmware upgrade file; the location marker code and the first check code constitute a joint check code; The step of extracting the firmware upgrade file, the first verification code corresponding to the firmware upgrade file, and the second verification code corresponding to the first verification code from the upgrade file package includes: Extract the firmware upgrade file, the first checksum corresponding to the firmware upgrade file, the location flag code, and the second checksum corresponding to the joint checksum from the upgrade file package; The step of determining whether the first check code was corrupted during transmission based on the second check code includes: The second check code is used to determine whether the joint check code has been corrupted during transmission; If it is determined that the first verification code did not contain any errors during transmission, then determining whether the firmware upgrade file contained any errors during transmission based on the first verification code includes: If it is determined that the joint check code did not have any errors during transmission, then the first check code in the joint check code is used to determine whether the firmware upgrade file had any errors during transmission. If it is determined that the firmware upgrade file was transmitted without error, then the determination of whether the firmware upgrade file matches the firmware to be upgraded in the current chip is based on the unique identifier in the firmware upgrade file, including: If it is determined that the firmware upgrade file was transmitted without error, then the unique identification code in the firmware upgrade file is obtained according to the position flag code in the joint check code; The unique identifier obtained is used to determine whether the firmware upgrade file matches the firmware to be upgraded in the current chip.
5. The firmware upgrade method according to claim 4, characterized in that, The step of determining whether the joint check code has been erroneous during transmission based on the second check code includes: The joint verification code is verified and calculated according to the third preset verification algorithm to obtain the fifth verification code; the third preset verification algorithm is the same as the third verification algorithm used by the sender who sent the upgrade file package to calculate the second verification code; Determine whether the fifth check code is the same as the second check code; If the fifth check code is the same as the second check code, then it is determined that the joint check code did not have an error during transmission; If the fifth check code is different from the second check code, it is determined that the joint check code has an error during transmission.
6. The firmware upgrade method according to any one of claims 1-5, characterized in that, After determining whether the first check code was corrupted during transmission based on the second check code, the process further includes: If it is determined that the first verification code is erroneous during transmission, a prompt message is issued to indicate that the upgrade file package is faulty; After determining whether the firmware upgrade file has encountered an error during transmission based on the first verification code, the process further includes: If it is determined that the firmware upgrade file has an error during transmission, a prompt message will be issued to indicate that the upgrade file package is faulty; After determining whether the firmware upgrade file matches the firmware to be upgraded in the current chip based on the unique identifier in the firmware upgrade file, the process further includes: If it is determined that the firmware upgrade file does not match the firmware to be upgraded in the current chip, a prompt message will be issued to indicate that the upgrade file package is faulty.
7. A firmware upgrade device, characterized in that, include: The receiving module is used to receive upgrade file packages; The extraction module is used to extract the firmware upgrade file, the first verification code corresponding to the firmware upgrade file, and the second verification code corresponding to the first verification code from the upgrade file package. The first processing module is used to determine whether the first verification code has been erroneous during transmission based on the second verification code; The second processing module is used to determine whether the firmware upgrade file has an error during transmission based on the first verification code if it is determined that the first verification code has not been erroneous during transmission. The third processing module is used to determine whether the firmware upgrade file matches the firmware to be upgraded in the current chip based on the unique identification code in the firmware upgrade file if it is determined that the firmware upgrade file was transmitted without error. An upgrade module is used to upgrade the firmware in the current chip according to the firmware upgrade file if it is determined that the firmware upgrade file matches the firmware to be upgraded in the current chip. The first processing module is specifically used for: The first verification code is verified and calculated according to the first preset verification algorithm to obtain the third verification code; the first preset verification algorithm is the same as the first verification algorithm used by the sender of the upgrade file package to calculate the second verification code. Determine whether the third check code is the same as the second check code; If the third verification code is the same as the second verification code, then it is determined that the first verification code did not have an error during transmission; If the third check code is different from the second check code, it is determined that the first check code was corrupted during transmission.
8. An embedded device, characterized in that, It includes a memory and a processor, the memory being used to store a computer program, and the processor being used to call and run the computer program stored in the memory to perform the method as described in any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 6 above.
Citation Information
Patent Citations
An equipment firmware upgrading method and an apparatus
CN106991326A
MCU firmware upgrading method of heterogeneous acceleration platform and related device
CN110389778A