Electronic device firmware upgrade method, device and electronic device

By dividing independent areas in electronic devices and using execution marks to redirect areas, the problem of abnormal stylus firmware upgrade is solved, and the automatic rollback and stability guarantee of the equipment during the upgrade process is achieved.

CN118259949BActive Publication Date: 2024-11-05SHENZHEN XINWEI INTELLIGENT TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410700703.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-11-05
Estimated Expiration
2044-05-31

AI Technical Summary

Technical Problem

Existing stylus are prone to abnormalities during firmware upgrade, resulting in failure or crashes in the upgrade and cannot be used normally.

Method used

By dividing independent areas in electronic devices, storing and running firmware and upgrading files, and using execution identifiers to jump zones, ensuring that the original firmware files are automatically switched to the original firmware files when upgrade abnormalities are not available to the device.

Benefits of technology

It realizes automatic rollback to the original firmware file in abnormal situations during the upgrade process, ensuring device reliability and stability, and avoiding the problem of equipment being unavailable due to upgrade failure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118259949B_ABST
    Figure CN118259949B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a method, device and electronic device for upgrading the firmware of an electronic device, and the method includes: receiving an upgrade file sent by a host computer; determining that the firmware file is running in a first area, and storing the upgrade file in a second area; verifying the upgrade file, and changing the execution identifier to a first jump state if the verification is successful; after the electronic device system is reset, in response to the execution identifier being the first jump state, changing the execution identifier to a first running state; in response to the execution identifier being the first running state, jumping to the second area to run the upgrade file; determining that the upgrade file is running abnormally, jumping to the first area to run the firmware file. The method of the present application, by storing the upgrade file separately from the firmware file, and providing the area jump guide and the running status of the file through the execution identifier as the system program of the electronic device, enables the electronic device to automatically re-run the firmware file when the upgrade is abnormal, thereby avoiding the electronic device from being unusable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of touch pen technology, and in particular to an electronic device firmware upgrade method, device and electronic device. Background Art

[0002] With the development of electronic screen technology, more and more operations can be completed by touching the screen with fingers. In order to make the screen operation smoother and more accurate, a stylus can be used instead of fingers to complete it. In order to improve the performance of the stylus, it is necessary to continuously optimize the functions of the stylus. Therefore, the firmware of the circuit inside the stylus can be upgraded. However, the current stylus is prone to abnormality during the upgrade process, resulting in the failure of the stylus firmware upgrade or even a freeze and unusable situation. Summary of the invention

[0003] The embodiments of the present application provide a method, device and electronic device for upgrading the firmware of an electronic device, so as to solve the technical problem in the prior art that the firmware upgrade of a stylus pen is abnormal and cannot be used.

[0004] In order to solve the above technical problems, the embodiments of the present application disclose the following technical solutions:

[0005] In a first aspect, a method for upgrading firmware of an electronic device is provided, wherein the electronic device includes a first area and a second area that are independent of each other; the method includes:

[0006] Receive the upgrade file sent by the host computer;

[0007] Determine that a firmware file is running in the first area, and store the upgrade file in the second area, wherein the firmware file is a currently running file;

[0008] Verify the upgrade file, and if the verification is successful, change the execution flag to the first jump state;

[0009] After the electronic device system is reset, in response to the execution identifier being the first jump state, changing the execution identifier to a first running state;

[0010] In response to the execution identifier being the first running state, jumping to the second area to run the upgrade file;

[0011] Determining that the upgrade file runs abnormally, jumping to the first area to run the firmware file;

[0012] The first jump state is configured to instruct the loader to jump to the second area and read the upgrade file, and the first running state is configured to indicate that the current running file is the upgrade file.

[0013] In combination with the first aspect, the method of determining that the upgrade file runs abnormally and jumping to the first area to run the firmware file includes:

[0014] After determining that the upgrade file runs abnormally, resetting the system of the electronic device;

[0015] In response to the execution identifier being the first running state, changing the execution identifier to a second jump state;

[0016] In response to the execution identifier being the second jump state, jumping to the first area and changing the execution identifier to a second running state;

