Single-chip microcomputer partitioning method, single-chip microcomputer upgrading method, distributed repeater and distributed repeater upgrading method

By dividing the storage space of the microcontroller into a boot area, a main program area and a backup program area, and using the upgrade file generation method of header information merge, the problem of insufficient security and fault tolerance caused by the lack of partitioning mechanism in the existing microcontroller upgrade method is solved, and the system reliability and security improvement is achieved, and the upgrade operation process is simplified.

CN119576361APending Publication Date: 2025-03-07BEIJING SHUNSHI HONGXIN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411494816.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-24
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

The existing microcontroller upgrade methods usually replace the entire firmware, lacking an effective partitioning mechanism, resulting in a lack of security and fault tolerance during the upgrade process, which easily leads to the device being unable to start normally or get stuck.

Method used

The storage space of the microcontroller is divided into a boot area, a main program area and a backup program area. The boot area verifies the integrity of the main program area and the backup program area to ensure that the system can switch to the backup program area during the upgrade process to ensure the reliability of the system. At the same time, the upgrade file generation method of header information merge is adopted to ensure the accuracy and security of the upgrade process.

Benefits of technology

Through the partitioning mechanism, the problem of equipment failure or stuck due to upgrade failure is avoided, the system reliability and security is improved, and the upgrade operation process is simplified. At the same time, in the distributed repeater system, the partition status recording mechanism of far and near end machines reduces unnecessary data transmission, improves transmission efficiency, and shortens upgrade time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576361A_ABST
    Figure CN119576361A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of single-chip microcomputers. The invention provides a single-chip microcomputer partitioning method. The storage space of a single-chip microcomputer is divided into a guide area, a main program area and a backup program area. Compiling bin files respectively used for upgrading the main program area and the backup program area, and adding header information of 1 * Block Size bytes at the beginning of each bin file; secondly, the sizes of bin files of the main program area and the backup program area are checked, it is guaranteed that the bin files are integer multiples of the Block Size, and the bin files with the sizes smaller than the integer multiples are supplemented with 0; combining the supplemented bin files to serve as an upgrading file; and finally, the single-chip microcomputer receives an upgrading instruction, and the main program detects the current running program area and receives an upgrading file to upgrade the non-running program area. According to the method, the problem that different bin files are generated by the same program due to different partition addresses is effectively solved, so that the upgrading process is simplified, and the safety and the reliability are improved.
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 computers, and in particular relates to single chip computer partitioning, an upgrading method, and a distributed repeater station and an upgrading method thereof. Background Art

[0002] In digital repeater equipment, the microcontroller system usually does not have an operating system and file system due to cost and power consumption constraints. Traditional firmware upgrades often require suspending the normal operation of the device. In the current upgrade solution, the suspension of the program not only affects business operations but also causes the repeater equipment to be unable to provide communication services normally during the upgrade. Once the upgrade fails, the device may not start normally or even freeze, requiring manual intervention, which seriously affects the availability and service quality of the device.

[0003] Lack of partition management: Current upgrade technology usually replaces the entire firmware of the MCU, and there is no effective partition mechanism to ensure the security and fault tolerance of the upgrade. Summary of the invention

[0004] The present invention aims at the problem that in the prior art, the upgrade of a single-chip microcomputer usually involves replacing the entire firmware of the single-chip microcomputer, and there is no effective partitioning mechanism to ensure the security and fault tolerance of the upgrade. A single-chip microcomputer partitioning method is provided, wherein the storage space of the single-chip microcomputer is divided into a boot area, a main program area, and a backup program area;

[0005] The boot area is used to read the information of the main program area and check its integrity. If it is complete, the firmware program of the main program area is executed and the system starts successfully; otherwise, the backup program area is switched to repeat the above integrity check. If the integrity check of the backup program area passes, the backup program area is switched to the main program area mark, the firmware program of the backup program area is executed, and the system starts successfully; if the integrity checks of the main program area and the backup program area fail, the system starts unsuccessfully;

[0006] The main program area is used to store firmware programs;

[0007] The backup program area is used to back up the firmware program in the main program area and / or store other firmware programs;

[0008] There is at least one backup program area.

[0009] The present invention also provides a single chip computer upgrade method, which is applied to a single chip computer partitioned by the single chip computer partitioning method, and comprises the following steps:

[0010] Step 1: Compile the bin files used to upgrade the main program area and the backup program area respectively, and add 1*Block Size bytes of header information to the beginning of each bin file;

[0011] Step 2: Check the size of the bin files in the main program area and the backup program area to ensure that they are both integer multiples of the Block Size. If the size is less than an integer multiple, add 0 to it.

[0012] Step 3: Merge the supplemented bin files as the upgrade file;

[0013] Step 4: The MCU receives the upgrade instruction, detects the currently running program area, and receives the upgrade file to upgrade the non-running program area.

[0014] In some embodiments, in step 1, the header information at least includes program area information to which the bin file belongs.

[0015] In some embodiments, step 4 also includes the following steps: when receiving the upgrade file, the microcontroller detects each Block Size byte it receives until header information containing information about the program area to be upgraded is detected, and then receives the upgrade data suffixed to the header information to upgrade the non-running program area.

[0016] In some embodiments, receiving header information suffix upgrade data to upgrade the non-running program area includes the following steps: the microcontroller receives the upgrade data of each Block Size byte of the header information suffix in turn, and writes it into FLASH until the data transmission is completed or the header information is detected again, then stops writing.

[0017] In some embodiments, the single-chip microcomputer sequentially receives the upgrade data of each Block Size byte suffixed with the header information, determines whether the upgrade data of the byte is valid data, and writes it to FLASH if it is; otherwise, it does not write it, receives the next Block Size byte and repeats the above operation until the data transmission is completed or the header information is detected.

[0018] In some embodiments, after the microcontroller writes valid data into FLASH, it determines whether the FLASH is written successfully. If yes, it receives valid data of the next Block Size and repeats the writing success judgment until the data transmission is completed or the header information is detected; otherwise, the upgrade fails and ends.

[0019] The present invention also provides a distributed repeater, wherein a near-end machine is connected to a far-end machine via a medium, and the single-chip microcomputers of the near-end machine and the far-end machine are partitioned according to the single-chip microcomputer partitioning method described in the above claims.

[0020] The present invention also provides a method for upgrading a distributed repeater, which is applied to the above-mentioned distributed repeater. After the distributed repeater receives an upgrade instruction from the host computer, the near-end single-chip microcomputer is upgraded according to the above-mentioned single-chip microcomputer upgrade method.

[0021] The remote machine single-chip computer reports its own single-chip computer partition information to the local machine single-chip computer; the single-chip computer partition information includes the current running program area of ​​the remote machine single-chip computer and the firmware program version number of each program area;

[0022] When the local machine single-chip computer receives the remote machine upgrade file sent by the upper computer, it detects each Block Size byte received until the header information containing the remote machine program area to be upgraded is detected, and then the upgrade data with the suffix of the header information is transmitted to the remote machine single-chip computer. The remote machine single-chip computer uses the upgrade data to upgrade the remote machine single-chip computer program area to be upgraded.

[0023] In some embodiments, the local machine microcontroller receives the upgrade data of each Block Size byte suffixed with the header information, and determines whether the upgrade data of the byte is valid data. If so, the valid upgrade data is transmitted to the remote machine, and the remote machine microcontroller uses the valid upgrade data to upgrade the remote machine microcontroller program area to be upgraded.

[0024] The beneficial effects of the present invention are: the single-chip microcomputer FLASH is divided into a boot area, a main program area and a backup program area. During the upgrade process, the system continues to use the currently running partition, avoiding business interruption and improving the reliability of the system. At the same time, during the upgrade, the bin files of each program area are merged after adding header information to generate an upgrade file. When upgrading the single-chip microcomputer after the above partitioning, the problem of being unable to upgrade the partition due to inconsistent compiled files caused by different starting addresses is avoided, ensuring that the double partitions are transparent and imperceptible to the operator during the upgrade operation, reducing operational errors, improving safety, and simplifying the upgrade operation process. At the same time, in the distributed repeater system, the partition status recording mechanism of the far and near end machines reduces unnecessary data transmission, improves transmission efficiency, and shortens the upgrade time. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 , a partition structure diagram of the single chip computer in Example 1 of the present invention.

[0026] Figure 2 , a flowchart of verifying the integrity of the program area in the boot area in Example 1 of the present invention.

[0027] Figure 3 , the structure diagram of the merged bin file in Example 2 of the present invention.

[0028] Figure 4 , flowchart of program area upgrade in Example 2 of the present invention.

[0029] Figure 5 , a structural diagram of a repeater station upgrade in Embodiment 4 of the present invention. DETAILED DESCRIPTION

[0030] In order to make the technical problems, technical solutions and beneficial effects to be solved by the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0031] Example 1

[0032] In the existing upgrade method, the operation of the MCU system must be suspended to upgrade, resulting in the repeater equipment being unable to provide normal communication services during the upgrade. Since the upgrade process operates on key parts of the system, once the upgrade fails, the device may enter an unrecoverable state or even freeze, requiring manual intervention.

[0033] This example provides a MCU partitioning method, such as Figure 1 As shown, the storage space of the single-chip microcomputer is divided into a boot area (BootLoader), a main program area (A area) and a backup program area (B area). Among them, the main program area is used to store firmware programs, which are usually firmware programs that need to run automatically after the device is powered on. The backup program area can be used only to back up the firmware program in the main program area. It can also be used only to store other firmware programs that do not run by default after power-on, usually firmware programs of different versions from the main program area, or firmware programs with other functions. It can also be used to back up the firmware program in the main program area and to store other firmware programs that do not run by default after power-on. There is at least one backup program area. When upgrading, only the program area that is not running is upgraded.

[0034] like Figure 2 As shown, after power-on, BootLoader reads the main program area information and verifies its integrity. If it is complete, the firmware program in the main program area is executed and the system starts successfully; otherwise, the backup program area is switched to repeat the above integrity check. If the backup program area integrity check passes, the backup program area is switched to the main program area flag, the firmware program in the main program area is executed, and the system starts successfully; if the integrity checks of both the main program area and the backup program area fail, the system starts unsuccessfully.

[0035] After successful startup, when receiving the upgrade command, the main program detects the currently running program area (main program area or backup program area), calls the upgrade bin file to upgrade the program area that is not running, and jumps to the upgraded program area after the upgrade is completed. Since the BootLoader will switch to the main program area flag at startup, in this example, the program area to be upgraded must be marked as the backup program area.

[0036] In this example, the design of BootLoader realizes reading partition information from EEPROM, verifying partition integrity, automatically switching partitions and startup logic, which is the core of ensuring the safe operation of the system. The dual-zone partition mechanism realizes mutual backup between partitions, ensuring that the system can still run normally even if the upgrade fails.

[0037] Example 2

[0038] With respect to the MCU partitioning method in Example 1, this example provides a MCU upgrade method, comprising the following steps:

[0039] Step 1: Compile the bin files used to upgrade the main program area and the backup program area respectively, and add 1*Block Size bytes of header information to the beginning of each bin file;

[0040] Step 2: Check the size of the bin files in the main program area and the backup program area to ensure that they are both integer multiples of the Block Size. If the size is less than an integer multiple, add 0 to it.

[0041] Step 3: Merge the supplemented bin files as the upgrade file;

[0042] Step 4: The MCU receives the upgrade instruction, detects the currently running program area, and receives the upgrade file to upgrade the non-running program area.

[0043] Bin file merging method is as follows Figure 3 As shown, the header information can include the following information:

[0044] Company: Company information, 20 bytes in length, the size can be adjusted according to actual conditions.

[0045] Model: device model, 20 bytes in length, the size can be adjusted according to actual conditions.

[0046] Version: software version number, 20 bytes in length, which can be adjusted according to actual conditions.

[0047] Current: The partition's header information of the current header, length is 1 byte.

[0048] Block Size: Transmission data block size, length 4 bytes.

[0049] Size A: The number of bytes of partition A, excluding padding bytes, with a length of 4 bytes.

[0050] BlockNumA: The number of data blocks that partition A will be divided into, with a length of 4 bytes.

[0051] SizeB: the number of bytes of partition B, excluding padding bytes, with a length of 4 bytes.

[0052] BlockNumB: The number of data blocks that partition B will be divided into, with a length of 4 bytes.

[0053] If there is space available, specific data may be added depending on the product type.

[0054] The specific header information can be adjusted according to actual needs, but the Current header is indispensable. The purpose is to let the microcontroller know the program area corresponding to the upgrade data of the suffix.

[0055] The MCU uses the upgrade file generated by the above merged bin file to perform partition upgrade process as follows Figure 4 As shown, specifically including:

[0056] When the MCU receives the upgrade file, it detects each Block Size byte until it detects the header information (i.e., header data block) containing the upgrade information. Then, it receives the upgrade data suffixed with the header information to upgrade the unrunning program area. That is, the MCU processes data while receiving the upgrade file.

[0057] Among them, receiving the header information suffix upgrade data to upgrade the non-running program area includes the following steps: the microcontroller receives the upgrade data of each Block Size byte of the header information suffix in turn, and writes it into FLASH until the data transmission is completed or the header information is detected again, then stops writing, the upgrade is successful, and ends the upgrade.

[0058] Specifically, the MCU receives the upgrade data of each Block Size byte suffixed with the header information in turn, and needs to determine whether the upgrade data of the byte is valid data. If it is valid, the valid data is written into the FLASH; otherwise, it is not written, and the next Block Size byte is received and the above operation is repeated until the data transmission is completed or the header information is detected.

[0059] Furthermore, after the MCU writes the transmission data into FLASH, it is also necessary to determine whether the FLASH is written successfully. If so, it receives the next valid Block Size byte and repeats the judgment of whether the writing is successful until the data transmission is completed or the header information is detected. The upgrade is successful and the upgrade is completed (not marked in the figure); otherwise, the upgrade fails and the upgrade is completed. In actual application, the upgrade can also be ended through an external upgrade end instruction. After the upgrade is completed, the MCU automatically switches the version or switches the running program area through an external switch partition command. When the upgrade fails but the program area is successfully switched, the BootLoader will also check when restarting, and then automatically select the normal partition that has not been upgraded to ensure the normal operation of the MCU.

[0060] Example 3

[0061] This example provides a distributed repeater, the near-end machine is connected to the remote machine through a medium (optical fiber or coaxial network), and the microcontrollers of the near-end machine and the remote machine are partitioned according to the microcontroller partitioning method described in the above embodiment 1. The remote machine can be one or more.

[0062] Example 4

[0063] This example provides a method for upgrading a distributed repeater, which is applied to the distributed repeater described in Example 3.

[0064] The local machine single chip microcomputer is upgraded according to the single chip microcomputer upgrading method described in Example 2. The upgrading method of the remote machine is described in detail below.

[0065] During registration, the remote MCU needs to report its own MCU partition information to the local MCU. Its own MCU partition information includes the current running program area of ​​the remote MCU and the firmware program version number of each program area.

[0066] When the system receives the upgrade command, it sends the upgrade command to the remote machine through the near machine. After the response, the near machine MCU receives the upgrade file of the remote machine, and detects it every time it receives a Block Size byte, until it detects the header information containing the remote machine's upgrade program area information, and transmits the upgrade data with the header information suffix to the remote machine MCU. The remote machine MCU main program uses the upgrade data to upgrade the remote machine MCU program area to be upgraded.

[0067] Specifically, the near-end microcontroller performs validity detection on the upgrade data of the header information suffix before transmitting the valid upgrade data to the remote microcontroller. After receiving the valid upgrade data, the remote machine writes the valid upgrade data into FLASH and detects whether the write is successful. If successful, it continues to receive the next valid Block Size byte and writes it into FLASH, and repeatedly detects whether the write is successful. Once the write fails, it means that the upgrade has failed, and the remote machine upgrade can be ended. If the transmitted upgrade data are all written successfully, the upgrade is successful and the upgrade is ended (not shown in the figure). The host computer can also send an upgrade end instruction to the remote machine through the near-end machine. After the upgrade is completed, the running program area can be automatically switched. The host computer can also send a partition switching command to the near-end machine. After receiving the command, the near-end machine changes the partition information of the remote machine, and the remote machine switches the running program area. Similarly, when the upgrade fails but the program area is successfully switched, the BootLoader will also check when restarting, and then automatically select the normal partition that has not been upgraded to ensure the normal operation of the microcontroller.

[0068] In a distributed repeater system, the near-end machine and the remote machine are usually one-to-many, and the remote machine usually does not have networking capabilities, so all signaling needs to be forwarded by the near-end machine. The upgrade methods for the near-end machine and the remote machine are essentially similar, but considering the convenience and efficiency of data transmission on the remote machine, this example innovatively selects valid upgrade data for the remote machine on the near-end machine. The near-end machine records the current partition status of the remote machine and only transmits valid partition data that needs to be upgraded to the remote machine, thereby reducing unnecessary data transmission and improving transmission efficiency.

