Online upgrading method and electronic equipment

By setting off-chip memory for the main and spare areas in the device, the problem of sudden power failure during the online upgrade of the device is solved, and the effect of successfully completing the upgrade and running normally after the device is powered on again.

CN119473338APending Publication Date: 2025-02-18KEHUA DATA CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411385774.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-30
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

During the online upgrade of the device, there may be a sudden power outage of the device, which causes the online upgrade of the device to fail, and the program cannot run normally after the device is powered on again.

Method used

By setting up the main area and backup area of ​​off-chip memory in the device to be upgraded, the main area is used to store the upgrade files, and the backup area is used to store the last upgrade files. The online upgrade method includes receiving the upgrade file and writing it to the main area, performing online upgrade preprocessing, and writing the files of the main area to the on-chip memory. If the device loses power, after the device is powered on again, enter the boot loader and complete the upgrade based on the files stored in the spare area or the main area.

Benefits of technology

Even if the equipment to be upgraded suddenly fails when the power is upgraded online, the upgrade can be successfully completed based on the files stored in the spare area or the files stored in the main area after powering up again, and the program can run normally.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473338A_ABST
    Figure CN119473338A_ABST
Patent Text Reader

Abstract

The invention provides an online upgrading method and electronic equipment, and belongs to the field of online upgrading. The to-be-upgraded device comprises an on-chip memory and an off-chip memory, the off-chip memory comprises a main area and a standby area, the main area is used for storing a current upgrade file, and the standby area is used for storing a last upgrade file; the method comprises the following steps: receiving a current upgrading file, and writing the current upgrading file into a main area; performing online upgrading preprocessing on the to-be-upgraded equipment; writing the upgrading file of the main area into an on-chip memory for online upgrading; and if the to-be-upgraded device is powered off in the online upgrading process, entering a boot loader after the to-be-upgraded device is powered on again, and completing the upgrading based on the file stored in the standby area or the file stored in the main area. According to the method and the device, even if the to-be-upgraded equipment is suddenly powered down during online upgrading, the upgrading can be successfully completed based on the file stored in the standby area or the file stored in the main area after the equipment is powered on again, and the program can run normally.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of online upgrading, and in particular to an online upgrading method and electronic equipment. Background Art

[0002] Online upgrade is a must-have feature for many products nowadays. There are many ways, such as JTAG, UART, CAN, etc., depending on the programming interface. Although the programming interface is different, the principle of online upgrade is similar. They all use external trigger conditions to make the chip out of the execution process of the regular application program, receive the upgrade package file and write it into the FLASH inside the chip.

[0003] However, during the online upgrade of the device, there may be a sudden power outage of the device, resulting in failure of the online upgrade of the device, and after the device is powered on again, the program cannot run normally. Summary of the invention

[0004] The embodiment of the present invention provides an online upgrade method and electronic device to solve the problem in the prior art that the online upgrade of the device fails and the program cannot run normally due to a sudden power failure of the device.

[0005] In a first aspect, an embodiment of the present invention provides an online upgrade method, wherein the device to be upgraded includes an on-chip memory and an off-chip memory, the off-chip memory includes a main area and a backup area, the main area is used to store the current upgrade file, and the backup area is used to store the last upgrade file; the online upgrade method includes:

[0006] Receive the upgrade file and write it into the main area;

[0007] Perform online upgrade preprocessing on the equipment to be upgraded;

[0008] Write the upgrade file of the main area to the on-chip memory for online upgrade;

[0009] If the device to be upgraded loses power during the online upgrade process, the device to be upgraded will enter the boot loader after it is powered on again, and complete the upgrade based on the files stored in the backup area or the files stored in the main area.

[0010] In a possible implementation, after writing the upgrade file to the main area, the following steps are also included:

[0011] Update the flag of the main area;

[0012] Complete this upgrade based on the files stored in the backup area or the files stored in the primary area, including:

[0013] Read the current flag of the backup area;

[0014] If the current flag bit of the backup area is incorrect, read the current flag bit of the main area;

[0015] If the current flag of the main area is correct, the files stored in the main area are written into the on-chip memory to complete the upgrade.

[0016] In a possible implementation, after reading the current flag bit of the backup area, the upgrade is completed based on the files stored in the backup area or the files stored in the main area, and further includes:

[0017] If the current flag of the backup area is correct, the files stored in the main area are erased, and the files stored in the backup area are written into the on-chip memory to complete the upgrade.

[0018] In a possible implementation, before receiving the current upgrade file, the online upgrade method further includes:

[0019] Receive a firmware keyword; the firmware keyword includes information about the device to be upgraded associated with the upgrade file; the firmware keyword is stored in the file header of the upgrade file;

[0020] Determine whether the information of the device to be upgraded matches the information of the device to be upgraded;

[0021] Receive this upgrade file, including:

[0022] If the information of the device to be upgraded matches the information of the device to be upgraded, the upgrade file is received.

[0023] In a possible implementation, receiving the current upgrade file and writing the current upgrade file into the main area includes:

[0024] Receive the upgrade file in frames;

[0025] Perform CRC check and frame index number check on each frame of upgrade data received, and write the upgrade data that passes the CRC check and frame index number check into the main area;

[0026] Perform MD5 verification on the entire upgrade file received;

[0027] If the MD5 verification passes, the operation of writing the upgrade file to the main area is successfully completed.

[0028] In a possible implementation, in the process of writing the current upgrade file of the main area into the on-chip memory for online upgrade, the online upgrade method further includes:

[0029] If a data writing error is detected during the process of writing the current upgrade file of the main area into the on-chip memory, the process jumps to the step of performing online upgrade preprocessing on the device to be upgraded and continues to execute.

[0030] In a possible implementation, after the upgrade file of the main area is successfully written into the on-chip memory, the online upgrade method further includes:

[0031] Based on the master-slave area migration total state machine and the master-slave area read-write state machine, the upgrade file stored in the master area is migrated to the backup area.

[0032] In a possible implementation, the main and backup area transport general state machine includes a main area flag bit read state, a backup area erase state, a main area data read state, a backup area data write state, a backup area flag bit write state and a first idle state;

[0033] When the main and backup area transport state machine is in the main area flag reading state, if the read flag is in the reset state and the read main area flag is correct, it jumps to the backup area erasing state, sets the erase flag, and executes the backup area erasing operation;

[0034] When the main backup area transfer state machine is in the backup area erasing state, if the erase flag is in the reset state and the backup area erasing operation is completed correctly, it jumps to the main area data reading state, sets the read flag, and executes the main area data reading operation;

[0035] When the main and backup area transport state machine is in the main area data reading state, if the read flag is in the reset state and the main area data reading operation is completed correctly, it jumps to the backup area data writing state, sets the write flag, writes the data read from the main area to the backup area, records the main area operation address, updates the backup area operation address, and copies the data written to the backup area;

[0036] When the main and standby area transport general state machine is in the standby area data writing state, if the write flag is in the reset state, the standby area data writing operation is completed correctly, and the upgrade file has not been fully written into the standby area, it will jump to the main area data reading state, set the read flag, continue to perform the main area data reading operation, and record the standby area operation address and update the main area operation address; if the write flag is in the reset state, the standby area data writing operation is completed correctly, and the upgrade file is fully written into the standby area, it will jump to the standby area flag writing state, set the write flag, write the standby area flag, and package all the data written into the standby area;

[0037] When the main-standby area transport general state machine is in the standby area flag writing state, if the write flag is in the reset state and the standby area flag writing operation is completed correctly, it jumps to the first idle state.

[0038] In a possible implementation, the primary-spare area read-write state machine includes a data write state, a data read state, a data check state, an erase state, and a second idle state;

[0039] When the master / slave area read / write state machine is in the second idle state, if the erase flag is in the set state, it jumps to the erase state; if the write flag is in the set state, it jumps to the data write state; if the read flag is in the set state, it jumps to the data read state;

[0040] When the master / slave area read / write state machine is in the erase state, if the erase operation is completed, it jumps to the second idle state and resets the erase flag bit;

[0041] When the primary / sparity area read / write state machine is in the data writing state, if the data writing operation is completed, it jumps to the data reading state and sets the write flag bit;

[0042] When the primary and backup area read-write state machine is in the data reading state, if the data reading operation is completed, it jumps to the data verification state;

[0043] When the primary and backup area read-write state machine is in the data verification state, if the data verification result is normal, it jumps to the second idle state and resets the read flag and the write flag; if the data verification result is abnormal, the data is read or written again, and the data is verified again until the data verification result is normal or the number of data verifications reaches the preset number.

[0044] In a second aspect, an embodiment of the present invention provides an online upgrade device, wherein the device to be upgraded includes an on-chip memory and an off-chip memory, the off-chip memory includes a main area and a backup area, the main area is used to store the current upgrade file, and the backup area is used to store the last upgrade file; the online upgrade device includes:

[0045] The receiving module is used to receive the current upgrade file and write the current upgrade file into the main area;

[0046] A preprocessing module is used to perform online upgrade preprocessing on the equipment to be upgraded;

[0047] The online upgrade module is used to write the upgrade file of the main area into the on-chip memory for online upgrade;

[0048] The power-off processing module is used to enter the boot loader after the device to be upgraded is powered on again if the device to be upgraded loses power during the online upgrade process, and complete the upgrade based on the files stored in the backup area or the files stored in the main area.

[0049] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory and a processor, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory, and executing the online upgrade method as described in the first aspect or any possible implementation of the first aspect.

[0050] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of the online upgrade method described in the first aspect or any possible implementation method of the first aspect.

[0051] The embodiment of the present invention provides an online upgrade method and an electronic device, wherein the device to be upgraded includes an on-chip memory and an off-chip memory, the off-chip memory includes a main area and a backup area, the main area is used to store the current upgrade file, and the backup area is used to store the last upgrade file. The method receives the current upgrade file and writes the current upgrade file into the main area; performs online upgrade preprocessing on the device to be upgraded; writes the current upgrade file in the main area into the on-chip memory for online upgrade; if the device to be upgraded loses power during the online upgrade, then after the device to be upgraded is powered on again, the boot loader is entered, and the current upgrade is completed based on the file stored in the backup area or the file stored in the main area, so that even if the device to be upgraded suddenly loses power during the online upgrade, the current upgrade can be successfully completed based on the file stored in the backup area or the file stored in the main area after powering on again, and the program can run normally. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0053] Figure 1 is a schematic diagram of an application scenario provided by an embodiment of the present invention;

[0054] Figure 2 It is a flowchart of an online upgrade method provided by an embodiment of the present invention;

[0055] Figure 3 is a flow chart of an online upgrade method provided by another embodiment of the present invention;

[0056] Figure 4 is a schematic diagram of a power-off processing process provided by an embodiment of the present invention;

[0057] Figure 5 is a schematic diagram comparing an upgrade file in a first format and an upgrade file in a second format provided by an embodiment of the present invention;

[0058] Figure 6 It is a schematic diagram of the upgrade handshake process provided by an embodiment of the present invention;

[0059] Figure 7It is a schematic diagram of data leakage provided by an embodiment of the present invention;

[0060] Figure 8 is a schematic diagram of data rewriting logic provided by an embodiment of the present invention;

[0061] Fig. 9 It is a schematic diagram of a process of writing the current upgrade file into the on-chip memory according to an embodiment of the present invention;

[0062] Fig.10 It is a schematic diagram of a master-slave area transport general state machine provided by an embodiment of the present invention;

[0063] Fig.11 It is a schematic diagram of a primary-backup area read-write state machine provided by an embodiment of the present invention;

[0064] Fig.12 is a structural diagram of an online upgrade device provided by an embodiment of the present invention;

[0065] Fig.13 is a schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0066] The present application is described more clearly below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the effects of the present application, but are not intended to limit the present application in any form. It should be noted that, for those of ordinary skill in the art, several variations and improvements may be made without departing from the concept of the present application. These all fall within the scope of protection of the present application.

[0067] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0068] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0069] In the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0070] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0071] In addition, the “plurality” mentioned in the embodiments of the present application should be interpreted as two or more.

[0072] As mentioned above, online upgrade is a must-have feature for many products nowadays. There are many ways, such as JTAG, UART, CAN, etc., depending on the programming interface. Although the programming interface is different, the principle of online upgrade is similar. They all use external trigger conditions to make the chip out of the execution process of the regular application program, receive the upgrade package file and write it into the FLASH inside the chip.

[0073] However, depending on whether an external FLASH is configured, the upgrade method can be divided into two types: (1) Without external FLASH: the upgrade data is imported into the internal FLASH while being received; (2) With external FLASH: the upgrade data is first stored in the external FLASH, and after all the upgrade data is received, it is imported from the external FLASH to the internal FLASH.

[0074] A typical example of no external FLASH is the online upgrade method of the public debugging platform. Its disadvantage is that the upgrade data reception is purely open-loop and is easily interfered with, resulting in upgrade data transmission errors, thus causing equipment upgrade failure.

