Movatterモバイル変換


[0]ホーム

URL:


CN109240730B - Singlechip online upgrading method and system - Google Patents

Singlechip online upgrading method and system
Download PDF

Info

Publication number
CN109240730B
CN109240730BCN201810995065.2ACN201810995065ACN109240730BCN 109240730 BCN109240730 BCN 109240730BCN 201810995065 ACN201810995065 ACN 201810995065ACN 109240730 BCN109240730 BCN 109240730B
Authority
CN
China
Prior art keywords
area
upgrading
chip microcomputer
single chip
application program
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810995065.2A
Other languages
Chinese (zh)
Other versions
CN109240730A (en
Inventor
陈建宇
胡毅
张博
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Accelink Technologies Co Ltd
Original Assignee
Accelink Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Accelink Technologies Co LtdfiledCriticalAccelink Technologies Co Ltd
Priority to CN201810995065.2ApriorityCriticalpatent/CN109240730B/en
Publication of CN109240730ApublicationCriticalpatent/CN109240730A/en
Application grantedgrantedCritical
Publication of CN109240730BpublicationCriticalpatent/CN109240730B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Images

Classifications

Landscapes

Abstract

The invention relates to the technical field of single-chip microcomputers, in particular to a method and a system for upgrading a single-chip microcomputer on line, wherein the method comprises the following steps: the single chip microcomputer initializes an upgrading variable after receiving an upgrading starting command and replies a current operation area to the upper computer upgrading software so that the upper computer upgrading software can determine to generate an upgrading Bin file to be transmitted according to the current operation area; the single chip microcomputer receives the upgrade Bin file and stores the upgrade Bin file in a current non-operation area of the single chip microcomputer; and the single chip microcomputer closes the interruption after receiving the upgrading skip command, copies the interruption vector area of the upgrading program to the interruption vector area of the single chip microcomputer, and runs a new program after soft restart to complete upgrading. The invention divides the FLASH of the singlechip into an interrupt vector area, an application program A area and an application program B area, the interrupt vector area occupies small bytes, and only the interrupt vector area needs to be copied during upgrading, thereby saving the FLASH space and program moving time; meanwhile, the method can perform regional conversion on the upgraded Bin file, and realize online upgrade without interrupting the service.

Description

Singlechip online upgrading method and system
[ technical field ] A method for producing a semiconductor device
The invention relates to the technical field of single-chip microcomputers, in particular to a method and a system for upgrading a single-chip microcomputer on line.
[ background of the invention ]
Currently, electronic products in the market increasingly widely adopt single-chip microcomputers. The application program runs on the single chip microcomputer to complete various functions of the product, under the normal condition, after the electronic product is sold to a client, a manufacturer needs to maintain and upgrade the electronic product, so that software in a CPU (Central processing Unit) can be downloaded and upgraded on the client site, and the normal work of the product is not influenced as much as possible.
At present, the upgrading modes of the single chip microcomputer mainly comprise two types: one is to divide the FLASH of the single-chip microcomputer into an application program area and an upgrade boot area, refer to the left diagram in fig. 1, and upgrade the application program area through the upgrade boot area; the biggest problem of the upgrading mode is that the uninterrupted service cannot be supported, namely, the upgrading must be carried out in an upgrading boot area. Another upgrading mode is to divide the FLASH of the single-chip microcomputer into an application program area, an upgrading backup area and an upgrading guide area, referring to the right diagram in fig. 1; although the upgrading mode can support online upgrading without interrupting the service, the upgrading boot area occupies more FLASH, and the standby program needs to be completely moved from the upgrading backup area to the application program area, so that the content of the copied program is more, more time is spent, and time waste is caused.
In view of the above, it is an urgent problem in the art to overcome the above-mentioned drawbacks of the prior art.
[ summary of the invention ]
The technical problems to be solved by the invention are as follows:
in the traditional upgrading mode, FLASH of a single chip microcomputer is divided into an application program area, an upgrading backup area and an upgrading guide area, the upgrading guide area occupies more FLASH, and standby programs need to be completely moved to the application program area, so that more copied contents exist, and time waste is caused.
The invention achieves the above purpose by the following technical scheme:
in a first aspect, the present invention provides a method for upgrading a monolithic processor online, which divides a FLASH of the monolithic processor into an interrupt vector area, an application a area, and an application B area, wherein the interrupt vector area is a common area of the application a area and the application B area, and the method includes:
the single chip microcomputer initializes an upgrading variable after receiving an upgrading starting command and replies a currently running application program area to the upper computer upgrading software so that the upper computer upgrading software can determine to generate an upgrading Bin file needing to be transmitted according to the currently running area of the single chip microcomputer;
the single chip microcomputer receives an upgrade Bin file transmitted by upgrade software of an upper computer, and stores the upgrade Bin file in an application program area which is not operated by the single chip microcomputer FLASH currently;
and the single chip microcomputer closes the interruption after receiving the upgrading skip command, copies the interruption vector area of the upgrading program to the interruption vector area of the single chip microcomputer, and restarts the single chip microcomputer software and runs a new program to complete upgrading.
Preferably, the upper computer upgrading software determines the upgrade Bin file to be transmitted according to the current operation area of the single chip microcomputer, and specifically includes: according to the currently running application program area replied by the single chip microcomputer, the upper computer upgrading software judges whether the upgrading program is in the same area as the currently running application program area of the single chip microcomputer, and if the upgrading program is in the different area, the current upgrading Bin file is directly transmitted to the single chip microcomputer; if the two-zone upgrading file is the same zone, the upper computer upgrading software converts the current upgrading Bin file into another zone upgrading Bin file and then transmits the converted upgrading Bin file to the single chip microcomputer.
Preferably, the upper computer upgrade software converts the current upgrade Bin file into another region upgrade Bin file, specifically:
calculating an address offset according to the converted region;
reading a byte of the current upgrade Bin file, obtaining the number N of bytes contained in the corresponding instruction through table lookup, and analyzing whether the instruction is related to the address or not;
if the instruction is related to the address, adding or subtracting an address offset to the address corresponding to the instruction to generate a new address and replace the original address byte; if the instruction is not related to the address, the N bytes are directly copied to a new Bin file.
Preferably, the method includes the steps that the single chip microcomputer receives an upgrade Bin file transmitted by upgrade software of an upper computer, and stores the upgrade Bin file in an application program area which is not currently operated by the single chip microcomputer FLASH, and specifically includes:
the single chip microcomputer receives a data packet of an upgrading Bin file transmitted by upgrading software of an upper computer, calculates and judges whether a check value of the data packet is correct or not, and if the check value is correct, writes the data packet into an application program area which is not operated at present in the single chip microcomputer FLASH; if the first Bin file data packet is upgraded, judging whether the area of the upgrading program is correct, and calculating and judging whether the check value of the data packet is correct on the premise of correctness.
Preferably, before the single chip receives an upgrade start command, the method further includes: and importing the Hex file generated by the compiler into upper computer upgrading software, and converting the Hex file into a Bin file required by upgrading by the upper computer upgrading software.
Preferably, the upgrade Bin file consists of an interrupt vector area and a program code area, and a file information area is arranged in the interrupt vector area of the upgrade Bin file and used for storing the file length and the check value of the upgrade Bin file; and a file identification area is arranged in the program code area of the upgrade Bin file and is used for judging whether the upgrade Bin file is a required upgrade file.
Preferably, for the application program a area and the application program B area, the file identification area of the upgrade Bin file is located at a fixed address, and specifically: for the upgrade Bin files of the two application program areas, the address difference value of the file identification area is consistent with the address offset between the two application program areas, and the difference value between the starting address of the file identification area and the starting address of each application program area is also consistent.
Preferably, before the single chip microcomputer shuts down the interrupt after receiving the upgrade jump command, the method further includes:
the single chip microcomputer receives the upgrading verification command, verifies the received upgrading Bin file and then returns an upgrading verification result to the upper computer upgrading software; the verification of the upgrade Bin file specifically comprises the following steps: respectively verifying the file identification area of the upgraded Bin file, the file length and a verification value written into the FLASH application program; if the three are verified correctly, the upgrade verification is successful; if any one of the verification errors exists, upgrading the verification failure.
Preferably, after the single chip microcomputer is in soft restart and runs a new program, the single chip microcomputer reports the currently running application program area to the upper computer upgrading software, and the upper computer upgrading software judges whether upgrading is successful according to the reported currently running area.
In a second aspect, the present invention further provides a system for upgrading a single chip microcomputer online, which is used for implementing the method for upgrading a single chip microcomputer online in the first aspect, and the system comprises asingle chip microcomputer 1, upper computer upgradingsoftware 2 and acommunication interface 3, wherein a FLASH of thesingle chip microcomputer 1 is divided into an interrupt vector area, an application program a area and an application program B area, and the interrupt vector area is a common area of the application program a area and the application program B area;
the upper computer upgradingsoftware 2 is used for converting the upgrading Bin file in the same area into an effective upgrading Bin file in another area according to the running area reported by thesinglechip 1 and completing online upgrading;
thecommunication interface 3 is used for realizing the communication connection between thesingle chip microcomputer 1 and the upper computer upgradingsoftware 2.
The invention has the beneficial effects that:
in the method and the system for upgrading the single chip microcomputer on line, FLASH of the single chip microcomputer is divided into an interrupt vector area, an application program A area and an application program B area, the interrupt vector area occupies a lot of bytes compared with a traditional upgrading guide area, the interrupt vector area of the upgrading program is copied to the interrupt vector area of the single chip microcomputer during upgrading, and the interrupt vector area is only copied, so that the FLASH and the program moving time are greatly saved; meanwhile, the upper computer upgrading software can convert the generated upgrading Bin file into an effective upgrading Bin file of another area according to the current operation area reported by the single chip microcomputer, and the online upgrading is smoothly realized under the condition of not interrupting the service.
[ description of the drawings ]
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required to be used in the embodiments of the present invention will be briefly described below. It is obvious that the drawings described below are only some embodiments of the invention, and that for a person skilled in the art, other drawings can be derived from them without inventive effort.
FIG. 1 is a schematic diagram of two FLASH partitions of a single chip microcomputer in a conventional scheme;
fig. 2 is a schematic diagram of a FLASH partition of a single chip microcomputer provided in the embodiment of the present invention;
fig. 3 is a schematic diagram of code distribution of an application program area a and an application program area B of a single chip microcomputer according to an embodiment of the present invention;
FIG. 4 is a schematic flow chart of a method for upgrading a single chip microcomputer on line according to an embodiment of the present invention;
fig. 5 is a schematic diagram of an upgraded Bin file according to an embodiment of the present invention;
fig. 6 is a schematic diagram of code distribution of the single chip microcomputer after the upgrade is completed according to the embodiment of the present invention;
fig. 7 is a flowchart of generating a Bin file of an application according to an embodiment of the present invention;
fig. 8 is a flowchart of converting a Bin file into a Bin file of another area application according to an embodiment of the present invention;
fig. 9 is a flowchart of receiving an upgrade file by a single chip microcomputer according to an embodiment of the present invention;
fig. 10 is a flowchart of checking an upgrade file by a single chip according to an embodiment of the present invention;
FIG. 11 is a complete flowchart of a method for upgrading a single chip microcomputer on line according to an embodiment of the present invention;
fig. 12 is a schematic structural diagram of an on-line upgrading system for a single chip microcomputer according to an embodiment of the present invention.
[ detailed description ] embodiments
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
In addition, the technical features involved in the embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other. The invention will be described in detail below with reference to the figures and examples.
Example 1:
the embodiment of the invention provides a method for upgrading a singlechip on line, which is characterized in that before the method is used for upgrading, firstly referring to fig. 2, a FLASH of the singlechip is divided into an interrupt vector area, an application program A area and an application program B area; wherein the interrupt vector area is a common area of the application program A area and the application program B area. The useful part in the interrupt vector area has 300 bytes at most, and is usually more than 100 bytes, so the byte occupied by the interrupt vector area is usually less than 512 bytes, which is much smaller than that of the traditional upgrade boot area, and thus the code space allocated to the application program area A and the application program area B is greatly increased.
In the embodiment of the present invention, for example, a 51-chip microcomputer, the interrupt vector area occupies the first 512 bytes (code 0 × 0000-0 × 01 FF). The application program A area and the application program B area are both composed of an interrupt vector area and a program code area, and the interrupt vector area also occupies 512 bytes. The code distribution of the application program area a and the application program area B is respectively as shown in the left diagram and the right diagram in fig. 3, except for the shared interrupt vector area, the code distribution of the application program area a is in the first half area of the FLASH, and the code distribution of the application program area B is in the second half area of the FLASH. In this embodiment, a compiler is used to generate codes, for example, a Keil C51 compiler is used to fill a corresponding address Range in Code Range, and when the Code is generated by compilation, the Code can be generated in the corresponding address Range. In order to reserve Code space for the interrupt vectors of each region, the partition address of each region should be 512 bytes smaller than the start address of Code Range. As shown in fig. 3, in the application program a area, a code range of 0 × 0200 to 0 × 03FF is reserved for the interrupt vector area, and a range of the program code area is 0 × 0400 to 0 × 7 FFF; in the application program B area, a code range of 0 x 8000-0 x 81FF is reserved for the interrupt vector area, and the range of the program code area is 0 x 8200-0 x FFFF.
Referring to fig. 4, the method for upgrading a single chip microcomputer according to the embodiment of the present invention includes the following steps:
step 201, after receiving an upgrade start command, the single chip initializes an upgrade variable, and replies a currently running application program area to the upper computer upgrade software, so that the upper computer upgrade software determines an upgrade Bin file to be transmitted according to the currently running area of the single chip.
Because the application program is divided into an application program area A and an application program area B, the Bin file which needs to be upgraded is determined according to the actual operation area of the single chip microcomputer, so that two application programs need to be managed, the management is troublesome, and errors are easy to occur during upgrading. To solve this problem, the upper computer upgrade software of the present invention has a function of converting an upgrade Bin file of one area into an upgrade Bin file of another area, so that only one application program needs to be managed. The method specifically comprises the following steps: according to the currently running application program area replied by the single chip microcomputer, the upper computer upgrading software judges whether the upgrading program is in the same area as the currently running application program area of the single chip microcomputer, and if the upgrading program is in the different area, the current upgrading Bin file is directly transmitted to the single chip microcomputer for upgrading; if the two-zone upgrading method is the same zone, the upper computer upgrading software converts the current upgrading Bin file into another zone upgrading Bin file, and then transmits the converted upgrading Bin file to the single chip microcomputer for upgrading. In this embodiment, taking the current operation of the single chip in the application program a area as an example, the upgrade must be performed in the application program B area, and if the upgrade Bin file is in the application program B area, the upgrade Bin file may be directly transmitted for upgrade; and if the upgrade Bin file is in the application program A area, firstly converting the upgrade Bin file corresponding to the A area into the upgrade Bin file corresponding to the B area, and then upgrading.
Step 202, the single chip microcomputer receives an upgrade Bin file transmitted by upgrade software of an upper computer, and stores the upgrade Bin file in an application program area which is not operated by the single chip microcomputer FLASH currently. Taking the current operation of the single chip microcomputer in the application program area A as an example, the upgrade software of the upper computer is finally transmitted through conversion to be the upgrade Bin file corresponding to the area B, and then the single chip microcomputer stores the received upgrade Bin file in the application program area B of the single chip microcomputer FLASH so as to be upgraded in the application program area B in the following.
And step 203, the single chip microcomputer closes the interruption after receiving the upgrading skip command, copies the interruption vector area of the upgrading program to the interruption vector area of the single chip microcomputer, and softly restarts the single chip microcomputer and runs a new program to finish upgrading.
When all interrupts are set to be opened in the program, all types of interrupts of the singlechip enter respective interrupt programs to execute work under specific time and conditions. If the interrupt is closed, all types of interrupts will not enter the interrupt routine regardless of condition and time. In thestep 202, if the upgrade Bin file is stored in the application program B area of the single chip microcomputer, the upgrade program is written into the application program B area, and correspondingly, the interrupt vector area of the upgrade program is correspondingly written into the interrupt vector area (0 × 8000-0 × 81FF) of the application program B area of the single chip microcomputer; after all interrupts are closed, copying and transferring the interrupt vector area of the written upgrading program to the interrupt vector area of the single chip microcomputer, namely copying the interrupt vector area (0 multiplied by 8000-0 multiplied by 81FF) of the updated application program B area to the interrupt vector area (0 multiplied by 0000-0 multiplied by 01FF) of the single chip microcomputer. After copying, the single chip microcomputer is soft restarted to run a new program, the single chip microcomputer reports the currently running application program area to the upper computer upgrading software, and the upper computer upgrading software judges whether upgrading is successful according to the reported currently running area: if the current operation area is the application program B area, the operation area is correct, and the upgrading is successful; otherwise, the upgrade fails.
In the single chip microcomputer online upgrading method provided by the invention, the FLASH of the single chip microcomputer is divided into an interrupt vector area, an application program A area and an application program B area, the interrupt vector area occupies a lot of bytes compared with the traditional upgrading guide area, the interrupt vector area of the upgrading program is copied to the interrupt vector area of the single chip microcomputer during upgrading, and the space of the FLASH and the program moving time are greatly saved as only the interrupt vector area needs to be copied; meanwhile, the upper computer upgrading software can convert the generated upgrading Bin file into an effective upgrading Bin file of another area according to the current operation area reported by the single chip microcomputer, and the online upgrading is smoothly realized under the condition of not interrupting the service.
Referring to fig. 5, in the embodiment of the present invention, the upgrade Bin file is also composed of an interrupt vector area and a program code area, and the interrupt vector area also occupies 512 bytes. A file information area is arranged in the interrupt vector area of the upgrade Bin file and used for storing file information of the upgrade Bin file, such as file length and a check value; and a file identification area is arranged in the program code area of the upgrade Bin file, and file identification bytes are stored in the file identification area and used for judging whether the upgrade Bin file is a required upgrade file. The file information can be stored in the second half of the interrupt vector area, because the useful part of the interrupt vector has 300 bytes at most, and the latter 200 bytes are all invalid codes, the file information can be stored in the last 128 bytes of the interrupt vector area so as to be transmitted to the singlechip for upgrade check when upgrading.
In the embodiment of the invention, in order to prevent the wrong file from being upgraded, the file identification byte is used in the upgrade Bin file. After the updated Bin file is generated, before the updated Bin file is sent, whether the updated file is valid can be judged according to the file identification byte. Specifically, a C file can be defined in the application program, only one Code array is defined in the C file, and is initialized to a special identification byte, and finally, the address location of the Code array is defined. The file identification areas of the upgrade Bin files in the application program area A and the application program area B are located at the same position, namely fixed addresses, when the addresses are defined, for the upgrade Bin files in the two application program areas, the address difference value of the file identification areas is consistent with the address offset between the two application program areas, and the difference values between the starting addresses of the file identification areas and the starting addresses of the respective application program areas are also consistent. For example, for the upgrade Bin file in the application a area, the file identification area is located at 0 × 0500-0 × 050F, and for the upgrade Bin file in the application B area, the file identification area is located at 0 × 8300-0 × 830F. The file identification area occupies a small memory, and generally 16 bytes are enough.
In thestep 203, the upgrade program is written into the application program B area of the single chip microcomputer, that is, the upgrade Bin file corresponding to the B area is written into the application program B area of the single chip microcomputer, and then the interrupt vector area (0 × 8000-0 × 81FF) of the application program B area of the single chip microcomputer is copied into the interrupt vector area (0 × 0000-0 × 01FF) of the single chip microcomputer. After the upgrade is completed, the FLASH of the single chip microcomputer is as shown in fig. 6, where the first 512 bytes (0 × 0000-0 × 01FF) are the interrupt vector area of the current running area, and the application a area and the application B area are both composed of 512-byte interrupt vector areas and program code areas.
Generally, only a Hex file can be generated by compiling by adopting Keil C51, and general upgrade files are Bin files, so in the embodiment of the invention, before an upgrade start command is sent to a single chip microcomputer, the upgrade software of an upper computer is led into the upgrade Hex file generated by a compiler, and then the Hex file generated by the compiler is converted into the upgrade Bin file required by upgrading, so that the Hex file in an application program area a or an application program area B is uniformly generated into the Bin file. Then, the upper computer upgrading software judges whether the generated upgrading Bin file is valid or not, and if the generated upgrading Bin file is valid, the upgrading software continues to send an upgrading starting command to the single chip microcomputer; if the upgrade is invalid, the upgrade fails, and the upgrade is directly finished.
Fig. 7 is referred to in the process of converting a Hex file into a Bin file by the upper computer upgrade software, and the conversion method is the same as the conversion of a general Hex file into a Bin file, but the difference is that: in order to make the Bin format generated by the application A area and the application B area consistent, if the data address is not in the address range (0 x 0000-0 x 01FF) of the interrupt vector area, subtracting an address offset from the data address; wherein, the address offset of the application program A area is 0, and the address offset of the application program B area is the address difference of the two areas, namely 0 × 7E 00; after the offset, the corresponding array content and file length are updated with the new address. After the conversion is completed, file information of the Bin file, such as the file length and the check value of the file, needs to be generated.
After generating a Bin file according to the above steps, if the upgrade program is in the same region as the current operation region of the single chip microcomputer in step 201, the upgrade software of the upper computer needs to convert the current upgrade Bin file into an upgrade Bin file of another region, and the specific process refers to fig. 8:
firstly, calculating address offset, namely address difference between two application program intervals according to the converted area; defining a file character string and assigning a value to be null, opening a current upgrade Bin file and setting a file index as a file start;
reading a byte of the current upgrade Bin file, obtaining the byte number N contained in the corresponding instruction by inquiring the singlechip assembly language instruction table, and analyzing whether the instruction is related to the address or not; if the instruction is related to the address, adding (transferring the application program area A to the application program area B) or subtracting (transferring the application program area B to the application program area A) an address offset to the address corresponding to the instruction to generate a new address and replace the original address byte, and adding the instruction to the tail of the file string according to the original sequence; if the instruction is not related to the address, the remaining N-1 bytes are directly read, and N bytes are added to the tail of the file string. The codes of the file information area and the file identification area are not required to be analyzed through table lookup, and byte data are directly added to the tail of the file character string;
and continuously and circularly and repeatedly reading the bytes in the current upgrade Bin file, analyzing and copying according to the second step until the reading length is 0, and finishing the conversion of the Bin file. Then replacing the old file information bytes with 0 XFF in the file character string, generating the file information of a new file according to the new code, and filling the file information into the corresponding position of the file character string; and finally, writing the file character string into a new Bin file, and generating the Bin file of the new area successfully.
Instep 202, the single chip receives the upgrade Bin file transmitted by the upgrade software of the upper computer, and stores the upgrade Bin file in an application program area where the FLASH of the single chip is not currently running, and the specific implementation manner may refer to fig. 9, and the steps are as follows: the single chip microcomputer receives a data packet of an upgrading Bin file transmitted by upgrading software of an upper computer, calculates and judges whether a check value of the data packet is correct or not, and if the check value is correct, the upgrading file data packet is written into an application program area which is not operated at present of the single chip microcomputer FLASH, namely an application program area B; if the error occurs, the reception of the upgrade file fails. If the update result is the first update Bin file data packet, judging whether the area of the update program is correct or not according to the relevant bytes of the code after receiving the data packet, namely whether the update program is the update Bin file in the application program B area or not, if so, calculating and judging whether the check value of the data packet is correct or not; if the region is incorrect, receiving the upgrade file fails.
Generally, between thestep 202 and thestep 203, the method further comprises the step of verifying the upgrade file: and the single chip microcomputer receives the upgrading verification command, verifies the received upgrading Bin file and then replies an upgrading verification result to the upper computer upgrading software. The verification of the upgrade Bin file specifically comprises the following steps: respectively verifying the file identification area of the upgraded Bin file, the file length and a verification value written into the FLASH application program; if the three are verified correctly, the upgrade verification is successful; if any one of the verification errors exists, upgrading the verification failure. Referring to fig. 10, firstly, it may be determined whether the upgrade Bin file is a required upgrade file according to the code of the file identification area, that is, whether the application program is correct, if not, the upgrade verification fails, and if correct, the verification continues; secondly, judging whether the length of the received application program is correct or not according to the file length of the file information area, if not, failing to update and verify, and if so, continuing to verify; and finally, calculating a check value of the application program received by the writing FLASH, judging whether the application program written into the FLASH is correct or not according to the check value of the file information area, if not, failing to update and check, and if so, successfully updating and checking.
In the embodiment of the present invention, the whole upgrade process of the single chip microcomputer may refer to fig. 11, and by combining the above description of the steps, the whole upgrade process of the single chip microcomputer may be divided into four processes, i.e., an upgrade start process, an upgrade file transfer process, an upgrade check process, and an upgrade skip process. In the upgrading starting stage, the single chip microcomputer receives the instruction and reports the current operation area, so that the upgrading software of the upper computer determines whether to convert the upgrading Bin file into another upgrading Bin file according to the operation area; in the upgrade file transmission stage, the upgrade software of the upper computer transmits the upgrade Bin file to the single chip microcomputer, and the single chip microcomputer stores the upgrade Bin file in a current non-operation area; in the upgrading verification stage, respectively verifying a file identification area, a file length and an application program verification value written into FLASH; and in the stage of upgrading skip, closing the interrupt, copying the interrupt vector area of the upgrading program to the interrupt vector area of the single chip microcomputer, and running a new program after the single chip microcomputer is soft restarted. Through the steps, the on-line upgrading of the single chip microcomputer can be completed under the condition that the service is not influenced.
Example 2:
on the basis of the foregoingembodiment 1, an embodiment of the present invention further provides an on-line upgrade system for a single chip microcomputer, which is used for executing the on-line upgrade method for a single chip microcomputer inembodiment 1, and as shown in fig. 12, the upgrade system includes asingle chip microcomputer 1, uppercomputer upgrade software 2, and acommunication interface 3. Referring to fig. 2, the FLASH of thesingle chip microcomputer 1 is divided into an interrupt vector area, an application program a area and an application program B area; wherein the interrupt vector area is a common area of the application program A area and the application program B area. The interrupt vector area here occupies the first 512 bytes (code 0 x 0000-0 x 01FF), which is much smaller than the conventional upgrade boot area, so that the code space allocated to the application a area and the application B area is greatly increased. The application program A area and the application program B area are both composed of a 512-byte interrupt vector area and a program code area. By the partition mode, when the upgrading system provided by the embodiment of the invention is adopted for upgrading, only the interrupt vector area of the upgrading program needs to be copied to the interrupt vector area of the single chip microcomputer, and the FLASH and program moving time is greatly saved as only the interrupt vector area needs to be copied.
The uppercomputer upgrading software 2 mainly has three functions: firstly, the Hex file generated by the compiler can be converted into the Bin file required for upgrading, i.e. the steps shown in fig. 7 are executed; secondly, the generated upgrade Bin file can be converted to generate an effective upgrade Bin file of another area according to the operation area reported by thesingle chip microcomputer 1, namely, the steps shown in fig. 8 are executed; and thirdly, implementing an online upgrading function. The generated upgrade Bin file is converted to generate an effective upgrade Bin file of another area, although the application program is divided into an application program area A and an application program area B, only one application program needs to be managed, the trouble brought by managing the two application programs is avoided, and online upgrade is smoothly realized under the condition of not interrupting service.
Thecommunication interface 3 is used for realizing communication connection between thesingle chip microcomputer 1 and the uppercomputer upgrading software 2, and the uppercomputer upgrading software 2 can send related commands to thesingle chip microcomputer 1 through thecommunication interface 3, so that thesingle chip microcomputer 1 can realize corresponding operations according to the commands, such as executing steps shown in fig. 9 when receiving an upgrading file and steps shown in fig. 10 when upgrading is checked; meanwhile, thesingle chip microcomputer 1 can reply information to the uppercomputer upgrading software 2 through thecommunication interface 3, so that the uppercomputer upgrading software 2 carries out corresponding operation according to a reply result. Thecommunication interface 3 may be a serial port, I2C or a network port, and is not particularly limited.
Specifically, referring to fig. 11, in a flow chart portion in a dashed line frame of thesingle chip microcomputer 1, corresponding operation steps in the dashed line frame may be implemented by thesingle chip microcomputer 1; correspondingly, in the flow chart part in the dashed line frame of the uppercomputer upgrading software 2, the corresponding operation steps in the dashed line frame can be completed by the uppercomputer upgrading software 2. The specific function implementation processes of thesingle chip microcomputer 1 and the uppercomputer upgrade software 2 can refer to the descriptions of the steps and the drawings inembodiment 1, and are not described herein again.
In the on-line upgrading system of the single chip microcomputer, the FLASH of the single chip microcomputer is divided into an interrupt vector area, an application program A area and an application program B area, the interrupt vector area occupies a plurality of bytes smaller than that of a traditional upgrading guide area, and the interrupt vector area of the upgrading program is only copied to the interrupt vector area of the single chip microcomputer during upgrading, so that the FLASH and program moving time is greatly saved; meanwhile, the upper computer upgrading software can convert the generated upgrading Bin file into an effective upgrading Bin file of another area according to the current operation area reported by the single chip microcomputer, and the online upgrading is smoothly realized under the condition of not interrupting the service.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.

Claims (10)

2. The on-line upgrading method of the single chip microcomputer according to claim 1, wherein the upgrading software of the upper computer determines to generate an upgrading Bin file to be transmitted according to the current operation area of the single chip microcomputer, and specifically comprises the following steps: according to the currently running application program area replied by the single chip microcomputer, the upper computer upgrading software judges whether the upgrading program is in the same area as the currently running application program area of the single chip microcomputer, and if the upgrading program is in the different area, the current upgrading Bin file is directly transmitted to the single chip microcomputer; if the two-zone upgrading file is the same zone, the upper computer upgrading software converts the current upgrading Bin file to generate another zone upgrading Bin file, and then transmits the converted upgrading Bin file to the single chip microcomputer.
10. An on-line upgrading system of a single chip microcomputer, which is characterized in that the on-line upgrading system is used for completing the on-line upgrading method of the single chip microcomputer according to any one of claims 1 to 9, and comprises the single chip microcomputer (1), upper computer upgrading software (2) and a communication interface (3), wherein FLASH of the single chip microcomputer (1) is divided into a common interrupt vector area, an application program area A and an application program area B, wherein the interrupt vector area is a common area of the application program area A and the application program area B, and the application program area A and the application program area B are respectively composed of an interrupt vector area and a program code area;
the upper computer upgrading software (2) is used for converting the upgrading Bin file in the same area into an effective upgrading Bin file in another area according to the running area reported by the single chip microcomputer (1) and completing online upgrading; after receiving the upgrade Bin file transmitted by the upper computer upgrade software (2), the single chip microcomputer (1) correspondingly writes an interrupt vector area of an upgrade program into an interrupt vector area of an application program area which is not currently operated in the single chip microcomputer (1); the single chip microcomputer (1) closes interruption after receiving an upgrading skip command, an interruption vector area of an upgrading program is copied to a common interruption vector area in the single chip microcomputer (1), and the single chip microcomputer (1) runs a new program after soft restart to complete upgrading;
CN201810995065.2A2018-08-292018-08-29Singlechip online upgrading method and systemActiveCN109240730B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201810995065.2ACN109240730B (en)2018-08-292018-08-29Singlechip online upgrading method and system

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201810995065.2ACN109240730B (en)2018-08-292018-08-29Singlechip online upgrading method and system

Publications (2)

Publication NumberPublication Date
CN109240730A CN109240730A (en)2019-01-18
CN109240730Btrue CN109240730B (en)2021-10-08

Family

ID=65069779

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201810995065.2AActiveCN109240730B (en)2018-08-292018-08-29Singlechip online upgrading method and system

Country Status (1)

CountryLink
CN (1)CN109240730B (en)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN109358887B (en)*2018-12-172021-10-22武汉精立电子技术有限公司On-line upgrading method, device and system for single chip microcomputer program
CN110209531A (en)*2019-05-232019-09-06湖北三江航天险峰电子信息有限公司A kind of long-range ARM online upgrade system and method based on RS422 interface
CN110244971A (en)*2019-05-282019-09-17湖北三江航天险峰电子信息有限公司A kind of On-line Product upgrade-system and method based on multiple load
CN110347417B (en)*2019-07-112023-08-29南京沁恒微电子股份有限公司IAP program upgrading method for MCU of fixed vector table
CN110471675B (en)*2019-08-212023-06-16山东比特智能科技股份有限公司Program burning method, system, device and computer readable storage medium
CN111008010A (en)*2019-11-142020-04-14天津航空机电有限公司RS485 bus-based singlechip application software online programming method and device
CN111273937B (en)*2020-01-182023-04-07四川九洲空管科技有限责任公司Remote upgrading method based on STM32F746 processor
CN112035151A (en)*2020-08-172020-12-04西安航天三沃机电设备有限责任公司Method for upgrading inertial measurement unit software on line
CN112631628B (en)*2020-12-112024-09-20邦彦技术股份有限公司Singlechip upgrading method, singlechip and storage medium
CN113407206A (en)*2021-06-082021-09-17厦门美科物联科技有限公司Self-defined upgrading method of single chip microcomputer
CN114185572B (en)*2021-11-042025-09-19潍柴动力股份有限公司Data refreshing method, device, equipment and storage medium
CN114490178A (en)*2021-12-222022-05-13青岛乾程科技股份有限公司 Method for upgrading electric energy meter software and electric energy meter
CN114741107A (en)*2022-05-092022-07-12珠海格力电器股份有限公司Program online upgrading method and system and air conditioner
CN116594661B (en)*2023-07-192023-09-19成都泰格微电子研究所有限责任公司Singlechip upgrading method for ensuring matching of firmware and engineering in compiling stage

Citations (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN105912356A (en)*2016-03-312016-08-31武汉光迅科技股份有限公司Optical module firmware program online upgrade method supporting version fallback
CN107977222A (en)*2017-12-212018-05-01北京京存技术有限公司Suitable for the conversion of the upgrade file of eMMC, generation method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US6834384B2 (en)*2001-03-142004-12-21General Instrument CorporationMethods and apparatus for upgrading firmware in an embedded system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN105912356A (en)*2016-03-312016-08-31武汉光迅科技股份有限公司Optical module firmware program online upgrade method supporting version fallback
CN107977222A (en)*2017-12-212018-05-01北京京存技术有限公司Suitable for the conversion of the upgrade file of eMMC, generation method and device

Also Published As

Publication numberPublication date
CN109240730A (en)2019-01-18

Similar Documents

PublicationPublication DateTitle
CN109240730B (en)Singlechip online upgrading method and system
US5826017A (en)Apparatus and method for communicating data between elements of a distributed system using a general protocol
US6314567B1 (en)Apparatus and method for transferring state data when performing on-line replacement of a running program code and data
KR100675518B1 (en) Modular BIOS Update Mechanism
US6269442B1 (en)Apparatus and method for on-line replacement of a running program code and data using checkpoints
US10216514B2 (en)Identification of a component for upgrade
WO2021115477A1 (en)Program upgrade method and apparatus, electronic device and storage medium
CN110633091A (en)Electronic module and software wireless upgrading method thereof
US20110283274A1 (en)Firmware image update and management
CN108509215B (en)System software replacing method and device, terminal equipment and storage medium
CN111813428A (en)Method and device for upgrading terminal firmware, electronic equipment and storage medium
CN111666094B (en)Real-time firmware upgrading system and method
EP4060484A1 (en)Control method and control device for enabling operations of application program in multiple systems
CN118426848A (en)Operating system starting method and device, computing equipment and storage medium
CN117950694A (en) Software upgrade method, device, vehicle and storage medium
US20060080636A1 (en)Method of building intelligent platform management interface firmware architecture
CN113377425B (en) Method and device for generating BMC firmware, method and device for starting BMC, and storage medium
CN110737455A (en)Firmware updating method and device and electronic equipment
CN114064086B (en)Multi-stage processor system and upgrading method thereof
CN115421761A (en)Method, device, system, equipment and medium for upgrading micro-control unit application program
CN113157329A (en)Method, system, server and storage medium for starting application
CN116594661B (en)Singlechip upgrading method for ensuring matching of firmware and engineering in compiling stage
CN115827023A (en)Firmware updating method of controller under master-slave board design
CN118885202B (en) An incremental upgrade method for embedded DSP programs
CN117688017B (en)Automatic updating method and device for protection area address adapting to AUTOSAR standard

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp