Double-mirror-image kernel upgrading method based on embedded system

By repartitioning and identifying the image storage media of the embedded system, the secure and reliable upgrade of the embedded Linux device kernel is achieved, and the system crash caused by file corruption is solved, ensuring the security and reliability of the upgrade process.

CN119166170APending Publication Date: 2024-12-20BEIJING INHAND NETWORKS TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310726962.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-19
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

Embedded Linux devices can easily cause file corruption and system crash when writing upgrade files during operation, and it is difficult for existing technology to achieve safe and reliable kernel upgrades.

Method used

Using the dual-mirror kernel upgrade method based on embedded systems, the kernel partition is divided into startup partitions and upgrade partitions by repartitioning the mirror storage media, and the file status is identified by using a specific file name in the mirror marking partition to ensure the upgrade process Safety and reliability.

Benefits of technology

It effectively avoids system crashes caused by file corruption, ensures the security and reliability of kernel upgrades, prevents the risks brought about by upgrade failure, and completes the initialization of the mirror mark partition file after the system restarts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166170A_ABST
    Figure CN119166170A_ABST
Patent Text Reader

Abstract

The invention discloses a double-mirror-image kernel upgrading method based on an embedded system, which comprises the following steps of: re-partitioning a mirror image storage medium of the embedded system, and at least changing a partition of an original storage kernel into a first partition, a second partition and a mirror image mark partition, information corresponding to the first partition or the second partition is stored in a mirror image marking partition in the form of identification files with different file names, when kernel updating is started, the state of a current starting partition is obtained according to a current starting partition file in the mirror image marking partition, and the current starting partition serves as an upgrading partition; the kernel upgrading mirror image is stored in an upgrading partition for kernel upgrading and updating, and after upgrading and updating are completed, a partition effective file corresponding to the upgrading partition is created in the mirror image marking partition; and restarting the system, and completing the initialization of the file in the mirror image mark partition when the system starts a boot loader.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a dual-image kernel upgrade method based on an embedded system. Background Art

[0002] Embedded devices are customized devices that can flexibly tailor software and hardware modules according to user needs (function, reliability, cost, size, power consumption, environment, etc.). With the rapid development of information technology and the popularization of electronic products, more and more embedded system devices are widely used in industrial control, traffic management, information appliances, home smart management, aerospace and other fields. Due to its high reliability, strong real-time performance and customization, embedded devices have brought great convenience to our production and life.

[0003] As embedded Linux devices are increasingly used in the industrial field, the safe and reliable upgrade method of embedded Linux devices has become one of the factors to be considered. Abnormal writing of upgrade files during the operation of embedded Linux devices will cause file corruption. How to achieve safe and reliable upgrade of the kernel of embedded Linux devices and avoid the risks caused by upgrade failures or abnormalities are issues that users are concerned about.

[0004] It can be seen that in the prior art, a dual-image kernel upgrade method based on an embedded system is needed to effectively implement a safe and reliable upgrade of the kernel of an embedded Linux device. Summary of the invention

[0005] The invention provides a dual-image kernel upgrade method based on an embedded system, which solves the problem of system crash caused by file loss during the upgrade process of the current embedded system.

[0006] To achieve the above technical objectives, the present invention provides a dual-image kernel upgrade method based on an embedded system, the method comprising:

[0007] Repartitioning the image storage medium of the embedded system, changing the partition of the original storage kernel into at least a first partition, a second partition and an image mark partition;

[0008] One of the first partition and the second partition is used as a boot partition for starting the kernel, and the other is used as an upgrade partition for upgrading the kernel, and information corresponding to the first partition or the second partition is stored in the image mark partition in the form of identification files with different file names;

[0009] The types of identification files include: first partition valid file, first partition normal startup file, first partition attempted startup number file, second partition valid file, second partition normal startup file, second partition attempted startup number file and current startup partition file;

[0010] When starting the kernel update, the current boot partition status is obtained according to the current boot partition file in the image mark partition, and the current boot partition is used as the upgrade partition;

[0011] After confirming the partition upgrade, delete the partition valid file, partition normal boot file and partition boot attempt count file related to the upgraded partition in the image mark partition;

[0012] Store the kernel upgrade image in the upgrade partition to perform kernel upgrade and update. After the upgrade is completed, create a partition valid file corresponding to the upgrade partition in the image mark partition;

[0013] Restart the system and complete the initialization of the files in the image marked partition when the system starts the boot loader.

[0014] In one embodiment, the kernel A partition or the kernel B partition is essentially the same as the original kernel partition, and both are used to store kernel images.

[0015] In one embodiment, the presence of an identification file with a special file name in the image mark partition indicates that the information is valid, otherwise the information is invalid; the file size of the identification file is zero.

[0016] In one embodiment, the first partition valid file and the second partition valid file are synchronously created in the image mark partition when the kernel upgrade image is updated to the corresponding partition, and the first partition valid file or the second partition valid file of the corresponding partition is deleted when the system startup boot loader attempts to boot the first partition or the second partition to an upper limit threshold number of times.

[0017] In one embodiment, after the system successfully starts the first partition or the second partition, and when the corresponding partition startup normal file does not exist in the image mark partition, the first partition startup normal file and the second partition startup normal file are created in the image mark partition; and when the kernel upgrade image is updated to the first partition or the second partition, the first partition startup normal file and the second partition startup normal file of the corresponding partition are deleted.

[0018] In one embodiment, the first partition boot attempt count file and the second partition boot attempt count file are created when the system starts the boot loader and fails to boot the partition; the first partition boot attempt count file and the second partition boot attempt count file are deleted when the number of boot attempts reaches an upper limit or the kernel image is updated to the corresponding partition.

[0019] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:

[0021] Figure 1 It is a flow chart of a dual-image kernel upgrade method based on an embedded system of the present invention;

[0022] Figure 2 It is a schematic diagram of the storage kernel partition structure of the present invention;

[0023] Figure 3 It is a schematic diagram of the initialization process after upgrading and updating of the present invention; DETAILED DESCRIPTION

[0024] In order to make the objectives, technical solutions and advantages of the present invention more clear, the present invention is further described in detail below with reference to the accompanying drawings.

[0025] The dual-image kernel upgrade method based on the embedded system of this embodiment includes:

[0026] 1. Repartition the image storage medium based on the embedded Linux device, and change the original storage kernel partition into kernel A partition, kernel B partition and image tag partition, such as Figure 2 As shown, the kernel A partition or kernel B partition is essentially the same as the original kernel partition and is used to store kernel images. During a complete system startup process and operation cycle, the kernel A partition or kernel B partition is divided into the current kernel startup partition, i.e., the startup partition, and the partition that can be used for upgrading, i.e., the upgrade partition, according to the role. The information corresponding to the kernel A partition or kernel B partition is stored in the image tag partition in the form of a file. For example, the partition scheme shown in Table 1 below is used.

[0027] Table 1

[0028]

[0029]

[0030] 2. In order to solve the problem of file content corruption caused by abnormal power failure or abnormal restart of embedded Linux system when writing files, and avoid the situation that the file content in the image mark partition is abnormal when the kernel is upgraded, the present invention adopts a special file name to indicate the image information instead of the file content. Therefore, the existence of a file with a special file name in the image mark partition indicates that the information is valid, otherwise the information is invalid, the corresponding file content is empty, and the file size is zero.

[0031] The files stored in the image mark partition include identification files with the following file names: (taking Kernel as an example)

[0032] File name: partA_valid; Partition A valid file. If the file exists, it means that Kernel partition A is available. Otherwise, it means that partition A is unavailable.

[0033] File name: partA_success; Partition A boots normally. If the file exists, it means that Kernel partition A boots successfully. Otherwise, it means that partition A fails to boot successfully.

[0034] File name: partA_try_?, the file of the number of times partition A has tried to start. For example, partA_try_2 means that kernel partition A has tried to start twice.

[0035] File name: partB_valid; Partition B valid file. If the file exists, it means that Kernel partition B is available. Otherwise, it means that partition B is unavailable.

[0036] File name: partB_success; Partition B boots normally. If the file exists, it means that Kernel partition B boots successfully. Otherwise, it means that partition B fails to boot successfully.

[0037] File name: partB_try_?, file of the number of times partition B tries to start. For example, partB_try_2 means that kernel partition B has tried to start twice.

[0038] File name: present_part, the current boot partition file. If the file exists, it means the current boot partition is partition B. Otherwise, it means the boot partition is partition A.

[0039] In the above files, the partition A valid file and the partition B valid file are synchronously created in the image tag partition when the kernel upgrade image is updated to the corresponding partition, and the partition A valid file or the partition B valid file of the corresponding partition is deleted when the system startup boot loader (for example: U-boot) attempts to boot partition A or partition B and reaches the upper limit threshold of the number of times.

[0040] After the system successfully starts partition A or partition B, and when the corresponding partition startup normal file does not exist in the image mark partition, the partition A startup normal file or the partition B startup normal file is created in the image mark partition; and when the kernel image is updated to partition A or partition B, the partition A startup normal file or the partition B startup normal file of the corresponding partition is deleted.

[0041] The partition A startup attempt number file and the partition B startup attempt number file are created when the system starts the boot loader and fails to boot the partition; the partition A startup attempt number file or the partition B startup attempt number file is deleted when the number of boot attempts reaches the upper limit or the kernel image is updated to the corresponding partition.

[0042] The creation and deletion of the current boot partition file is determined by the system boot loader according to the status of the other files mentioned above during booting.

[0043] 3. After the update program of the dual-image kernel upgrade method of the present invention is started, the update program obtains the 'current boot partition' status from the image mark partition. When the current boot partition file does not exist, it indicates that the upgrade partition is partition B, otherwise the upgrade partition is partition A.

[0044] After confirming the upgrade partition, delete the 'partition valid', 'partition boot normal' and 'partition boot attempt times' identification files related to the upgrade partition in the image mark partition, and then download the kernel upgrade image to the upgrade partition for upgrade and update.

[0045] After the upgrade is complete, create an upgrade partition 'partition valid' file in the image tag partition. For scenarios where multiple upgrades are required or there are abnormal restarts during the upgrade process, this process and steps can effectively prevent system risks caused by incomplete image updates or image tag file updates, and ensure that the current boot partition and boot partition information used for booting are not damaged.

[0046] 4. Restart the system after the upgrade and complete the following initialization steps when the system starts the boot loader:

[0047] a. Get the file status of 'Partition A is valid', 'Partition A starts normally', 'Partition A tries to start times', 'Partition B is valid', 'Partition B starts normally', 'Partition B tries to start times' and 'Current boot partition' in the image mark partition to determine whether the file exists;

[0048] b. When 'Partition A is valid' exists and 'Partition A boots normally' does not exist, continue to determine whether 'Partition A boot attempts' has reached the upper limit. If so, delete 'Partition A is valid' and 'Partition A boot attempts' and create the 'Current boot partition' file, and restart the system. Otherwise, delete the 'Current boot partition' file, increment the 'Partition A boot attempts', and load the kernel and boot from partition A;

[0049] c. When 'Partition B is valid' exists and 'Partition B boots normally' does not exist, continue to determine whether 'Partition B boot attempts' has reached the upper limit. If so, delete 'Partition B is valid', 'Partition B boot attempts' and 'Current boot partition' files, and restart the system. Otherwise, create 'Current boot partition' file, increment 'Partition B boot attempts', and load kernel and boot from partition B;

[0050] d. When the 'current boot partition' file does not exist and 'Partition A is valid' exists and 'Partition A boots normally' exists, load the kernel from partition A and boot;

[0051] e. When the 'current boot partition' file exists, 'partition B is valid' exists, and 'partition B boots normally' exists, load the kernel from partition B and boot;

[0052] After the kernel upgrade is completed and the boot loader loads and boots the new image normally, when the device starts normally and runs to the system, the system startup program checks the status of the 'current boot partition' file in the image mark partition, confirms the boot partition, and creates the corresponding partition startup normal file when the partition startup normal file of the boot partition does not exist.

[0053] The present invention may be a system, method and / or computer program product at any possible level of integrated technical detail. The computer program product may include a computer-readable storage medium (or multiple media) having computer-readable program instructions thereon for causing a processor to perform various aspects of the present invention.

[0054] A computer readable storage medium may be a tangible device that can retain and store instructions used by an instruction execution device. The computer readable storage medium may be, for example, but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of computer readable storage media includes the following: a portable computer floppy disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device such as a punch card or a raised structure in a groove on which instructions are recorded, and any suitable combination of the above. A computer readable storage medium, as used herein, should not be interpreted as a transient signal itself, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted by a wire.

[0055] The computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to a corresponding computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network may include copper transmission cables, optical transmission fibers, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions to be stored in a computer-readable storage medium within the corresponding computing / processing device.

[0056] The computer-readable program instructions for performing the operation of the present invention may be assembler instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, configuration data for integrated circuits, or source code or object code written in any combination of one or more programming languages ​​and process programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer, partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer by any type of network including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., by using the Internet of an Internet service provider). In certain embodiments, the electronic circuit including, for example, a programmable logic circuit, a field programmable gate array (FPGA) or a programmable logic array (PLA) may execute the computer-readable program instructions by utilizing the state information of the computer-readable program instructions to personalize the electronic circuit, thereby performing aspects of the present invention.

[0057] Various aspects of the present invention are described herein with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present invention. It is understood that each block of the flowchart illustration and / or block diagram, and the combination of blocks in the flowchart illustration and / or block diagram, can be implemented by computer-readable program instructions.

[0058] These computer-readable program instructions may be provided to a processor of a computer 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 create instructions for implementing the flowcharts and / or block diagrams. Figure 1 These computer-readable program instructions may also be stored in a computer-readable storage medium capable of booting a computer, a programmable data processing device and / or other device that operates in a specific manner, so that the computer-readable storage medium having the instructions stored therein includes a manufactured product that includes instructions that implement aspects of the functions / actions specified in the flowchart and / or block diagram blocks.

[0059] Computer readable program instructions may also be loaded into a computer, other programmable data processing device, or other device to cause a series of operating steps to be performed on the computer, other programmable devices or other devices for producing a computer-implemented process, so that the instructions executed on the computer, other programmable device or other device implement the functions / actions specified in the flowchart and / or block diagram blocks.

[0060] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the system, method and computer program product according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, segment or portion of an instruction, which includes one or more executable instructions for implementing a specified logical function. In some optional implementations, the functions indicated in the block may occur outside the order indicated in the figure. For example, in fact, two blocks shown in succession can be completed as a step, and depending on the functions involved, they can be executed concurrently, substantially concurrently, in a partially or fully time-overlapping manner, or sometimes these blocks can be executed in reverse order. It will also be noted that each block of the block diagram and / or flowchart illustration, as well as the combination of blocks in the block diagram and / or flowchart illustration, can be implemented by a dedicated hardware-based system that performs a specified function or action or performs a combination of dedicated hardware and computer instructions.

[0061] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, apparatuses (devices) and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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 generate 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.

[0062] 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.

[0063] 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.

[0064] The above description is only a specific implementation case of the present invention, and the protection scope of the present invention is not limited thereto. Any modification or replacement of the present invention by any technician familiar with the present technology within the technical specifications described in the present invention should be within the protection scope of the present invention.

Claims

1. A dual-image kernel upgrade method based on an embedded system, characterized in that: The method includes: Repartitioning the image storage medium of the embedded system, changing the partition of the original storage kernel into at least a first partition, a second partition and an image mark partition; One of the first partition and the second partition is used as a boot partition for starting the kernel, and the other is used as an upgrade partition for upgrading the kernel, and information corresponding to the first partition or the second partition is stored in the image mark partition in the form of identification files with different file names; The types of identification files include: first partition valid file, first partition normal startup file, first partition attempted startup number file, second partition valid file, second partition normal startup file, second partition attempted startup number file and current startup partition file; When starting the kernel update, the current boot partition status is obtained according to the current boot partition file in the image mark partition, and the current boot partition is used as the upgrade partition; After confirming the partition upgrade, delete the partition valid file, partition normal boot file and partition boot attempt count file related to the upgraded partition in the image mark partition; Store the kernel upgrade image in the upgrade partition to perform kernel upgrade and update. After the upgrade is completed, create a partition valid file corresponding to the upgrade partition in the image mark partition; Restart the system and complete the initialization of the files in the image marked partition when the system starts the boot loader.

2. The dual-image kernel upgrade method according to claim 1, characterized in that: The kernel A partition or the kernel B partition is essentially the same as the original kernel partition and is used to store kernel images.

3. The dual-image kernel upgrade method according to claim 1, characterized in that: If there is an identification file with a special file name in the image mark partition, it means that the information is valid, otherwise the information is invalid; the file size of the identification file is zero.

4. The dual-image kernel upgrade method according to claim 1, characterized in that: The first partition valid file and the second partition valid file are synchronously created in the image tag partition when the kernel upgrade image is updated to the corresponding partition, and the first partition valid file or the second partition valid file of the corresponding partition is deleted when the system startup boot loader attempts to boot the first partition or the second partition to an upper limit threshold.

5. The dual-image kernel upgrade method according to claim 1, characterized in that: After the system successfully starts the first partition or the second partition, and when the corresponding partition startup normal file does not exist in the image mark partition, the first partition startup normal file and the second partition startup normal file are created in the image mark partition; When the kernel upgrade image is updated to the first partition or the second partition, the first partition normal startup file and the second partition normal startup file of the corresponding partition are deleted.

6. The dual-image kernel upgrade method according to claim 1, characterized in that: The first partition boot attempt count file and the second partition boot attempt count file are created when the system starts the boot loader and fails to boot the partition; the first partition boot attempt count file and the second partition boot attempt count file are deleted when the boot attempt count reaches an upper limit or the kernel image is updated to the corresponding partition.

7. A computing device comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the document generation method described in any one of claims 1 to 6 are implemented.

8. A computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the document generation method according to any one of claims 1 to 6.