Single-chip microcomputer online upgrading method and system

By constructing an initial upgrade package in the applied application upgrade in the single -chip microcomputer, and using the complete logo level to optimize the upgrade process, the problem of data loss and cumbersome upgrade process in existing technologies to be updated in existing technologies, realizing efficient and secure and safe Single -chip machine upgrade online.

CN119336367APending Publication Date: 2025-01-21武汉市蓝电电子股份有限公司
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411254338.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-09
Publication Date
2025-01-21

AI Technical Summary

Technical Problem

The existing microcontroller upgrade method requires erasing the entire Flash when updating the boot program, resulting in the loss of important data. The flashing process is cumbersome and requires a large amount of manpower and material investment.

Method used

A method and system for online upgrading of microcontrollers are proposed. By constructing an initial upgrade package for the application that supports boot program upgrade, the application is updated and restarted, and instructions for upgrading the boot program are issued. The application writes the upgrade package into the Flash fan where the boot program is located. area, and optimize the upgrade process through complete flags.

Benefits of technology

The guidance program was upgraded without changing the entire Flash, the loss of important data was avoided, the upgrade process was simplified, the production efficiency was improved, and the two -way online upgrade of the single -chip microcomputer was achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119336367A_ABST
    Figure CN119336367A_ABST
Patent Text Reader

Abstract

The invention discloses an online upgrading method and system for a single-chip microcomputer. The online upgrading method comprises the steps that an initial upgrading package of an application program is constructed; the initial upgrade package supports upgrade of a bootstrap program; the initial upgrade package of the application program is updated to the single-chip microcomputer, and the application program is restarted; issuing an instruction for upgrading the bootstrap program to the single-chip microcomputer; and the application program writes the received upgrade package of the bootstrap program into a Flash sector where the bootstrap program is located. According to the method, the bootstrap program can be upgraded under the condition that the whole Flash is not changed, and a system main body can be kept unchanged; secondly, closed loop of the bootstrap program and the application program is achieved, and after the application program of the single-chip microcomputer is upgraded, the bootstrap program does not need to be manually reinstalled; bidirectional online upgrading of the single-chip microcomputer is achieved, namely, application program upgrading of the bootstrap program and closed loop of the bootstrap program upgrading of the application program are achieved, and the fault-tolerant capability of the program is enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of single-chip computer online upgrade, and in particular relates to a single-chip computer online upgrade method and system. Background Art

[0002] Most of the existing MCU upgrade methods are only for application upgrades, and generally the bootloader is rarely modified after it matures. In the production process of a specific industry, the bootloader sometimes needs to be updated. The bootloader update usually requires a downloader or other flashing methods, and these operations will erase the entire Flash of the MCU, including important data stored in the Flash, but these data are very critical and cannot be erased; in addition, simply flashing with a downloader is very cumbersome. Flashing some chips requires entering the flashing mode first, and requires manual dialing or short-circuiting to the ground. These operations will lead to a large investment of manpower and material resources in actual large-scale applications. Summary of the invention

[0003] In order to solve the problem that the boot program can be upgraded independently without affecting other Flash sectors, the present invention proposes a single-chip microcomputer online upgrade method and system

[0004] A method for online upgrading a single-chip microcomputer to achieve one of the purposes of the present invention comprises:

[0005] Building an initial upgrade package of the application; the initial upgrade package supports upgrading the boot program;

[0006] Updating the initial upgrade package of the application to the single-chip microcomputer and restarting the application;

[0007] Send instructions to upgrade the boot program to the microcontroller;

[0008] The application writes the received boot program upgrade package into the Flash sector where the boot program is located.

[0009] It should be noted that the upgrade of the application program or the boot program in the present invention refers to updating the application program or the boot program.

[0010] Furthermore, it also includes setting a complete flag bit when setting the Flash address to indicate whether to upgrade the application. The technical effect of this step is that after the microcontroller is turned on, there is no need to wait for the bootloader to count down before entering the application. With this complete flag bit, the application can be entered immediately or the application upgrade step can be jumped immediately without waiting for the initialization of the communication peripherals, thereby improving the efficiency of online upgrades.

[0011] Furthermore, when the application receives an instruction to upgrade the application, the application sets the value of the complete flag bit to a flag bit indicating that the application needs to be upgraded, and resets the single-chip microcomputer.

[0012] Furthermore, the application is upgraded through the boot program, and the upgrading method includes:

[0013] After the boot program of the single-chip computer reads the value of the complete flag bit, when the value of the complete flag bit is a flag bit indicating that the application needs to be upgraded, it waits to receive an upgrade package of the application;

[0014] After receiving the upgrade package of the application, the upgrade package is written into the Flash sector where the application is located; after writing is completed, the boot program sets the value of the complete flag to a flag that does not require application upgrade; jumps to the Flash sector where the application is located to execute the upgraded application.