[0075] There is an off-chip FLASH upgrade method that can avoid the above problems by performing multi-layer verification of the upgrade package. Although this method greatly reduces the risk of upgrade failure, there are still two problems: (1) Power failure during the process of importing upgrade data from the off-chip FLASH to the on-chip FLASH, resulting in device upgrade failure; (2) An error occurs when the upgrade file is imported into the on-chip FLASH, resulting in an error when the program jumps after the upgrade data is imported. During the online upgrade of the device, there may be a sudden power failure of the device, resulting in the failure of the online upgrade of the device, and after the device is powered on again, the program cannot run normally.

[0076] In order to solve the above problems, an embodiment of the present application provides an online upgrade method for upgrading a device to be upgraded, wherein the device to be upgraded includes an on-chip memory (on-chip FLASH) and an off-chip memory (off-chip FLASH), the off-chip memory includes a main area and a backup area, the main area is used to store the current upgrade file, and the backup area is used to store the last upgrade file; the method first writes the current upgrade file into the main area, and performs online upgrade preprocessing on the device to be upgraded, and then writes the current upgrade file in the main area into the on-chip memory, if the device to be upgraded loses power during this process, the boot loader can be entered after it is powered on again, and the upgrade can be completed based on the file stored in the backup area or the file stored in the main area, so that even if the device to be upgraded suddenly loses power during the online upgrade, the upgrade can be successfully completed after powering on again, and the program can run normally.

[0077] First, see Figure 1 , Figure 1 The schematic diagram of the application scenario provided according to the embodiment of the present application is schematically shown, and the device involved in the application scenario includes a device to be upgraded and an upgrade file issuing device. The device to be upgraded may be a DSP, and the DSP includes an on-chip memory and an off-chip memory, wherein the data stored in the off-chip memory is not lost when the power is off. The upgrade file issuing device may be an ARM.

[0078] In specific application scenarios, DSP can be upgraded through ARM. The upgrade process includes: using the USB interface as the firmware import point, ARM reads the firmware information in the U disk and forwards the firmware information to DSP. After DSP receives the upgrade package, it first stores the data in the off-chip memory. After the upgrade package is sent completely and verified, the program in the on-chip memory is erased and the program stored in the off-chip memory is moved to the on-chip memory to complete the upgrade.

[0079] See also Figure 1 The communication interface between ARM and DSP is CAN or RS485, which can support single-point upgrade or broadcast upgrade. DSP and external memory can complete data transmission through SPI.

[0080] Combine the following Figure 1 For application scenarios, refer to Figures 2 to 11 To describe the online upgrade method provided according to the exemplary embodiment of the present application. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principle of the present application, and the embodiments of the present application are not limited in this respect. On the contrary, the embodiments of the present application can be applied to any applicable scenario.

[0081] It should be noted that the embodiments of the present application can be applied to electronic devices, and the electronic devices can be servers, computers, controllers, etc., that is, the online upgrade method provided by the exemplary embodiments of the present application can be performed on devices such as servers, computers, controllers, etc. The electronic device can be the above-mentioned device to be upgraded.

[0082] It should be noted that the online upgrade method provided according to the exemplary embodiment of the present application can be executed on the same device or on different devices.

[0083] See also Figure 2 , which shows an implementation flow chart of the online upgrade method provided by an embodiment of the present invention. The online upgrade method is used to upgrade the device to be upgraded, and can be specifically used to upgrade the application APP in the device to be upgraded. Among them, the device to be upgraded includes an on-chip memory and an off-chip memory, and the off-chip memory includes a main area and a backup area. The main area is used to store the current upgrade file, and the backup area is used to store the last upgrade file. The data stored in the off-chip memory is not lost when the power is off, and the main area and the backup area can be different storage areas in the off-chip memory.

[0084] It should be noted that the current upgrade file and the last upgrade file are files defined for this upgrade. The current upgrade file stores the upgrade data required for this upgrade, and the last upgrade file stores the upgrade data required for the last upgrade. When the next upgrade is performed, the current upgrade file becomes the last upgrade file corresponding to the next upgrade.

[0085] See also Figure 2 , the online upgrade method may include:

[0086] In S201, the current upgrade file is received and written into the main area.

[0087] In this embodiment, see Figure 3 The process of receiving, verifying and storing the upgrade file can receive the upgrade file issued by the upgrade file issuing device and write the upgrade file into the main area in the off-chip memory.

[0088] In some possible implementations, when the upgrade file distribution device issues the upgrade file, in order to ensure information security and reliability and prevent the upgrade file from being maliciously modified, the upgrade file will be encrypted. After the upgrade device receives the encrypted upgrade file, it will decrypt it accordingly to obtain the upgrade file.

[0089] Exemplarily, the above encryption can be performed using the AES encryption algorithm, using a 128-bit key, where the key is a custom "firmware keyword" and zeros are added if the key is less than 128 bits.

[0090] In S202, online upgrade preprocessing is performed on the device to be upgraded.

[0091] Among them, see Figure 3 In the upgrade solution process for the device to be upgraded, the online upgrade preprocessing can include APP-level preprocessing and memory (FLASH)-level preprocessing. APP-level preprocessing can include: shutting down the device to be upgraded, blocking the drive (blocking the PWM pulse), and putting the device to be upgraded in a reliable standby state. Memory (FLASH)-level preprocessing can include: unlocking the FLASH API, confirming the chip model and API tool version number, and erasing the program in the specified sector in the on-chip memory. The specified sector refers to the sector where the application to be upgraded is stored, and the sector where BootMain is located is not erased.

[0092] It should be noted that, in the above-mentioned online upgrade preprocessing process, the above-mentioned APP level preprocessing may be performed first, and then the above-mentioned memory level preprocessing may be performed.

[0093] In S203, the current upgrade file of the main area is written into the on-chip memory to perform online upgrade.

[0094] In this embodiment, see Figure 3 In the upgrade solution process of the device to be upgraded, after the device to be upgraded is pre-processed for online upgrade, the upgrade file stored in the main area can be written into the on-chip memory, specifically, it can be written into the above-mentioned specified sector of the on-chip memory to complete the online upgrade.

[0095] In S204, if the device to be upgraded loses power during the online upgrade process, the device to be upgraded enters the boot loader after it is powered on again, and completes the upgrade based on the files stored in the backup area or the files stored in the main area.

[0096] During the online upgrade process, power outage may occur, resulting in online upgrade failure. For example, during the process of writing the upgrade file of the main area to the on-chip memory, a sudden power outage occurs, resulting in the upgrade file not being completely written to the on-chip memory. At this time, after the device to be upgraded is powered on again, the application in the device to be upgraded cannot run normally.

