Upgrading method and upgrading device of electronic equipment

By judging the available space of the storage area in the microcontroller of the electronic equipment, and flexibly selecting the receiving path of upgrading the data, the problem of not flexible upgrade methods in the existing technology has been solved, and the reliability and adaptability of program upgrades are improved.

CN114281385BActive Publication Date: 2025-01-28SUNGROW POWER SUPPLY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111617857.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-27
Publication Date
2025-01-28
Estimated Expiration
2041-12-27

AI Technical Summary

Technical Problem

In the prior art, when upgrading programs in microcontroller units (MCUs) of electronic devices, the upgrade method cannot be flexibly switched, resulting in low reliability of program upgrades and the upgrade method cannot be adaptively adjusted according to the upgrade data and the size of memory space.

Method used

By determining whether the first storage area of ​​the electronic equipment has space for storage and upgrade data, if so, it will be coexisted into the first storage area by receiving and upgraded instructions through the storage area or the second storage area; The district receiving upgrade instructions are also stored in the storage area to be upgraded to achieve adaptive receiving of upgrade data.

Benefits of technology

It improves the reliability of program upgrades and meets the needs of upgrading data receiving data to be upgraded at different stages. It does not need to increase system memory costs, reducing the impact of the normal operation of the equipment on the equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114281385B_ABST
    Figure CN114281385B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses an upgrade method and an upgrade device for an electronic device. A microcontroller unit is configured in the electronic device, and the upgrade method of the electronic device is applicable to upgrading a program to be upgraded in the microcontroller unit, and the memory area of ​​the microcontroller unit includes a first storage area, a second storage area, and a storage area to be upgraded; the upgrade method of the electronic device includes: judging whether the first storage area has space for storing upgrade data; when the first storage area has space for storing upgrade data, receiving an upgrade instruction through the storage area to be upgraded or the second storage area, so as to store the upgrade data in the upgrade instruction into the first storage area; when the first storage area does not have space for storing upgrade data, receiving an upgrade instruction through the second storage area, so as to store the upgrade data in the upgrade instruction into the storage area to be upgraded, thereby upgrading the program to be upgraded, and realizing adaptive adjustment of the upgrade method according to the memory space required for the upgrade data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of program upgrade, and in particular to an upgrade method and an upgrade device for an electronic device. Background Art

[0002] Electronic devices, such as converters, electronic switches, and electronic AC power controllers, which use power electronic devices as main functional components, are generally difficult to burn software into a microcontroller unit (MCU) through a burning interface after production and assembly. Therefore, the prior art mostly uses a software online upgrade method to upgrade the program software inside the MCU, that is, the upgrade data is transmitted to the MCU in the electronic device in a communication manner, without relying on the burning interface for burning. However, the prior art generally only uses one upgrade method to upgrade the program in the MCU, and the upgrade method cannot be flexibly switched according to the size of the upgrade data and the memory space of the electronic device, making the reliability of the program upgrade low. Summary of the invention

[0003] The embodiments of the present invention provide an upgrade method and an upgrade device for an electronic device, so as to adaptively adjust the receiving mode of upgrade data according to the memory space required by the upgrade data, thereby meeting the upgrade data receiving requirements of the program to be upgraded at different stages and improving the reliability of the program upgrade.

[0004] In a first aspect, an embodiment of the present invention provides an upgrade method of an electronic device, wherein the electronic device is configured with a micro control unit, and the upgrade method of the electronic device is applicable to upgrading a program to be upgraded in the micro control unit, wherein a memory area of ​​the micro control unit includes a first storage area, a second storage area, and a storage area to be upgraded; the storage area to be upgraded is used to store data of the program to be upgraded;

[0005] The electronic device upgrade method comprises:

[0006] Determining whether the first storage area has space for storing upgrade data;

[0007] When the first storage area has space for storing the upgrade data, receiving an upgrade instruction through the storage area to be upgraded or the second storage area, so as to store the upgrade data in the upgrade instruction into the first storage area;

[0008] When the first storage area does not have space for storing the upgrade data, the upgrade instruction is received through the second storage area, so as to store the upgrade data in the upgrade instruction into the storage area to be upgraded.

[0009] Optionally, the first storage area is used to store upgrade data of the program to be upgraded, and the program to be upgraded includes an application program and a boot program;

[0010] When the program to be upgraded is an application program, the storage area to be upgraded is used to store application program data, and the second storage area is a boot area; when the program to be upgraded is a boot program, the storage area to be upgraded is used to store boot program data, and the second storage area is an application area.

[0011] Optionally, determining whether the first storage area has space for storing the upgrade data includes:

[0012] Acquire the length information of the upgrade data, the total memory and the currently used memory of the first storage area;

[0013] Calculate the current remaining available memory in the first storage area according to the difference between the total memory and the currently used memory;

[0014] If the current remaining available memory in the first storage area is greater than or equal to the length of the upgrade data, determining that the first storage area has space to store the upgrade data;

[0015] If the current remaining available memory in the first storage area is smaller than the length of the upgrade data, it is determined that the first storage area does not have space for storing the upgrade data.

[0016] Optionally, when the first storage area has space for storing upgrade data, after receiving an upgrade instruction through the storage area to be upgraded or the second storage area to store the upgrade data in the upgrade instruction into the first storage area, the upgrade method of the electronic device further includes:

[0017] Determining whether the upgrade data stored in the first storage area is correct and complete;

[0018] If the upgrade data stored in the first storage area is correct and complete, the upgrade data stored in the first storage area is used to replace the data of the program to be upgraded in the storage area to be upgraded through the second storage area, thereby completing the upgrade of the program to be upgraded.

[0019] Optionally, when the first storage area does not have space for storing the upgrade data, receiving the upgrade instruction through the second storage area to store the upgrade data in the upgrade instruction into the storage area to be upgraded includes:

[0020] Jump to the second storage area;

[0021] receiving the upgrade instruction through the second storage area to store the upgrade data in the upgrade instruction into the storage area to be upgraded;

[0022] If the upgrade data stored in the storage area to be upgraded is correct and complete, the upgrade of the program to be upgraded is completed.

[0023] Optionally, the memory area of ​​the micro control unit further includes an upgrade flag storage area, the upgrade flag storage area is used to store an upgrade flag, the upgrade flag includes an upgrade completion flag, the upgrade completion flag is used to indicate that the first storage area has stored correct and complete upgrade data;

[0024] After determining whether the upgrade data stored in the first storage area is correct and complete, the upgrade method of the electronic device further includes:

[0025] If the upgrade data stored in the first storage area is correct and complete, writing an upgrade completion flag into the upgrade flag storage area;

[0026] If the upgrade data stored in the first storage area is incorrect and / or incomplete, the upgrade completion flag is not written into the upgrade flag storage area;

[0027] Among them, if the upgrade completion flag has been written into the upgrade flag storage area, the upgrade data stored in the first storage area is used to replace the program data to be upgraded in the storage area to be upgraded through the second storage area. After the program data to be upgraded in the storage area to be upgraded has been replaced with the upgrade data in the first storage area, the upgrade completion flag is cleared to complete the upgrade of the program to be upgraded.

[0028] Optionally, the upgrade flag further includes an upgrading flag, and the upgrading flag is used to indicate that it has been determined that the first storage area does not have space for storing upgrade data, and the upgrade instruction needs to be received through the second storage area;