[0017] The second running state is configured to indicate that the current running file is the firmware file.

[0018] In conjunction with the first aspect, the method for determining that the upgrade file is running abnormally includes:

[0019] Obtaining a progress signal representing the running progress of the upgrade file;

[0020] In response to the absence time of the progress signal exceeding a progress threshold, it is determined that the upgrade file is running abnormally.

[0021] In combination with the first aspect, the method further includes:

[0022] Determine that the upgrade file runs normally, change the execution identifier to the first jump state, and perform a system reset on the electronic device.

[0023] In combination with the first aspect, the method for receiving the upgrade file sent by the host computer includes:

[0024] A plurality of sub-upgrade files are received one by one, wherein the plurality of sub-upgrade files are obtained by splitting the upgrade file by the host computer.

[0025] In conjunction with the first aspect, the method for verifying the upgrade file includes:

[0026] Get the sub-check code and the total check code;

[0027] Verifying the multiple sub-upgrade files based on the sub-verification code;

[0028] The multiple sub-upgrade files are merged to obtain the upgrade file, and the upgrade file is verified based on the total verification code.

[0029] In combination with the first aspect, the electronic device further includes a third area, wherein the third area is configured to store the loading program;

[0030] The third area is independent of the first area and the second area.

[0031] In combination with the first aspect, the electronic device further includes a fourth area, which is independent of the first area, the second area and the third area, and is configured to store the execution identifier and the log file.

[0032] In combination with the first aspect, the electronic device further includes a cache area, which is independent of the first area, the second area and the third area, and is configured to store data files.

[0033] In a second aspect, a device for upgrading firmware of an electronic device is provided, comprising:

[0034] A receiving module, wherein the receiving module is configured to receive an upgrade file sent by a host computer;

[0035] A storage module, wherein the storage module is configured to determine that a firmware file is running in a first area and store the upgrade file in a second area, wherein the firmware file is a currently running file, and the first area and the second area are independent of each other;

[0036] A verification module, wherein the verification module is configured to verify the upgrade file;

[0037] an execution identification module, the execution identification module comprising a first jump state, a first running state, and a second running state, the first jump state being configured to instruct the loader to jump to the second area and read the upgrade file, the first running state being configured to indicate that the current running file is the upgrade file, and the second running state being configured to indicate that the current running file is the firmware file;

[0038] A loading module is configured to change the state of the execution identification module and run the upgrade file or the firmware file based on the state of the execution identification module.

[0039] In a third aspect, an electronic device is provided, comprising a memory and a processor; the memory is used to store a computer program; the processor is used to implement the electronic device firmware upgrade method as described in any one of the first aspects when executing the computer program.

[0040] One of the above technical solutions has the following advantages or beneficial effects:

[0041] The present application provides a method for upgrading the firmware of an electronic device, wherein the electronic device includes a first area and a second area that are independent of each other; the method includes: receiving an upgrade file sent by a host computer; determining that the firmware file is running in the first area, storing the upgrade file in the second area, wherein the firmware file is the current running file; verifying the upgrade file, and changing the execution identifier to the first jump state if the verification is successful; after the electronic device system is reset, in response to the execution identifier being the first jump state, changing the execution identifier to the first running state; in response to the execution identifier being the first running state, jumping to the second area to run the upgrade file; determining that the upgrade file is running abnormally, jumping to the first area to run the firmware file; wherein the first jump state is configured to instruct the loader to jump to the second area and read the upgrade file, and the first running state is configured to characterize that the current running file is the upgrade file. The method for upgrading the firmware of an electronic device provided by the present application stores the upgrade file separately from the currently running firmware file, and provides a regional jump guide and a running state of the file through the execution identifier as a system program of the electronic device, so that the electronic device can automatically jump to the first area to run the original firmware file when an abnormality occurs in the process of running the upgrade file, thereby avoiding the electronic device from being unable to return to the previous running version after the upgrade fails. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] The technical solution and other beneficial effects of the present application will be made apparent by describing in detail the specific implementation methods of the present application in conjunction with the accompanying drawings.

