Firmware upgrading method, device and equipment and computer readable medium
By merging and burning the target firmware in the free partition of the micro control unit, the problem of traditional micro control unit upgrades taking up large space and the inability to run the original firmware is solved, achieving efficient and safe firmware upgrades, improving user experience and system availability.
Patent Information
- Application Number
- CN202410741210.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-08-30
AI Technical Summary
Upgrading traditional microcontroller units requires a large amount of storage space, and the original firmware program cannot run during the upgrade process, resulting in poor user experience.
By obtaining two upgraded firmware with different starting addresses and merging them, determine the free partition of the micro control unit, burn the merged target firmware to the partition, and set the jump address so that the micro control unit starts running from the new partition when it restarts. , to achieve efficient, safe, and stable firmware upgrades that do not require backup of the old version of firmware and do not affect the operation of the old version of the firmware.
It achieves efficient, safe, and stable firmware upgrades, avoids the problems of excessive space occupation and poor user experience during traditional upgrades, and improves system availability and user satisfaction.
Smart Images

Figure CN118567686A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a firmware upgrade method, device, equipment and computer-readable medium. Background Art
[0002] Firmware upgrade is a crucial link in existing technologies for embedded systems, portable devices and various smart hardware products. With the continuous advancement of technology and the rapid update of hardware environment, firmware upgrade has become a key means to meet user needs, optimize product performance, fix vulnerabilities and add new functions.
[0003] In the traditional MCU (Microcontroller Unit) upgrade, the firmware upgrade faces a series of challenges. First, the firmware upgrade usually takes up a large storage space. This is because an APP (Application) firmware needs to occupy both the running area and the backup area, resulting in a total space occupied twice as much as the firmware. Secondly, the high cost of use is also a significant problem. Since the size of the MCU's on-chip Flash is fixed, when a larger Flash space is needed, it is often necessary to replace the MCU or use off-chip Flash, and the read and write speed of the off-chip Flash is usually slow, affecting the overall performance of the system. In addition, poor user experience is also an issue that cannot be ignored during the firmware upgrade process. During the upgrade process, the area where the original APP is running will be erased, resulting in the original APP being unable to run during the upgrade. The user needs to wait for the update to be completed before continuing to use it, which undoubtedly reduces user satisfaction.
[0004] Currently, no effective solution has been proposed to address the problem that upgrading traditional microcontroller units requires a large amount of space and the original firmware program cannot run during the upgrade. Summary of the invention
[0005] The present application provides a firmware upgrade method, device, equipment and computer-readable medium to solve the technical problems that the upgrade of traditional micro control units requires a large space and the original firmware program cannot be run during the upgrade.
[0006] According to one aspect of an embodiment of the present application, the present application provides a firmware upgrade method, comprising: obtaining a target firmware, wherein the target firmware is obtained by merging upgrade firmwares of two different starting addresses, and the starting address is the starting address of a running partition of a microcontroller unit; determining a target partition that is currently in an idle state among the two running partitions of the microcontroller unit; determining a target upgrade firmware corresponding to the target partition in the target firmware; burning the target upgrade firmware into the target partition of the microcontroller unit, and setting a jump address to the starting address of the target partition, so that when the microcontroller unit is restarted, the target upgrade firmware is run from the starting address of the target partition.
[0007] Optionally, obtaining the target firmware includes: compiling the upgrade code with the starting address of the first running partition of the micro control unit to obtain the first upgrade firmware; compiling the upgrade code with the starting address of the second running partition of the micro control unit to obtain the second upgrade firmware; merging the first upgrade firmware with the second upgrade firmware to obtain the target firmware.
[0008] Optionally, merging the first upgrade firmware with the second upgrade firmware to obtain the target firmware includes: using a link compiler to link the first upgrade firmware with the second upgrade firmware, and inserting an identification mark at the boundary between the first upgrade firmware and the second upgrade firmware to distinguish the first upgrade firmware from the second upgrade firmware through the identification mark.
[0009] Optionally, determining the target partition that is currently in an idle state among the two running partitions of the microcontroller unit includes: reading data information in the information area of the flash memory of the microcontroller unit; if the data information indicates that the running partition that is currently in a running state in the microcontroller unit is the first running partition, determining the second running partition as the target partition; if the data information indicates that the running partition that is currently in a running state in the microcontroller unit is the second running partition, determining the first running partition as the target partition; if the data information indicates that the running partition that is currently in an idle state in the microcontroller unit is the first running partition, determining the first running partition as the target partition; if the data information indicates that the running partition that is currently in an idle state in the microcontroller unit is the second running partition, determining the second running partition as the target partition.
[0010] Optionally, the method further comprises: during the upgrade process of burning the target upgrade firmware in the target partition, continuing to run the old version firmware in the initial partition that is currently in operation, so as to continuously provide services during the upgrade process.
[0011] Optionally, the method further includes: if the target upgrade firmware is not successfully burned on the target partition of the micro control unit, keeping the jump address as the starting address of the initial partition so that when the micro control unit is restarted, the old version firmware is run from the starting address of the initial partition.
[0012] Optionally, the method also includes: when a version rollback instruction is received, or the target upgrade firmware cannot be run after the microcontroller unit is restarted, resetting the jump address to the starting address of the initial partition, so that when the microcontroller unit is restarted again, the old version of the firmware is run from the starting address of the initial partition.
[0013] According to another aspect of an embodiment of the present application, the present application provides a firmware upgrade device, including: an acquisition module, used to acquire a target firmware, wherein the target firmware is obtained by merging upgrade firmwares of two different starting addresses, and the starting address is the starting address of a running partition of a microcontroller unit; a partition determination module, used to determine a target partition that is currently in an idle state among the two running partitions of the microcontroller unit; a firmware determination module, used to determine a target upgrade firmware corresponding to the target partition in the target firmware; and an upgrade module, used to burn the target upgrade firmware into the target partition of the microcontroller unit, and set a jump address to the starting address of the target partition, so that when the microcontroller unit is restarted, the target upgrade firmware is run from the starting address of the target partition.
[0014] According to another aspect of an embodiment of the present application, the present application provides an electronic device, including a memory, a processor, a communication interface and a communication bus, wherein the memory stores a computer program that can be run on the processor, the memory and the processor communicate through the communication bus and the communication interface, and the steps of the above method are implemented when the processor executes the computer program.
[0015] According to another aspect of an embodiment of the present application, the present application also provides a computer-readable medium having a non-volatile program code executable by a processor, and the program code enables the processor to execute the above method.
[0016] The above technical solution provided by the embodiment of the present application has the following advantages compared with the related art:
[0017] The present application provides a firmware upgrade method, including: obtaining a target firmware, wherein the target firmware is obtained by merging upgrade firmwares of two different starting addresses, and the starting address is the starting address of the running partition of the microcontroller unit; determining the target partition that is currently in an idle state in the two running partitions of the microcontroller unit; determining the target upgrade firmware corresponding to the target partition in the target firmware; burning the target upgrade firmware into the target partition of the microcontroller unit, and setting the jump address to the starting address of the target partition, so that when the microcontroller unit is restarted, the target upgrade firmware starts to run from the starting address of the target partition. The present application realizes efficient, safe and stable firmware upgrade by merging two firmwares running in different partitions into one firmware, selecting an idle partition for burning the new version of firmware by arbitration by the upper computer, and finally setting the jump address to the starting address of the target partition where the new version of firmware is located, that is, there is no need to back up the old version of firmware, and it will not affect the operation of the old version of firmware in another running partition, solving the technical problems that the upgrade of the traditional microcontroller unit needs to occupy a large space and the original firmware program cannot run during the upgrade. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0020] Figure 1 A schematic diagram of an optional MCU Flash partition provided according to an embodiment of the present application;
[0021] Figure 2 A schematic diagram of an optional firmware upgrade method flow according to an embodiment of the present application;
[0022] Figure 3 A schematic diagram of an optional firmware upgrade success and failure processing provided according to an embodiment of the present application;
[0023] Figure 4 A schematic diagram of an optional firmware version rollback provided according to an embodiment of the present application;
[0024] Figure 5 A block diagram of an optional firmware upgrade device provided according to an embodiment of the present application;
[0025] Figure 6A schematic diagram of an optional electronic device structure provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0027] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present application and have no specific meaning. Therefore, "module" and "component" can be used interchangeably.
[0028] In order to solve the problems mentioned in the background technology, according to one aspect of the embodiments of the present application, an embodiment of a firmware upgrade method is provided, which can be executed by a host computer or by a host computer and a micro control unit. The firmware upgrade method relies on a specific micro control unit Flash partitioning method, such as Figure 1 As shown, the Flash of the microcontroller unit is divided into a boot area BOOT, a first operation partition APP1, a second operation partition APP2 and an information area Information, wherein the first operation partition APP1 and the second operation partition APP2 are not used at the same time, and the first operation partition APP1 and the second operation partition APP2 have different starting addresses, corresponding to different operation starting points after the microcontroller unit is started. Figure 2 As shown, the firmware upgrade method may include the following steps:
[0029] Step S202, obtaining a target firmware, wherein the target firmware is obtained by merging two upgrade firmwares with different starting addresses, and the starting address is the starting address of the running partition of the micro control unit;
[0030] Step S204, determining a target partition that is currently in an idle state among the two running partitions of the micro control unit;
[0031] Step S206, determining a target upgrade firmware corresponding to the target partition in the target firmware;
[0032] Step S208, burning the target upgrade firmware into the target partition of the micro control unit, and setting the jump address to the start address of the target partition, so that when the micro control unit is restarted, the target upgrade firmware starts to run from the start address of the target partition.
[0033] Through steps S202 to S208, the present application merges two firmwares running in different partitions into one firmware, selects an idle partition by arbitration by the upper computer to burn the new version of the firmware, and finally sets the jump address to the starting address of the target partition where the new version of the firmware is located, thereby achieving efficient, safe and stable firmware upgrades. That is, there is no need to back up the old version of the firmware, and it will not affect the operation of the old version of the firmware in another running partition. This solves the technical problems that the upgrade of traditional micro control units requires a large space and the original firmware program cannot run during the upgrade.
[0034] In step S202, the target firmware is obtained by merging two upgrade firmwares with different starting addresses. The functions of the two upgrade firmwares are exactly the same, but the difference is that the two run in different areas. Therefore, if the first running partition of the micro control unit is running, the upgrade firmware corresponding to the second running partition is burned to the second running partition for upgrading. Conversely, if the second running partition of the micro control unit is running, the upgrade firmware corresponding to the first running partition is burned to the first running partition for upgrading. In short, the method of merging two firmwares running in different partitions into one firmware for selective upgrading can eliminate the need to back up the old version of the firmware and will not affect the operation of the old version of the firmware in another running partition.
[0035] In an optional embodiment, the acquiring the target firmware includes:
[0036] Step 1, compile the upgrade code with the starting address of the first running partition of the micro control unit to obtain the first upgrade firmware;
[0037] Step 2, compiling the upgrade code with the starting address of the second running partition of the micro control unit to obtain a second upgrade firmware;
[0038] Step 3: merge the first upgrade firmware and the second upgrade firmware to obtain the target firmware.
[0039] In the embodiment of the present application, the target firmware is obtained in the compilation stage. The compilation stage is the process of converting the source code to generate machine code that can run on the target hardware. In this process, the setting of the project file will directly affect the size of the final generated firmware and its position in Flash. In the compilation stage, by modifying the ROM settings in the project file, including the start address (Start address) and size (Size), the developer can control the specific location and layout of the software code in the MCU Flash. When the start address of the ROM is different, the compiler will recalculate the address offset of all code and data according to this new start address. This includes the addresses of functions and variables, the target address of jump instructions, etc. Therefore, even if the source code is exactly the same, the firmware compiled with different start addresses will be different because their internal address references have changed. Similarly, after being burned into the MCU, the MCU will execute the code according to the address information in the firmware. When the location of the firmware in Flash changes, the offset address of the MCU jump instruction will also change accordingly. This means that when the MCU starts or performs a specific jump operation, it will jump to the correct execution point according to the actual location of the firmware in Flash.
[0040] Therefore, in the present application, an upgrade firmware can be compiled for the first operation partition and the second operation partition of the microcontroller, that is, the upgrade code (i.e., the new software code that needs to be updated to the MCU) is compiled based on the starting address of the first operation partition using a compiler. The compilation process converts the source code into machine code and ensures that all functions, variables, and jump instructions are correctly mapped to the specified memory address. In this way, what is obtained after the compilation is completed is the first upgrade firmware that matches the first operation partition. The compiler is also used to compile the upgrade code based on the starting address of the second operation partition. What is obtained after the compilation is completed is the second upgrade firmware that matches the second operation partition.
[0041] In the embodiment of the present application, since the design does not require BOOT to determine the upgrade firmware, but instead leaves it to the host computer for processing, it is necessary to merge the first upgrade firmware and the second upgrade firmware, and then the host computer selects the appropriate upgrade firmware based on the partition operation status of the microcontroller unit.
[0042] In an optional embodiment, merging the first upgrade firmware and the second upgrade firmware to obtain the target firmware includes:
[0043] The first upgrade firmware and the second upgrade firmware are linked by using a link compiler, and an identification mark is inserted at a boundary between the first upgrade firmware and the second upgrade firmware to distinguish the first upgrade firmware from the second upgrade firmware by the identification mark.
[0044] In the embodiment of the present application, a link compiler such as gcc or armcc can be used to link the two versions of firmware together. An identification mark can also be inserted at the boundary between the two versions to facilitate the distinction between the two versions of firmware after the upper computer arbitration is completed.
[0045] In step S204, the host computer can check the status of the two running partitions of the MCU to determine which partition is currently in an idle state. Selecting the idle partition as the target partition for upgrading can ensure that the running programs will not be interfered with during the upgrade process, thereby avoiding system crashes or data loss, and will not affect the normal use of users, without having to wait for the update to be completed before continuing to use.
[0046] In an optional embodiment, determining the target partition that is currently in an idle state among the two running partitions of the micro control unit includes:
[0047] Reading data information in the information area of the flash memory of the micro control unit;
[0048] If the data information indicates that the running partition currently in the running state in the micro control unit is the first running partition, determining the second running partition as the target partition;
[0049] If the data information indicates that the running partition currently in the running state in the micro control unit is the second running partition, determining the first running partition as the target partition;
[0050] If the data information indicates that the running partition currently in the idle state in the micro control unit is the first running partition, determining the first running partition as the target partition;
[0051] If the data information indicates that the running partition currently in the idle state in the micro control unit is the second running partition, the second running partition is determined to be the target partition.
[0052] In the present application embodiment, Figure 1 As shown in the figure, an information area is defined in the MCU's Flash to record the currently running APP partition or the currently idle APP partition. In this way, the host computer can determine which running partition is in an idle state through the data information in the information area, and then select the partition for upgrade.
[0053] In step S206, once the target partition is determined, the upgrade firmware corresponding to the partition needs to be found in the target firmware. Since the target firmware is formed by merging two upgrade firmwares with different starting addresses, we need to identify and extract the correct upgrade firmware according to the starting address of the target partition, or we can distinguish the two versions of firmware according to the identification mark inserted at the boundary of the two versions.
[0054] In step S208, the host computer can burn the extracted target upgrade firmware into the target partition of the MCU. The burning process usually involves converting the firmware file into machine code that the MCU can understand and writing it to a specified memory address. At the same time, in order to ensure that the MCU can start running from the new upgrade firmware when it is restarted, it is also necessary to set the jump address to the starting address of the target partition. In this way, when the MCU is restarted, the MCU will start executing code from the starting address of the target partition to run the new upgrade firmware.
[0055] In an optional embodiment, the method further includes: during the upgrade process of burning the target upgrade firmware in the target partition, continuing to run the old version firmware in the initial partition that is currently in operation, so as to continuously provide services during the upgrade process.
[0056] When a traditional MCU is upgraded, the area where the original APP is running is erased, so the original APP cannot run during the upgrade, and the user needs to wait for the update to be completed before continuing to use it.
[0057] In the embodiment of the present application, by separating the upgrade operation from the normal operation of the system, the firmware update can be performed while the system is running normally. Specifically, when the target partition is determined and the target upgrade firmware is ready to be burned, the system will not immediately stop the currently running service. On the contrary, the system will continue to run the old version of the firmware on the initial partition that is currently in operation. The advantage of doing this is that the system can continue to provide services and the user will not notice any interruption or delay. At the same time, it is safe to perform the firmware upgrade operation on the target partition because the two partitions are independent of each other, and the operation of one partition will not affect the other partition. Therefore, even if any problems or errors occur during the upgrade process, the old version of the firmware that is running will not be affected, and the system can still maintain stable operation. Once the target upgrade firmware is successfully burned to the target partition, the system can switch to the new firmware version at the right time (for example, when the system is restarted or according to a predetermined maintenance window) so that it can be executed from the new firmware version at the next startup.
[0058] Through this method, the present application can not only achieve seamless firmware upgrades, but also maintain service continuity during the upgrade process, thereby improving system availability and user experience.
[0059] In an optional embodiment, the method also includes: if the target upgrade firmware is not successfully burned on the target partition of the microcontroller unit, keeping the jump address as the starting address of the initial partition so that when the microcontroller unit is restarted, the old version of the firmware is run from the starting address of the initial partition.
[0060] In the embodiment of the present application, since there is no need to erase the old version firmware of the initial partition, there is no need to back up the old version firmware. Even when the target upgrade firmware fails to be successfully burned, the running address can be kept without jumping and the old version firmware can continue to run to continue providing services without affecting the system.
[0061] In an optional embodiment, the method also includes: when a version rollback instruction is received, or the target upgrade firmware cannot be run after the microcontroller unit is restarted, the jump address is reset to the starting address of the initial partition, so that when the microcontroller unit is restarted again, the old version of the firmware is run from the starting address of the initial partition.
[0062] This application provides a version rollback and error recovery mechanism to ensure that when problems occur during firmware upgrade, the system can be restored to the previous stable version, thereby avoiding potential system failures or data loss.
[0063] In the embodiment of the present application, when the user or system administrator finds that the newly upgraded firmware has problems, such as performance degradation, poor stability or security vulnerabilities, the user or system administrator may choose to roll back to the previous firmware version. In the present application, since the two APP running partitions are alternately used as the running partitions of the new version of the firmware, that is, at the same time, one APP running partition stores the new version of the firmware, and the other APP running partition stores the old version of the firmware, then it can be rolled back to the old version of the firmware by directly jumping to the address. Therefore, when the version is rolled back, the present application can directly change the starting address of the APP running from the upgraded partition back to the address of another partition to achieve version rollback, which saves the steps and time of moving the code, and also saves the space required for backup.
[0064] Combine the following Figure 3 and Figure 4 The firmware upgrade method and rollback method provided in this application are explained.
[0065] like Figure 3As shown, the initial partition currently running in the microcontroller unit is the partition where APP2 is located, and the current running address is the starting address of the partition where APP2 is located. When the firmware is upgraded, the partition where APP1 is located is selected as the target partition, and APP2 and its partition are not affected during the upgrade process. When the upgrade is successful, APP1 is replaced by APP3, and the jump address is set to the starting address of the partition where APP3 is located. When the upgrade fails due to damage to APP3 or write errors, keeping the running address unchanged as the starting address of the partition where APP2 is located will not have any impact on APP2, and can maximize the use of Flash space. At the same time, since no backup is required, backup time is saved, saving time and effort, and simplifying the overall system architecture, making the system architecture logic during the entire upgrade clearer and more concise.
[0066] like Figure 4 As shown in the figure, if the new version of the firmware after the upgrade is APP2, the running address is the starting address of the partition where APP2 is located. When the version needs to be rolled back, the running address can be directly set to the starting address of the partition where the old version of the firmware, that is, APP1, is located. Then, after the microcontroller unit is restarted, APP1 can be started from the starting address of the partition where APP1 is located, thereby saving the steps and time of moving the code, and also saving the space required for backup.
[0067] In summary, in terms of application development, this application can compile two versions of firmware scripts and synthesized firmware scripts, which can be generated with one click after they are written. In terms of MCU upgrades, BOOT does not require arbitration firmware, it only needs to interact with the host computer to transmit information, and the host computer automatically arbitrates. In terms of user experience, the user's perception of the upgrade is almost minimized, and non-intrusive upgrades can be achieved. In terms of cost savings, this solution can save nearly half of the MCU's internal Flash space, which can significantly reduce costs and increase profits. In terms of system architecture, the lightweight BOOT program makes the division of labor of the entire system architecture clearer, making the entire framework logic clearer and concise.
[0068] According to another aspect of the embodiment of the present application, Figure 5 As shown, a firmware upgrade device is provided, comprising:
[0069] The acquisition module 501 is used to acquire the target firmware, wherein the target firmware is obtained by merging two upgrade firmwares with different starting addresses, and the starting address is the starting address of the running partition of the micro control unit;
[0070] A partition determination module 503, used to determine a target partition that is currently in an idle state among the two running partitions of the micro control unit;
[0071] A firmware determination module 505, configured to determine a target upgrade firmware corresponding to the target partition in the target firmware;
[0072] The upgrade module 507 is used to burn the target upgrade firmware into the target partition of the micro control unit and set the jump address to the starting address of the target partition so that when the micro control unit is restarted, the target upgrade firmware starts to run from the starting address of the target partition.
[0073] It should be noted that the acquisition module 501 in this embodiment can be used to execute step S202 in the embodiment of the present application, the partition determination module 503 in this embodiment can be used to execute step S204 in the embodiment of the present application, the firmware determination module 505 in this embodiment can be used to execute step S206 in the embodiment of the present application, and the upgrade module 507 in this embodiment can be used to execute step S208 in the embodiment of the present application.
[0074] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be implemented by software or hardware.
[0075] Optionally, the acquisition module is specifically used to: compile the upgrade code with the starting address of the first running partition of the micro control unit to obtain the first upgrade firmware; compile the upgrade code with the starting address of the second running partition of the micro control unit to obtain the second upgrade firmware; merge the first upgrade firmware with the second upgrade firmware to obtain the target firmware.
[0076] Optionally, the acquisition module is further used to: use a link compiler to link the first upgrade firmware and the second upgrade firmware, and insert an identification mark at the boundary between the first upgrade firmware and the second upgrade firmware to distinguish the first upgrade firmware from the second upgrade firmware through the identification mark.
[0077] Optionally, the partition determination module is specifically used to: read data information in the information area of the flash memory of the microcontroller unit; if the data information indicates that the running partition currently in the running state in the microcontroller unit is the first running partition, determine the second running partition as the target partition; if the data information indicates that the running partition currently in the running state in the microcontroller unit is the second running partition, determine the first running partition as the target partition; if the data information indicates that the running partition currently in the idle state in the microcontroller unit is the first running partition, determine the first running partition as the target partition; if the data information indicates that the running partition currently in the idle state in the microcontroller unit is the second running partition, determine the second running partition as the target partition.
[0078] Optionally, the firmware upgrade device further includes a continuous service module, which is used to: during the upgrade process of burning the target upgrade firmware in the target partition, continue to run the old version firmware in the initial partition that is currently in operation, so as to continuously provide services during the upgrade process.
[0079] Optionally, the firmware upgrade device also includes a failure processing module, which is used to: if the target upgrade firmware is not successfully burned on the target partition of the micro control unit, keep the jump address as the starting address of the initial partition, so that when the micro control unit is restarted, the old version of the firmware will be run from the starting address of the initial partition.
[0080] Optionally, the firmware upgrade device also includes a rollback module, which is used to: when a version rollback instruction is received, or the target upgrade firmware cannot be run after the micro control unit is restarted, reset the jump address to the starting address of the initial partition, so that when the micro control unit is restarted again, the old version of the firmware will be run from the starting address of the initial partition.
[0081] According to another aspect of the embodiments of the present application, the present application provides an electronic device, such as Figure 6 As shown, it includes a memory 601, a processor 603, a communication interface 605 and a communication bus 607. The memory 601 stores a computer program that can be run on the processor 603. The memory 601 and the processor 603 communicate through the communication interface 605 and the communication bus 607. When the processor 603 executes the computer program, the steps of the above method are implemented.
[0082] The memory and processor in the above electronic device communicate via a communication bus and a communication interface. The communication bus may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus may be divided into an address bus, a data bus, a control bus, etc.
[0083] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0084] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0085] According to another aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps of any of the above embodiments.
[0086] Optionally, in an embodiment of the present application, the computer-readable medium is configured to store program codes for the processor to perform the following steps:
[0087] Obtaining a target firmware, wherein the target firmware is obtained by merging two upgrade firmwares with different starting addresses, and the starting address is the starting address of the running partition of the micro control unit;
[0088] Determine a target partition that is currently in an idle state among two running partitions of the micro control unit;
[0089] Determining a target upgrade firmware corresponding to the target partition in the target firmware;
[0090] The target upgrade firmware is burned into the target partition of the micro control unit, and the jump address is set to the starting address of the target partition, so that when the micro control unit is restarted, the target upgrade firmware starts to run from the starting address of the target partition.
[0091] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.
[0092] When the embodiments of the present application are specifically implemented, reference may be made to the above-mentioned embodiments, which have corresponding technical effects.
[0093] It is understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application, or a combination thereof.
[0094] For software implementation, the technology described herein can be implemented by a unit that performs the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0095] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0096] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0097] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0098] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0099] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0100] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a ROM, a RAM, a magnetic disk or an optical disk. It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such a process, method, article or device. Without more constraints, an element defined by the phrase "comprising a..." does not exclude the existence of other identical elements in the process, method, article or apparatus comprising the element.
[0101] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A firmware upgrade method, characterized in that: include: Obtaining a target firmware, wherein the target firmware is obtained by merging two upgrade firmwares with different starting addresses, and the starting address is the starting address of the running partition of the micro control unit; Determine a target partition that is currently in an idle state among two running partitions of the micro control unit; Determining a target upgrade firmware corresponding to the target partition in the target firmware; The target upgrade firmware is burned into the target partition of the micro control unit, and the jump address is set to the starting address of the target partition, so that when the micro control unit is restarted, the target upgrade firmware starts to run from the starting address of the target partition.
2. The method according to claim 1, characterized in that: The obtaining of the target firmware comprises: Compiling the upgrade code with the starting address of the first running partition of the micro control unit to obtain the first upgrade firmware; Compiling the upgrade code with the starting address of the second running partition of the micro control unit to obtain a second upgrade firmware; The first upgrade firmware and the second upgrade firmware are merged to obtain the target firmware.
3. The method according to claim 2, characterized in that The merging the first upgrade firmware and the second upgrade firmware to obtain the target firmware includes: The first upgrade firmware and the second upgrade firmware are linked by using a link compiler, and an identification mark is inserted at a boundary between the first upgrade firmware and the second upgrade firmware to distinguish the first upgrade firmware from the second upgrade firmware by the identification mark.
4. The method according to claim 2, characterized in that: The step of determining a target partition that is currently in an idle state among the two running partitions of the micro control unit comprises: Reading data information in the information area of the flash memory of the micro control unit; If the data information indicates that the running partition currently in the running state in the micro control unit is the first running partition, determining the second running partition as the target partition; If the data information indicates that the running partition currently in the running state in the micro control unit is the second running partition, determining the first running partition as the target partition; If the data information indicates that the running partition currently in the idle state in the micro control unit is the first running partition, determining the first running partition as the target partition; If the data information indicates that the running partition currently in the idle state in the micro control unit is the second running partition, the second running partition is determined to be the target partition.
5. The method according to claim 1, characterized in that: The method further comprises: During the upgrade process of burning the target upgrade firmware in the target partition, the old version firmware continues to run in the initial partition that is currently in the running state, so as to continuously provide services during the upgrade process.
6. The method according to claim 5, characterized in that The method further comprises: If the target upgrade firmware is not successfully burned on the target partition of the micro control unit, the jump address is kept as the starting address of the initial partition, so that when the micro control unit is restarted, the old version firmware starts running from the starting address of the initial partition.
7. The method according to claim 5, characterized in that The method further comprises: When a version rollback instruction is received, or the target upgrade firmware cannot be run after the micro control unit is restarted, the jump address is reset to the starting address of the initial partition so that when the micro control unit is restarted again, the old version firmware will be run from the starting address of the initial partition.
8. A firmware upgrade device, characterized in that: include: An acquisition module, used for acquiring a target firmware, wherein the target firmware is obtained by merging two upgrade firmwares with different starting addresses, and the starting address is the starting address of the running partition of the micro control unit; A partition determination module, used to determine a target partition that is currently in an idle state among the two running partitions of the micro control unit; A firmware determination module, configured to determine a target upgrade firmware corresponding to the target partition in the target firmware; The upgrade module is used to burn the target upgrade firmware into the target partition of the micro control unit and set the jump address to the starting address of the target partition so that when the micro control unit is restarted, the target upgrade firmware starts to run from the starting address of the target partition.
9. The device according to claim 8, characterized in that The acquisition module is specifically used for: Compiling the upgrade code with the starting address of the first running partition of the micro control unit to obtain the first upgrade firmware; Compiling the upgrade code with the starting address of the second running partition of the micro control unit to obtain a second upgrade firmware; The first upgrade firmware and the second upgrade firmware are merged to obtain the target firmware.
10. The device according to claim 9, characterized in that The acquisition module is also used for: The first upgrade firmware and the second upgrade firmware are linked by using a link compiler, and an identification mark is inserted at a boundary between the first upgrade firmware and the second upgrade firmware to distinguish the first upgrade firmware from the second upgrade firmware by the identification mark.
11. The device according to claim 9, characterized in that The partition determination module is specifically used for: Reading data information in the information area of the flash memory of the micro control unit; If the data information indicates that the running partition currently in the running state in the micro control unit is the first running partition, determining the second running partition as the target partition; If the data information indicates that the running partition currently in the running state in the micro control unit is the second running partition, determining the first running partition as the target partition; If the data information indicates that the running partition currently in the idle state in the micro control unit is the first running partition, determining the first running partition as the target partition; If the data information indicates that the running partition currently in the idle state in the micro control unit is the second running partition, the second running partition is determined to be the target partition.
12. The device according to claim 8, characterized in that The firmware upgrade device also includes a continuous service module, which is used to: During the upgrade process of burning the target upgrade firmware in the target partition, the old version firmware continues to run in the initial partition that is currently in the running state, so as to continuously provide services during the upgrade process.
13. The device according to claim 12, characterized in that The firmware upgrade device further includes a failure processing module, which is used to: If the target upgrade firmware is not successfully burned on the target partition of the micro control unit, the jump address is kept as the starting address of the initial partition, so that when the micro control unit is restarted, the old version firmware starts running from the starting address of the initial partition.
14. The device according to claim 12, characterized in that The firmware upgrade device further includes a rollback module, which is used to: When a version rollback instruction is received, or the target upgrade firmware cannot be run after the micro control unit is restarted, the jump address is reset to the starting address of the initial partition so that when the micro control unit is restarted again, the old version firmware will be run from the starting address of the initial partition.
15. An electronic device, comprising a memory, a processor, a communication interface and a communication bus, wherein the memory stores a computer program that can be run on the processor, and the memory and the processor communicate through the communication bus and the communication interface, characterized in that: When the processor executes the computer program, the firmware upgrade method described in any one of claims 1 to 7 is implemented.
16. A computer readable medium having a non-volatile program code executable by a processor, characterized in that: The program code enables the processor to execute the firmware upgrade method described in any one of claims 1 to 7.