[0097] In order to solve this problem, in the embodiment of the present application, if the device to be upgraded loses power during the upgrade process and is powered on again, it automatically enters the boot loader Bootloder, boots into the Boot program area, calls the BootMain function, and adds an online upgrade program to the BootMain function. By calling the upgrade data or upgrade file stored in the backup area or the main area, the online upgrade process is re-executed to complete the upgrade, thereby avoiding the application program of the device to be upgraded from being unable to run normally.

[0098] The online upgrade method provided in the embodiment of the present application performs online upgrade on the device to be upgraded. The device to be upgraded includes an on-chip memory and an off-chip memory. The off-chip memory includes a main area and a backup area. The main area is used to store the current upgrade file, and the backup area is used to store the last upgrade file. The method receives the current upgrade file and writes the current upgrade file into the main area; performs online upgrade preprocessing on the device to be upgraded; writes the current upgrade file in the main area into the on-chip memory for online upgrade; if the device to be upgraded loses power during the online upgrade, then after the device to be upgraded is powered on again, the boot loader is entered, and the current upgrade is completed based on the file stored in the backup area or the file stored in the main area. Therefore, even if the device to be upgraded suddenly loses power during the online upgrade, the current upgrade can be successfully completed based on the file stored in the backup area or the file stored in the main area after power is restored, and the program can run normally.

[0099] In some embodiments, see FIG. Figure 3 In the above S201, after writing the upgrade file to the main area, it also includes:

[0100] Update the flag of the main area;

[0101] In the above S204, see Figure 4 The above files stored in the backup area or the files stored in the main area complete this upgrade, including:

[0102] Read the current flag of the backup area;

[0103] If the current flag bit of the backup area is incorrect, read the current flag bit of the main area;

[0104] If the current flag of the main area is correct, the files stored in the main area are written into the on-chip memory to complete the upgrade.

[0105] In some embodiments, see Figure 4 After reading the current flag of the backup area, the above-mentioned files stored in the backup area or the files stored in the main area complete this upgrade, and also include:

[0106] If the current flag of the backup area is correct, the files stored in the main area are erased, and the files stored in the backup area are written into the on-chip memory to complete the upgrade.

[0107] See also Figure 3 In the process of receiving, verifying and storing the upgrade file in this embodiment, after successfully writing the upgrade file to the main area, the flag of the main area needs to be updated. The flag of the main area may include the value of the flag of the main area and the size of the upgrade file. The flag of the main area is stored in the main area.

[0108] Updating the flag of the main area may include updating the value of the main area flag to a preset main area flag, and writing the size of the current upgrade file. When the value of the main area flag is the preset main area flag, it indicates that the current upgrade file has been successfully written into the main area. The size of the current upgrade file can be used to indicate the length of the current upgrade file transferred from the main area to the backup area.

[0109] The current flag bit of the backup area includes a current backup area flag bit value, which is stored in the backup area.

[0110] Determining whether the current flag bit of the backup area is correct may include: determining whether the current flag bit of the backup area is the pre-device area flag bit, if so, the current flag bit of the backup area is correct, if not, the current flag bit of the backup area is incorrect.

[0111] If the current flag of the backup area is the pre-device area flag, that is, the current flag of the backup area is incorrect, it means that the backup area has successfully written the upgrade file, or the backup area completely stores the last upgrade file. At this time, the files stored in the main area can be erased, and based on the files stored in the backup area, call Figure 3 According to the upgrade plan for the device to be upgraded, the files stored in the backup area are written into the on-chip memory to complete the upgrade, so that the device to be upgraded completes the upgrade successfully and can successfully run the upgraded application. Alternatively, the upgrade can be rolled back to restore the device to be upgraded to the state before the upgrade, so that the application before the upgrade can be successfully run without affecting the normal operation of the device.

[0112] If the current flag bit of the backup area is not the flag bit of the pre-device area, the upgrade cannot be completed according to the files stored in the backup area. At this time, the current flag bit of the main area can be read, that is, the current flag bit value of the main area can be read.

[0113] Determining whether the current flag bit of the main area is correct may include: determining whether the current flag bit of the main area is a preset main area flag bit, if so, the current flag bit of the main area is correct, if not, the current flag bit of the main area is incorrect.

[0114] If the current flag of the main area is correct, it means that the upgrade file has been successfully written into the main area. At this time, you can call Figure 3 According to the upgrade plan for the device to be upgraded, the files stored in the main area are written into the on-chip memory to complete the upgrade, so that the device to be upgraded is successfully upgraded and the upgraded application can be successfully run.

[0115] If the current flag of the main area is incorrect, it means that the upgrade file has not been successfully written into the main area, and the upgrade cannot be performed based on the file stored in the main area. Exit this upgrade. At this time, you can upgrade through the debugging platform or use manual upgrade.

[0116] In some embodiments, before the above S201, the above online upgrade method further includes:

[0117] Receive a firmware keyword; the firmware keyword includes information about the device to be upgraded associated with the upgrade file; the firmware keyword is stored in the file header of the upgrade file;

[0118] Determine whether the information of the device to be upgraded matches the information of the device to be upgraded;

[0119] Accordingly, in the above S201, the above receiving the upgrade file includes:

[0120] If the information of the device to be upgraded matches the information of the device to be upgraded, the upgrade file is received.

[0121] See also Figure 3 Before receiving the upgrade file, an upgrade handshake is required. After the handshake succeeds, the upgrade file can be received, verified, and stored. The upgrade handshake refers to some data interaction between the upgrade file issuing device and the device to be upgraded before the upgrade, which is used to determine whether the upgrade firmware of the device to be upgraded matches, and / or whether the device to be upgraded meets the upgrade conditions, etc., to prevent the upgrade of the unmatched upgrade firmware to the device to be upgraded, causing machine abnormalities.

[0122] In order to correctly upgrade the device to be upgraded, the embodiment of the present application provides a verification mechanism to determine whether the upgraded firmware matches.

[0123] The upgrade file in the first format is transformed into the upgrade file in the second format, and the specific transformation is to add a verification code to the file header of the upgrade file in the first format, and the verification code mainly includes the information shown in Table 1. The first format and the second format can be any applicable formats, for example, one can be in .hex format and the other can be in .bin format, and so on.

[0124] Table 1 Information contained in the file header of the second format of the upgrade file

[0125]

[0126]

[0127] Compared with the original file, the modified upgrade file only adds the above code in the file header, and the subsequent upgrade data is the same as the upgrade data of the original file, and its number of bytes is the same as the value of the "upgrade data size" field.

[0128] Figure 5 This is a schematic diagram comparing the upgrade file in the first format and the upgrade file in the second format. It can be seen that the difference is only in the first line, and there is no difference in other lines.