[0043] Figure 1 A schematic diagram of the steps of a firmware upgrade method for an electronic device provided in an embodiment of the present application;

[0044] Figure 2 A schematic diagram of a firmware upgrade method for an electronic device provided in an embodiment of the present application;

[0045] Figure 3 A schematic diagram of loading steps after a system reset of an electronic device provided in an embodiment of the present application;

[0046] Figure 4 A schematic diagram of the regional structure of a main control chip of an electronic device provided in an embodiment of the present application;

[0047] Figure 5 A schematic diagram of the structure of a firmware upgrade device for an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. In the description of the present application, it is necessary to understand that the orientation or position relationship indicated by the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", etc. is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation to the present application. In addition, the terms "first" and "second" are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" can explicitly or implicitly include one or more of the features. In the description of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.

[0049] The specific implementation methods of the present application are further described below through the examples:

[0050] like Figure 1 and Figure 2 As shown, an embodiment of the present application provides a method for upgrading the firmware of an electronic device, wherein the electronic device includes a first area and a second area that are independent of each other; the method includes:

[0051] S1: Receive the upgrade file sent by the host computer.

[0052] Specifically, the host computer splits the upgrade file into multiple sub-upgrade files, and sends the multiple sub-upgrade files to the electronic device one by one. In an embodiment of the present application, the host computer first obtains the upgrade file, and then splits the upgrade file into multiple sub-upgrade files according to a certain size. The size of each sub-upgrade file can be determined according to specific needs, communication protocols or transmission line widths. After the split is completed, the host computer is connected to the electronic device by a wired connection or a wireless connection, and multiple sub-upgrade files are sent to the electronic device. The connection mode is selected according to the interface of the electronic device and the supported communication mode. By splitting the upgrade file into multiple sub-upgrade files for sending, the transmission efficiency of the upgrade file can be improved. Compared with sending the entire upgrade file at one time, packet sending can reduce the time and resource occupation of transmission, which is particularly suitable for use in network transmission or limited bandwidth, and can avoid long waiting and transmission interruption. At the same time, packet sending can also improve the fault tolerance of transmission. If an error occurs during the transmission process, only the erroneous sub-packet needs to be resent, and the entire upgrade file does not need to be retransmitted. Thereby reducing the amount of retransmitted data, improving the reliability of transmission, and reducing the transmission time of the entire upgrade file. In addition, when sending in packets, if the transmission process is interrupted or terminated, the transmission can be restarted from the interruption point without retransmitting the entire upgrade file, which has better transmission reliability and flexibility.

[0053] In the embodiments of the present application, the host computer includes a personal computer, a workstation, a controller, an embedded system, and a server. Wired connection methods include USB, Micro USB, Type-C, etc. Wireless connection methods include Bluetooth, Wi-Fi, and OTA (Over The Air) transmission, etc. The specific selection of the host computer and the connection method between the host computer and the electronic device can be selected according to actual conditions, and the embodiments of the present application will not be listed here.

[0054] S2: Determine that the firmware file is running in the first area, and store the upgrade file in the second area, wherein the firmware file is a currently running file.

[0055] Specifically, by storing the firmware file and the upgrade file in different areas, the security of the electronic device system can be improved. If the upgrade file is stored in an independent second area and the firmware file is run in the first area, even if an error or attack occurs during the upgrade process, the normal running firmware file will not be damaged, reducing the potential risk. If an accident or error occurs during the upgrade process, such as a power outage or network interruption, storing the upgrade file and the firmware file in different areas can provide fault tolerance. Even if an interruption occurs during the upgrade process, the firmware file still runs reliably without leaving the system in an unrecoverable state. In addition, by storing the upgrade file in an independent second area, a more flexible and reliable upgrade process can be achieved. The upgrade file can be downloaded to the second area and prepared for the upgrade without interrupting the operation of the system. Once the preparation is complete, the upgrade process can be triggered as needed, which can minimize the impact on the operation of the system. At the same time, storing the firmware file and the upgrade file in independent areas can better support the modularity and scalability of the system. For example, if a new function needs to be added to the system or a vulnerability needs to be fixed, the second area can be updated through the upgrade file without recompiling and replacing the entire firmware file, thereby simplifying the maintenance and upgrade process of the system.

