Online upgrading method suitable for MPU microprocessor
By setting specific mapping and steps in the Flash memory of the MPU microprocessor, it solves the problem that IAP technology cannot be applied to the MPU microprocessor, realized the online upgrade function of the MPU microprocessor, simplified the update process and improved Stability.
Patent Information
- Application Number
- CN202411855301.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2044-12-17
AI Technical Summary
The existing IAP technology cannot be applied to MPU microprocessors to achieve online upgrades, resulting in the MPU microprocessor being unable to perform online program updates simply and efficiently.
By setting a specific map in the Flash memory of the MPU microprocessor, including the first boot area, the second boot area, the boot program area, the third boot area, the application area and the upgrade program area, and follow specific steps. Program loading, encryption, decryption and overwriting to achieve online upgrade.
The online upgrade function of the MPU microprocessor is implemented, the program update process is simplified, the development cost and cycle is reduced, and the updated application is more stable.
Smart Images

Figure CN119336370A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software upgrade, and in particular to an online upgrade method suitable for an MPU microprocessor. Background Art
[0002] As an online upgrade technology, IAP (In Application Programming) technology can upgrade the firmware without burning the chip again, so it is of great significance in the process of program vulnerability modification and program update.
[0003] The principle of IAP technology is: map the Flash memory into two storage bodies. When running the user program on one storage body, the other storage body can be reprogrammed, and then the reprogrammed user program is transferred from one storage body to another. The implementation of IAP technology requires using its own program code to write the upgraded user program from the external interface to the Flash memory, and then through the Flash memory read and write operation, the new application program overwrites the original application program, and then restarts from the new application entry position.
[0004] However, the existing IAP technology is mostly applied to MCU (Micro Control Unit) platforms, and is rarely applied to MPU (Micro Processor Unit) platforms. The reason is that the normal startup mode of the MCU chip is to start from the main flash memory. In the main flash memory startup mode, the system memory is mapped to the startup space, and the user boot program and application program stored in the main flash memory can be automatically loaded into the startup space of the chip. However, on the MPU (Micro Processor Unit) platform, the storage area of the application is generally an external Flash memory. When the MPU chip is selected to start from the external Flash memory, the chip core processor will copy the application program to the startup space of the chip according to the system secondary boot program pointed to by the boot parameter of the first address of the Flash memory. And because the length and size of the application program copied by the system secondary boot program each time are limited, it is necessary to copy the application program multiple times according to the program segment. In order to make each program segment be placed at the specified address to realize the operation of the application program in the best way, the logic of the system secondary boot program will be very complicated. At this time, if a user boot program for online programming is added to realize the IAP function, then the system secondary boot program needs to copy the user boot program and the application program to the startup space of the chip at the same time. This will not only further increase the complexity of the system's secondary boot program, but also pose a risk that the updated application will not run properly. Summary of the invention
[0005] The purpose of the present invention is to provide an online upgrade method suitable for an MPU microprocessor to solve the technical problem that the existing IAP technology cannot be applied to the MPU microprocessor to realize online upgrade.
[0006] To achieve the above object, the present invention proposes the following technical solutions: In a first aspect, the technical solution provides an online upgrade method applicable to an MPU microprocessor, comprising: The mapping diagram of the MPU program in the external Flash memory connected to the MPU program is set as follows: starting from the first position, the mapping areas are sequentially included: the first boot area, the second boot area, the boot program area, the third boot area, the application area and the upgrade program area; wherein the first boot area is used to store the boot parameters of the application and the boot parameters of the boot program; the second boot area is used to store the boot parameters of the boot program, and the third boot area is used to store the boot parameters of the application; And includes the following steps: The MPU microprocessor is powered on to trigger reading of the boot parameters of the application stored in the first boot area, and then points to the application area to load the application in it into the MPU microprocessor for execution; Based on the upgrade instruction obtained by the application program during operation, the encrypted firmware to be upgraded is triggered and stored in the upgrade program area; After the application area receives the encrypted firmware to be upgraded, the MPU microprocessor automatically restarts and triggers the copying of boot parameters of the boot program from the second boot area to the first address of the first boot area; Based on the boot parameter of the boot program stored at the first address of the first boot area, the boot program area is directed to decrypt the encrypted firmware to be upgraded to obtain a new application program; After overwriting the old application in the application area with the new application, triggering the boot parameter of copying the application from the third boot area and overwriting it to the first address of the first boot area; The MPU microprocessor is reset to reload the new application program therein for execution.
[0007] Furthermore, the method triggers the storage of the encrypted firmware to be upgraded before the upgrade program area based on the upgrade instruction obtained during the operation of the application program; includes: Sequentially grouping the original firmware to be upgraded according to a preset number of bytes to obtain a plurality of groups of sub-firmware; When it is determined that the number of bytes of the last group of sub-firmware is not equal to the preset number of bytes, obtaining a byte difference between the number of bytes of the last group of sub-firmware and the preset number of bytes; Starting from the first free bit of the last group of sub-firmware, fill the last group of sub-firmware with invalid data equal to the byte number difference so that the final number of bytes is equal to the preset number of bytes; wherein each of the invalid data filled is the byte number difference; All group sub-firmware are encrypted based on the AES encryption algorithm to serve as the encrypted firmware to be upgraded.
[0008] Furthermore, the boot parameter of the boot program stored based on the first address of the first boot area instructs the boot program area to decrypt the encrypted firmware to be upgraded to obtain a new application program; including: decrypting each group of encrypted sub-firmware to obtain corresponding groups of decrypted sub-firmware; When determining that the last bit in the last set of decryption sub-firmware is digital data, confirming that the last set of decryption sub-firmware is filled with invalid data; From the last digit of the last group of decryption sub-firmware, delete the same number of characters corresponding to the digital data; The remaining groups of decryption sub-firmware and the last group of decryption sub-firmware that has been invalid data deleted are sequentially spliced to obtain the new application.
[0009] Furthermore, the application area receives the encrypted firmware to be upgraded; including: After determining that a group of encrypted sub-firmware is received successfully, triggering the reception of the next group of encrypted sub-firmware that is sequentially adjacent to it; otherwise, terminating the reception and sending an alarm feedback to the host computer; wherein the alarm feedback includes the number of groups corresponding to the abnormally received encrypted sub-firmware; The previous step is repeated until all group-encrypted sub-firmware are obtained.
[0010] Further, including: An abnormality occurs in the MPU microprocessor and / or the Flash memory; When it is determined that the encrypted firmware to be upgraded is being received in the application area, the receiving is terminated, and the receiving of the encrypted firmware to be upgraded is restarted based on the receiving instruction of the host computer; When it is determined that the encrypted firmware to be upgraded is decrypted in the boot program area, or the new application is used to overwrite the old application, the upgrade process is continued after restarting from the decryption of the encrypted firmware to be upgraded, or the new application is used to overwrite the old application.
[0011] In a second aspect, the technical solution provides an online upgrade system applicable to an MPU microprocessor, including: The mapping diagram of the MPU program in the external Flash memory connected to the MPU program is set as follows: starting from the first position, the mapping areas are sequentially included: the first boot area, the second boot area, the boot program area, the third boot area, the application area and the upgrade program area; wherein the first boot area is used to store the boot parameters of the application and the boot parameters of the boot program; the second boot area is used to store the boot parameters of the boot program, and the third boot area is used to store the boot parameters of the application; And includes the following modules: An application running module, used for powering on the MPU microprocessor to trigger reading the boot parameters of the application stored in the first boot area, and then pointing to the application area to load the application in it into the MPU microprocessor for running; A first storage module, used for triggering the storage of the encrypted firmware to be upgraded to the upgrade program area based on the upgrade instruction obtained by the application during operation; A second storage module is used for automatically restarting the MPU microprocessor after the application area receives the encrypted firmware to be upgraded, and triggering the copying of boot parameters of the boot program from the second boot area to the first address of the first boot area; A third storage module, based on the boot parameter of the boot program stored at the first address of the first boot area, directs the boot program area to decrypt the encrypted firmware to be upgraded to obtain a new application program; A fourth storage module, after overwriting the old application in the application area with the new application, triggers the boot parameter of copying the application from the third boot area and overwriting it to the first address of the first boot area; The reset operation module is used to reset the MPU microprocessor to reload the new application program into it for operation.
[0012] Further, including: A grouping module, used for grouping the original firmware to be upgraded in sequence according to a preset number of bytes to obtain several groups of sub-firmware; A calculation module, configured to obtain a byte difference between the byte number of the last group of sub-firmware and the preset byte number when determining that the byte number of the last group of sub-firmware is not equal to the preset byte number; A filling module, used for filling the last group of sub-firmware with invalid data of the byte number difference starting from the first free bit of the last group of sub-firmware so that the final number of bytes is equal to the preset number of bytes; wherein each of the invalid data filled is the byte number difference; The encryption module is used to encrypt all group sub-firmware based on the AES encryption algorithm to serve as the encrypted firmware to be upgraded.
[0013] Furthermore, the third storage module includes: A decryption unit, used for decrypting each group of encrypted sub-firmware to obtain each corresponding group of decrypted sub-firmware; a judging unit, configured to judge that when the last bit in the last set of decryption sub-firmware is digital data, confirm that the last set of decryption sub-firmware is filled with invalid data; a deleting unit, used for deleting a number of characters corresponding to the digital data starting from the last digit of the last group of decryption sub-firmware; The splicing unit is used to sequentially splice the remaining groups of decryption sub-firmware and the last group of decryption sub-firmware that deletes invalid data to obtain the new application program.
[0014] In a third aspect, the technical solution provides an electronic device, comprising at least one processor, wherein the processor is coupled to a memory, wherein a computer program is stored in the memory, and wherein the computer program is configured to execute the method described when executed by the processor.
[0015] In a fourth aspect, the present technical solution provides a computer-readable storage medium having a computer program stored thereon, and the computer program implements the described method when executed by a computer.
[0016] Beneficial effects: It can be seen from the above technical solutions that the technical solution of the present invention provides an online upgrade method suitable for an MPU microprocessor to solve the technical defect that the existing IAP technology cannot be applied to the MPU microprocessor to realize online upgrade, so that the MPU microprocessor can also realize the online update of the program simply and efficiently.
[0017] Specifically, the technical solution pre-maps the corresponding Flash memory as follows: starting from the first position, it includes the following mapping areas in sequence: the first boot area, the second boot area, the boot program area, the third boot area, the application area and the upgrade program area; wherein the first boot area is used to store the boot parameters of the application and the boot parameters of the boot program; the second boot area is used to store the boot parameters of the boot program, and the third boot area is used to store the boot parameters of the application. Based on the Flash mapping map, the following steps are performed: first, the MPU microprocessor is powered on to trigger the reading of the boot parameters of the application stored in the first boot area, and then points to the application area to load the application in it into the MPU microprocessor for operation. Secondly, based on the upgrade instruction obtained by the application during operation, the encrypted firmware to be upgraded is stored in the upgrade program area. After the application area receives the encrypted firmware to be upgraded, it triggers the copying of the boot parameters of the boot program from the second boot area to the first address of the first boot area. Then, based on the boot parameters of the boot program stored at the first address of the first boot area, the boot program area is instructed to decrypt the encrypted firmware to be upgraded to obtain a new application; after the new application is used to overwrite the old application in the application area, the boot parameters of the application are copied from the third boot area and overwritten to the first address of the first boot area. Finally, the MPU microprocessor is reset to reload the new application into it for execution.
[0018] In specific implementation, since the technical solution sets up boot areas for storing corresponding boot parameters for the application and the boot program respectively, the corresponding online update steps can be guided by the boot area. At the same time, during the update process, the update of the boot parameters stored in the first address in the first boot area can prompt the update progress and trigger the jump of the update steps in each program storage area and each boot storage area. Therefore, without the need to load the boot program and the application at the same time, online program upgrades or vulnerability repairs can be quickly, reliably and flexibly implemented based on the IAP technology.
[0019] It should be appreciated that all combinations of the foregoing concepts, as well as additional concepts described in greater detail below, may be considered to be part of the inventive subject matter of the present disclosure, provided such concepts are not mutually inconsistent.
[0020] The foregoing and other aspects, embodiments and features of the present invention can be more fully understood from the following description in conjunction with the accompanying drawings. Other additional aspects of the present invention, such as the features and / or beneficial effects of the exemplary embodiments, will be apparent from the following description or learned from the practice of the specific embodiments according to the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings are not intended to be drawn to scale. In the drawings, each identical or nearly identical component shown in various figures may be represented by the same reference numeral. For clarity, not every component is labeled in every figure. Embodiments of various aspects of the present invention will now be described by way of example and with reference to the accompanying drawings, in which: Figure 1 This is a mapping diagram of the MPU program on the Flash memory in this embodiment; Figure 2 This is a flow chart of the online upgrade method applicable to the MPU microprocessor described in this embodiment; Figure 3 A flowchart for encrypting the original firmware to be upgraded; Figure 4 A flowchart of abnormal handling in receiving encrypted firmware to be upgraded; Figure 5 A flowchart for decrypting the encrypted firmware to be upgraded; Figure 6 A flowchart of abnormal handling during online upgrade; Figure 7 This is a structural block diagram of the online upgrade system applicable to the MPU microprocessor described in this embodiment; Figure 8 is a structural block diagram of the electronic device described in this embodiment. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the embodiment of the present invention clearer, the technical solution of the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings of the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all of the embodiments. Based on the described embodiment of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. Unless otherwise defined, the technical terms or scientific terms used herein should be the common meaning understood by people with general skills in the field to which the present invention belongs.
[0023] The words "first", "second" and similar words used in the specification and claims of this application do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, unless the context clearly indicates otherwise, the singular form of "a", "an" or "the" and other similar words do not indicate a quantitative limitation, but rather indicate the presence of at least one. Words such as "include" or "comprise" and the like mean that the elements or objects appearing before "include" or "comprise" cover the features, wholes, steps, operations, elements and / or components listed after "include" or "comprise", and do not exclude the existence or addition of one or more other features, wholes, steps, operations, elements, components and / or their collections. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0024] As an online upgrade technology, IAP (In Application Programming) technology is of great significance in the process of program vulnerability modification and program update because it can realize firmware upgrade without burning the chip again. However, it is mostly used in MCU processors, but not in MPU microprocessors. The reason is that the Flash memory of the MPU microprocessor is external, and the chip core cannot read data directly from the Flash memory when executing instructions. Therefore, compared with the MCU, the MPU has one more operation than the MCU when the chip is powered on, which is to load the application into the internal RAM (Random Access Memory) of the chip. In view of this problem, the operation of loading the user boot program and the application into the RAM of the MPU microprocessor at the same time will be very complicated. Therefore, the IAP technology is not widely used in MPU microprocessors at present. Based on this, the present embodiment aims to provide an online upgrade method suitable for MPU microprocessors to solve the above technical problems.
[0025] The online upgrade method applicable to the MPU microprocessor described in this embodiment is specifically introduced below in conjunction with the accompanying drawings.
[0026] When the MCU microprocessor is upgraded online based on IAP technology, the corresponding built-in Flash memory mapping diagram is: starting from the first position, it is: boot program area, application program area, and upgrade program area. In specific implementation, the MCU program first enters the user boot program after power-on, and then reads a flag to determine whether an upgrade is in progress. If it is not being upgraded, the program will jump directly to the application; if the online upgrade process is in progress, the decryption upgrade will be performed and the new application corresponding to the decrypted upgrade firmware will be used to overwrite the old application.
[0027] However, the MPU microprocessor cannot load the boot program and the application program at the same time due to the external plug-in form of the Flash memory. Based on this, the technical solution designs a new IAP online upgrade solution suitable for the MPU microprocessor.
[0028] In order to implement this solution, the corresponding Flash memory is mapped as follows. Figure 1 As shown, the mapping diagram of the MPU program in the external Flash memory connected to the communication connection is set as follows: starting from the first position, it includes the following mapping areas in sequence: the first boot area, the second boot area, the boot program area, the third boot area, the application area and the upgrade program area. Among them, the first boot area is used to store the boot parameters of the application and the boot parameters of the boot program. By default, the first address of the first boot area stores the boot parameters of the application. The second boot area is used to store the boot parameters of the boot program. The third boot area is used to store the boot parameters of the application. The boot program area is used to decrypt the firmware to be upgraded and overwrite the old application with the new application. The application area is used to receive the encrypted firmware to be upgraded. The upgrade program area is used to store the encrypted firmware to be upgraded, and the application receives and programs it through its own program in this area.
[0029] At this time, based on Figure 1 The Flash memory map shown in the figure is combined with Figure 2 As shown, perform the following steps to implement the method described in this embodiment: Step S102, the MPU microprocessor is powered on to trigger reading of the boot parameters of the application stored in the first boot area, and then points to the application area to load the application in it into the MPU microprocessor for execution.
[0030] This step is the default operation after the MPU microprocessor is powered on, that is, the application is pointed to by default and copied to the startup space of the MPU microprocessor for execution. If no upgrade instruction is received, the application is kept running. If an upgrade instruction is received, continue with the following steps: Step S104: triggering the storage of the encrypted firmware to be upgraded to the upgrade program area based on the upgrade instruction obtained during the operation of the application program.
[0031] In this step, the upgrade instruction is issued by the host computer. Figure 3 As shown, the original firmware to be upgraded is encrypted through the following steps: Step S10402: The original firmware to be upgraded is grouped in sequence according to a preset number of bytes to obtain a plurality of groups of sub-firmware.
[0032] Step S10404: when it is determined that the number of bytes of the last group of sub-firmware is not equal to the preset number of bytes, the difference between the number of bytes of the last group of sub-firmware and the preset number of bytes is obtained.
[0033] Step S10406: Starting from the first free bit of the last group of sub-firmware, fill the last group of sub-firmware with invalid data equal to the byte number difference so that the final byte number is equal to the preset byte number.
[0034] Among them, each invalid data filled is the byte number difference.
[0035] As another implementation, starting from a preset starting number, the byte number difference numbers can be filled in arithmetic progression in order to the end of the last group of sub-firmware so that the final byte number is equal to the preset byte number. In the specific implementation, for ease of processing, the number "1" is used as the preset starting number and "1" is used as the arithmetic progression term. For example, if the byte number difference is 8, then "1, 2, 3, 4, 5, 6, 7, 8" are filled in order as invalid data.
[0036] Step S10408: encrypt all group sub-firmware based on the AES encryption algorithm to serve as the encrypted firmware to be upgraded.
[0037] At this time, based on steps S10402 to S10408, the character length restriction of the AES encryption algorithm can be broken. In order to improve efficiency, it is possible to directly determine whether all byte numbers are multiples of 1008, and when the last group of bytes is not a multiple of 1008, continue to group them in units of 16 bytes and adopt the above invalid data filling method.
[0038] Step S106: After the application area receives the encrypted firmware to be upgraded, the MPU microprocessor automatically restarts and triggers the copying of boot parameters of the boot program from the second boot area to the first address of the first boot area.
[0039] Considering the possible abnormalities in the process of receiving the encrypted firmware to be upgraded, as a specific implementation method, Figure 4 As shown, including: Step S10602: after determining that a group of encrypted sub-firmware is received successfully, trigger the reception of the next group of encrypted sub-firmware that is adjacent to it in sequence; otherwise, terminate the reception and send an alarm feedback to the host computer.
[0040] The alarm feedback includes the number of groups corresponding to the abnormal encryption sub-firmware.
[0041] Step S10604, loop through the previous step until all group encryption sub-firmware are obtained.
[0042] At this time, the reliability of all sub-packet receiving processes will be improved by gradually verifying each packet one by one, and when receiving abnormalities, it will be convenient for technicians to quickly lock the abnormal data packets and perform corresponding vulnerability repairs.
[0043] Step S108: Based on the boot parameter of the boot program stored at the first address of the first boot area, the boot program area is directed to decrypt the encrypted firmware to be upgraded to obtain a new application program.
[0044] Specifically, based on steps S10402 to S10408, combined with Figure 5 As shown, the process of decrypting the encrypted firmware to be upgraded is as follows: Step S10802: decrypt each group of encrypted sub-firmware to obtain each group of corresponding decrypted sub-firmware.
[0045] Step S10804: When it is determined that the last bit in the last set of decryption sub-firmware is digital data, confirm that the last set of decryption sub-firmware is filled with invalid data.
[0046] As above, when the invalid data filled is in the form of an arithmetic progression, step S10804 corresponds to: obtaining the last digit of the last set of decryption sub-firmware data, and obtaining the difference in the number of filled bytes based on the preset starting number and the arithmetic progression.
[0047] Step S10806: Delete characters that are consistent with the number corresponding to the digital data from the last digit of the last group of decryption sub-firmware.
[0048] As above, when the invalid data filled is in the form of an arithmetic progression, step S10806 corresponds to: starting from the last digit of the last group of decryption sub-firmware, delete the characters of the byte difference. For example, when the preset starting number is 1, the arithmetic progression is 1, and the last digit of the digital data obtained is 8, the byte difference filled is 8, and 8 bits of invalid data are deleted from the last digit.
[0049] Step S10808: sequentially splice the remaining groups of decryption sub-firmware and the last group of decryption sub-firmware that has been invalid data deleted to obtain the new application.
[0050] At this time, based on steps S10802 to S10808, the number of bits of invalid data can be quickly locked and removed through the tail data. Similarly, in order to improve efficiency, it can be directly determined whether all bytes are multiples of 1024, and when the last group of bytes is not a multiple of 1024, it continues to be grouped and read in units of 16 bytes.
[0051] Step S110: After the old application in the application area is overwritten with the new application, the boot parameters of the application are copied from the third boot area and overwritten to the first address of the first boot area.
[0052] Step S112: reset the MPU microprocessor to reload the new application program into it for execution.
[0053] Furthermore, considering that the upgrade process also includes other possible exceptions in addition to the firmware to be upgraded receiving exception, as a specific implementation method, combined with Figure 6 As shown, it also includes: Step S202: An abnormality occurs in the MPU microprocessor and / or the Flash memory.
[0054] Step S204: when it is determined that the encrypted firmware to be upgraded is being received in the application area, the receiving is terminated, and the receiving of the encrypted firmware to be upgraded is restarted based on the instruction of the host computer.
[0055] Step S206: When it is determined that the encrypted firmware to be upgraded is decrypted or the new application is used to overwrite the old application in the boot program area, the upgrade process is continued after restarting from the decryption of the encrypted firmware to be upgraded or the use of the new application to overwrite the old application.
[0056] At this time, based on steps S202 to S206, the exceptions in different upgrade processes are handled differently. On the one hand, the smooth progress of the upgrade is ensured. On the other hand, it also avoids the problem of entering an infinite loop when an exception occurs in the boot program area, and the power is cut off when the old application is half overwritten, and the problem of being unable to recover after powering on is avoided.
[0057] From the above, it can be seen that this embodiment designs a new online upgrade method based on IAP technology based on the principle that the system secondary boot program that comes with the MPU will choose to execute different programs according to the boot parameters of the Flash memory, thereby realizing the applicability of IAP technology on the MPU microprocessor. This embodiment not only has the advantages of simpler and more flexible programs, low development costs, and short cycles, but also has the characteristics of more stable updated applications. At the same time, in the original firmware encryption process to be upgraded, the limitation of the number of bytes of the AES encryption algorithm is solved by filling invalid data with frames that do not exceed a fixed length, and the value of the invalid data happens to be the number of invalid data filled in each frame of data; the information security of the program is ensured.
[0058] The above program can be run in a processor, or it can also be stored in a memory (or referred to as a computer-readable storage medium). Computer-readable media include permanent and non-permanent, removable and non-removable media. Information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. According to the definition in this embodiment, computer-readable media does not include temporary computer-readable media, such as modulated data signals and carriers.
[0059] These computer programs can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps of the functions specified in one or more blocks can be implemented by different modules corresponding to different steps.
[0060] Correspondingly, this embodiment also provides an online upgrade system suitable for an MPU microprocessor, which is built based on the method. Figure 7 As shown, the system includes the following functional modules: The application running module is used for powering on the MPU microprocessor to trigger reading the boot parameters of the application stored in the first boot area, and then pointing to the application area to load the application in it into the MPU microprocessor for execution.
[0061] The first storage module is used to trigger the storage of the encrypted firmware to be upgraded to the upgrade program area based on the upgrade instruction obtained by the application program during operation.
[0062] The second storage module is used for the MPU microprocessor to automatically restart after the application area receives the encrypted firmware to be upgraded, and trigger the boot parameters of the boot program to be copied from the second boot area to the first address of the first boot area.
[0063] The third storage module instructs the boot program area to decrypt the encrypted firmware to be upgraded to obtain a new application program based on the boot parameter of the boot program stored at the first address of the first boot area.
[0064] The fourth storage module, after overwriting the old application in the application area with the new application, triggers the boot parameter of copying the application from the third boot area and overwriting it to the first address of the first boot area.
[0065] The reset operation module is used to reset the MPU microprocessor to reload the new application program into it for operation.
[0066] Since the system is built based on the method, what has been described above will not be repeated here.
[0067] For example, the system further comprises: The grouping module is used to group the firmware to be upgraded in sequence according to a preset number of bytes to obtain a plurality of groups of sub-firmware.
[0068] The calculation module is used to obtain the byte number difference between the byte number of the last group of sub-firmware and the preset byte number when it is determined that the byte number of the last group of sub-firmware is not equal to the preset byte number.
[0069] A filling module is used to fill the last group of sub-firmware with invalid data equal to the byte number difference starting from the first free bit of the last group of sub-firmware so that the final number of bytes is equal to the preset number of bytes; wherein each invalid data filled is the byte number difference.
[0070] The encryption module is used to encrypt all group sub-firmware based on the AES encryption algorithm to serve as the encrypted firmware to be upgraded.
[0071] For another example, the third storage module includes: The decryption unit is used for decrypting all the group-encrypted sub-firmware to obtain all the group-decrypted sub-firmware.
[0072] The judging unit is used to judge that the last bit in the last set of decryption sub-firmware is digital data, and confirm that the last set of decryption sub-firmware is filled with invalid data.
[0073] The deleting unit is used to delete the same number of characters corresponding to the digital data starting from the last digit of the last group of decryption sub-firmware.
[0074] The splicing unit is used to sequentially splice the remaining groups of decryption sub-firmware and the last group of decryption sub-firmware that deletes invalid data to obtain the new application program.
[0075] Combination Figure 8As shown, this embodiment further provides an electronic device, including at least one processor, wherein the processor is coupled to a memory, wherein a computer program is stored in the memory, and wherein the computer program is configured to execute the method when executed by the processor.
[0076] Similarly, this embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a computer, the method described is implemented.
[0077] Since the system, electronic device and computer-readable storage medium are all used to implement the method, or are built based on the method, in actual application, the program update process is simpler and more flexible, the updated program is more stable, and the corresponding development cost is lower and the cycle is shorter. Technical advantages.
[0078] Although the present invention has been disclosed as above with preferred embodiments, it is not intended to limit the present invention. A person with ordinary knowledge in the technical field to which the present invention belongs may make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be determined by the definition of the claims.
Claims
1. An online upgrade method applicable to an MPU microprocessor, characterized in that: include: The mapping diagram of the MPU program in the external Flash memory connected to the MPU program is set as follows: starting from the first position, the mapping areas are sequentially included: the first boot area, the second boot area, the boot program area, the third boot area, the application area and the upgrade program area; wherein the first boot area is used to store the boot parameters of the application and the boot parameters of the boot program; the second boot area is used to store the boot parameters of the boot program, and the third boot area is used to store the boot parameters of the application; And includes the following steps: The MPU microprocessor is powered on to trigger reading of the boot parameters of the application stored in the first boot area, and then points to the application area to load the application in it into the MPU microprocessor for execution; Based on the upgrade instruction obtained by the application program during operation, the encrypted firmware to be upgraded is triggered and stored in the upgrade program area; After the application area receives the encrypted firmware to be upgraded, the MPU microprocessor automatically restarts and triggers the copying of boot parameters of the boot program from the second boot area to the first address of the first boot area; Based on the boot parameter of the boot program stored at the first address of the first boot area, the boot program area is directed to decrypt the encrypted firmware to be upgraded to obtain a new application program; After overwriting the old application in the application area with the new application, triggering the boot parameter of copying the application from the third boot area and overwriting it to the first address of the first boot area; The MPU microprocessor is reset to reload the new application program therein for execution.
2. The online upgrade method applicable to the MPU microprocessor according to claim 1, characterized in that: The method triggers the storage of the encrypted firmware to be upgraded to the upgrade program area based on the upgrade instruction obtained during the operation of the application program; comprising: Sequentially grouping the original firmware to be upgraded according to a preset number of bytes to obtain a plurality of groups of sub-firmware; When it is determined that the number of bytes of the last group of sub-firmware is not equal to the preset number of bytes, obtaining a byte difference between the number of bytes of the last group of sub-firmware and the preset number of bytes; Starting from the first free bit of the last group of sub-firmware, fill the last group of sub-firmware with invalid data equal to the byte number difference so that the final number of bytes is equal to the preset number of bytes; wherein each of the invalid data filled is the byte number difference; All group sub-firmware are encrypted based on the AES encryption algorithm to serve as the encrypted firmware to be upgraded.
3. The online upgrade method applicable to the MPU microprocessor according to claim 2, characterized in that: The boot parameter of the boot program stored based on the first address of the first boot area instructs the boot program area to decrypt the encrypted firmware to be upgraded to obtain a new application program; including: decrypting each group of encrypted sub-firmware to obtain corresponding groups of decrypted sub-firmware; When determining that the last bit in the last set of decryption sub-firmware is digital data, confirming that the last set of decryption sub-firmware is filled with invalid data; From the last digit of the last group of decryption sub-firmware, delete the same number of characters corresponding to the digital data; The remaining groups of decryption sub-firmware and the last group of decryption sub-firmware that has been invalid data deleted are sequentially spliced to obtain the new application.
4. The online upgrade method applicable to the MPU microprocessor according to claim 2, characterized in that: The application area receives the encrypted firmware to be upgraded; including: After determining that a group of encrypted sub-firmware is received successfully, triggering the reception of the next group of encrypted sub-firmware that is sequentially adjacent to it; otherwise, terminating the reception and sending an alarm feedback to the host computer; wherein the alarm feedback includes the number of groups corresponding to the abnormally received encrypted sub-firmware; The previous step is repeated until all group-encrypted sub-firmware are obtained.
5. The online upgrade method applicable to the MPU microprocessor according to claim 1, characterized in that: include: An abnormality occurs in the MPU microprocessor and / or the Flash memory; When it is determined that the encrypted firmware to be upgraded is being received in the application area, the receiving is terminated, and the receiving of the encrypted firmware to be upgraded is restarted based on the receiving instruction of the host computer; When it is determined that the encrypted firmware to be upgraded is decrypted in the boot program area, or the new application is used to overwrite the old application, the upgrade process is continued after restarting from the decryption of the encrypted firmware to be upgraded, or the new application is used to overwrite the old application.
6. An online upgrade system suitable for an MPU microprocessor, characterized in that: include: The mapping diagram of the MPU program in the external Flash memory connected to the MPU program is set as follows: starting from the first position, the mapping areas are sequentially included: the first boot area, the second boot area, the boot program area, the third boot area, the application area and the upgrade program area; wherein the first boot area is used to store the boot parameters of the application and the boot parameters of the boot program; the second boot area is used to store the boot parameters of the boot program, and the third boot area is used to store the boot parameters of the application; And includes the following modules: An application running module, used for powering on the MPU microprocessor to trigger reading the boot parameters of the application stored in the first boot area, and then pointing to the application area to load the application in it into the MPU microprocessor for running; A first storage module, used for triggering the storage of the encrypted firmware to be upgraded to the upgrade program area based on the upgrade instruction obtained by the application during operation; A second storage module is used for automatically restarting the MPU microprocessor after the application area receives the encrypted firmware to be upgraded, and triggering the copying of boot parameters of the boot program from the second boot area to the first address of the first boot area; A third storage module, based on the boot parameter of the boot program stored at the first address of the first boot area, directs the boot program area to decrypt the encrypted firmware to be upgraded to obtain a new application program; A fourth storage module, after overwriting the old application in the application area with the new application, triggers the boot parameter of copying the application from the third boot area and overwriting it to the first address of the first boot area; The reset operation module is used to reset the MPU microprocessor to reload the new application program into it for operation.
7. The online upgrade system suitable for an MPU microprocessor according to claim 6, characterized in that: include: A grouping module, used for grouping the original firmware to be upgraded in sequence according to a preset number of bytes to obtain several groups of sub-firmware; A calculation module, configured to obtain a byte difference between the byte number of the last group of sub-firmware and the preset byte number when determining that the byte number of the last group of sub-firmware is not equal to the preset byte number; A filling module, used for filling the last group of sub-firmware with invalid data of the byte number difference starting from the first free bit of the last group of sub-firmware so that the final number of bytes is equal to the preset number of bytes; wherein each of the invalid data filled is the byte number difference; The encryption module is used to encrypt all group sub-firmware based on the AES encryption algorithm to serve as the encrypted firmware to be upgraded.
8. The online upgrade system suitable for an MPU microprocessor according to claim 7, characterized in that: The third storage module includes: A decryption unit, used for decrypting each group of encrypted sub-firmware to obtain each corresponding group of decrypted sub-firmware; a judging unit, configured to judge that when the last bit in the last set of decryption sub-firmware is digital data, confirm that the last set of decryption sub-firmware is filled with invalid data; a deleting unit, used for deleting a number of characters corresponding to the digital data starting from the last digit of the last group of decryption sub-firmware; The splicing unit is used to sequentially splice the remaining groups of decryption sub-firmware and the last group of decryption sub-firmware that deletes invalid data to obtain the new application program.
9. An electronic device, characterized in that: The method comprises at least one processor, wherein the processor is coupled to a memory, wherein a computer program is stored in the memory, and wherein the computer program is configured to execute the method according to any one of claims 1 to 5 when executed by the processor.
10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a computer, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Embedded microprocessor system and method for updating firmware thereof
CN102360304A
Remote application program on-line updating method based on DSP
CN103257880A
Program upgrading method and system, application system, and storage medium
CN109358883A
Silent upgrading method and system, terminal and readable medium
CN116582526A