[0129] The detailed process of upgrading handshake can be found in Figure 6 , no more details.

[0130] In some embodiments, in the above S201, the above receiving the current upgrade file and writing the current upgrade file into the main area includes:

[0131] Receive the upgrade file in frames;

[0132] Perform CRC check and frame index number check on each frame of upgrade data received, and write the upgrade data that passes the CRC check and frame index number check into the main area;

[0133] Perform MD5 verification on the entire upgrade file received;

[0134] If the MD5 verification passes, the operation of writing the upgrade file to the main area is successfully completed.

[0135] See also Figure 3 The upgrade file distribution device sends the upgrade file to the device to be upgraded in the form of multiple frames. It can be sent in a broadcast form or a point-to-point form, and there is no specific restriction here. The size of each frame of data can also be set according to actual needs, and there is no specific restriction here. For example, each frame can include 192 bytes of valid data, and so on.

[0136] The device to be upgraded needs to store the upgrade file issued this time in an off-chip memory. In order to ensure the accuracy and integrity of the data, it is very important to perform data verification on the received data.

[0137] Data verification may include CRC verification and frame index number verification for each frame of upgrade data, as well as MD5 verification for the entire upgrade file.

[0138] CRC check: Each time a frame of upgrade data is received, it is stored in the main area of ​​the off-chip memory, and the main area storage strategy is: receive data → check → write to the main area → read back → check again. The above two checks both use the CRC check method. Only when the results of the two checks are consistent, it is allowed to reply to the upgrade file distribution device that the frame of upgrade data is received successfully. Otherwise, it is replied that it is not received successfully, so that the upgrade file distribution device resends the frame of upgrade data.

[0139] Frame index number verification: the upgrade file distribution device divides the data of the current upgrade file in the second format into N frames and sends them to the device to be upgraded; N = the total number of bytes of the current upgrade file / the number of bytes sent in a single frame.

[0140] In order to prevent frame leakage and frame loss during communication and storage, it is necessary to check the index number of the received data frame by frame. The index number must satisfy the formula: ReceiveIndex = FlashIndex + 1; ReceiveIndex represents the index number of the currently received data frame; FlashIndex represents the index number of the last frame of data stored in the off-chip memory.

[0141] If the above formula is satisfied, it can be ensured that the data frames are continuous and there is no frame loss.

[0142] After the above two checks, most data anomalies can be identified. However, there is also a possibility that the upgrade file distribution device will Figure 7 If a whole line of data in the box is missing, the above communication data CRC check, frame index number check and subsequent line-by-line CRC check can all pass during the upgrade. However, because a line is missing, it will still cause program abnormality, so it is necessary to perform MD5 check on the entire file.

[0143] The process of performing MD5 verification on the entire file may include: the upgrade file issuing device sends the file header of this upgrade file to the device to be upgraded, and the device to be upgraded extracts the MD5 checksum therein; the upgrade file issuing device sends the upgrade data, and the device to be upgraded calculates the MD5 checksum on the authentic data and updates the MD5 checksum every time it receives a frame of upgrade data; when the transmission of this upgrade file is completed, the device to be upgraded compares the calculated MD5 checksum with the MD5 checksum extracted from the file header, and if the two are consistent, the upgrade continues, otherwise, the upgrade is exited or the upgrade file issuing device resends this upgrade file.

[0144] In some possible implementations, when the device to be upgraded writes the upgrade data to the off-chip memory, data anomalies may occur due to some reasons. The device to be upgraded allows a certain number of anomalies to exist, thereby improving the fault tolerance and success rate of the upgrade. The detailed logic can be found in Figure 8 When a data frame is invalid data, the data frame number will not be automatically increased by 1 when it is written. It can be marked as invalid data and rewritten until it is successfully written. When reading, invalid data is read and automatically discarded. Among them, the external FLASH is the off-chip memory.

[0145] In some possible implementations, the detailed implementation process of writing the current upgrade file of the main area into the on-chip memory in the above S203 can be found in Fig. 9. Specifically, data is read and verified in units of lines. Each line of data contains a check code for the data in this line. For example, the last byte can be the check code. The calculated check code is compared with the check code stored in the data in this line. If they are the same, the check passes, otherwise the check fails. Each line of data is marked with a record type, which is used to mark whether the line of data is upgrade data, an extended segment address, or the end of an upgrade file. Different operations are performed according to different record types. If it is upgrade data, the corresponding function is called to write it to the on-chip memory, that is, the on-chip FLASH; if it is an extended segment address, the base address is calculated. If it is the end of an upgrade file, the judgment process of whether the data is written correctly is entered.

[0146] In some embodiments, in the above S203, in the process of writing the current upgrade file of the main area into the on-chip memory for online upgrade, the online upgrade method further includes:

[0147] If a data writing error is detected during the process of writing the current upgrade file of the main area into the on-chip memory, the process jumps to the step of performing online upgrade preprocessing on the device to be upgraded and continues to execute.

[0148] In the process of writing the upgrade data into the on-chip memory, due to interference and other problems, the data writing error of the on-chip memory may occur. If the upgrade process is executed directly at this time, it will cause program errors. Therefore, the judgment of the upgrade result is added. If it fails, the execution jumps to the upgrade preprocessing link and re-executes the online upgrade solution.

[0149] Among them, when a data write error is detected, it is possible to directly jump to the online upgrade preprocessing step, or after detecting a data write error, rewrite the data, and when the number of rewrites reaches the upper limit, jump to the online upgrade preprocessing step, or after the entire upgrade file is written to the on-chip memory, when an error is detected in the data stored in the on-chip memory, jump to the online upgrade preprocessing step. The upper limit of the number of times can be set according to actual needs, such as 5 times, 10 times, and so on. The number of times of data writing and jumping to the online upgrade preprocessing step to re-execute is not unlimited, and can be set according to actual needs. For example, a maximum of 10 times is allowed. If a write error still occurs, the upgrade will be exited and the staff will debug and upgrade.

[0150] The above jump to the step of online upgrade preprocessing of the device to be upgraded continues, which can be directly jumped to Figure 3 The APP level preprocessing shown continues to execute, or it can jump directly to Figure 3 The memory level preprocessing shown continues to be performed without any specific limitation.

[0151] In some embodiments, after the upgrade file of the main area is successfully written into the on-chip memory, the online upgrade method may further include:

[0152] Based on the master-slave area migration total state machine and the master-slave area read-write state machine, the upgrade file stored in the master area is migrated to the backup area.