[0029] After determining that the first storage area does not have space for storing the upgrade data and before jumping to the second storage area, the upgrade method of the electronic device further includes:

[0030] Writing the upgrading flag into the upgrading flag storage area;

[0031] Wherein, if the upgrading flag has been written into the upgrading flag storage area, the upgrading instruction is received through the second storage area, and the upgrading data in the upgrading instruction is stored into the storage area to be upgraded;

[0032] After the upgrade data is correctly and completely stored in the storage area to be upgraded, the upgrading flag is cleared to complete the upgrade of the program; if the upgrade data is not correctly and / or not completely stored in the storage area to be upgraded, the upgrading flag is not cleared.

[0033] Optionally, before determining whether the first storage area has space for storing the upgrade data, the method for upgrading the electronic device further includes:

[0034] receiving an upgrade scheduling instruction, wherein the upgrade scheduling instruction at least includes: an instruction to enter an upgrade mode;

[0035] After receiving the upgrade scheduling instruction, the upgrade preparation is completed.

[0036] Optionally, the upgrade flag further includes a storage area jump flag, and the storage area jump flag is used to indicate that the electronic device has received the upgrade scheduling instruction and completed the upgrade preparation;

[0037] After writing the upgrading flag into the upgrading flag storage area and before jumping to the second storage area, the upgrading method of the electronic device further includes:

[0038] The storage area jump flag is written into the upgrade flag storage area.

[0039] Optionally, after jumping to the second storage area, the method for upgrading the electronic device further includes:

[0040] If the upgrading flag and the storage area jump flag have been written into the upgrading flag storage area, clearing the storage area jump flag;

[0041] After jumping to the second storage area, if the upgrading flag has been written into the upgrading flag storage area, but the storage area jump flag has been cleared, the upgrading scheduling instruction is received again to complete the upgrading preparation.

[0042] In a second aspect, an embodiment of the present invention further provides an upgrade device for an electronic device, wherein the electronic device is provided with a micro control unit, and the upgrade method of the electronic device is applicable to upgrading a program to be upgraded in the micro control unit, wherein the memory area of ​​the micro control unit includes a first storage area, a second storage area and a storage area to be upgraded; the storage area to be upgraded is used to store data of the program to be upgraded;

[0043] The upgrading device of the electronic equipment comprises:

[0044] A storage space determination module, used to determine whether the first storage area has space for storing upgrade data;

[0045] a first upgrading module, configured to receive an upgrading instruction through the storage area to be upgraded or the second storage area when the first storage area has space for storing upgrading data, so as to store the upgrading data in the upgrading instruction into the first storage area;

[0046] The second upgrading module is used for receiving the upgrading instruction through the second storage area when the first storage area does not have space for storing the upgrading data, so as to store the upgrading data in the upgrading instruction into the storage area to be upgraded.

[0047] The upgrade method and upgrade device of the electronic device provided by the embodiment of the present invention are suitable for upgrading the program to be upgraded in the micro control unit MCU of the electronic device, and the program to be upgraded can be either an application program or a boot program. When the first storage area has space for storing upgrade data, the upgrade instruction is received through the storage area to be upgraded or the second storage area, so that the upgrade data in the upgrade instruction is stored in the first storage area, thereby upgrading the program to be upgraded. When the first storage area does not have space for storing upgrade data, the upgrade instruction is received through the second storage area, so that the upgrade data in the upgrade instruction is stored in the storage area to be upgraded, thereby upgrading the program to be upgraded, and adaptive adjustment of the receiving method of the upgrade data is achieved according to the memory space required for the upgrade data. For electronic devices, there are differences in the memory space occupied by the programs to be upgraded at different stages. This solution helps to meet the upgrade data receiving requirements of the programs to be upgraded in the electronic device at different stages, and does not need to increase the system memory cost, helps to improve the reliability of the upgrade of the programs to be upgraded, and reduces the impact of the upgrade process on the normal operation of the device. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 It is a flowchart of an upgrade method of an electronic device provided by an embodiment of the present invention;

[0049] Figure 2 is a flow chart of another method for upgrading an electronic device provided by an embodiment of the present invention;

[0050] Figure 3 is a flow chart of another method for upgrading an electronic device provided by an embodiment of the present invention;

[0051] Figure 4 is a flow chart of another method for upgrading an electronic device provided by an embodiment of the present invention;

[0052] Figure 5 It is a schematic diagram of the module structure of an upgrading device for an electronic device provided by an embodiment of the present invention;

[0053] Figure 6 It is a schematic diagram of the structure of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0054] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0055] At present, there are generally two schemes for receiving upgrade data of the program to be upgraded: the first is to receive the upgrade data through the backup area. After the upgrade data is received, if the upgrade data is complete, the upgrade data in the backup area is copied to the program area to be upgraded to realize the program upgrade; the second is to first erase the program area to be upgraded, and then directly store the upgrade data in the program area to be upgraded. The advantage of the first scheme is that when the upgrade data is not received completely, the system can continue to run based on the original program, and the disadvantage is that the device must have enough memory space to store the upgrade data; the advantage of the second scheme is that no additional backup area is required to store the upgrade data, and the disadvantage is that if the upgrade data is not received completely, the system cannot continue to run. For electronic devices, the memory space occupied by software at different stages may be different. For example, in the early debugging, the function is relatively simple, the software occupies less memory, and the storage space in the backup area is sufficient to store the upgrade data; and as the program function is improved, the software occupies more memory, and the storage space in the backup area is difficult to store the upgrade data. As described in the background technology, the prior art generally only uses one upgrade method to upgrade the program in the MCU, and it is impossible to flexibly switch the upgrade method, and it is difficult to adapt to the upgrade data storage requirements at different stages, making the reliability of program upgrade low.

[0056] In view of the above problems, an embodiment of the present invention provides an upgrading method of an electronic device. Figure 1 It is a flowchart of an upgrade method of an electronic device provided by an embodiment of the present invention. The method can be executed by an upgrade device of an electronic device, and the device can be implemented in software and / or hardware. The device can be configured in an electronic device, such as a power electronic device, a server or a terminal device. Typical terminal devices include mobile terminals, specifically mobile phones, computers or tablet computers, etc. The electronic device in this embodiment is configured with a microcontroller unit. This embodiment is applicable to the case of upgrading a program to be upgraded in a microcontroller unit MCU. The memory area of ​​the microcontroller unit includes a first storage area, a second storage area and a storage area to be upgraded; accordingly, see Figure 1 , the upgrading method of the electronic device comprises the following steps:

[0057] S110: Determine whether the first storage area has space for storing upgrade data.

[0058] Specifically, the electronic device in the embodiment of the present invention includes a power electronic device, which can be an electric energy conversion device in a photovoltaic system, such as an inverter. The first storage area, the second storage area and the storage area to be upgraded are all independent storage areas. The program to be upgraded in the microcontroller unit MCU can be either an application program or a boot program. Optionally, when the program to be upgraded is an application program, the storage area to be upgraded is used to store application program data, and the second storage area is a boot area; when the program to be upgraded is a boot program, the storage area to be upgraded is used to store boot program data, and the second storage area is an application area. Among them, the boot area (i.e., the Boot area) stores a system boot file for booting. The application area is the APP area. The first storage area can be used to store upgrade data of the program to be upgraded. For example, the memory area of ​​the microcontroller unit also includes a remaining memory area, and the first storage area can be a storage area in the remaining memory area. The area other than the first storage area in the remaining memory area can be vacant or used to store other data, such as the operating status data of the photovoltaic system. The size of the first storage area can vary with the usage of the area other than the first storage area in the remaining memory area.