[0015] Furthermore, the boot program, coefficient parameters dynamically generated during the running of the application, the complete flag bit, and the application are located in different Flash sectors respectively.

[0016] A single-chip microcomputer online upgrade system to achieve the second purpose of the present invention comprises:

[0017] Application upgrade package building module: used to build an initial upgrade package of an application; the initial upgrade package supports upgrading the boot program;

[0018] Application program update module: used to update the initial upgrade package of the application program to the single-chip microcomputer and restart the application program;

[0019] Boot program update module: used to send instructions to the microcontroller to upgrade the boot program; the application writes the received boot program upgrade package into the Flash sector where the boot program is located.

[0020] Furthermore, the initial upgrade package of the application includes a complete flag bit added to the Flash address setting to indicate whether the application of the single-chip microcomputer needs to be upgraded.

[0021] Furthermore, it also includes an application upgrade module, which is used to perform online upgrade of the application through a boot program, and the upgrade method includes:

[0022] The boot program of the microcontroller reads the value of the complete flag bit, and when the value of the complete flag bit is a flag bit that requires an application program to be upgraded, it waits to receive an upgrade package of the application program;

[0023] After receiving the upgrade package of the application, the upgrade package is written into the Flash sector where the application is located; after writing is completed, the boot program sets the value of the complete flag to a flag that does not require application upgrade; jumps to the Flash sector where the application is located to execute the upgraded application.

[0024] The beneficial effects of the present invention include:

[0025] The present invention can upgrade the bootloader without changing the entire Flash, and can keep the main body of the system unchanged; secondly, a closed loop of the bootloader and the application program is realized, and after the application program of the single-chip microcomputer is upgraded, there is no need to manually flash the bootloader; the present invention realizes a two-way online upgrade of the single-chip microcomputer, that is, a closed loop of the bootloader upgrading the application program and the application program upgrading the bootloader is realized, thereby enhancing the fault tolerance of the program. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 is a schematic diagram of the online upgrade method of the present invention;

[0027] Figure 2 It is a schematic diagram of the hardware framework for MCU upgrade;

[0028] Figure 3 This is a complete storage area mapping diagram;

[0029] Figure 4 It is a schematic diagram of the application upgrade process;

[0030] Figure 5 This is a schematic diagram of the boot program upgrade process. DETAILED DESCRIPTION

[0031] The following specific implementations are used to explain the technical solutions of the claims of the present invention so that those skilled in the art can understand the claims. The protection scope of the present invention is not limited to the following specific implementation structures. The technical solutions of the claims of the present invention made by those skilled in the art but different from the following specific implementations are also within the protection scope of the present invention.

[0032] Example 1

[0033] like Figure 2 The main hardware framework involved in the present invention is shown, including a host computer system and a single-chip computer system; the host computer system can be any host with communication transceiver capabilities; the single-chip computer system is a single-chip computer with a suitably large Flash, which supports Flash erasing by sector, and it is necessary to reasonably manage the memory of the single-chip computer to ensure that no data loss or damage occurs during the upgrade process; the communication medium can be a serial port, CAN, Bluetooth, Ethernet and other entities, which are used to realize the communication between the single-chip computer and the host computer system.

[0034] In order to realize the upgrade of the boot program of the single chip microcomputer described in the present invention, the technical points of the upgrade scheme include:

[0035] (1) The upgrade protocol needs to include data verification to ensure the integrity and security of data transmission. In this embodiment, the universal CRC-16 cyclic redundancy check is used to ensure that each frame of data will not be erroneous due to factors such as electromagnetic interference during link transmission, so as to avoid minor errors causing the microcontroller system to crash.

[0036] (2) Reasonably divide the Flash sectors. The Bootloader program is usually small and can start quickly after the system is powered on. It has the ability to read and write to the memory and is placed in the starting sector of the microcontroller.

[0037] (3) A separate sector is allocated to store the application complete flag. In this embodiment, when the Bootloader program detects that the value of the application complete flag is true during startup, it means that there is no need to upgrade the application and the program jumps to the application for execution. If it is false, it means that the application does not exist or is damaged or that a version update is required, and the program stays in the Bootloader program and waits for the application to be upgraded.

[0038] (4) In the application, you need to fall back to the Bootloader program to receive the application upgrade.

[0039] (5) The application program adds the function of reading and writing the memory to upgrade the Bootloader program.

[0040] Combination Figure 3 The complete storage area map is shown below, and the following is a detailed explanation of how each part is implemented:

[0041] In this embodiment, the bootloader exists in the segment starting with address 0x8000000 and not exceeding 16K (0x8004000-0x8000000=16K). The bootloader needs to be burned by a special burning tool when it is loaded into the microcontroller for the first time. After the bootloader is burned for the first time, because the complete flag is not true, the bootloader will stay in its own loop and wait for the host computer to send the upgrade data. When the upgrade application is received, if Figure 4 As shown, new data is overwritten at address 0x8020000. After overwriting, the value of the integrity flag is set to true, and the program jumps to 0x8020000 for execution. When the computer is turned on next time, since the integrity flag is true, the boot program detects the integrity flag and immediately jumps to the application for execution.

[0042] The system parameters are stored at 0x8004000 and are the key data to be saved by the entire system. This is why the entire Flash cannot be erased. It is dynamically generated during the running of the application and records various information collected by the system.

[0043] The complete flag is stored at 0x8010000, and its purpose is to jump to the manually set identifier when the computer is turned on. Since the default value of Flash is FF when powered on, the true value of the complete flag can be any value except FF, which is 0x87654321 in this embodiment.

[0044] The application is stored at 0x8020000. There is enough space after 0x8020000, which does not affect the later addition of application code. In addition to realizing its own specific functions, the application should have a communication receiving function and the ability to read and write to the memory. Figure 5 As shown in the figure, when receiving the self-upgrade instruction, first erase the complete flag to make the complete flag value not true, then reset the system, so as to return to the boot program, start a new application upgrade, and set the complete flag value to true after the upgrade is completed. When receiving the boot program upgrade instruction, overwrite the new data at 0x8000000, and after the overwriting is completed, wait for the next restart of the machine, at which time the boot program has been updated.

[0045] Example 2

[0046] A single chip computer online upgrade method, comprising:

[0047] Building an initial upgrade package of the application; the initial upgrade package supports upgrading the boot program;

[0048] Updating the initial upgrade package of the application to the single-chip microcomputer and restarting the application;

[0049] Send instructions to upgrade the boot program to the microcontroller;

[0050] The application writes the received boot program upgrade package into the Flash sector where the boot program is located.

[0051] The present invention modifies the application program so that the boot program can be upgraded without using a downloader or other flashing methods, thereby improving production efficiency and avoiding the loss of important data caused by flashing the entire Flash.

[0052] In order to enable the application to support the upgrade of the boot program, the modification of the application includes: supporting the instruction of upgrading the boot program issued by the single chip microcomputer, and when receiving this command, the application writes the received boot program upgrade package to the Flash sector where the boot program is located. When the application is subsequently changed or modified, it only needs to inherit the above modification to support the modification of the boot program by the application.

[0053] In some embodiments, a complete flag is set in setting the Flash address to indicate whether the application is to be upgraded. The technical effect is that the application can be upgraded online when the single-chip microcomputer is in the boot program through the complete flag.

[0054] In certain embodiments, when an application receives an instruction to upgrade the application, the application sets the value of the complete flag to a flag indicating that the application does not need to be upgraded, and resets the microcontroller; after the microcontroller is reset, the boot program runs by default; since the default value of the Flash after power-on is all 0xFF, the flag indicating that the application does not need to be upgraded can be any value other than FF, which is 0x87654321 in this embodiment, but is not limited to this.

[0055] In some embodiments, the application is also upgraded online through a boot program, and the upgrade method includes:

[0056] The boot program of the microcontroller reads the value of the complete flag bit, and when the value of the complete flag bit is a flag bit that requires an application program to be upgraded, it waits to receive an upgrade package of the application program;

[0057] After receiving the upgrade package of the application, the upgrade package is written into the Flash sector where the application is located; after writing is completed, the boot program sets the value of the complete flag to a flag that does not require application upgrade; jumps to the Flash sector where the application is located to execute the upgraded application.

[0058] In some embodiments, the boot program, the coefficient parameters dynamically generated during the running of the application, the complete flag, and the application are located in different Flash sectors. Since the application occupies a large space, the starting address of the application is larger than the end address of the sector where the boot program, the coefficient parameters dynamically generated during the running of the application, and the complete flag are located, so that the application can be expanded without considering overwriting other data.

[0059] In some embodiments, the sector start address where the boot program is stored is smaller than the sector start address where the system parameters are stored; the sector start address where the system parameters are stored is smaller than the sector start address where the complete flag is stored; the sector start address where the complete flag is stored is smaller than the sector start address where the application is stored. For example: the boot program exists in the sector starting with address 0x8000000; the system parameters are stored in the sector starting with address 0x8004000; the complete flag is stored in the sector starting with address 0x8010000; the application is stored in the sector starting with address 0x8020000.

[0060] Example 3

[0061] A single-chip computer online upgrade system, comprising:

[0062] Application upgrade package building module: used to build an initial upgrade package of an application; the initial upgrade package supports upgrading the boot program;

[0063] Application program update module: used to update the initial upgrade package of the application program to the single-chip microcomputer and restart the application program;