[0056] S3: Verify the upgrade file. If the verification succeeds, change the execution flag to a first jump state. The first jump state is configured to instruct the loader to jump to the second area and read the upgrade file.

[0057] Specifically, the method for verifying the upgrade file includes: obtaining a sub-verification code and a total verification code; verifying multiple sub-upgrade files based on the sub-verification code; merging multiple sub-upgrade files to obtain an upgrade file, and verifying the upgrade file based on the total verification code. First, the current running program reads the contents of multiple sub-upgrade files one by one, and applies a pre-stored verification algorithm (such as a hash algorithm or a digital signature, etc.) to verify the multiple sub-upgrade files. The verification algorithm calculates the verification value of the sub-upgrade file (such as the verification result of the hash value or the digital signature); the current running program compares the calculated verification code with the obtained verification code. If the two values ​​match, it means that the sub-upgrade file has passed the verification. At this time, the current running program will merge the multiple sub-upgrade files to obtain the upgrade file, and use the total verification code and the same steps to verify the upgrade file. If the sub-upgrade file or the upgrade file fails to pass the verification, the current running program may terminate the upgrade process or take other specified error handling measures. If the upgrade file passes the verification, the current running program changes the execution identifier to the first jump state. This state indicates that the loader should jump to the second area and read the upgrade file. Based on the first jump state, the loader will transfer control to the corresponding position in the second area according to the predefined agreement. This process involves jump instructions or other appropriate mechanisms to ensure that the running program can jump smoothly from the first area to the second area. In the second area, the loader will read the contents of the upgrade file according to the format and specifications of the upgrade file. These contents may include instructions, data or other necessary information for the upgrade program to update or modify the relevant parts of the firmware.

[0058] In an embodiment of the present application, the method steps of verifying the verification code of the sub-upgrade file or the total verification code of the upgrade file using a hash algorithm include: inputting the verification code of the sub-upgrade file to be verified or the total verification code of the upgrade file into the hash algorithm. Using a specified hash algorithm to calculate the verification code or the total verification code to generate a hash value. The hash algorithm takes the verification code or the total verification code as input, and after a series of processing and operations, generates a hash value of a fixed length. Obtain the calculated hash value. The hash value is a unique, fixed-length string used to represent the verification code or the total verification code. Re-input the verification code or the total verification code to be verified into the hash algorithm, and calculate and generate a new hash value. Then, compare the new hash value with the previously calculated hash value. If the newly calculated hash value is exactly the same as the previously calculated hash value, it means that the verification is passed; if the hash values ​​are not equal, it means that the verification failed.

[0059] In an embodiment of the present application, the method steps of verifying the verification code of the sub-upgrade file or the total verification code of the upgrade file by using the digital signature method include: obtaining the verification code of the sub-upgrade file or the total verification code of the upgrade file and the corresponding digital signature. The verification code or the total verification code is the data to be verified, and the digital signature is the result of signing the data. The digital signature is usually a fixed-length string associated with the verification code or the total verification code. Obtain the public key of the publisher of the digital signature. The public key is the public part of a pair of keys generated using an asymmetric encryption algorithm. The public key is open to the public and is used to verify the authenticity and integrity of the digital signature. Use the public key to verify the digital signature. The verification steps are as follows: Use the public key of the publisher of the digital signature to decrypt or decode the digital signature to obtain a hash value. Perform the same hash operation on the verification code or the total verification code to generate a hash value that is the same as the hash value obtained by decryption / decoding. Compare whether the two hash values ​​are the same. If they are the same, the digital signature verification passes, indicating that the data is complete and has not been tampered with; if they are different, it means that the verification fails and the data may have been modified or tampered with.

[0060] like Figure 1 and Figure 2 As shown, in an embodiment of the present application, by verifying the upgrade file, its integrity and legitimacy can be verified to prevent unauthorized upgrades or malicious tampering. This helps to ensure the security and stability of the system. By judging by the verification results, errors or abnormalities in the upgrade file can be discovered in a timely manner, and corresponding error handling measures can be taken. This helps to avoid system failures or instability caused by erroneous upgrade files. By using execution identification and indication status, the behavior of the currently running program and the loader can be accurately controlled, and the upgrade process can be ensured to proceed as expected. This helps to improve the controllability and manageability of the upgrade process. Directing the loader to jump to the second area and read the upgrade file helps to achieve flexible maintenance and updating of the system.

[0061] In some other embodiments of the present application, the sub-verification code of the sub-upgrade file and the total verification code of the upgrade file may be pre-stored in the electronic device to improve the security of the electronic device upgrade process.

[0062] S4: After the electronic device system is reset, in response to the execution identifier being the first jump state, the execution identifier is changed to the first running state, and in response to the execution identifier being the first running state, jump to the second area to run the upgrade file, and the first running state is configured to characterize that the current running file is an upgrade file.

[0063] Specifically, when the loader reads that the execution identifier is the first jump state, the execution identifier is changed to the first running state, and then the loader jumps to the second area based on the first running state to read the upgrade file and start running the upgrade file. By changing the execution identifier, the current running file can be accurately identified as an upgrade file, which helps to identify the firmware version or update status currently used by the electronic device system. At the same time, by saving the configuration information of the first running state, the loader can correctly process and roll back to the running file before the upgrade after the system is restarted. This helps to avoid errors or abnormal situations during the upgrade process that cause the system to fail to operate normally.

[0064] S5: Determine that the upgrade file runs abnormally, and jump to the first area to run the firmware file.

[0065] Specifically, if it is determined that the upgrade file is running abnormally, the electronic device is reset. If the upgrade file is running abnormally, it means that an erroneous instruction, access rights problem or other running errors occurred during the upgrade process. At this time, the system in the electronic device starts the reset program, and the loader determines that the upgrade file is running abnormally when reading the execution identifier as the first running state, and then changes the execution identifier from the first running state to the second jump state. The loader jumps to the first area and changes the execution identifier to the second running state. The loader runs the firmware file after reading the execution identifier as the second running state. Among them, the second running state is configured to characterize that the current running file is a firmware file. This method can ensure that when an electronic device fails to upgrade, the running program can switch to the original firmware file to avoid the electronic device being unusable after an error in the upgrade file.

[0066] like Figure 1 and Figure 2As shown, in an embodiment of the present application, a method for determining that the upgrade file is running abnormally includes: obtaining a process signal representing the progress of the upgrade file; in response to the missing time of the process signal exceeding the process threshold, determining that the upgrade file is running abnormally. Specifically, the system program of the electronic device will regularly check the process signal of the upgrade file running. This process signal can be some status indicators, progress bars or other indication signals used to indicate the progress of the upgrade file running. The system program of the electronic device will monitor the response time of the process signal. This includes recording the arrival time of the process signal and calculating the time interval with the last arrival at the next check. If the system program of the electronic device does not receive the process signal in multiple consecutive cycles and reaches a preset process threshold, it can be determined that the upgrade file is running abnormally. Once it is determined that the upgrade file is running abnormally, the system program of the electronic device can take corresponding error handling measures, such as terminating the upgrade process, rolling back to the previous state or notifying the administrator. Among them, the process threshold can be a certain number of cycles or a progress percentage, which can be selected according to the actual situation. By monitoring the arrival of the process signal, the abnormality of the upgrade file running can be discovered in time. It helps to discover problems early and take corresponding measures to avoid further affecting the system and operation. By setting the process threshold and the missing time of the detection process signal, the system program of the electronic device can automatically determine the abnormality of the upgrade file operation. This reduces manual intervention and improves the efficiency of detecting abnormal operation. Therefore, by timely detecting and handling the abnormal operation of the upgrade file, the reliability and stability of the system can be improved. It helps to protect the system from potential problems and reduce the risk of system failure and instability.