[0059] Before upgrading the program to be upgraded, it is determined whether the first storage area has space for storing the upgrade data. When the currently available storage space in the first storage area is sufficient to store the upgrade data, it can be determined that the first storage area has space for storing the upgrade data; when the currently available storage space in the first storage area is insufficient to store the upgrade data, it can be determined that the first storage area does not have space for storing the upgrade data.

[0060] S120. When the first storage area has space for storing the upgrade data, the upgrade instruction is received through the storage area to be upgraded or the second storage area to store the upgrade data in the upgrade instruction into the first storage area. When the first storage area does not have space for storing the upgrade data, the upgrade instruction is received through the second storage area to store the upgrade data in the upgrade instruction into the storage area to be upgraded.

[0061] Exemplarily, in one embodiment, the program to be upgraded is an application program, and the storage area to be upgraded is used to store application program data, that is, the storage area to be upgraded is the APP area, and the second storage area is the boot area. When upgrading the application program, if the first storage area has space to store the upgrade data, the upgrade instruction is received by the storage area to be upgraded or the second storage area, so that the storage area to be upgraded or the second storage area responds to the upgrade instruction and stores the upgrade data corresponding to the upgrade instruction in the first storage area. After the first storage area has completely received all the upgrade data, the upgrade data in the first storage area can be used to replace the application program data currently stored in the storage area to be upgraded. At this time, the data stored in the storage area to be upgraded is already the upgraded application program data, thereby realizing the upgrade of the application program. The advantage of such a setting is that during the upgrade process, the storage area to be upgraded still stores the application program data before the upgrade. Even if the upgrade data received by the first storage area is incomplete, the device can continue to run based on the application program data before the upgrade stored in the storage area to be upgraded.

[0062] When upgrading the application, if the first storage area does not have space to store the upgrade data, the second storage area, i.e., the boot area, can respond to the upgrade instruction, first erase the application data currently stored in the storage area to be upgraded, and then store the upgrade data in the storage area to be upgraded. At this time, the data stored in the storage area to be upgraded is already the upgraded application data, thus realizing the upgrade of the application. The advantage of this setting is that the application can still be upgraded when the memory of the first storage area is insufficient to store the upgrade data.

[0063] In another embodiment, the program to be upgraded is a boot program, and the storage area to be upgraded is used to store boot program data, and the second storage area is an application area (APP area). When upgrading the boot program, if the first storage area has space to store upgrade data, the upgrade instruction is received through the storage area to be upgraded or the second storage area, so that the upgrade instruction is responded to in the storage area to be upgraded or the second storage area, and the upgrade data corresponding to the upgrade instruction is stored in the first storage area. After the first storage area receives all the upgrade data completely, the upgrade data in the first storage area can be used to replace the boot program data currently stored in the storage area to be upgraded. At this time, the data stored in the storage area to be upgraded is already the upgraded boot program data, and the upgrade of the boot program is realized. If the first storage area does not have space to store upgrade data, the upgrade instruction can be responded to in the second storage area, that is, the application area, first erase the boot program data currently stored in the storage area to be upgraded, and then store the upgrade data in the storage area to be upgraded. At this time, the data stored in the storage area to be upgraded is already the upgraded boot program data, and the upgrade of the boot program is realized.

[0064] The technical solution of the embodiment of the present invention is applicable to upgrading the program to be upgraded in the microcontroller unit MCU of the electronic device. The program to be upgraded can be either an application program or a boot program. When the first storage area has space for storing upgrade data, the upgrade instruction is received through the storage area to be upgraded or the second storage area, so that the upgrade data in the upgrade instruction is stored in the first storage area, thereby upgrading the program to be upgraded. When the first storage area does not have space for storing upgrade data, the upgrade instruction is received through the second storage area, so that the upgrade data in the upgrade instruction is stored in the storage area to be upgraded, thereby upgrading the program to be upgraded, and adaptive adjustment of the receiving method of the upgrade data is achieved according to the memory space required for the upgrade data. For electronic devices, there are differences in the memory space occupied by the program to be upgraded at different stages. This solution helps to meet the upgrade data receiving requirements of the program to be upgraded in the electronic device at different stages, and does not need to increase the system memory cost, helps to improve the reliability of the upgrade of the program to be upgraded, and reduces the impact of the upgrade process on the normal operation of the device.

[0065] Figure 2 1 is a flowchart of another method for upgrading an electronic device provided by an embodiment of the present invention. Based on the above embodiment, this embodiment optimizes the method for upgrading an electronic device. Optionally, in this embodiment and the following embodiments, when the program to be upgraded is an application program, the storage area to be upgraded is used to store application program data, and the second storage area is a boot area; when the program to be upgraded is a boot program, the storage area to be upgraded is used to store boot program data, and the second storage area is an application area. Figure 2 The method of this embodiment specifically includes the following steps:

[0066] S210: Receive an instruction to enter an upgrade mode.

[0067] The difference between the instruction to enter the upgrade mode and the upgrade instruction is that the upgrade instruction includes the upgrade data required to upgrade the program to be upgraded, while the instruction to enter the upgrade mode includes the attribute information of the upgrade data, for example, the instruction to enter the upgrade mode includes the length information of the upgrade data, etc. Exemplarily, the instruction to enter the upgrade mode is an instruction converted from the upgrade file through the communication protocol, and the length information of the upgrade data can be directly extracted from the instruction to enter the upgrade mode, or the length information of the upgrade data can be extracted from the upgrade file.

[0068] S220: Obtain the length information of the upgrade data, the total memory of the first storage area, and the currently used memory.

[0069] S230: Calculate the current remaining available memory in the first storage area according to the difference between the total memory and the currently used memory.

[0070] S240: Determine whether the first storage area has space for storing the upgrade data according to the relationship between the current remaining available memory in the first storage area and the length of the upgrade data.

[0071] If the current remaining available memory in the first storage area is greater than or equal to the length of the upgrade data, it is determined that the first storage area has space to store the upgrade data, and step S250 is executed; if the current remaining available memory in the first storage area is less than the length of the upgrade data, it is determined that the first storage area does not have space to store the upgrade data, and step S260 is executed.

[0072] Exemplarily, the length information of the upgrade data may indicate the memory size that the upgrade data needs to occupy. The current remaining available memory of the first storage area is equal to the difference between the total memory of the first storage area and the currently used memory. If the remaining available memory is greater than or equal to the length of the upgrade data, it means that the current remaining memory of the first storage area can store the upgrade data. If the remaining available memory is less than the length of the upgrade data, it means that the current remaining memory of the first storage area cannot store the upgrade data. When the first storage area is a storage area in the remaining memory area, since the size of the first storage area varies with the usage of the area in the remaining memory area except the first storage area, the total memory of the first storage area can be determined based on the total memory of the remaining memory area and the usage of the area in the remaining memory area except the first storage area, and then the current remaining available memory of the first storage area is calculated.