[0064] Boot program update module: used to send instructions to the microcontroller to upgrade the boot program; the application writes the received boot program upgrade package into the Flash sector where the boot program is located.

[0065] In some embodiments, the initial upgrade package of the application includes a new complete flag bit in setting the Flash address, which is used to indicate whether the application of the microcontroller needs to be upgraded.

[0066] In some embodiments, an application program upgrade module is further included, which is used to perform online upgrade of the application program through a boot program. The upgrade method includes:

[0067] The boot program of the microcontroller reads the value of the complete flag bit, and when the value of the complete flag bit is a flag bit that requires an application program to be upgraded, it waits to receive an upgrade package of the application program;

[0068] After receiving the upgrade package of the application, the upgrade package is written into the Flash sector where the application is located; after writing is completed, the boot program sets the value of the complete flag to a flag that does not require application upgrade; jumps to the Flash sector where the application is located to execute the upgraded application.

[0069] Example 4

[0070] A computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the various steps of the method of the present invention are implemented, which will not be described in detail herein.

[0071] The computer-readable storage medium may be the data transmission device provided in any of the aforementioned embodiments or the internal storage unit of the computer device, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (smartmedia card, SMC), a secure digital (secure digital, SD) card, a flash card (flash card), etc., provided on the computer device.

[0072] Furthermore, the computer-readable storage medium may include both an internal storage unit of the computer device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data to be output or has been output.

[0073] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0074] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0075] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0076] These computer program instructions 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, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0077] Example 5

[0078] A computer program product comprises a computer program / instruction, wherein when the computer program / instruction is executed by a processor, any step of the single-chip computer online upgrade method is implemented.

[0079] The contents not described in detail in this specification belong to the prior art known to professional and technical personnel in this field.

Claims

1. A method for online upgrading of a single chip microcomputer, characterized in that: include: Build the initial upgrade package of the application; The initial upgrade package supports upgrading the boot program; Updating the initial upgrade package of the application to the single-chip microcomputer and restarting the application; Send instructions to upgrade the boot program to the microcontroller; The application writes the received boot program upgrade package into the Flash sector where the boot program is located.

2. The method for online upgrading of a single chip microcomputer as claimed in claim 1, characterized in that: It also includes setting a complete flag bit when setting the Flash address to indicate whether to upgrade the application.

3. The method for online upgrading of a single chip microcomputer as claimed in claim 2, characterized in that: When the application receives an instruction to upgrade the application, the application sets the value of the complete flag bit to the flag bit indicating that the application needs to be upgraded, and resets the single-chip microcomputer.

4. The method for online upgrading of a single chip microcomputer as claimed in claim 2, characterized in that: It also includes upgrading the application through the boot program. The upgrade method includes: After the boot program reads the value of the complete flag, when the value of the complete flag is a flag indicating that the application needs to be upgraded, it waits to receive an upgrade package of the application; After receiving the upgrade package of the application, the upgrade package is written into the Flash sector where the application is located; after writing is completed, the boot program sets the value of the complete flag to a flag that does not require application upgrade; jumps to the Flash sector where the application is located to execute the upgraded application.

5. The single chip computer online upgrade method according to claim 1, characterized in that: The boot program, coefficient parameters dynamically generated during the running of the application, the complete flag bit, and the application are located in different Flash sectors.

6. A single-chip microcomputer online upgrade system, characterized in that: include: Application upgrade package building module: used to build the initial upgrade package of the application; The initial upgrade package supports upgrading the boot program; Application update module: used to update the initial upgrade package of the application to the single-chip microcomputer and restart the application; Boot program update module: used to send instructions to the microcontroller to upgrade the boot program; the application writes the received boot program upgrade package into the Flash sector where the boot program is located.

7. The single chip microcomputer online upgrade system as claimed in claim 6, characterized in that: The initial upgrade package of the application includes a complete flag bit added to the Flash address setting to indicate whether the application is to be upgraded.

8. The single chip microcomputer online upgrade system as claimed in claim 7, characterized in that: It also includes an application upgrade module, which is used to upgrade the application through the boot program. The upgrade method includes: The boot program reads the value of the complete flag bit, and when the value of the complete flag bit is a flag bit indicating that the application needs to be upgraded, waits for receiving an upgrade package of the application program; After receiving the upgrade package of the application, the upgrade package is written into the Flash sector where the application is located; after writing is completed, the boot program sets the value of the complete flag to a flag that does not require application upgrade; jumps to the Flash sector where the application is located to execute the upgraded application.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the single-chip microcomputer online upgrade method as claimed in any one of claims 1 to 5 are implemented.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the single-chip microcomputer online upgrade method described in claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Program upgrading area in flash memory and program upgrading method and system

    CN111984298A

  • Software upgrading method and system

    CN114880008A

  • Single-chip microcomputer bootstrap program upgrading method and device, equipment and storage medium

    CN117971253A