[0153] After successfully writing the current upgrade file into the on-chip memory, this embodiment moves the current upgrade file stored in the main area to the backup area, so that during the next upgrade, the backup area can store the previous upgrade file, facilitating the successful completion of the next upgrade.

[0154] In some embodiments, see Fig.10 , the main and backup area transport total state machine includes the main area flag bit reading state, the backup area erasing state, the main area data reading state, the backup area data writing state, the backup area flag bit writing state and the first idle state;

[0155] When the main and backup area transport state machine is in the main area flag reading state, if the read flag is in the reset state and the read main area flag is correct, it jumps to the backup area erasing state, sets the erase flag, and executes the backup area erasing operation;

[0156] When the main backup area transfer state machine is in the backup area erasing state, if the erase flag is in the reset state and the backup area erasing operation is completed correctly, it jumps to the main area data reading state, sets the read flag, and executes the main area data reading operation;

[0157] When the main and backup area transport state machine is in the main area data reading state, if the read flag is in the reset state and the main area data reading operation is completed correctly, it jumps to the backup area data writing state, sets the write flag, writes the data read from the main area to the backup area, records the main area operation address, updates the backup area operation address, and copies the data written to the backup area;

[0158] When the main and standby area transport general state machine is in the standby area data writing state, if the write flag is in the reset state, the standby area data writing operation is completed correctly, and the upgrade file has not been fully written into the standby area, it will jump to the main area data reading state, set the read flag, continue to perform the main area data reading operation, and record the standby area operation address and update the main area operation address; if the write flag is in the reset state, the standby area data writing operation is completed correctly, and the upgrade file is fully written into the standby area, it will jump to the standby area flag writing state, set the write flag, write the standby area flag, and package all the data written into the standby area;

[0159] When the main-standby area transport general state machine is in the standby area flag writing state, if the write flag is in the reset state and the standby area flag writing operation is completed correctly, it jumps to the first idle state.

[0160] Fig.10 The main and standby area transfer state machine of the embodiment of the present application is shown, and Table 2 shows the operation mechanism of the main and standby area transfer state machine. The switching priority in Table 2 has a higher priority than 2. For each flag bit in Table 2, its value is FALSE, indicating that the corresponding flag bit is in the reset state, and its value is TRUE, indicating that the corresponding flag bit is in the set state.

[0161] To determine whether the flag bit of the primary area and the flag bit of the backup area are correct, reference may be made to the relevant description in the aforementioned embodiment, which will not be described in detail.

[0162] See also Fig.10 As shown in Table 2, the master-slave area transfer state machine may also include a first power-on state, a first line data read state, a master area flag write state, and a failure state. The first line data read state may also be referred to as a file header data read state.

[0163] When the main and standby area transport state machine is in the first power-on state, if the power-on is completed, it jumps to the first line data reading state, sets the read flag bit, and reads the first line of data of the current upgrade file;

[0164] When the main and standby area transfer total state machine is in the first row data reading state, if the read flag is in the reset state and valid data exists in the first preset number of data read, it jumps to the main area flag reading state, sets the read flag, and reads the main area flag; if the read flag is in the reset state and the first preset number of data read are all invalid data, it jumps to the first idle state; the preset number can be set according to actual needs, for example, it can be 10 or 20, etc.; 0xFF in Table 2 represents invalid data.

[0165] When the main and standby area transport state machine is in the main area flag bit reading state, if the read flag bit is in the reset state and the main area flag bit is wrong, it jumps to the first idle state;

[0166] When the master-slave area transport state machine is in the first idle state, if a master area flag write request is detected, it jumps to the master area flag write state, sets the write flag, writes the master area flag, and packages all the data written to the master area;

[0167] When the main-backup area transport state machine is in the main area flag bit writing state, if the write flag bit is in the reset state and the main area flag bit writing operation is completed correctly, it jumps to the first idle state;

[0168] When the main and backup area transport state machine is in any state except the failure state, if a read or write operation error is detected, it jumps to the failure state and sets the error flag bit;

[0169] When the main and standby area transport state machine is in a failed state, it can directly jump to the first idle state.

[0170] Table 2 Operation mechanism of the main and backup area transport state machine

[0171]

[0172]

[0173] In some embodiments, the primary-spare area read-write state machine includes a data write state, a data read state, a data check state, an erase state, and a second idle state;

[0174] When the master / slave area read / write state machine is in the second idle state, if the erase flag is in the set state, it jumps to the erase state; if the write flag is in the set state, it jumps to the data write state; if the read flag is in the set state, it jumps to the data read state;

[0175] When the master / slave area read / write state machine is in the erase state, if the erase operation is completed, it jumps to the second idle state and resets the erase flag bit;

[0176] When the primary / sparity area read / write state machine is in the data writing state, if the data writing operation is completed, it jumps to the data reading state and sets the write flag bit;

[0177] When the primary and backup area read-write state machine is in the data reading state, if the data reading operation is completed, it jumps to the data verification state;

[0178] When the primary and backup area read-write state machine is in the data verification state, if the data verification result is normal, it jumps to the second idle state and resets the read flag and the write flag; if the data verification result is abnormal, the data is read or written again, and the data is verified again until the data verification result is normal or the number of data verifications reaches the preset number.

[0179] Fig.11 The main and standby area read and write state machine of the embodiment of the present application is shown, and Table 3 shows the operation mechanism of the main and standby area read and write state machine. The switching priority in Table 3 has a higher priority than 2. For each flag bit in Table 3, its value is FALSE, indicating that the corresponding flag bit is in a reset state, and its value is TRUE, indicating that the corresponding flag bit is in a set state.

[0180] See also Fig.11 As shown in Table 3, the primary and secondary area read and write state machine may further include a second power-on state. When the primary and secondary area read and write state machine is in the second power-on state, if power-on is completed, it jumps to the second idle state.

[0181] Table 3 Operation mechanism of the master and backup area read and write state machine

[0182]

[0183]

[0184] It should be noted that, in the corresponding process in the aforementioned embodiment, the corresponding process can also be implemented according to the primary and backup area transport general state machine and the primary and backup area read-write state machine.

[0185] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0186] The following is an embodiment of the device of the present invention. For details not described in detail therein, reference may be made to the corresponding method embodiment described above.

[0187] Fig.12 The following is a schematic diagram showing the structure of an online upgrade device provided by an embodiment of the present invention. For ease of explanation, only the parts related to the embodiment of the present invention are shown, which are described in detail as follows:

[0188] The device to be upgraded includes an on-chip memory and an off-chip memory. The off-chip memory includes a main area and a backup area. The main area is used to store the current upgrade file, and the backup area is used to store the last upgrade file. Fig.12 As shown, the online upgrade device 30 may include: a receiving module 31 , a pre-processing module 32 , an online upgrade module 33 and a power-off processing module 34 .