[0073] When upgrading the program to be upgraded in the microcontroller unit MCU, the host computer can establish communication with the microcontroller unit MCU, and the host computer can send instructions to enter the upgrade mode and upgrade instructions to the microcontroller unit MCU; or, the microcontroller unit MCU can also establish communication with the host computer through the upper communication unit, that is, the host computer sends instructions to enter the upgrade mode and upgrade instructions to the microcontroller unit MCU through the upper communication unit. The above-mentioned step of judging whether the first storage area can store the upgrade data can be executed by the host computer or the microcontroller unit MCU. The subsequent step of the microcontroller unit MCU responding to the upgrade instruction to receive the upgrade data to upgrade the program to be upgraded can be executed under the scheduling of the host computer or the upper communication unit, or it can be executed autonomously by the microcontroller unit MCU.

[0074] S250: receiving an upgrade instruction through the storage area to be upgraded or the second storage area, so as to store the upgrade data in the upgrade instruction into the first storage area.

[0075] S260: Receive an upgrade instruction through the second storage area to store the upgrade data in the upgrade instruction into the storage area to be upgraded.

[0076] Figure 3FIG. 1 is a flow chart of another method for upgrading an electronic device provided by an embodiment of the present invention. This embodiment optimizes the method for upgrading an electronic device. Figure 3 The method of this embodiment specifically includes the following steps:

[0077] S301, receiving an instruction to enter an upgrade mode.

[0078] S302: Determine whether the first storage area has space for storing upgrade data.

[0079] If the first storage area has space for storing the upgrade data, step S303 is executed; if the first storage area does not have space for storing the upgrade data, step S308 is executed.

[0080] S303: receiving an upgrade instruction through the storage area to be upgraded or the second storage area, so as to store the upgrade data in the upgrade instruction into the first storage area.

[0081] S304: Determine whether the upgrade data stored in the first storage area is correct and complete.

[0082] Specifically, after the upgrade data is stored in the first storage area, it is determined whether the upgrade data stored in the first storage area is correct and complete. If the upgrade data stored in the first storage area is correct and complete, S305 is executed; if the upgrade data stored in the first storage area is incorrect and / or incomplete, S307 is executed.

[0083] When the first storage area has space for storing the upgrade data, the upgrade instruction is received through the storage area to be upgraded or the second storage area to store the upgrade data in the upgrade instruction into the first storage area to upgrade the program to be upgraded. If the upgrade data received by the first storage area is correct and complete, the subsequent upgrade steps can be performed normally.

[0084] S305: Replace the program data to be upgraded in the storage area to be upgraded with the upgrade data stored in the first storage area through the second storage area.

[0085] When the first storage area has space for storing upgrade data, if the upgrade instruction is received through the storage area to be upgraded, it is necessary to jump from the storage area to be upgraded to the second storage area to execute step S305; if the upgrade instruction is received through the second storage area, no jump is required and step S305 can be executed directly.

[0086] S306: Complete the upgrade of the program to be upgraded.

[0087] Specifically, the upgrade data stored in the first storage area is copied to the storage area to be upgraded through the second storage area, so that the upgrade data stored in the first storage area replaces the program data to be upgraded in the storage area to be upgraded, and after the data in the storage area to be upgraded has been replaced with the upgrade data, the second storage area jumps back to the storage area to be upgraded, at which time the data in the storage area to be upgraded has been updated to the upgraded data, and the upgrade of the program to be upgraded is completed. Optionally, after step S306, the upgrade data temporarily stored in the first storage area can also be cleared.

[0088] S307: Clear the upgrade data in the first storage area.

[0089] Optionally, in one embodiment, if the upgrade data received by the first storage area is incorrect and / or incomplete, the upgrade data currently stored in the first storage area can be cleared through the second storage area or the storage area to be upgraded. This can avoid the system replacing the program data to be upgraded based on incorrect and / or incomplete upgrade data, so that the system can still operate normally based on the program data to be upgraded in the storage area to be upgraded.

[0090] Optionally, in another implementation, if the upgrade data received by the first storage area is incorrect and / or incomplete, no other operations may be performed.

[0091] S308, jump to the second storage area.

[0092] S309: receiving an upgrade instruction through the second storage area to store the upgrade data in the upgrade instruction into the storage area to be upgraded.

[0093] Specifically, when the first storage area does not have space for storing the upgrade data, the program can jump to the second storage area to receive the upgrade instruction through the second storage area, thereby responding to the upgrade instruction and storing the upgrade data in the storage area to be upgraded. Optionally, the second storage area responds to the upgrade instruction, first erasing the original program data to be upgraded in the storage area to be upgraded, and then storing the upgrade data in the storage area to be upgraded.

[0094] S310: Determine whether the upgrade data stored in the storage area to be upgraded is correct and complete.

[0095] If the upgrade data stored in the storage area to be upgraded is correct and complete, step S311 is executed; optionally, if the upgrade data stored in the storage area to be upgraded is wrong and / or incomplete, step S312 is executed.

[0096] S311, completing the upgrade of the program to be upgraded.

[0097] Specifically, after the storage area to be upgraded completely and correctly receives the upgrade data, the second storage area jumps back to the storage area to be upgraded. At this time, the data in the storage area to be upgraded has been updated to the upgraded data, and the upgrade of the program to be upgraded is completed.

[0098] S312, waiting for another upgrade.

[0099] On the basis of the above embodiment, optionally, the memory area of ​​the microcontroller unit MCU also includes an upgrade flag storage area, the upgrade flag storage area is used to store the upgrade flag, the upgrade flag includes an upgrade completion flag, and the upgrade completion flag is used to indicate that the first storage area has stored correct and complete upgrade data. Exemplarily, the memory area of ​​the microcontroller unit MCU can be divided into a boot area, an APP area, an upgrade flag storage area, and a remaining memory area. The first storage area is a storage area in the remaining memory area, one of the second storage area and the storage area to be upgraded is a boot area, and the other is an APP area. The upgrade flag storage area is used to store upgrade flags representing different upgrade states. Accordingly, after step S304, the upgrade method of the electronic device also includes:

[0100] If the upgrade data stored in the first storage area is correct and complete, the upgrade completion flag is written into the upgrade flag storage area; if the upgrade data stored in the first storage area is incorrect and / or incomplete, the upgrade completion flag is not written into the upgrade flag storage area.

[0101] Among them, if the upgrade completion flag has been written into the upgrade flag storage area, the upgrade data stored in the first storage area is used to replace the program data to be upgraded in the storage area to be upgraded through the second storage area. After the program data to be upgraded in the storage area to be upgraded has been replaced with the upgrade data in the first storage area, the upgrade completion flag is cleared to complete the upgrade of the program to be upgraded.

[0102] Specifically, when the first storage area has space for storing the upgrade data, the upgrade instruction is received through the storage area to be upgraded or the second storage area, so that the upgrade data in the upgrade instruction is stored in the first storage area, and the program to be upgraded is upgraded. After the upgrade data is stored in the first storage area, it is determined whether the upgrade data stored in the first storage area is correct and complete. If the upgrade data received in the first storage area is correct and complete, the "upgrade completion flag" can be written into the upgrade flag storage area to indicate that the upgrade data has been correctly and completely received. If the upgrade data received in the first storage area is incorrect and / or incomplete, the "upgrade completion flag" is not written into the upgrade flag storage area.

[0103] If the "upgrade completion flag" has been written into the upgrade flag storage area, it means that the "upgrade completion flag" is currently valid. If the "upgrade completion flag" has not been written into the upgrade flag storage area, it means that the "upgrade completion flag" is currently invalid. After determining whether the "upgrade completion flag" is written into the upgrade flag storage area, and before executing step S305, read the upgrade flag in the upgrade flag storage area to determine the upgrade status. If the "upgrade completion flag" is valid, execute step S305 to replace the program data to be upgraded in the storage area to be upgraded with the upgrade data stored in the first storage area through the second storage area. After the data in the storage area to be upgraded has been replaced with the upgrade data, clear the "upgrade completion flag". At this time, the data in the storage area to be upgraded has been updated to the upgraded data, and the upgrade of the program to be upgraded has been completed.

[0104] Based on the above embodiment, optionally, the upgrade flag also includes an upgrading flag, and the upgrading flag is used to indicate that it has been determined that the first storage area does not have space to store the upgrade data, and it is necessary to receive the upgrade instruction through the second storage area; accordingly, after determining that the first storage area does not have space to store the upgrade data, and before executing step S308, the upgrading method of the electronic device also includes: writing the upgrading flag into the upgrade flag storage area.

[0105] Among them, if the upgrading flag has been written into the upgrade flag storage area, the upgrading instruction is received through the second storage area, and the upgrading data in the upgrading instruction is stored in the storage area to be upgraded; after the upgrading data is correctly and completely stored in the storage area to be upgraded, the upgrading flag is cleared to complete the program upgrade; if the upgrading data is not correctly and / or incompletely stored in the storage area to be upgraded, the upgrading flag is not cleared.

[0106] If the "upgrading flag" has been written into the upgrade flag storage area, it means that the "upgrading flag" is valid. If the "upgrading flag" has not been written into the upgrade flag storage area, it means that the "upgrading flag" is invalid. After determining that the first storage area does not have space to store the upgrade data, the upgrading flag is written into the upgrade flag storage area, and then step S308 is executed to jump to the second storage area and read the upgrade flag in the upgrade flag storage area to determine the upgrade status. If the "upgrading flag" is valid, step S309 is executed to receive the upgrade instruction through the second storage area to store the upgrade data in the upgrade instruction into the storage area to be upgraded. After determining that the upgrade data stored in the storage area to be upgraded is correct and complete, the "upgrading flag" in the upgrade flag storage area is cleared. At this time, the data in the storage area to be upgraded has been updated to the upgraded data, and the upgrade of the program to be upgraded is completed. If the upgrade data is not correctly and / or incompletely stored in the storage area to be upgraded, the "upgrading flag" is not cleared, and step S312 is executed to wait for another upgrade.

[0107] Based on the above embodiment, optionally, before step S301, the method for upgrading the electronic device further includes:

[0108] receiving an upgrade scheduling instruction, the upgrade scheduling instruction at least including: an instruction to enter an upgrade mode;

[0109] After receiving the upgrade scheduling instruction, complete the upgrade preparation.

[0110] Among them, the upgrade preparation may include, after receiving the upgrade scheduling instruction, first switching from the normal operation mode to the upgrade mode, switching to the upgrade protocol, sending the length information of the upgrade data, the total memory of the first storage area and the currently used memory, etc. It should be noted that the upgrade preparation work is not limited to the above steps, and the upgrade preparation work may also include other steps, or at least some of the above steps. This embodiment does not limit the specific content of the upgrade preparation work.

[0111] Exemplarily, the host computer sends the upgrade scheduling instruction to the micro control unit MCU of the electronic device, or sends the upgrade scheduling instruction to the upper communication unit of the electronic device through the host computer, and sends the upgrade scheduling instruction to the micro control unit MCU through the upper communication unit.

[0112] After the microcontroller unit MCU receives the upgrade scheduling instruction and completes the upgrade preparation, the upgrade-ready information can be generated so that the host computer can query (or the host computer queries through the upper communication unit) the upgrade-ready information of the microcontroller unit MCU, thereby issuing the upgrade instruction to the microcontroller unit MCU according to the queried upgrade-ready information. For example, when other control units are connected to the communication bus between the host computer and the microcontroller unit MCU, the microcontroller unit MCU and other control units can complete the upgrade preparation and generate the upgrade-ready information after receiving the upgrade scheduling instruction. After the upgrade-ready information of the microcontroller unit MCU and other control units can be queried by the host computer, the host computer can issue the upgrade instruction to the microcontroller unit MCU and other control units, so that the microcontroller unit MCU and other control units execute steps S302 to S312 in the above embodiment to achieve the upgrade of the program to be upgraded.

[0113] Exemplarily, when receiving an instruction to enter the upgrade mode, and determining that the first storage area does not have space to store the upgrade data based on the length information of the upgrade data in the instruction to enter the upgrade mode and the current remaining available memory in the first storage area, it is necessary to receive the upgrade instruction through the second storage area, that is, it is necessary to execute step S308 in the above embodiment to jump to the second storage area. If the upgrade process of the program to be upgraded is interrupted or fails after jumping to the second storage area, for example, during the execution of step S309, the upgrade process of the program to be upgraded is interrupted or fails, and when the electronic device is powered off and restarted to prepare for upgrading again, the upgrade scheduling instruction can be re-received through the second storage area to complete the upgrade preparation, so as to re-respond to the upgrade instruction through the second storage area, store the upgrade data in the storage area to be upgraded, and complete the upgrade of the program to be upgraded.

[0114] The technical solution of this embodiment can re-receive the upgrade scheduling instruction and complete the upgrade preparation when the electronic device is upgraded again after the upgrade fails, so as to upgrade the program to be upgraded. This solution can be applied to a system in which multiple electronic devices communicate. If multiple electronic devices are upgraded at the same time, and the upgrade of a certain electronic device is interrupted or fails, the electronic device can re-receive the upgrade scheduling instruction, complete the upgrade preparation, generate the upgrade readiness information and send it to the upper computer or the upper communication unit, so as to continue the upgrade process.

[0115] Based on the above embodiment, optionally, the upgrade flag also includes a storage area jump flag, and the storage area jump flag is used to indicate that the electronic device has received the upgrade scheduling instruction and completed the upgrade preparation; accordingly, after writing the upgrading flag into the upgrade flag storage area and before jumping to the second storage area, the upgrading method of the electronic device also includes: writing the storage area jump flag into the upgrade flag storage area.

[0116] Exemplarily, the "storage area jump flag" can be used to inform the second storage area whether it needs to cooperate with the system to receive the upgrade scheduling instruction and complete the upgrade preparation. After determining that the first storage area does not have space to store the upgrade data, the "upgrading flag" is written into the upgrade flag storage area, and the "storage area jump flag" is written into the upgrade flag storage area (the "upgrading flag" can be written before the "storage area jump flag", or both can be written at the same time). After the "upgrading flag" and the "storage area jump flag" are both written into the upgrade flag storage area, step S308 is executed to jump to the second storage area. Since it has been determined that the first storage area does not have space to store the upgrade data, it is necessary to receive the upgrade instruction through the second storage area, so as to respond to the upgrade instruction to store the upgrade data in the storage area to be upgraded, and the electronic device has received the upgrade scheduling instruction and completed the upgrade preparation, therefore, before executing step S308, the "storage area jump flag" can be written into the upgrade flag storage area.

[0117] Based on the above embodiment, optionally, after step S308, the method for upgrading the electronic device further includes:

[0118] If the upgrading flag and the storage area jump flag have been written into the upgrading flag storage area, the storage area jump flag is cleared;

