Master-slave device local firmware upgrading method and device
By sending upgrade commands and determining the working mode through an external host computer, and using the Bootloader to perform local firmware upgrades, the applicability and storage performance requirements of existing embedded device upgrade solutions are solved, enabling efficient firmware upgrades for low-cost, resource-constrained devices.
Patent Information
- Application Number
- CN202611341159.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-01
- Publication Date
- 2026-11-24
AI Technical Summary
Existing master-slave embedded device upgrade solutions have low applicability, rely on network communication and high storage performance, cannot be applied to low-cost, resource-constrained devices, and have high management complexity.
By sending an upgrade start command to a pre-set external host computer, the host working mode and target upgrade object are determined. The bootloader is used to perform local firmware upgrades, which do not require device network connection or large-capacity storage, and realize local forwarding and updating of firmware files.
It reduces reliance on master and slave device storage and networking capabilities, simplifies the upgrade process, avoids the risk of hardware failure, and reduces management complexity.
Smart Images

Figure CN123157240A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method and apparatus for local firmware upgrade of master and slave devices, belonging to the field of embedded device firmware upgrade technology. Background Technology
[0002] Existing master-slave embedded device upgrade solutions generally suffer from two types of drawbacks: one type uses a remote cloud OTA architecture, where the host actively requests firmware from the cloud, relying on the device's own network communication capabilities, and the timing of the upgrade is determined by the device or cloud policies, making it unsuitable for mass production line burning or on-site upgrades by after-sales personnel; the other type sets up dual firmware backup partitions inside the device, relying on local storage to achieve automatic rollback in case of upgrade failure. This solution has high requirements for hardware storage space, and many low-cost, resource-constrained embedded hosts and slaves cannot be equipped with dual-partition storage, resulting in high hardware modification costs and increased firmware management complexity. Summary of the Invention
[0003] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method and apparatus for local firmware upgrade of master and slave devices. This method and apparatus can perform local firmware upgrades of master and slave devices based on upgrade start commands sent from an external host computer. It does not require the master and slave devices to have the ability to actively request from the external network, further reducing the requirements for the storage performance of master and slave devices. This solves the problems of low applicability of current master and slave embedded device upgrade schemes and high requirements for master and slave device network communication and storage performance.
[0004] To solve the above-mentioned technical problems, the present invention is implemented using the following technical solution: This invention provides a method for local firmware upgrade between master and slave devices, comprising: Obtain the upgrade start command and the firmware file to be upgraded sent by the preset external host computer; Based on the upgrade startup command, the host's operating mode and the target upgrade object are determined; wherein, the operating mode includes service execution mode and firmware loading mode; If the host is in firmware loading mode, the firmware file to be upgraded is forwarded to the Bootloader of the target upgrade object; wherein, the target upgrade object includes the host and the slave. Using the bootloader of the target upgrade object, the firmware file to be upgraded is updated to the program storage area of the target upgrade object, and the update result is obtained; Based on the update results, generate a feedback identifier; Send the feedback flag to the preset external host computer.
[0005] Furthermore, determining the host's operating mode and the target upgrade object based on the upgrade startup command includes: Based on the upgrade startup command, obtain the global flag and the target object identifier; Load global flags and target object identifiers into the host's program storage area to trigger the host reset mechanism; The global loading flag is checked. If the global loading flag is valid, the host is in firmware loading mode; otherwise, the host is in service execution mode. Based on the target object identifier, the target upgrade object is located as either a host or a slave device.
[0006] Furthermore, if the host is in firmware loading mode, forwarding the firmware file to be upgraded to the Bootloader of the target upgrade object includes: If the target upgrade object is the host, the firmware file to be upgraded will be forwarded to the host's bootloader; If the target device to be upgraded is a slave device, the firmware file to be upgraded is forwarded to the host's program storage area, and then forwarded from the host's program storage area to the slave device's bootloader.
[0007] Furthermore, if there are multiple slave devices, the firmware file to be upgraded and burned will be divided into firmware fragments corresponding to the multiple slave devices; The firmware fragments corresponding to multiple slave devices are forwarded to the host's program storage area, and then the firmware fragments are forwarded from the host's program storage area to the corresponding slave device's bootloader in turn.
[0008] Furthermore, the Bootloader of the target upgrade object updates the firmware file to be upgraded to the program storage area of the target upgrade object, obtaining the update result, including: If the target of the upgrade is the host, the host's bootloader will be used to burn the firmware file to be upgraded into the host's program storage area to obtain the update result.
[0009] Furthermore, the step of using the Bootloader of the target upgrade object to update the firmware file to be upgraded to the program storage area of the target upgrade object and obtain the update result also includes: If the target device for upgrade is a slave device, the slave device's bootloader is used to burn the firmware file to be upgraded into the slave device's program storage area to obtain the update result.
[0010] Furthermore, the step of generating a feedback identifier based on the update result includes: If the update is successful, a success feedback flag will be generated; Otherwise, generate a failure feedback flag.
[0011] Furthermore, after sending the feedback identifier to the preset external host computer, the host's working mode also needs to be updated based on the feedback identifier; The process of updating the host's operating mode based on the feedback identifier includes: If the preset external host computer receives a success feedback flag, the preset external host computer will send a global flag clearing command; According to the global flag clearing instruction, clear the global flags and target object identifier loaded in the host's program storage area.
[0012] Furthermore, the step of updating the host's operating mode based on the feedback identifier also includes: If the preset external host computer receives a failure feedback flag or does not receive a feedback flag, the preset external host computer will repeatedly send the upgrade start command and the firmware file to be upgraded until the preset external host computer can receive a success feedback flag.
[0013] In another aspect, the present invention provides a local firmware upgrade device for master and slave devices, comprising: The upgrade command and firmware acquisition module is used to acquire the upgrade start command and the firmware file to be upgraded sent by the preset external host computer; The working mode and upgrade target determination module is used to determine the working mode of the host and the target upgrade target based on the upgrade start command; wherein, the working mode includes the service execution mode and the firmware loading mode; The firmware forwarding module is used to forward the firmware file to be upgraded to the Bootloader of the target upgrade object if the host is in firmware loading mode; wherein, the target upgrade object includes the host and the slave. The firmware update module is used to update the firmware file to be upgraded to the program storage area of the target upgrade object using the bootloader of the target upgrade object, and obtain the update result. The feedback identifier generation module is used to generate feedback identifiers based on the update results; The feedback identifier forwarding module is used to send feedback identifiers to a preset external host computer.
[0014] Compared with the prior art, the beneficial effects achieved by the present invention are as follows: 1. This invention initiates firmware upgrades for the host or slave device based on an upgrade startup command sent by a preset external host computer, without relying on the host or slave device's own network capabilities to actively obtain the upgrade firmware. Moreover, after determining the host's operating mode and the target upgrade object, regardless of whether the target upgrade object is a host or a slave device, the upgrade firmware comes from the firmware file to be upgraded sent by the preset external host computer. By forwarding the firmware file to be upgraded to the Bootloader of the target upgrade object for update, the dependence on the host or slave device's own storage capabilities is reduced, and the target upgrade object does not need to have a large capacity of non-volatile storage. This solves the problems of low applicability of current master-slave embedded device upgrade schemes and high requirements for master-slave device network communication and storage performance.
[0015] 2. This invention loads a global flag in the program storage area by pre-setting an upgrade start command sent by an external host computer, thereby triggering a host reset mechanism. After reset, it uses the method of detecting whether the global flag is valid to determine whether to enter firmware loading mode, so as to achieve conflict-free switching between running and upgrade modes without manual intervention.
[0016] 3. In this invention, the success or failure of firmware upgrade is determined by obtaining feedback identifiers from a preset external host computer. The firmware resend and target object identifier clearing commands can both be sent through the preset external host computer, which can avoid unknown errors during the upgrade process that could brick the hardware and further reduce the complexity of the host software control logic. Attached Figure Description
[0017] Figure 1 This is a flowchart of a local firmware upgrade method for master and slave devices provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the device architecture in a master-slave device local firmware upgrade method provided in an embodiment of the present invention; Figure 3 This is a flowchart illustrating the process of determining the host's operating mode and the target upgrade object, provided in an embodiment of the present invention. Figure 4 This is a schematic diagram of a local firmware upgrade device for master and slave devices provided in an embodiment of the present invention. Detailed Implementation
[0018] The present invention will be further described below with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and should not be used to limit the scope of protection of the present invention. Example 1
[0019] like Figure 1 As shown, this embodiment provides a method for local firmware upgrade of master and slave devices, including: Step 1: Obtain the upgrade start command and the firmware file to be upgraded from the preset external host computer; specifically: like Figure 2 As shown in the figure, in this embodiment, the master-slave device includes a master and at least one slave connected to the master. n Indicates the first n Each slave device is electrically connected to the master device via an internal bus. Both the master and slave devices are microcontrollers or microprocessors with program storage areas and data interaction capabilities. Their program storage areas can only hold a single running firmware and do not have the conditions to divide independent backup partitions, such as A / B partitions or Boot / Backup partitions. There is no extra space for storing backup firmware. It should be noted that in this embodiment, the slave device is only connected to the host through the internal bus interface, and the host is only provided with an external communication interface for connecting to a preset external host computer. The external communication interface is electrically connected to the preset external host computer through a wired communication link. It is not required that the host or slave device have additional independent external communication capabilities. The external host computer is pre-configured to have the ability to access the firmware via the network. It has a built-in firmware storage area for storing firmware files to be upgraded and an upgrade management module for issuing upgrade start commands and making logical judgments.
[0020] like Figure 3 As shown, step 2, based on the upgrade startup command, determines the host's operating mode and the target upgrade object; specifically: the operating mode includes service execution mode and firmware loading mode; the target upgrade object includes the host and slave devices; Based on the upgrade startup command, obtain the global flag and the target object identifier; Load global flags and target object identifiers into the host's program storage area to trigger the host reset mechanism; Check the global flag. If the global flag is valid, the host is in firmware loading mode; otherwise, the host is in service execution mode. Based on the target object identifier, locate the target upgrade object as a host or slave device; It should be noted that the target object identifier is the ID or address corresponding to the master or slave device. The target upgrade object can be determined as the master or slave device based on the target object identifier. After the entire machine is powered on, both the master and slave devices default to the business execution mode, meaning that both the master and slave devices execute their respective business logic normally, such as data acquisition and control output. When production line or after-sales personnel need to upgrade equipment, the preset external host computer is connected to the host's external communication interface via a wired link. The preset external host computer can then send the upgrade start command and the firmware file to be upgraded to the host. In this embodiment, by loading the global flag bit, the hardware watchdog timeout reset can be triggered, forcing the whole machine to perform a software reset. After the reset starts, the global loading flag bit is detected. If the global loading flag bit is a specific value 0x5A, the global loading flag bit is valid. Then the host bootloader does not load the service firmware corresponding to the service execution mode, but jumps to the firmware loading mode. That is, the host is in the firmware loading mode at this time. The global flag and target object identifier occupy very little storage space, only 1 to 2 bytes in size, and do not occupy the program storage area.
[0021] Step 3: If the host is in firmware loading mode, forward the firmware file to be upgraded to the Bootloader of the target upgrade object; specifically; If the target upgrade object is the host, the firmware file to be upgraded will be forwarded to the host's bootloader; If the target device to be upgraded is a slave device, the firmware file to be upgraded is forwarded to the host's program storage area, and then the firmware file to be upgraded is forwarded from the host's program storage area to the slave device's bootloader. It should be noted that if there are multiple slave devices, the firmware file to be upgraded and burned is divided into firmware fragments corresponding to multiple slave devices; the firmware fragments corresponding to multiple slave devices are forwarded to the host's program storage area, and then the firmware fragments are forwarded from the host's program storage area to the corresponding slave device's bootloader in turn.
[0022] Step 4: Using the bootloader of the target upgrade object, update the firmware file to be upgraded to the program storage area of the target upgrade object, and obtain the update result; specifically: If the target of the upgrade is the host, the host's bootloader will be used to burn the firmware file to be upgraded into the host's program storage area to obtain the update result; If the target device for upgrade is a slave device, the slave device's bootloader is used to burn the firmware file to be upgraded into the slave device's program storage area to obtain the update result.
[0023] Step 5: Generate a feedback identifier based on the update results; specifically: If the update is successful, a success feedback flag will be generated; Otherwise, generate a failure feedback flag.
[0024] Step 6: Send the feedback flag to the preset external host computer; In this system, after the host completes firmware burning in the Bootloader, it directly reports a burning completion flag to the preset external host computer. The slave device burns the firmware into the local program storage area, and after burning is completed, it reports a burning completion flag to the preset external host computer through the host.
[0025] In this embodiment, after sending the feedback flag to the preset external host computer, it is also necessary to update the host's working mode based on the feedback flag, including: If the preset external host computer receives a success feedback flag, the preset external host computer will send a global flag clearing command; According to the global flag clearing instruction, clear the global flags and target object identifier loaded in the host's program storage area; If the preset external host computer receives a failure feedback flag or does not receive a feedback flag, the preset external host computer will repeatedly send the upgrade start command and the firmware file to be upgraded until the preset external host computer can receive a success feedback flag. Example 2
[0026] like Figure 4 As shown, this embodiment provides a local firmware upgrade device for master and slave devices, including: The upgrade command and firmware acquisition module is used to acquire the upgrade start command and the firmware file to be upgraded sent by the preset external host computer; The working mode and upgrade target determination module is used to determine the host's working mode and the target upgrade target based on the upgrade start command; wherein, the working mode includes the service execution mode and the firmware loading mode; The firmware forwarding module is used to forward the firmware file to be upgraded to the Bootloader of the target upgrade object if the host is in firmware loading mode; the target upgrade object includes the host and the slave. The firmware update module is used to update the firmware file to be upgraded to the program storage area of the target upgrade object using the bootloader of the target upgrade object, and obtain the update result. The feedback identifier generation module is used to generate feedback identifiers based on the update results; The feedback identifier forwarding module is used to send feedback identifiers to a preset external host computer.
[0027] The specific functions of each module described above are explained in the relevant content of the method in Embodiment 1, and will not be repeated here.
[0028] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage CD-ROMs, optical storage, etc.) containing computer-usable program code.
[0029] This invention is described with reference to flowchart illustrations of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each step in the flowchart can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing device, generate instructions for implementing the process. Figure 1 One or more processes or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0030] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 The function specified in one or more processes.
[0031] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 Steps of a specified function in one or more processes.
[0032] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims. All of these forms are within the protection scope of the present invention.
Claims
1. A method for local firmware upgrade between master and slave devices, characterized in that, include: Obtain the upgrade start command and the firmware file to be upgraded sent by the preset external host computer; Based on the upgrade startup command, the host's operating mode and the target upgrade object are determined; wherein, the operating mode includes service execution mode and firmware loading mode; If the host is in firmware loading mode, the firmware file to be upgraded is forwarded to the Bootloader of the target upgrade object; wherein, the target upgrade object includes the host and the slave. Using the bootloader of the target upgrade object, the firmware file to be upgraded is updated to the program storage area of the target upgrade object, and the update result is obtained; Based on the update results, generate a feedback identifier; Send the feedback flag to the preset external host computer.
2. The master-slave device local firmware upgrade method according to claim 1, characterized in that, The process of determining the host's operating mode and the target upgrade object based on the upgrade startup command includes: Based on the upgrade startup command, obtain the global flag and the target object identifier; Load global flags and target object identifiers into the host's program storage area to trigger the host reset mechanism; The global loading flag is checked. If the global loading flag is valid, the host is in firmware loading mode; otherwise, the host is in service execution mode. Based on the target object identifier, the target upgrade object is located as either a host or a slave device.
3. The master-slave device local firmware upgrade method according to claim 1, characterized in that, If the host is in firmware loading mode, the firmware file to be upgraded will be forwarded to the Bootloader of the target upgrade object, including: If the target upgrade object is the host, the firmware file to be upgraded will be forwarded to the host's bootloader; If the target device to be upgraded is a slave device, the firmware file to be upgraded is forwarded to the host's program storage area, and then forwarded from the host's program storage area to the slave device's bootloader.
4. The master-slave device local firmware upgrade method according to claim 3, characterized in that, If there are multiple slave devices, the firmware file to be upgraded and burned will be divided into firmware fragments corresponding to the multiple slave devices; The firmware fragments corresponding to multiple slave devices are forwarded to the host's program storage area, and then the firmware fragments are forwarded from the host's program storage area to the corresponding slave device's bootloader in turn.
5. The master-slave device local firmware upgrade method according to claim 1, characterized in that, The Bootloader of the target upgrade object updates the firmware file to be upgraded to the program storage area of the target upgrade object, and obtains the update result, including: If the target of the upgrade is the host, the host's bootloader will be used to burn the firmware file to be upgraded into the host's program storage area to obtain the update result.
6. The master-slave device local firmware upgrade method according to claim 1, characterized in that, The method of using the Bootloader of the target upgrade object to update the firmware file to be upgraded to the program storage area of the target upgrade object and obtain the update result also includes: If the target device for upgrade is a slave device, the slave device's bootloader is used to burn the firmware file to be upgraded into the slave device's program storage area to obtain the update result.
7. The master-slave device local firmware upgrade method according to claim 2, characterized in that, The step of generating a feedback identifier based on the update result includes: If the update is successful, a success feedback flag will be generated; Otherwise, generate a failure feedback flag.
8. The master-slave device local firmware upgrade method according to claim 7, characterized in that, After sending the feedback identifier to the preset external host computer, the host's working mode also needs to be updated based on the feedback identifier; The process of updating the host's operating mode based on the feedback identifier includes: If the preset external host computer receives a success feedback flag, the preset external host computer will send a global flag clearing command; According to the global flag clearing instruction, clear the global flags and target object identifier loaded in the host's program storage area.
9. The master-slave device local firmware upgrade method according to claim 7, characterized in that, The method of updating the host's operating mode based on the feedback identifier also includes: If the preset external host computer receives a failure feedback flag or does not receive a feedback flag, the preset external host computer will repeatedly send the upgrade start command and the firmware file to be upgraded until the preset external host computer can receive a success feedback flag.
10. A local firmware upgrade device for master and slave devices, characterized in that, include: The upgrade command and firmware acquisition module is used to acquire the upgrade start command and the firmware file to be upgraded sent by the preset external host computer; The working mode and upgrade target determination module is used to determine the working mode of the host and the target upgrade target based on the upgrade start command; wherein, the working mode includes the service execution mode and the firmware loading mode; The firmware forwarding module is used to forward the firmware file to be upgraded to the Bootloader of the target upgrade object if the host is in firmware loading mode; wherein, the target upgrade object includes the host and the slave. The firmware update module is used to update the firmware file to be upgraded to the program storage area of the target upgrade object using the bootloader of the target upgrade object, and obtain the update result. The feedback identifier generation module is used to generate feedback identifiers based on the update results; The feedback identifier forwarding module is used to send feedback identifiers to a preset external host computer.