[0067] like Figure 1 and Figure 2 As shown, in the embodiment of the present application, if there is no abnormality after the upgrade file is completely executed, such as no error instruction, access right problem or other operation error, it means that the upgrade of the electronic device is successful. At this time, the execution flag is changed to the first jump state to ensure that the electronic device can jump to the second area to run the upgrade file when it is subsequently powered on or reset.

[0068] like Figure 4As shown, in an embodiment of the present application, the main control chip of the electronic device also includes a third area, the third area is configured to store a loader, and the loader is configured as a program that the electronic device runs preferentially when it is turned on or reset; wherein the third area is independent of the first area and the second area. Specifically, the third area includes a Boot loader area, and the Boot loader area is an independent storage area specifically used to store the loader. The loader contains the key instructions and functions required for system startup, as well as the program code for controlling the startup and initialization of the device. Configuring the loader as the first step to execute when the electronic device is started can ensure that the system first runs the necessary initialization and configuration programs during the startup process. It helps to stabilize the startup of the device and initialize the correct function. By storing the loader in an independent third area, it can be separated and managed from other areas (such as firmware files and upgrade files). Thereby improving the modularity of the electronic device system components and facilitating the updating and maintenance of the loader. Storing the loader in an independent area helps to enhance the security of the system. Since the loader is the first step in the startup of the device, isolating it from other areas can prevent unauthorized access and modification, and improve the system's anti-attack capability. During the upgrade process, if an abnormality occurs in the upgrade file, it will not affect the operation of the loader in the third area, so that the electronic device can still execute the loader first when reset, thereby ensuring that the loader can jump to the first area to read and run the firmware file.

[0069] like Figure 3 As shown, in an embodiment of the present application, after the system of the electronic device is reset and restarted, the loader in the third area of ​​the main control chip runs first, and then the loader judges the state of the execution mark. For example, first judge whether the execution mark is the first jump state, if so, change the execution mark to the first running state, and then jump to the second area to run the upgrade file; if not, continue to judge whether the execution mark is the second jump state, if so, change the execution mark to the second running state, and then jump to the first area to run the firmware file; if not, continue to judge whether the execution mark is the first running state, if so, change the execution mark to the second jump state, and reset the system of the electronic device; if not, continue to judge whether the execution mark is the second running state, if so, change the execution mark to the first jump state, and then reset the system of the electronic device, and then end the program running, if not, also end the program running. By resetting the system of the electronic device and judging the execution mark, the system of the electronic device can be directed to jump to the corresponding area to execute the corresponding file, thereby avoiding abnormalities in the electronic device during the upgrade process that cause the electronic device to be unable to be used normally.

[0070] like Figure 4As shown, in an embodiment of the present application, the main control chip of the electronic device also includes a fourth area, the fourth area is independent of the first area, the second area and the third area, and the fourth area is configured to store execution identification and log files. Specifically, the fourth area is an independent storage area, which is specifically used to store execution identification and log files. The execution identification is a mark used to mark the current execution stage of the system program of the electronic device. The execution identification can be a specific value, a flag bit or other data used to identify the state of the device. The log file records information such as the operation, events and state changes of the device, and can provide detailed records and historical information during the operation of the device. By storing the fourth area independently of other areas, the execution identification and log files can be isolated from other programs and data. This helps to improve the modularity of the system, facilitate the management and update of execution identification and log files, improve the reliability and persistence of data, prevent data loss or overwriting, and ensure that the execution status and history of the device can be accessed and analyzed at any time.

[0071] like Figure 4 As shown, in an embodiment of the present application, the main control chip of the electronic device also includes a cache area, which is independent of the first area, the second area and the third area, and the cache area is configured to store data files. Specifically, the cache area is an independent storage area configured to specifically store data files. Data files may include configuration files, user data, temporary data, etc. of the device. These files may be key configuration files of the device, data files required for the application, data generated by the user, etc. Data files stored in the cache area can be quickly accessed and processed. By temporarily storing data files in the cache area, data access speed and response performance can be improved. In addition, by storing the cache area independently of other areas, data files can be isolated from other programs and system data. Independent management and protection of data can be improved to avoid data conflicts and accidental modifications.