[0119] If the upgrading flag has been written into the upgrading flag storage area, but the storage area jump flag has been cleared, the upgrading scheduling instruction is received again to complete the upgrading preparation.

[0120] Exemplarily, if the "storage area jump flag" has been written into the upgrade flag storage area, it means that the "storage area jump flag" is valid; if the "storage area jump flag" has not been written into the upgrade flag storage area, it means that the "storage area jump flag" is invalid. After determining that the first storage area does not have space to store the upgrade data, execute step S308 in the above embodiment, jump to the second storage area, and read the upgrade flag in the upgrade flag storage area to determine the upgrade status. In the case where the "upgrading flag" is valid, if the "storage area jump flag" is valid, it means that the electronic device has received the upgrade scheduling instruction and completed the upgrade preparation, and the "storage area jump flag" in the upgrade flag storage area can be cleared, and continue to execute steps S309 to S311, thereby completing the upgrade of the program to be upgraded.

[0121] In the case of an interruption or failure in the upgrade process of the program to be upgraded, for example, after the electronic device is powered off and restarted after the last upgrade failure, it is detected whether the various upgrade flags in the upgrade flag storage area are valid. If the "upgrading flag" is valid, and the "storage area jump flag" is invalid, it means that the "storage area jump flag" has been cleared, and the interruption or failure of the last upgrade occurred after it was determined that the first storage area does not have space to store upgrade data, and it is necessary to receive the upgrade instruction through the second storage area, and after jumping to the second storage area. Therefore, the upgrade scheduling instruction can be re-received through the second storage area and the upgrade preparation can be completed, so that the upgrade instruction can be re-responded through the second storage area, and the upgrade data is stored in the storage area to be upgraded, thereby completing the upgrade of the program to be upgraded.

[0122] On the basis of the above embodiments, optionally, the upgrade mark storage area includes a first sub-storage area, a second sub-storage area and a third sub-storage area; the first sub-storage area is used to store the upgrade completion mark, the second sub-storage area is used to store the upgrading mark, and the third sub-storage area is used to store the storage area jump mark. This solution stores different types of upgrade marks by setting different sub-storage areas, so that the value interval that can be stored in each sub-storage area is larger, thereby reducing the probability of misjudgment of the upgrade status. For example, if the value 0 represents one upgrade mark and 1 represents another upgrade mark, then the corresponding space in the memory will change from one upgrade mark to another upgrade mark as long as one bit is changed, and if the value 0xAA represents one upgrade mark and 0x55 represents another upgrade mark, then the probability of misjudgment of the upgrade status will be reduced. Optionally, in other embodiments of the present invention, different values ​​can also be used in the upgrade mark storage area to represent different upgrade marks. For example, different upgrade flags such as "upgrade completion flag", "upgrading flag" and "storage area jump flag" are represented by different four-bit binary values. By reading the values ​​stored in the upgrade flag storage area, it can be determined whether each upgrade flag is valid, thereby determining the current upgrade status of the program to be upgraded.

[0123] Based on the above embodiments, optionally, the upgrade flag storage area may also include a fourth sub-storage area. Before jumping to the second storage area, other upgrade data attribute information related to the upgrade of the program to be upgraded may also be stored in the fourth sub-storage area, such as the length information, verification information and data packet information of the upgrade data, etc. This is conducive to the second storage area obtaining more upgrade data attribute information.

[0124] Based on the above embodiments, optionally, when all upgrade flags in the upgrade flag storage area are invalid, or when no upgrade flag is stored in the upgrade flag storage area, the program jumps back to the storage area to be upgraded to implement the secondary boot function to avoid the program to be upgraded from failing to run normally.

[0125] On the basis of the above embodiments, optionally, the boot area (when the program to be upgraded is an application program, the second storage area is the boot area, and when the program to be upgraded is a boot program, the storage area to be upgraded is the boot area) can also support more control functions. For example, the APP area has the function of controlling the corresponding electronic device, and the boot area can be set to have the same function as the APP area, that is, the corresponding electronic device can be controlled through the boot area. The advantage of such a setting is that in the case of upgrade failure, the electronic device can be directly controlled through the boot area to avoid the system being unable to operate after the data of the program to be upgraded in the APP area is cleared, thereby reducing the impact of the upgrade failure on the normal operation of the system. When the electronic device is an electric energy conversion device in a photovoltaic system, this solution helps to reduce the power generation loss of the photovoltaic system.

[0126] Figure 4 FIG. 1 is a flow chart of another method for upgrading an electronic device provided by an embodiment of the present invention. Based on the above embodiments, this embodiment optimizes the method for upgrading an electronic device. Figure 4 The method of this embodiment specifically includes the following steps:

[0127] S401, receiving an upgrade scheduling instruction.

[0128] The upgrade scheduling instruction at least includes: an instruction to enter the upgrade mode.

[0129] S402: After receiving the upgrade scheduling instruction, complete the upgrade preparation.

[0130] S403: Determine whether the first storage area has space for storing the upgrade data according to the length information of the upgrade data and the remaining available memory in the first storage area.

[0131] Among them, when the program to be upgraded is an application, the storage area to be upgraded is used to store application data, and the second storage area is a boot area. When the program to be upgraded is a boot program, the storage area to be upgraded is used to store boot program data, and the second storage area is an application area.

[0132] If the first storage area has space for storing the upgrade data, step S404 is executed; if the first storage area does not have space for storing the upgrade data, step S411 is executed.

[0133] S404: receiving an upgrade instruction through the storage area to be upgraded or the second storage area, so as to store the upgrade data in the upgrade instruction into the first storage area.

[0134] S405: Determine whether the upgrade data received by the first storage area is correct and complete.

[0135] Specifically, after the first storage area has received the upgrade data, it is determined whether the upgrade data received by the first storage area is correct and complete. If the upgrade data received by the first storage area is incorrect and / or incomplete, step S406 is executed; if the upgrade data received by the first storage area is correct and complete, step S407 is executed.

[0136] S406: Do not write the upgrade completion flag into the upgrade flag storage area, and clear the upgrade data in the first storage area.

[0137] S407: Write the upgrade completion flag into the upgrade flag storage area.

[0138] S408: Determine whether the upgrade completion flag is valid.

[0139] If the upgrade completion flag is valid, step S409 is executed; if the upgrade completion flag is invalid, step S413 or step S415 is executed (only the case of executing step S413 is shown in the figure). If the upgrade completion flag has been written into the upgrade flag storage area, it means that the upgrade completion flag is valid; if the upgrade completion flag has not been written into the upgrade flag storage area, or the upgrade completion flag has been cleared, it means that the upgrade completion flag is invalid.

[0140] S409: Replace the program data to be upgraded in the storage area to be upgraded with the upgrade data stored in the first storage area through the second storage area, and after the data in the storage area to be upgraded has been replaced with the upgrade data stored in the first storage area, clear the upgrade completion flag.

[0141] S410, jumping from the second storage area back to the storage area to be upgraded, completing the upgrade of the program to be upgraded.

[0142] S411, writing the upgrading flag and the storage area jump flag into the upgrade flag storage area.

[0143] S412, jump to the second storage area.

[0144] S413: Determine whether the upgrading flag is valid.

[0145] If the upgrading flag is valid, step S414 is executed; if the upgrading flag is invalid, step S415 is executed. If the upgrading flag is written into the upgrading flag storage area, it means that the upgrading flag is valid; if the upgrading flag is not written into the upgrading flag storage area, or the upgrading flag is cleared, it means that the upgrading flag is invalid.