[0189] The receiving module 31 is used to receive the current upgrade file and write the current upgrade file into the main area;

[0190] A preprocessing module 32, used for performing online upgrade preprocessing on the device to be upgraded;

[0191] The online upgrade module 33 is used to write the upgrade file of the main area to the on-chip memory for online upgrade;

[0192] The power failure processing module 34 is used to enter the boot loader after the device to be upgraded is powered on again if the device to be upgraded loses power during the online upgrade process, and complete the upgrade based on the files stored in the backup area or the files stored in the main area.

[0193] In a possible implementation, in the receiving module 31, after writing the current upgrade file into the main area, the following is further included:

[0194] Update the flag of the main area;

[0195] In the power failure processing module 34, based on the files stored in the backup area or the files stored in the main area, the upgrade is completed, including:

[0196] Read the current flag of the backup area;

[0197] If the current flag bit of the backup area is incorrect, read the current flag bit of the main area;

[0198] If the current flag of the main area is correct, the files stored in the main area are written into the on-chip memory to complete the upgrade.

[0199] In a possible implementation, in the power-off processing module 34, after reading the current flag bit of the backup area, the upgrade is completed based on the files stored in the backup area or the files stored in the main area, and further includes:

[0200] If the current flag of the backup area is correct, the files stored in the main area are erased, and the files stored in the backup area are written into the on-chip memory to complete the upgrade.

[0201] In a possible implementation, the online upgrade device 30 may further include: an upgrade handshake module.

[0202] The upgrade handshake module is used to: receive a firmware keyword before receiving the upgrade file; the firmware keyword includes information about the device to be upgraded associated with the upgrade file; the firmware keyword is stored in the file header of the upgrade file; determine whether the information about the device to be upgraded matches the information about the device to be upgraded;

[0203] In the receiving module 31, receiving the current upgrade file includes:

[0204] If the information of the device to be upgraded matches the information of the device to be upgraded, the upgrade file is received.

[0205] In a possible implementation, in the receiving module 31, receiving the current upgrade file and writing the current upgrade file into the main area includes:

[0206] Receive the upgrade file in frames;

[0207] Perform CRC check and frame index number check on each frame of upgrade data received, and write the upgrade data that passes the CRC check and frame index number check into the main area;

[0208] Perform MD5 verification on the entire upgrade file received;

[0209] If the MD5 verification passes, the operation of writing the upgrade file to the main area is successfully completed.

[0210] In a possible implementation, in the online upgrade module 33, in the process of writing the current upgrade file of the main area into the on-chip memory for online upgrade, the process further includes:

[0211] If a data writing error is detected during the process of writing the current upgrade file of the main area into the on-chip memory, the process jumps to the step of performing online upgrade preprocessing on the device to be upgraded and continues to execute.

[0212] In a possible implementation, in the online upgrade module 33, after the current upgrade file of the main area is successfully written into the on-chip memory, the online upgrade method further includes:

[0213] Based on the master-slave area migration total state machine and the master-slave area read-write state machine, the upgrade file stored in the master area is migrated to the backup area.

[0214] In a possible implementation, the main and backup area transport general state machine includes a main area flag bit read state, a backup area erase state, a main area data read state, a backup area data write state, a backup area flag bit write state and a first idle state;

[0215] When the main and backup area transport state machine is in the main area flag reading state, if the read flag is in the reset state and the read main area flag is correct, it jumps to the backup area erasing state, sets the erase flag, and executes the backup area erasing operation;

[0216] When the main backup area transfer state machine is in the backup area erasing state, if the erase flag is in the reset state and the backup area erasing operation is completed correctly, it jumps to the main area data reading state, sets the read flag, and executes the main area data reading operation;

[0217] When the main and backup area transport state machine is in the main area data reading state, if the read flag is in the reset state and the main area data reading operation is completed correctly, it jumps to the backup area data writing state, sets the write flag, writes the data read from the main area to the backup area, records the main area operation address, updates the backup area operation address, and copies the data written to the backup area;

[0218] When the main and standby area transport general state machine is in the standby area data writing state, if the write flag is in the reset state, the standby area data writing operation is completed correctly, and the upgrade file has not been fully written into the standby area, it will jump to the main area data reading state, set the read flag, continue to perform the main area data reading operation, and record the standby area operation address and update the main area operation address; if the write flag is in the reset state, the standby area data writing operation is completed correctly, and the upgrade file is fully written into the standby area, it will jump to the standby area flag writing state, set the write flag, write the standby area flag, and package all the data written into the standby area;

[0219] When the main-standby area transport general state machine is in the standby area flag writing state, if the write flag is in the reset state and the standby area flag writing operation is completed correctly, it jumps to the first idle state.

[0220] In a possible implementation, the primary-spare area read-write state machine includes a data write state, a data read state, a data check state, an erase state, and a second idle state;

[0221] When the master / slave area read / write state machine is in the second idle state, if the erase flag is in the set state, it jumps to the erase state; if the write flag is in the set state, it jumps to the data write state; if the read flag is in the set state, it jumps to the data read state;

[0222] When the master / slave area read / write state machine is in the erase state, if the erase operation is completed, it jumps to the second idle state and resets the erase flag bit;

[0223] When the primary / sparity area read / write state machine is in the data writing state, if the data writing operation is completed, it jumps to the data reading state and sets the write flag bit;

[0224] When the primary and backup area read-write state machine is in the data reading state, if the data reading operation is completed, it jumps to the data verification state;

[0225] When the primary and backup area read-write state machine is in the data verification state, if the data verification result is normal, it jumps to the second idle state and resets the read flag and the write flag; if the data verification result is abnormal, the data is read or written again, and the data is verified again until the data verification result is normal or the number of data verifications reaches the preset number.

[0226] Fig.13 Schematic diagram of an electronic device provided by an embodiment of the present invention. Fig.13 As shown, the electronic device 4 of this embodiment includes: a processor 40 and a memory 41. The memory 41 is used to store a computer program 42, and the processor 40 is used to call and run the computer program 42 stored in the memory 41 to perform the steps in the above-mentioned various online upgrade method embodiments, such as Figure 2 Alternatively, the processor 40 is used to call and run the computer program 42 stored in the memory 41 to implement the functions of each module / unit in the above-mentioned device embodiments, for example Fig.12 The functions of each module are shown.

[0227] Exemplarily, the computer program 42 may be divided into one or more modules / units, which are stored in the memory 41 and executed by the processor 40 to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program 42 in the electronic device 4. For example, the computer program 42 may be divided into Fig.12 The modules shown.