[0069] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0070] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A single chip computer partitioning method, characterized in that: The storage space of the single chip microcomputer is divided into a boot area, a main program area and a backup program area; The boot area is used to read the information of the main program area and check its integrity. If it is complete, the firmware program of the main program area is executed and the system starts successfully; otherwise, the backup program area is switched to repeat the above integrity check. If the integrity check of the backup program area passes, the backup program area is switched to the main program area mark, the firmware program of the backup program area is executed, and the system starts successfully; if the integrity checks of the main program area and the backup program area fail, the system starts unsuccessfully; The main program area is used to store firmware programs; The backup program area is used to back up the firmware program in the main program area and / or store other firmware programs; There is at least one backup program area.

2. A method for upgrading a single-chip microcomputer, applied to a single-chip microcomputer partitioned by the single-chip microcomputer partitioning method as described in claim 1, characterized in that: The following steps are involved: Step 1: Compile the bin files used to upgrade the main program area and the backup program area respectively, and add 1*Block Size bytes of header information to the beginning of each bin file; Step 2: Check the size of the bin files in the main program area and the backup program area to ensure that they are both integer multiples of BlockSize. If the size is less than an integer multiple, add 0 to it. Step 3: Merge the supplemented bin files as the upgrade file; Step 4: The MCU receives the upgrade instruction, detects the currently running program area, and receives the upgrade file to upgrade the non-running program area.

3. A single chip computer upgrade method according to claim 2, characterized in that: In the step 1, the header information at least includes the program area information to which the bin file belongs.

4. A single chip computer upgrade method according to claim 3, characterized in that: The step 4 also includes the following steps: when receiving the upgrade file, the single-chip microcomputer detects each Block Size byte it receives until the header information containing the program area information to be upgraded is detected, and then the upgrade data suffixed with the header information is received to upgrade the program area that is not running.

5. A single chip computer upgrade method according to claim 4, characterized in that: Receiving the header information suffix upgrade data to upgrade the non-running program area includes the following steps: the microcontroller sequentially receives the upgrade data of each Block Size byte of the header information suffix and writes it into the FLASH until the data transmission is completed or the header information is detected again, then stops writing.

6. A single chip computer upgrade method according to claim 5, characterized in that: The MCU receives the upgrade data of each Block Size byte suffixed with the header information in turn, and determines whether the upgrade data of the byte is valid data. If it is, it is written into FLASH; otherwise, it is not written, and the next Block Size byte is received and the above operation is repeated until the data transmission is completed or the header information is detected.

7. A single chip computer upgrade method according to claim 6, characterized in that: After the MCU writes valid data into FLASH, it determines whether the FLASH is written successfully. If yes, it receives valid data of the next Block Size and repeats the judgment of whether the writing is successful until the data transmission is completed or the header information is detected; Otherwise, the upgrade fails and ends.

8. A distributed repeater, wherein the near-end unit is connected to the far-end unit through a medium, characterized in that: The single-chip microcomputers of the near-end machine and the remote machine are partitioned according to the single-chip microcomputer partitioning method described in claim 1 above.

9. A method for upgrading a distributed repeater as claimed in claim 8, characterized in that: After the distributed repeater receives the upgrade instruction from the host computer, the local machine single-chip computer is upgraded according to the single-chip computer upgrade method described in any one of claims 2 to 7; The remote machine single-chip computer reports its own single-chip computer partition information to the local machine single-chip computer; the single-chip computer partition information includes the current running program area of ​​the remote machine single-chip computer and the firmware program version number of each program area; When the local machine single-chip computer receives the remote machine upgrade file sent by the upper computer, it detects each Block Size byte received until the header information containing the remote machine program area to be upgraded is detected, and then the upgrade data with the suffix of the header information is transmitted to the remote machine single-chip computer. The remote machine single-chip computer uses the upgrade data to upgrade the remote machine single-chip computer program area to be upgraded.

10. A method for upgrading a distributed repeater according to claim 9, characterized in that: The local machine single-chip computer receives the upgrade data of each Block Size byte suffixed with the header information, and determines whether the upgrade data of the byte is valid data. If it is, it transmits the valid upgrade data to the remote machine, and the remote machine single-chip computer uses the valid upgrade data to upgrade the remote machine single-chip computer program area to be upgraded.