[0146] S414, responding to the upgrade instruction through the second storage area, first erasing the data in the storage area to be upgraded, then storing the upgrade data in the storage area to be upgraded, and clearing the upgrading flag after the storage area to be upgraded has completed storing the upgrade data.

[0147] S415: Jump to the storage area to be upgraded.

[0148] When the upgrading flag is valid, the upgrading method of the electronic device further includes:

[0149] S416, determine whether the storage area jump flag is valid.

[0150] If the storage area jump flag is valid, step S417 is executed; if the storage area jump flag is invalid, step S418 is executed. If the storage area jump flag has been written into the upgrade flag storage area, it means that the storage area jump flag is valid; if the storage area jump flag has not been written into the upgrade flag storage area, or the storage area jump flag has been cleared, it means that the storage area jump flag is invalid.

[0151] S417, clear the storage area jump flag.

[0152] S418. Re-receive the upgrade scheduling instruction through the second storage area to complete the upgrade preparation.

[0153] Exemplarily, when the "upgrading flag" is valid, if the "storage area jump flag" is valid, it means that the electronic device has received the upgrade scheduling instruction and completed the upgrade preparation, and the "storage area jump flag" in the upgrade flag storage area can be cleared, that is, after executing and completing step S417, continue to execute steps S414 and S410 to complete the upgrade of the program to be upgraded.

[0154] In the case where the upgrade process of the program to be upgraded is interrupted or fails, for example, after the electronic device is powered off and restarted after the last upgrade failure, it is detected whether the various upgrade flags in the upgrade flag storage area are valid. If the "upgrading flag" is valid, and the "storage area jump flag" is invalid, it means that the "storage area jump flag" has been cleared, and the interruption or failure of the last upgrade occurred after it was determined that the first storage area does not have space to store upgrade data, and it is necessary to receive the upgrade instruction through the second storage area, and the program to be upgraded has jumped to the second storage area. Therefore, the upgrade scheduling instruction can be re-received through the second storage area to complete the upgrade preparation, thereby completing the upgrade of the program to be upgraded. For example, after executing and completing step S418, continue to execute steps S414 and S410, thereby completing the upgrade of the program to be upgraded.

[0155] The technical solution of the embodiment of the present invention is applicable to upgrading the program to be upgraded in the microcontroller unit MCU of the electronic device. The program to be upgraded can be either an application program or a boot program. When the first storage area has space for storing upgrade data, the upgrade instruction is received through the storage area to be upgraded or the second storage area, so that the upgrade data in the upgrade instruction is stored in the first storage area, thereby upgrading the program to be upgraded. When the first storage area does not have space for storing upgrade data, the upgrade instruction is received through the second storage area, so that the upgrade data in the upgrade instruction is stored in the storage area to be upgraded, thereby upgrading the program to be upgraded, and adaptive adjustment of the receiving method of the upgrade data is achieved according to the memory space required for the upgrade data. For electronic devices, there are differences in the memory space occupied by the program to be upgraded at different stages. This solution helps to meet the upgrade data receiving requirements of the program to be upgraded in the electronic device at different stages, and does not need to increase the system memory cost, helps to improve the reliability of the upgrade of the program to be upgraded, and reduces the impact of the upgrade process on the normal operation of the device.

[0156] The embodiment of the present invention also provides an upgrading device for an electronic device. Figure 5 The module structure diagram of an electronic device upgrade device provided by an embodiment of the present invention is applicable to the case of upgrading the program to be upgraded in the microcontroller unit MCU. The electronic device upgrade device provided by an embodiment of the present invention can execute the electronic device upgrade method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. Figure 5 The device specifically includes a storage space determination module 510, a first upgrade module 520 and a second upgrade module 530, wherein:

[0157] The storage space determination module 510 is used to determine whether the first storage area has space for storing the upgrade data;

[0158] The first upgrade module 520 is used to receive the upgrade instruction through the storage area to be upgraded or the second storage area when the first storage area has space for storing the upgrade data, so as to store the upgrade data in the upgrade instruction into the first storage area;

[0159] The second upgrading module 530 is used for receiving the upgrading instruction through the second storage area when the first storage area does not have the space for storing the upgrading data, so as to store the upgrading data in the upgrading instruction into the storage area to be upgraded.

[0160] The electronic device upgrade device provided in the embodiment of the present invention can execute the electronic device upgrade method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method, which will not be described in detail.

[0161] Figure 6It is a schematic diagram of the structure of a terminal provided by an embodiment of the present invention. Figure 6 A block diagram of an exemplary device 610 suitable for use in implementing embodiments of the present invention is shown. Figure 6 The device 610 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0162] like Figure 6 As shown, the device 610 is presented in the form of a general purpose device. The components of the device 610 may include, but are not limited to: one or more processors 614, a storage device 626, and a bus 616 connecting different system components (including the storage device 626 and the processor 614).

[0163] Bus 616 represents one or more of several types of bus structures, including a storage device bus or storage device controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Subversive Alliance (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.

[0164] Device 610 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by device 610, including volatile and non-volatile media, removable and non-removable media.

[0165] The storage device 626 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 630 and / or cache memory 632. The device 610 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 634 may be used to read and write non-removable, non-volatile magnetic media ( Figure 6 not shown, usually called a "hard drive"). Although Figure 6Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk, such as a compact disc read-only memory (CD-ROM), a digital video disc (DVD-ROM) or other optical media can be provided. In these cases, each drive can be connected to the bus 616 via one or more data medium interfaces. The storage device 626 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.

[0166] A program / utility 660 having a set (at least one) of program modules 662 may be stored, for example, in the storage device 626, such program modules 662 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 662 generally perform the functions and / or methods of the embodiments described herein.

[0167] The device 610 may also communicate with one or more external devices 612 (e.g., a keyboard, a pointing terminal, a display 624, etc.), one or more terminals that enable a user to interact with the device 610, and / or any terminal that enables the device 610 to communicate with one or more other computing terminals (e.g., a network card, a modem, etc.). Such communication may be performed through an input / output (I / O) interface 622. Furthermore, the device 610 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 620. Figure 6 As shown, the network adapter 620 communicates with other modules of the device 610 via the bus 616. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the device 610, including but not limited to: microcode, terminal drivers, redundant processors, external disk drive arrays, disk arrays (Redundant Arrays of Independent Disks, RAID) systems, tape drives, and data backup storage systems.

[0168] The processor 614 executes various functional applications and data processing by running the program stored in the storage device 626, for example, implementing the upgrade method of the electronic device provided in the embodiment of the present invention, the method comprising:

[0169] Determining whether the first storage area has space for storing the upgrade data;

[0170] When the first storage area has space for storing the upgrade data, receiving the upgrade instruction through the storage area to be upgraded or the second storage area, so as to store the upgrade data in the upgrade instruction into the first storage area;

[0171] When the first storage area does not have space for storing the upgrade data, the upgrade instruction is received through the second storage area to store the upgrade data in the upgrade instruction into the storage area to be upgraded.

[0172] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the method for upgrading the electronic device provided in the embodiment of the present invention is implemented. The method includes:

[0173] Determining whether the first storage area has space for storing the upgrade data;

[0174] When the first storage area has space for storing the upgrade data, receiving the upgrade instruction through the storage area to be upgraded or the second storage area, so as to store the upgrade data in the upgrade instruction into the first storage area;

[0175] When the first storage area does not have space for storing the upgrade data, the upgrade instruction is received through the second storage area to store the upgrade data in the upgrade instruction into the storage area to be upgraded.

[0176] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0177] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0178] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0179] Computer program code for performing the operation of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer, partially on a remote computer, or entirely on a remote computer or terminal. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0180] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for upgrading an electronic device, characterized in that: The electronic device is provided with a micro control unit, the electronic device upgrade method is applicable to upgrade the program to be upgraded in the micro control unit, and the memory area of ​​the micro control unit includes a first storage area, a second storage area and a storage area to be upgraded; The storage area to be upgraded is used to store program data to be upgraded; The electronic device upgrade method comprises: Determining whether the first storage area has space for storing upgrade data; When the first storage area has space for storing the upgrade data, receiving an upgrade instruction through the storage area to be upgraded or the second storage area, so as to store the upgrade data in the upgrade instruction into the first storage area; When the first storage area does not have space for storing the upgrade data, the upgrade instruction is received through the second storage area, so as to store the upgrade data in the upgrade instruction into the storage area to be upgraded.