[0228] The electronic device 4 may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will appreciate that Fig.13 It is only an example of the electronic device 4 and does not constitute a limitation of the electronic device 4. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.

[0229] The processor 40 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0230] The memory 41 may be an internal storage unit of the electronic device 4, such as a hard disk or memory of the electronic device 4. The memory 41 may also be an external storage device of the electronic device 4, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 4. Further, the memory 41 may also include both an internal storage unit and an external storage device of the electronic device 4. The memory 41 is used to store the computer program and other programs and data required by the electronic device. The memory 41 may also be used to temporarily store data that has been output or is to be output.

[0231] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0232] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0233] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0234] In the embodiments provided by the present invention, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0235] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0236] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0237] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned online upgrade method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium.

[0238] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. An online upgrade method, characterized in that: The device to be upgraded includes an on-chip memory and an off-chip memory, the off-chip memory includes a main area and a backup area, the main area is used to store the current upgrade file, and the backup area is used to store the last upgrade file; The online upgrade method comprises: Receive the current upgrade file and write the current upgrade file into the main area; Performing online upgrade preprocessing on the device to be upgraded; Writing the current upgrade file of the main area into the on-chip memory to perform online upgrade; If the device to be upgraded loses power during the online upgrade process, the device to be upgraded enters the boot loader after it is powered on again, and completes the upgrade based on the files stored in the backup area or the files stored in the main area.

2. The online upgrade method according to claim 1, characterized in that: After writing the upgrade file to the main area, the method further includes: Update the flag of the main area; The step of completing the upgrade based on the files stored in the backup area or the files stored in the primary area includes: Read the current flag bit of the backup area; If the current flag bit of the backup area is incorrect, read the current flag bit of the main area; If the current flag of the main area is correct, the files stored in the main area are written into the on-chip memory to complete the upgrade.

3. The online upgrade method according to claim 2, characterized in that: After reading the current flag bit of the backup area, completing the upgrade based on the file stored in the backup area or the file stored in the main area, further comprising: If the current flag bit of the backup area is correct, the files stored in the main area are erased, and the files stored in the backup area are written into the on-chip memory to complete the upgrade.

4. The online upgrade method according to claim 1, characterized in that: Before receiving the current upgrade file, the online upgrade method further includes: Receive a firmware keyword; the firmware keyword includes information of a device to be upgraded associated with the current upgrade file; the firmware keyword is stored in a file header of the current upgrade file; Determine whether the information of the device to be upgraded matches the information of the device to be upgraded; The receiving of the upgrade file includes: If the information of the device to be upgraded matches the information of the device to be upgraded, the upgrade file is received.

5. The online upgrade method according to claim 1, characterized in that: The receiving the current upgrade file and writing the current upgrade file into the main area includes: Receive the upgrade file in frames; Performing CRC check and frame index number check on each frame of received upgrade data, and writing the upgrade data that passes the CRC check and frame index number check into the main area; Perform MD5 verification on the entire upgrade file received; If the MD5 check passes, the operation of writing the upgrade file into the main area is successfully completed.

6. The online upgrade method according to claim 1, characterized in that: In the process of writing the current upgrade file of the main area into the on-chip memory for online upgrade, the online upgrade method further includes: If a data writing error is detected during the process of writing the current upgrade file of the main area into the on-chip memory, the process jumps to the step of performing online upgrade preprocessing on the device to be upgraded and continues to execute.

7. The online upgrade method according to any one of claims 1 to 6, characterized in that: After the current upgrade file of the main area is successfully written into the on-chip memory, the online upgrade method further includes: Based on the main and backup area transfer general state machine and the main and backup area read-write state machine, the current upgrade file stored in the main area is transferred to the backup area.

8. The online upgrade method according to claim 7, characterized in that: The main and backup area transport state machine includes a main area flag bit reading state, a backup area erasing state, a main area data reading state, a backup area data writing state, a backup area flag bit writing state and a first idle state; When the main-backup area transport state machine is in the main area flag reading state, if the read flag is in the reset state and the read flag of the main area is correct, it jumps to the backup area erasing state, sets the erase flag, and performs the backup area erasing operation; When the main-backup area transport state machine is in the backup area erasing state, if the erase flag is in the reset state and the backup area erasing operation is completed correctly, it jumps to the main area data reading state, sets the read flag, and executes the main area data reading operation; When the main-backup area transport general state machine is in the main area data reading state, if the read flag is in the reset state and the main area data reading operation is completed correctly, it jumps to the backup area data writing state, sets the write flag, writes the data read from the main area to the backup area, records the main area operation address, updates the backup area operation address, and copies the data written to the backup area; When the main-standby area transport general state machine is in the standby area data writing state, if the write flag is in the reset state, the standby area data writing operation is completed correctly, and the current upgrade file has not been fully written into the standby area, then jump to the main area data reading state, set the read flag, continue to perform the main area data reading operation, and record the standby area operation address and update the main area operation address; if the write flag is in the reset state, the standby area data writing operation is completed correctly, and the current upgrade file is fully written into the standby area, then jump to the standby area flag writing state, set the write flag, write the standby area flag, and package all the data written into the standby area; When the main-spare area transport general state machine is in the spare area flag writing state, if the write flag is in the reset state and the spare area flag writing operation is completed correctly, it jumps to the first idle state.

9. The online upgrade method according to claim 7, characterized in that: The main-spare area read-write state machine includes a data write state, a data read state, a data check state, an erase state, and a second idle state; When the master-slave area read-write state machine is in the second idle state, if the erase flag is in the set state, it jumps to the erase state; if the write flag is in the set state, it jumps to the data write state; If the read flag is in the set state, jump to the data reading state; When the primary-spare area read-write state machine is in the erasing state, if the erasing operation is completed, it jumps to the second idle state and resets the erasing flag bit; When the primary / spare area read / write state machine is in the data writing state, if the data writing operation is completed, it jumps to the data reading state and sets the write flag bit; When the primary-backup area read-write state machine is in the data reading state, if the data reading operation is completed, it jumps to the data verification state; When the primary-backup area read-write state machine is in the data verification state, if the data verification result is normal, it jumps to the second idle state and resets the read flag and the write flag; if the data verification result is abnormal, the data is read or written again, and the data is verified again until the data verification result is normal or the number of data verifications reaches a preset number of times.

10. An electronic device, characterized in that: The system comprises a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the online upgrade method according to any one of claims 1 to 9.

Citation Information

Cited By

  • System and method for wirelessly upgrading software program of vehicle-mounted power supply

    CN121309574A