Method for updating device firmware of a user and related device
By detecting the device through the user's computer operating system and simplifying device firmware upgrades using drivers and callback functions, the complexity of device firmware upgrades is solved, achieving rapid upgrades and cost savings.
Patent Information
- Application Number
- CN202110357075.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-01
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2041-04-01
AI Technical Summary
The current technology for upgrading device firmware is complex, which increases the complexity of the device hardware and software and requires a lot of manpower and resources.
The device is detected by the user's computer operating system, the driver is downloaded and installed, the target firmware file is located using the driver, and the upgrade conditions are detected by a callback function. The firmware file and upgrade instructions are sent to the target device only when the conditions are met, which simplifies the device firmware upgrade process.
It enables rapid firmware upgrades for devices, reduces unnecessary hardware and software redundancy in devices, saves manpower and resources, and improves product quality and reliability.
Smart Images

Figure CN115185553B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to methods and related equipment for updating user device firmware. Background Technology
[0002] Currently, most companies use a server setup and install a client on the device, which then queries the server to download firmware for updates. However, this method requires more complex work, increases manpower and material costs, and adds complexity to the equipment. The device needs internet connectivity to enable automatic program detection and download, further increasing the complexity of the device's hardware and software, making firmware upgrades on the device quite complex. Summary of the Invention
[0003] The purpose of this application is to propose a method and related equipment for updating a user's device firmware, so as to achieve rapid firmware updates and upgrades while avoiding the presence of many unnecessary hardware and software in the device.
[0004] To address the aforementioned technical problems, this application provides a method for updating a user's device firmware, employing the following technical solution:
[0005] A method for updating a user's device firmware includes the following steps:
[0006] The user's computer's operating system performs device detection. When the operating system detects any associated device, it takes the detected associated device as the target device and downloads and installs the driver from the update server.
[0007] The user's computer's operating system locates the target firmware file through the driver.
[0008] The user computer's operating system creates a device instance in the Device Manager through the driver and binds a firmware upgrade callback function. The firmware upgrade callback function is then activated to detect whether the current computer meets the upgrade conditions. If the current computer meets the upgrade conditions, the target firmware file and upgrade instructions are sent to the target device.
[0009] Furthermore, the step of the callback function that initiates the firmware upgrade checks whether the current computer meets the upgrade conditions, and when the current computer meets the upgrade conditions, sends the target firmware file and upgrade instructions to the target device, including:
[0010] The callback function for firmware upgrade is initiated, and the callback function is used to detect whether the current operating system is currently undergoing an update operation;
[0011] When the current operating system is undergoing an update operation, start a pre-created timer to periodically check whether the current operating system is undergoing an update operation based on a preset time interval;
[0012] If the current operating system has not been updated, the target firmware file is transferred to the target device, and an upgrade command is sent to the target device.
[0013] Furthermore, the step of the callback function that initiates the firmware upgrade checks whether the current computer meets the upgrade conditions, and when the current computer meets the upgrade conditions, sends the target firmware file and upgrade instructions to the target device, including:
[0014] The callback function for firmware upgrade is initiated. The callback function is used to detect whether the current operating system is currently performing an update operation, and to open the handle of the target device to check the status of the target device.
[0015] When the current operating system is undergoing an update or the target device is in a busy state, a pre-created timer is started to periodically detect whether the current operating system is undergoing an update and to detect the status of the target device based on a preset time interval.
[0016] When the current operating system has not been updated and the target device is in an idle state, compare whether the firmware version in the target device and the version of the target firmware file in the driver are consistent.
[0017] When the firmware version in the target device and the version of the target firmware file in the driver are inconsistent, the target firmware file and upgrade instructions are sent to the target device.
[0018] Furthermore, the step by which the operating system locates the target firmware file through the driver includes:
[0019] The operating system uses the driver to determine the driver's installation file;
[0020] Obtain the target file path and version number carried in the installation file of the driver;
[0021] The target firmware file was located based on the target file path and version number.
[0022] Furthermore, after the step of sending the target firmware file and upgrade instructions to the target device when the current computer meets the upgrade conditions, the method further includes:
[0023] The target device receives the target firmware file and upgrade instructions sent by the user computer and performs a device firmware upgrade operation.
[0024] Furthermore, the target device includes multiple system partitions and data partitions. The target device receives the target firmware file and upgrade instructions sent by the user computer, and the steps for performing the device firmware upgrade operation include:
[0025] The target device receives the target firmware file sent by the user computer and stores the target firmware file in the data partition;
[0026] The system partition of the target device during initial operation is detected and used as the initial partition;
[0027] The target firmware file is decompressed to a system partition other than the initial partition to obtain the target firmware, and the system partition where the target firmware is located is used as the target partition.
[0028] Run the target partition and determine its status after running. Based on the status of the target partition, determine the system partition to continue running.
[0029] Furthermore, the system partition includes a first system partition and a second system partition, and the step of decompressing the target firmware file to a system partition other than the initial partition to obtain the target firmware includes:
[0030] When the target device is initially running on the first system partition, the first system partition is used as the initial partition, and the target firmware file is decompressed to the second system partition to obtain the target firmware;
[0031] When the target device is initially running on the second system partition, the second system partition is used as the initial partition, and the target firmware file is decompressed into the first system partition to obtain the target firmware;
[0032] The steps of running the target partition, determining the state of the target partition after running, and determining the system partition to continue running based on the state of the target partition include:
[0033] The target device modifies the variables corresponding to the boot operation to direct the next run to the target partition where the target firmware is located;
[0034] Upon receiving a reboot command, the target device runs the target partition;
[0035] The target device determines whether the target partition, which is currently running, can boot normally;
[0036] If the target partition can boot normally, the target device upgrade is determined to be successful, and the target partition is then run.
[0037] If the target partition fails to start normally, the target device performs a device restart operation, pointing to the system partition where the target device was initially running.
[0038] This application provides an apparatus for updating a user's device firmware, the apparatus comprising a user computer, the user computer including:
[0039] The detection module is used to perform device detection operations. When the operating system detects any associated device, it will take the detected associated device as the target device and download and install the driver from the update server.
[0040] The search module is used to locate the target firmware file through the driver.
[0041] A creation module is used to create a device instance in the Device Manager through the driver, create a timer and bind a callback function for firmware upgrade, start the callback function for firmware upgrade to detect whether the current computer meets the upgrade conditions, and send the firmware file and upgrade instructions to the target device when the current computer meets the upgrade conditions.
[0042] To address the aforementioned technical problems, this application also provides a computer device that employs the following technical solution:
[0043] A computer device includes a memory and a processor, the memory storing computer-readable instructions, the processor executing the computer-readable instructions to implement the steps of the method for updating a user's device firmware described above.
[0044] To address the aforementioned technical problems, this application also provides a computer-readable storage medium, employing the technical solution described below:
[0045] A computer-readable storage medium storing computer-readable instructions that, when executed by a processor, implement the steps of the method for updating a user's device firmware described above.
[0046] Compared with the prior art, the embodiments of this application have the following main advantages:
[0047] This application simplifies the hardware and software implementation on the user's computer and device sides, saving manpower and resources, allowing the device to focus more on its core functions, and improving product quality and reliability. When an associated device is detected, it is designated as the target device, and a driver is loaded for it. The driver quickly locates the target firmware file, and a callback function detects the environment. When the environment meets the upgrade conditions, the target firmware file is transferred to the target device, enabling rapid firmware upgrades. With this application, the target device does not require additional upgrade software; it only needs to receive the target device firmware transmitted by the driver, reducing software redundancy in the target device while achieving rapid firmware upgrades. Attached Figure Description
[0048] To more clearly illustrate the solutions in this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0049] Figure 1 This is an exemplary system architecture diagram to which this application can be applied;
[0050] Figure 2 This is a flowchart of one embodiment of a method for updating a user's device firmware according to this application;
[0051] Figure 3 This is a schematic diagram of one embodiment of an apparatus for updating a user's device firmware according to this application;
[0052] Figure 4 This is a schematic diagram of the structure of one embodiment of the computer device according to this application.
[0053] Attached reference numerals: 101, Detection module; 102, Search module; 103, Creation module. Detailed Implementation
[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein in the specification of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having," and any variations thereof, in the specification, claims, and foregoing drawings of this application, are intended to cover non-exclusive inclusion. The terms "first," "second," etc., in the specification, claims, or foregoing drawings of this application are used to distinguish different objects, not to describe a particular order.
[0055] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0056] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
[0057] The method for updating a user's device firmware in this application is applied to a system for updating a user's device firmware, such as... Figure 1 As shown, the system architecture may include an update server, user computers, and devices. The update server and user computers are connected via a network, and the user computers and devices are connected via wired connections. For example, when the device is a USB device, the user computer and the USB device are connected via a USB cable. The network may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0058] It should be understood that Figure 1 The number of update servers, user computers, and devices shown is merely illustrative. Any number of update servers, user computers, and devices can be included depending on implementation needs.
[0059] This application supports automatic firmware upgrades for USB devices compatible with the Windows operating system. These devices are typically already sold and widely distributed in end-user computer environments, utilizing Windows drivers, Windows update mechanisms, and USB embedded devices. This application continuously improves product quality. Since these devices are already sold and widely distributed in multiple remote user computer environments, manual maintenance and upgrades are no longer feasible. To meet evolving customer needs and address issues found in older firmware, efficient firmware upgrades for end-user devices are required.
[0060] This application first establishes a connection between the Windows driver and the device to be upgraded. An extended driver installation file is created to generate a virtual driver specifically for the upgrade. The driver installation file is configured to point to the device ID (name) to be upgraded, specifying the path and version number of the target firmware file. Both the created target firmware file and the driver installation file are given the extension .inf (Device INFormationFile), and both are uploaded to the Windows Update server. Upon receiving the target firmware file and the driver installation file, the Windows Update server automatically opens the driver installation file on a suitable computer to install the driver, and simultaneously downloads the target firmware file to the user's computer via the Windows Update server. A suitable computer refers to a computer that meets the conditions for supporting the driver.
[0061] Continue to refer to Figure 2 A flowchart illustrating an embodiment of a method for updating a user's device firmware according to this application is shown. The method for updating a user's device firmware includes the following steps:
[0062] S1: The user's computer operating system performs device detection. When the operating system detects any associated device, it takes the detected associated device as the target device and downloads and installs the driver.
[0063] In this embodiment, the operating system refers to the Windows operating system. The operating system determines whether any detected device is an associated device based on the device ID, thereby avoiding situations where the corresponding firmware file cannot be found, thus preventing device firmware upgrades. The steps of downloading and installing the driver from the update server include: downloading and installing the driver from the update server, and registering device creation and uninstallation functions. In this application, the operating system performs a detection operation to determine whether a device is plugged into the computer. The following operations are implemented through the driver.
[0064] S2: The user's computer operating system locates the target firmware file through the driver.
[0065] In this embodiment, the operating system locates the target firmware file through the driver to facilitate subsequent device upgrade operations.
[0066] Specifically, the steps by which the operating system locates the target firmware file through the driver include:
[0067] The operating system uses the driver to determine the driver's installation file;
[0068] Obtain the target file path and version number carried in the installation file of the driver;
[0069] The target firmware file was located based on the target file path and version number.
[0070] In this embodiment, the target file path and version number are read from the registry of the driver's installation file and saved, thereby locating the target firmware file based on the target file path and version number.
[0071] S3: The user computer's operating system creates a device instance in the Device Manager through the driver and binds a firmware upgrade callback function. The firmware upgrade callback function is started to detect whether the current computer meets the upgrade conditions. If the current computer meets the upgrade conditions, the target firmware file and upgrade instructions are sent to the target device.
[0072] In this embodiment, the firmware upgrade callback function checks a series of conditions, and performs the upgrade if the conditions are met. After determining the target device, a device instance corresponding to the target device is created, and the name of the target device is saved.
[0073] Specifically, in step S3, the step of the callback function that initiates the firmware upgrade checks whether the current computer meets the upgrade conditions, and when the current computer meets the upgrade conditions, sends the target firmware file and upgrade instructions to the target device, including:
[0074] The callback function for firmware upgrade is initiated, and the callback function is used to detect whether the current operating system is currently undergoing an update operation;
[0075] When the current operating system is undergoing an update operation, start a pre-created timer to periodically check whether the current operating system is undergoing an update operation based on a preset time interval;
[0076] If the current operating system has not been updated, the target firmware file is transferred to the target device, and an upgrade command is sent to the target device.
[0077] In this embodiment, the preset time interval is 4 hours. That is, every 4 hours, a callback function checks whether the current operating system is undergoing an update. The callback function is a function called via a function pointer. If an update is in progress, it is generally not suitable to upgrade, and the condition check can be postponed for one of the specified time intervals, i.e., 4 hours later. If the current Windows operating system is not undergoing an update, the device communication channel is opened to read and write to the device, i.e., the target firmware file is transmitted to the target device and an upgrade command is sent.
[0078] Furthermore, in step S3, the step of the callback function that initiates the firmware upgrade checks whether the current computer meets the upgrade conditions, and when the current computer meets the upgrade conditions, sends the target firmware file and upgrade instructions to the target device, including:
[0079] The callback function for firmware upgrade is initiated. The callback function is used to detect whether the current operating system is currently performing an update operation, and to open the handle of the target device to check the status of the target device.
[0080] When the current operating system is undergoing an update or the target device is in a busy state, a pre-created timer is started to periodically detect whether the current operating system is undergoing an update and to detect the status of the target device based on a preset time interval.
[0081] When the current operating system has not been updated and the target device is in an idle state, compare whether the firmware version in the target device and the version of the target firmware file in the driver are consistent.
[0082] When the firmware version in the target device and the version of the target firmware file in the driver are inconsistent, the target firmware file and upgrade instructions are sent to the target device.
[0083] In this embodiment, the preset time interval is 4 hours. When the current operating system is undergoing an update or the target device is in a busy state, the handle of the target device is closed, and the detection is postponed until the next callback function execution. If the firmware version in the target device and the version of the target firmware file in the driver are consistent, it is determined that no upgrade is needed, the device handle is closed, the current callback function is exited, and the callback function will run again after 4 hours, that is, it will return to the steps of periodically checking whether the current operating system is undergoing an update and checking the status of the target device based on the preset time interval.
[0084] It should be noted that in this application, since the new version of the firmware file is uploaded irregularly, after this detection, the new version of the firmware file will still be uploaded, and the device firmware upgrade operation will still be required. Therefore, even after detecting that the current operating system has not been updated, the timer is still running, and it checks at regular intervals (once every 4 hours) whether the operating system is being updated.
[0085] Specifically, step S3, which involves sending the target firmware file and upgrade instructions to the target device, includes:
[0086] Obtain the name of the target device and store the name of the target device in the context of the device instance;
[0087] Use createfile (a versatile function) to open a file handle;
[0088] Call the WinUSB API to obtain the configuration, interface, and endpoint information of the target device, and store the configuration, interface, and endpoint information of the target device in the context of the device instance;
[0089] The target firmware file and upgrade instructions are sent to the target device based on the target device's name, configuration, interface, and endpoint information.
[0090] In this embodiment, the communication process between the Windows driver and the target device includes: after creating a device instance, the driver saves the target device name in the context of the device instance, uses `createfile` to open a file handle, calls the WinUSB API to obtain the target device's configuration, interface, and endpoint information, and saves this information in the context of the device instance for subsequent communication with the target device. The driver sends first data or instructions to the target device; after receiving the first data or instructions, the target device returns second data; the driver receives the second data returned by the target device and processes the second data according to the sent instructions. `createfile` is a multi-functional function that can open or create files or I / O devices and return an accessible handle. The WinUSB API is a pre-configured API interface. The first data can be the target firmware file, and the instruction is an upgrade instruction (ID_UPDT instruction). The second data is the upgrade result returned by the target device (ID_OKAY indicates success, ID_FAIL indicates failure). The target device can be a Windows operating system-compatible USB embedded device.
[0091] S4: The target device receives the target firmware file and upgrade command sent by the user computer and performs a device firmware upgrade operation.
[0092] In this embodiment, when the target device receives the target firmware file and upgrade command sent by the user computer through the driver, it performs a device firmware upgrade operation.
[0093] Specifically, the target device includes multiple system partitions and data partitions. The target device receives the target firmware file and upgrade instructions sent by the user computer, and the steps for performing the device firmware upgrade operation include:
[0094] The target device receives the target firmware file sent by the user computer and stores the target firmware file in the data partition;
[0095] The system partition of the target device during initial operation is detected and used as the initial partition;
[0096] The target firmware file is decompressed to a system partition other than the initial partition to obtain the target firmware, and the system partition where the target firmware is located is used as the target partition.
[0097] Run the target partition and determine its status after running. Based on the status of the target partition, determine the system partition to continue running.
[0098] In this embodiment, the target firmware file is decompressed to a system partition other than the initial partition to avoid interference with the original old firmware and to facilitate subsequent operation on the target partition.
[0099] The system partition includes a first system partition and a second system partition. The step of decompressing the target firmware file to a system partition other than the initial partition to obtain the target firmware includes:
[0100] When the system partition in which the target device is initially running is the first system partition, the first system partition is used as the initial partition, and the target firmware file is decompressed to the second system partition to obtain the target firmware;
[0101] When the target device is initially running on the second system partition, the second system partition is used as the initial partition, and the target firmware file is decompressed into the first system partition to obtain the target firmware;
[0102] The steps of running the target partition, determining the state of the target partition after running, and determining the system partition to continue running based on the state of the target partition include:
[0103] The target device modifies the variables corresponding to the boot operation to direct the next run to the target partition where the target firmware is located;
[0104] Upon receiving a reboot command, the target device runs the target partition;
[0105] The target device determines whether the target partition, which is currently running, can boot normally;
[0106] If the target partition can boot normally, the target device upgrade is determined to be successful, and the target partition is then run.
[0107] If the target partition fails to start normally, the target device performs a device restart operation, pointing to the system partition where the target device was initially running.
[0108] In this embodiment, the target device pre-creates four partitions: a boot partition, a first system partition (system partition A), a second system partition (system partition B), and a data partition. The boot partition is a pre-defined partition used for booting and contains files that support booting. When a reboot command is received, these files are used to support booting from multiple target partitions. The target device initially runs on either system partition A or B, and the target firmware file is extracted to either system partition B or A. Modified variables include the `bootFromAorB` variable; when this variable is set to A, booting occurs from A. If the target partition fails to boot normally, the upgrade is considered failed, and the target device performs a reboot, redirecting to the system partition where the target device initially runs.
[0109] The communication protocol between the driver and the target device is as follows. Communication command definitions: #define MKID(a,b,c,d)((a)|((b)<<8)|((c)<<16)|((d)<<24)); #define ID_VERN MKID('V','E','R','N') -- This command queries the current device firmware version; #define ID_FIRM MKID('F','I','R','M') -- This indicates preparation to send a firmware file to the device; #define ID_UPDT MKID('U','P','D','T') -- This indicates a request to the device to begin firmware upgrade; #define ID_DONE MKID('D','O','N','E') -- This indicates the device has returned that a certain operation has been completed; #define ID_DATA `MKID('D','A','T','A')` -- Indicates sending data packets, splitting large files into smaller packets for transmission; `#define ID_OKAY MKID('O','K','A','Y')` -- Indicates the device is ready to proceed to the next operation; `#define ID_FAIL MKID('F','A','I','L')` -- Indicates the device returned an operation failure; `#define ID_STAT MKID('S','T','A','T')` -- Indicates checking if the device is idle; `#define ID_RBOTMKID('R','B','O','T')` -- Indicates requesting a device restart. To query the device firmware version: send `ID_VERN` to the device, which will return the current device version number. To query the device's idle status: send `ID_STAT` to the device; the device will return `ID_OKAY` if idle, and `ID_FAIL` if busy. Sending firmware files to the device: Sending files involves 3 steps: (1) Send the ID_FIRM command to the device, along with the firmware file size and path information. The device will return ID_OKAY to indicate successful reception and ID_FAIL to indicate failure to receive the information; (2) If step (1) returns ID_OKAY, then send the ID_DATA command to indicate that the firmware file will be sent in packets. The device will return a status for each packet it receives. If it returns ID_OKAY, then continue sending the next packet. If it returns ID_FAIL, then the packet will be resent. (3) If the entire firmware file is sent, send ID_DONE to the device. After receiving this command, the device will verify the file and return ID_OKAY to indicate that the file was received correctly and ID_FAIL to indicate that the file was not received correctly.Send an upgrade command to the device: Send the ID_UPDT command. After receiving the command, the device will perform a firmware upgrade and return ID_OKAY to indicate success and ID_FAIL to indicate failure.
[0110] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware with computer-readable instructions. These computer-readable instructions can be stored in a computer-readable storage medium, and when executed, they can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).
[0111] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0112] Further reference Figure 3 As a response to the above Figure 2 The implementation of the method shown in this application provides an embodiment of an apparatus for updating a user's device firmware, which is similar to... Figure 2 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.
[0113] like Figure 3 As shown, the device 300 for updating a user's device firmware according to this embodiment includes a user computer and a target device.
[0114] The user computer includes a detection module 101, a search module 102, and a creation module 103. The detection module 101 performs device detection; when the operating system detects any associated device, it uses that device as the target device and downloads and installs the driver from the update server. The search module 102 locates the target firmware file using the driver. The creation module 103 creates a device instance in the device manager using the driver, creates a timer and binds it to a firmware upgrade callback function, initiates the firmware upgrade callback function to check if the current computer meets the upgrade conditions, and if so, sends the firmware file and upgrade instructions to the target device.
[0115] The target device is used to receive the firmware file and upgrade instructions sent by the driver and to perform a device firmware upgrade operation.
[0116] In this embodiment, the application simplifies the hardware and software implementation on the user's computer and device sides, saving manpower and resources, allowing the device to focus more on its core functions, and improving product quality and reliability. When an associated device is detected, it is designated as the target device, and a driver is loaded for it. The driver can quickly locate the target firmware file, and then a callback function is used to detect the environment. When the environment meets the upgrade conditions, the target firmware file is transmitted to the target device, enabling rapid firmware upgrades. With this application, the target device does not need to install additional configuration upgrade software; it only needs to receive the target device firmware transmitted by the driver, reducing software redundancy in the target device while achieving rapid firmware upgrades.
[0117] The search module 102 includes a determining submodule, an obtaining submodule, and a searching submodule. The determining submodule is used to determine the installation file of the driver based on the driver; the obtaining submodule is used to obtain the target file path and version number carried in the driver's installation file; and the searching submodule is used to find the target firmware file based on the target file path and version number.
[0118] The creation module 103 includes a startup submodule, a detection submodule, and a transmission submodule. The startup submodule initiates the firmware upgrade callback function and uses this function to detect whether the current operating system is currently undergoing an update operation. The detection submodule, when the current operating system is undergoing an update operation, starts a pre-created timer to periodically detect whether the current operating system is undergoing an update operation at preset time intervals. The transmission submodule, when the current operating system is not undergoing an update operation, transmits the target firmware file to the target device and sends an upgrade command to the target device.
[0119] The creation module 103 further includes an open submodule, a status detection submodule, a comparison submodule, and a send submodule. The open submodule is used to initiate the firmware upgrade callback function, which detects whether the current operating system is currently performing an update operation and opens the handle of the target device to check its status. The status detection submodule is used to periodically detect whether the current operating system is performing an update operation and to detect the status of the target device based on a pre-created timer at preset time intervals when the current operating system is performing an update operation or the target device is busy. The comparison submodule is used to compare the firmware version in the target device with the version of the target firmware file in the driver when the current operating system is not performing an update operation and the target device is idle. The send submodule is used to send the target firmware file and upgrade instructions to the target device when the firmware version in the target device and the version of the target firmware file in the driver are inconsistent.
[0120] The creation module 103 further includes a first storage submodule, a handle submodule, a second storage submodule, and a file sending submodule. The first storage submodule is used to obtain the name of the target device and store it in the context of the device instance; the handle submodule is used to open a file handle using createfile (a multi-functional function); the second storage submodule is used to call the WinUSB API to obtain the configuration, interface, and endpoint information of the target device and store it in the context of the device instance; the file sending submodule is used to send the target firmware file and upgrade instructions to the target device according to the target device's name, configuration, interface, and endpoint information.
[0121] The target device includes multiple system partitions and data partitions. The target device includes a receiving submodule, an initialization submodule, a decompression submodule, and a running submodule. The receiving submodule receives a target firmware file sent by a user computer and stores the target firmware file in the data partition. The initialization submodule detects the system partition where the target device is initially running and designates it as the initial partition. The decompression submodule decompresses the target firmware file to a system partition other than the initial partition to obtain the target firmware, and designates the system partition containing the target firmware as the target partition. The running submodule runs the target partition, determines the state of the target partition after running, and determines the system partition to continue running based on the state of the target partition.
[0122] The system partition includes a first system partition and a second system partition. The decompression submodule includes a first decompression unit and a second decompression unit. The first decompression unit is used to decompress the target firmware file into the second system partition when the target device's initial operating system partition is the first system partition, thereby obtaining the target firmware. The second decompression unit is used to decompress the target firmware file into the first system partition when the target device's initial operating system partition is the second system partition, thereby obtaining the target firmware.
[0123] The running submodule includes a modification unit, a running unit, a determining unit, a determining upgrade completion unit, and a restart unit. The modification unit is used by the target device to modify the variables corresponding to the boot operation so that the next run points to the target partition where the target firmware is located. The running unit is used by the target device to run the target partition when a restart command is received. The determining unit is used by the target device to determine whether the target partition being run can boot normally. The determining upgrade completion unit is used by the target device to determine that the upgrade is successful when the target partition can boot normally, and then run the target partition. The restart unit is used by the target device to perform a device restart operation when the target partition fails to boot normally, pointing to the system partition where the target device initially runs.
[0124] This application simplifies the hardware and software implementation on the user's computer and device sides, saving manpower and resources, allowing the device to focus more on its core functions, and improving product quality and reliability. When an associated device is detected, it is designated as the target device, and a driver is loaded for it. The driver quickly locates the target firmware file, and a callback function detects the environment. When the environment meets the upgrade conditions, the target firmware file is transferred to the target device, enabling rapid firmware upgrades. With this application, the target device does not require additional upgrade software; it only needs to receive the target device firmware transmitted by the driver, reducing software redundancy in the target device while achieving rapid firmware upgrades.
[0125] To address the aforementioned technical problems, embodiments of this application also provide a computer device. Please refer to [link / reference needed]. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0126] The computer device 200 includes a memory 201, a processor 202, and a network interface 203 that are interconnected via a system bus. It should be noted that only the computer device 200 with components 201-203 is shown in the figure; however, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Those skilled in the art will understand that the computer device described here is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0127] The computer device can be a desktop computer, laptop, handheld computer, or cloud server, etc. The computer device can interact with the user via a keyboard, mouse, remote control, touchpad, or voice control.
[0128] The memory 201 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 201 may be an internal storage unit of the computer device 200, such as the hard disk or memory of the computer device 200. In other embodiments, the memory 201 may also be an external storage device of the computer device 200, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. Of course, the memory 201 may also include both internal storage units and external storage devices of the computer device 200. In this embodiment, the memory 201 is typically used to store the operating system and various application software installed on the computer device 200, such as computer-readable instructions for updating the user's device firmware. Furthermore, the memory 201 can also be used to temporarily store various types of data that have been output or will be output.
[0129] In some embodiments, the processor 202 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 202 is typically used to control the overall operation of the computer device 200. In this embodiment, the processor 202 is used to execute computer-readable instructions stored in the memory 201 or to process data, such as executing computer-readable instructions for the method of updating the user's device firmware.
[0130] The network interface 203 may include a wireless network interface or a wired network interface, wherein the wired network interface includes a USB interface. The network interface 203 is typically used to establish a communication connection between the computer device 200 and other electronic devices.
[0131] In this embodiment, no additional upgrade software needs to be configured and installed on the target device, which reduces software redundancy on the target device while enabling rapid firmware upgrades.
[0132] This application also provides another embodiment, namely, providing a computer-readable storage medium storing computer-readable instructions that can be executed by at least one processor to cause the at least one processor to perform the steps of the method for updating a user's device firmware as described above.
[0133] In this embodiment, no additional upgrade software needs to be configured and installed on the target device, which reduces software redundancy on the target device while enabling rapid firmware upgrades.
[0134] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0135] Obviously, the embodiments described above are only some embodiments of this application, not all embodiments. The accompanying drawings show preferred embodiments of this application, but do not limit the patent scope of this application. This application can be implemented in many different forms; rather, the purpose of providing these embodiments is to provide a more thorough and comprehensive understanding of the disclosure of this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this application's specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the scope of patent protection of this application.
Claims
1. A method for updating a user's device firmware, characterized in that, Includes the following steps: The user's computer's operating system performs device detection. When the operating system detects any associated device, it takes the detected associated device as the target device and downloads and installs the driver from the update server. The user's computer's operating system locates the target firmware file through the driver. The user computer's operating system creates a device instance in the Device Manager through the driver and binds a firmware upgrade callback function. The firmware upgrade callback function is started to detect whether the current computer meets the upgrade conditions. If the current computer meets the upgrade conditions, the target firmware file and upgrade instructions are sent to the target device. The step of the callback function that initiates the firmware upgrade checks whether the current computer meets the upgrade conditions, and if the current computer meets the upgrade conditions, sends the target firmware file and upgrade instructions to the target device, including: The callback function for firmware upgrade is initiated. The callback function is used to detect whether the current operating system is currently performing an update operation, and to open the handle of the target device to check the status of the target device. When the current operating system is undergoing an update or the target device is in a busy state, a pre-created timer is started to periodically detect whether the current operating system is undergoing an update and to detect the status of the target device based on a preset time interval. When the current operating system has not been updated and the target device is in an idle state, compare whether the firmware version in the target device and the version of the target firmware file in the driver are consistent. When the firmware version in the target device and the version of the target firmware file in the driver are inconsistent, the target firmware file and upgrade instructions are sent to the target device. The step of sending the target firmware file and upgrade instructions to the target device includes: Obtain the name of the target device and store the name of the target device in the context of the device instance; Use versatile functions to open file handles; Call the pre-configured API interface to obtain the configuration, interface, and endpoint information of the target device, and save the configuration, interface, and endpoint information of the target device in the context of the device instance; The target firmware file and upgrade instructions are sent to the target device based on the target device's name, configuration, interface, and endpoint information.
2. The method for updating a user's device firmware according to claim 1, characterized in that, The step of the callback function that initiates the firmware upgrade checks whether the current computer meets the upgrade conditions, and when the current computer meets the upgrade conditions, sends the target firmware file and upgrade instructions to the target device, including: The callback function for firmware upgrade is initiated, and the callback function is used to detect whether the current operating system is currently undergoing an update operation; When the current operating system is undergoing an update operation, start a pre-created timer to periodically check whether the current operating system is undergoing an update operation based on a preset time interval; If the current operating system has not been updated, the target firmware file is transferred to the target device, and an upgrade command is sent to the target device.
3. The method for updating a user's device firmware according to claim 1, characterized in that, The steps by which the operating system locates the target firmware file through the driver include: The operating system uses the driver to determine the driver's installation file; Obtain the target file path and version number carried in the installation file of the driver; The target firmware file was located based on the target file path and version number.
4. The method for updating a user's device firmware according to claim 1, characterized in that, After the step of sending the target firmware file and upgrade instructions to the target device when the current computer meets the upgrade conditions, the method further includes: The target device receives the target firmware file and upgrade instructions sent by the user computer and performs a device firmware upgrade operation.
5. The method for updating a user's device firmware according to claim 4, characterized in that, The target device includes multiple system partitions and data partitions. The target device receives the target firmware file and upgrade instructions sent by the user computer, and the steps for performing the device firmware upgrade operation include: The target device receives the target firmware file sent by the user computer and stores the target firmware file in the data partition; The system partition of the target device during initial operation is detected and used as the initial partition; The target firmware file is decompressed to a system partition other than the initial partition to obtain the target firmware, and the system partition where the target firmware is located is used as the target partition. Run the target partition and determine its status after running. Based on the status of the target partition, determine the system partition to continue running.
6. The method for updating a user's device firmware according to claim 5, characterized in that, The system partition includes a first system partition and a second system partition. The step of decompressing the target firmware file to a system partition other than the initial partition to obtain the target firmware includes: When the target device is initially running on the first system partition, the first system partition is used as the initial partition, and the target firmware file is decompressed to the second system partition to obtain the target firmware; When the target device is initially running on the second system partition, the second system partition is used as the initial partition, and the target firmware file is decompressed into the first system partition to obtain the target firmware; The steps of running the target partition, determining the state of the target partition after running, and determining the system partition to continue running based on the state of the target partition include: The target device modifies the variables corresponding to the boot operation to direct the next run to the target partition where the target firmware is located; Upon receiving a reboot command, the target device runs the target partition; The target device determines whether the target partition, which is currently running, can boot normally; If the target partition can boot normally, the target device upgrade is determined to be successful, and the target partition is then run. If the target partition fails to start normally, the target device performs a device restart operation, pointing to the system partition where the target device was initially running.
7. An apparatus for updating a user's device firmware, characterized in that, The apparatus for updating the user's device firmware includes a user computer, the user computer comprising: The detection module is used to perform device detection operations. When the operating system detects any associated device, it will take the detected associated device as the target device and download and install the driver from the update server. The search module is used to locate the target firmware file using the driver. A creation module is used to create a device instance in the device manager through the driver, create a timer and bind a callback function for firmware upgrade, start the callback function for firmware upgrade to detect whether the current computer meets the upgrade conditions, and send the firmware file and upgrade instructions to the target device when the current computer meets the upgrade conditions. The creation module includes an opening submodule, a status detection submodule, a comparison submodule, and a sending submodule; The open submodule is used to start the callback function of the firmware upgrade, and the callback function detects whether the current operating system is performing an update operation, and opens the handle of the target device to check the status of the target device; The status detection submodule is used to start a pre-created timer when the current operating system is performing an update operation or the target device is in a busy state, and to periodically detect whether the current operating system is performing an update operation and to detect the status of the target device based on a preset time interval. The comparison submodule is used to compare whether the firmware version in the target device and the version of the target firmware file in the driver are consistent when the current operating system has not been updated and the target device is in an idle state. The sending submodule is used to send the target firmware file and upgrade instructions to the target device when the firmware version in the target device and the version of the target firmware file in the driver are inconsistent. The creation module further includes a first saving submodule, a handle submodule, a second saving submodule, and a file sending submodule: The first storage submodule is used to obtain the name of the target device and store the name of the target device in the context of the device instance; The handle submodule is used to open file handles using multi-functional functions; The second storage submodule is used to call a pre-configured API interface to obtain the configuration, interface, and endpoint information of the target device, and store the configuration, interface, and endpoint information of the target device in the context of the device instance; The file sending submodule is used to send the target firmware file and upgrade instructions to the target device according to the name of the target device, the configuration of the target device, the interface and endpoint information.
8. A computer device, characterized in that, The device includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor, when executing the computer-readable instructions, implements the steps of the method for updating a user's device firmware as claimed in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-readable instructions that, when executed by a processor, implement the steps of the method for updating a user's device firmware as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Wireless WIFI video equipment and firmware update method thereof
CN107608705A
Firmware upgrading method and device and computer readable storage medium
CN109669714A
Client updating progress monitoring method and system, storage medium and electronic equipment
CN111221547A
Equipment driving reloading method and device, equipment and storage medium
CN112328328A