2. The method for upgrading an electronic device according to claim 1, characterized in that: The first storage area is used to store the upgrade data of the program to be upgraded, and the program to be upgraded includes an application program and a boot program; When the program to be upgraded is an application program, the storage area to be upgraded is used to store application program data, and the second storage area is a boot area; when the program to be upgraded is a boot program, the storage area to be upgraded is used to store boot program data, and the second storage area is an application area.

3. The method for upgrading an electronic device according to claim 1, characterized in that: Determining whether the first storage area has space for storing the upgrade data includes: Acquire the length information of the upgrade data, the total memory and the currently used memory of the first storage area; Calculate the current remaining available memory in the first storage area according to the difference between the total memory and the currently used memory; If the current remaining available memory in the first storage area is greater than or equal to the length of the upgrade data, determining that the first storage area has space to store the upgrade data; If the current remaining available memory in the first storage area is smaller than the length of the upgrade data, it is determined that the first storage area does not have space for storing the upgrade data.

4. The method for upgrading an electronic device according to claim 1, characterized in that: When the first storage area has space for storing the upgrade data, after receiving the upgrade instruction through the storage area to be upgraded or the second storage area to store the upgrade data in the upgrade instruction into the first storage area, the upgrade method of the electronic device further includes: Determining whether the upgrade data stored in the first storage area is correct and complete; If the upgrade data stored in the first storage area is correct and complete, the upgrade data stored in the first storage area is used to replace the data of the program to be upgraded in the storage area to be upgraded through the second storage area, thereby completing the upgrade of the program to be upgraded.

5. The method for upgrading an electronic device according to claim 1, characterized in that: When the first storage area does not have space for storing the upgrade data, receiving the upgrade instruction through the second storage area to store the upgrade data in the upgrade instruction into the storage area to be upgraded, comprising: Jump to the second storage area; receiving the upgrade instruction through the second storage area to store the upgrade data in the upgrade instruction into the storage area to be upgraded; If the upgrade data stored in the storage area to be upgraded is correct and complete, the upgrade of the program to be upgraded is completed.

6. The method for upgrading an electronic device according to claim 4, characterized in that: The memory area of ​​the micro control unit further includes an upgrade flag storage area, the upgrade flag storage area is used to store an upgrade flag, the upgrade flag includes an upgrade completion flag, the upgrade completion flag is used to indicate that the first storage area has stored correct and complete upgrade data; After determining whether the upgrade data stored in the first storage area is correct and complete, the upgrade method of the electronic device further includes: If the upgrade data stored in the first storage area is correct and complete, writing an upgrade completion flag into the upgrade flag storage area; If the upgrade data stored in the first storage area is incorrect and / or incomplete, the upgrade completion flag is not written into the upgrade flag storage area; Among them, if the upgrade completion flag has been written into the upgrade flag storage area, the upgrade data stored in the first storage area is used to replace the program data to be upgraded in the storage area to be upgraded through the second storage area. After the program data to be upgraded in the storage area to be upgraded has been replaced with the upgrade data in the first storage area, the upgrade completion flag is cleared to complete the upgrade of the program to be upgraded.

7. The method for upgrading an electronic device according to claim 6, characterized in that: The upgrade flag also includes an upgrading flag, and the upgrading flag is used to indicate that it has been determined that the first storage area does not have space for storing upgrade data, and the upgrade instruction needs to be received through the second storage area; After determining that the first storage area does not have space for storing the upgrade data and before jumping to the second storage area, the upgrade method of the electronic device further includes: Writing the upgrading flag into the upgrading flag storage area; Wherein, if the upgrading flag has been written into the upgrading flag storage area, the upgrading instruction is received through the second storage area, and the upgrading data in the upgrading instruction is stored into the storage area to be upgraded; After the upgrade data is correctly and completely stored in the storage area to be upgraded, the upgrading flag is cleared to complete the upgrade of the program; if the upgrade data is not correctly and / or not completely stored in the storage area to be upgraded, the upgrading flag is not cleared.

8. The method for upgrading an electronic device according to claim 1, characterized in that: Before determining whether the first storage area has space for storing the upgrade data, the upgrade method of the electronic device further includes: receiving an upgrade scheduling instruction, wherein the upgrade scheduling instruction at least includes: an instruction to enter an upgrade mode; After receiving the upgrade scheduling instruction, the upgrade preparation is completed.

9. The method for upgrading an electronic device according to claim 7, characterized in that: The upgrade mark also includes a storage area jump mark, and the storage area jump mark is used to indicate that the electronic device has received the upgrade scheduling instruction and completed the upgrade preparation; After writing the upgrading flag into the upgrading flag storage area and before jumping to the second storage area, the upgrading method of the electronic device further includes: The storage area jump flag is written into the upgrade flag storage area.

10. The method for upgrading an electronic device according to claim 9, characterized in that: After jumping to the second storage area, the method for upgrading the electronic device further includes: If the upgrading flag and the storage area jump flag have been written into the upgrading flag storage area, clearing the storage area jump flag; After jumping to the second storage area, if the upgrading flag has been written into the upgrading flag storage area, but the storage area jump flag has been cleared, the upgrading scheduling instruction is received again to complete the upgrading preparation.

11. An upgrading device for an electronic device, characterized in that: The electronic device is provided with a micro control unit, the electronic device upgrade method is applicable to upgrade the program to be upgraded in the micro control unit, and the memory area of ​​the micro control unit includes a first storage area, a second storage area and a storage area to be upgraded; The storage area to be upgraded is used to store program data to be upgraded; The upgrading device of the electronic equipment comprises: A storage space determination module, used to determine whether the first storage area has space for storing upgrade data; a first upgrading module, configured to receive an upgrading instruction through the storage area to be upgraded or the second storage area when the first storage area has space for storing upgrading data, so as to store the upgrading data in the upgrading instruction into the first storage area; The second upgrading module is used for receiving the upgrading instruction through the second storage area when the first storage area does not have space for storing the upgrading data, so as to store the upgrading data in the upgrading instruction into the storage area to be upgraded.

Citation Information

Patent Citations

  • Upgrading method and device of control unit

    CN108376077A

  • Application program updating method, nonvolatile memory, storage medium and household appliance

    CN112527365A