[0072] like Figure 5As shown, the embodiment of the present application also provides an electronic device firmware upgrade device, including a receiving module, a storage module, a verification module, an execution identification module and a loading module; the receiving module is configured to receive the upgrade file sent by the host computer; the storage module is configured to determine that the firmware file is running in the first area, and the upgrade file is stored in the second area, wherein the firmware file is the current running file, and the first area and the second area are independent of each other; the verification module is configured to verify the upgrade file; the execution identification module includes a first jump state, a first running state and a second running state, the first jump state is configured to indicate that the loader jumps to the second area and reads the upgrade file, the first running state is configured to characterize the current running file as an upgrade file, and the second running state is configured to characterize the current running file as a firmware file; the loading module is configured to change the state of the execution identification module, and run the upgrade file or run the firmware file based on the state of the execution identification module. Specifically, the host computer sends the upgrade file to the electronic device through a medium (which can be Bluetooth, UART, USB, etc.); after receiving the upgrade file, the electronic device saves it in another area, such as the firmware file running in the first area, the upgrade file is saved in the second area; if the firmware file runs in the second area, the upgrade file is saved in the first area. After the electronic device receives the file, it verifies the upgrade file. If the verification is normal, the chip of the electronic device changes the state of the execution identification module to the area where the upgrade file is located, and then turns on the automatic reset of the electronic device. At this time, the system program of the electronic device starts running the loader from the Bootloader area. The loader first determines which area to jump to based on the state of the execution identification module, and then changes the state of the execution identification module to the running state of this area. If the execution identification module is read to indicate that it needs to jump to the first area, the state of the execution identification module is changed to run in the first area, and then the loader jumps to the first area to start running the upgrade file. If the execution identification module is read to indicate that it needs to jump to the second area, the state of the execution identification module is changed to run in the second area, and then the loader jumps to the second area to run the upgrade file. When the upgrade file starts running, and all initializations are completed without abnormalities, the state of the execution identification module is changed from the running state of the area where the upgrade file is located to the jumping state of the area where the upgrade file is located. If the upgrade file runs without abnormalities in the first area at this time, the state of the execution identification module is changed to jump to the first area.When the upgrade file starts to run, if an exception occurs in the upgrade file, the chip of the electronic device will automatically start the reset program. At this time, the status of the execution identification module is still the running status of this area. The loader reads that the status of the execution identification module is the running status and then jumps to another area to run. For example, if an exception occurs in the first area of ​​the upgrade file, after the system of the electronic device is reset, the loader in the Bootloader area is run first. The loader reads that the status of the execution identification module is the running status of the first area, then the status of the execution identification module is changed to the running status of the second area, and then jumps to the second area to run the firmware file, thereby automatically falling back to the old version of the firmware file for running, thereby playing the role of automatically recovering the program.

[0073] The embodiment of the present application also provides an electronic device, including a memory and a processor; the memory is used to store a computer program; the processor is used to implement the electronic device firmware upgrade method provided in any of the above embodiments when executing the computer program. Specifically, in the embodiment of the present application, the electronic device refers to various devices and products that use electronic technology to process, store and transmit information, and can realize various computing, communication, entertainment, image processing, audio processing and control functions. Therefore, the electronic devices referred to in the embodiment of the present application include but are not limited to styluses, smart phones, tablet computers, personal computers, smart watches, smart bracelets, digital cameras, printers and scanners, etc.

[0074] The above is a detailed introduction to an electronic device firmware upgrade method, device and electronic device provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the technical solution and its core idea of ​​the present application. Ordinary technicians in this field should understand that they can still modify the technical solutions recorded in the aforementioned embodiments, or replace some of the technical features therein with equivalents; and these modifications or replacements do not cause the essence of the corresponding technical solution to deviate from the scope of the technical solution of the embodiments of the present application.

Claims

1. A method for upgrading the firmware of an electronic device, characterized in that: The electronic device comprises a first area and a second area which are independent of each other; and the method comprises: Receive the upgrade file sent by the host computer; Determine that a firmware file is running in the first area, and store the upgrade file in the second area, wherein the firmware file is a currently running file; Verify the upgrade file, and if the verification is successful, change the execution flag to the first jump state; After the electronic device system is reset, in response to the execution identifier being the first jump state, changing the execution identifier to a first running state; In response to the execution identifier being the first running state, jumping to the second area to run the upgrade file; Determining that the upgrade file runs abnormally, jumping to the first area to run the firmware file; The first jump state is configured to instruct the loader to jump to the second area and read the upgrade file, and the first running state is configured to indicate that the current running file is the upgrade file; the method of determining that the upgrade file runs abnormally and jumping to the first area to run the firmware file includes: After determining that the upgrade file runs abnormally, resetting the system of the electronic device; In response to the execution identifier being the first running state, changing the execution identifier to a second jump state; In response to the execution identifier being the second jump state, jumping to the first area and changing the execution identifier to a second running state; The second running state is configured to indicate that the current running file is the firmware file; and the method for determining that the upgrade file is running abnormally includes: Obtaining a progress signal representing the running progress of the upgrade file; In response to the absence time of the process signal exceeding the process threshold, determining that the upgrade file is running abnormally; The process signal includes a status indicator, a progress bar or other indication signals for indicating the progress of the upgrade file operation; The process threshold includes the number of cycles or the progress percentage; The method further comprises: Determine that the upgrade file runs normally, change the execution identifier to the first jump state, and perform a system reset on the electronic device.

2. The method for upgrading the firmware of an electronic device according to claim 1, wherein: The method for receiving the upgrade file sent by the host computer includes: A plurality of sub-upgrade files are received one by one, wherein the plurality of sub-upgrade files are obtained by splitting the upgrade file by the host computer.

3. The method for upgrading the firmware of an electronic device according to claim 2, wherein: The method for verifying the upgrade file includes: Get the sub-check code and the total check code; Verifying the multiple sub-upgrade files based on the sub-verification code; The multiple sub-upgrade files are merged to obtain the upgrade file, and the upgrade file is verified based on the total verification code.

4. The method for upgrading the firmware of an electronic device according to claim 1, wherein: The electronic device further comprises a third area, wherein the third area is configured to store the loading program; The third area is independent of the first area and the second area.

5. The method for upgrading the firmware of an electronic device according to claim 4, wherein: The electronic device further includes a fourth area, which is independent of the first area, the second area and the third area, and is configured to store the execution identifier and the log file.

6. The method for upgrading the firmware of an electronic device according to claim 5, wherein: The electronic device further includes a cache area, which is independent of the first area, the second area, the third area and the fourth area, and is configured to store data files.

7. An electronic device firmware upgrade device, which uses the electronic device firmware upgrade method according to any one of claims 1 to 6 to upgrade, characterized in that: include: A receiving module, wherein the receiving module is configured to receive an upgrade file sent by a host computer; A storage module, wherein the storage module is configured to determine that a firmware file is running in a first area and store the upgrade file in a second area, wherein the firmware file is a currently running file, and the first area and the second area are independent of each other; A verification module, wherein the verification module is configured to verify the upgrade file; an execution identification module, the execution identification module comprising a first jump state, a first running state, and a second running state, the first jump state being configured to instruct the loader to jump to the second area and read the upgrade file, the first running state being configured to indicate that the current running file is the upgrade file, and the second running state being configured to indicate that the current running file is the firmware file; A loading module is configured to change the state of the execution identification module and run the upgrade file or the firmware file based on the state of the execution identification module.

8. An electronic device, characterized in that: It comprises a memory and a processor; the memory is used to store a computer program; the processor is used to implement the electronic device firmware upgrade method as described in any one of claims 1 to 6 when executing the computer program.

Citation Information

Patent Citations

  • Reliable firmware upgrading realizing method for distributed control system

    CN104007996A

  • Firmware upgrade method for stylus, terminal and stylus

    CN110352402A

  • 5G communication power supply firmware updating method and device

    CN113656061A

  • Firmware upgrade processing method and device, electronic equipment and storage medium

    CN115113904A

  • Data interaction method for multi-connection scene of handwriting pen, handwriting pen and Bluetooth system

    CN117135602A