A method and storage medium for building software for an easy-to-maintain and highly reliable embedded system
By encapsulating the LINUX core and RAM-ROOTFS into a single startup image, and introducing ZPK packages and dual image management, the problems of complex construction and poor maintenance of embedded system software are solved, fast maintenance and high reliability are achieved, and the system is improved stability and resource utilization.
Patent Information
- Application Number
- CN202411176551.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-08-26
AI Technical Summary
The existing embedded system software has complex construction, poor maintenance, difficult upgrade, unable to respond quickly to market changes, and insufficient stability and anti-interference capabilities in complex environments.
The LINUX kernel and RAM-ROOTFS root file system are encapsulated as a single startup image through UBOOT tool. Using the BUSYBOX tool set, the ZPK package mechanism and dual image management strategy are designed to automatically detect, load and execute ZPK packages, and support rapid maintenance and expansion. .
Simplifies the startup process of embedded systems, improves startup speed and resource utilization, enhances the stability and fault tolerance of the system, realizes flexible maintenance and expansion, reduces development and maintenance costs, and ensures high reliability of the system. and maintainability.
Smart Images

Figure CN118672569B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of embedded systems, and in particular to an easy-to-maintain and highly reliable embedded system software construction method and storage medium. Background Art
[0002] Embedded devices are widely used in various fields of modern social life. They often work continuously for a long time in various unattended complex environments. With the emergence of a large number of various embedded devices, the demand for embedded system software maintenance is also increasing.
[0003] The current embedded system software construction basically uses UBOOT to boot the LINUX kernel directly, then mounts the file system on FLASH or EMMC, and then runs various purpose applications.
[0004] Ordinary system software construction can successfully complete the verification of the hardware system, but it is very weak in the long-term maintainability of the software system itself. For example, various requirements such as repartitioning, system update, factory entry, file scanning, data transfer, remote testing and board maintenance often have to start from their own purposes. There are many duplications in development but they don’t know how to reuse them. In terms of logic, they often have to consider each other. Adding and removing functions during development is prone to logical loopholes, and it is not easy to want to fully cover the logic test. This loses the simplicity advantage of embedded systems, and the cost of both development and testing has increased significantly, and the reliability of products has inevitably decreased. What's more, if you suddenly want to add a completely unexpected special ability after the product is released, you are helpless because you have no way.
[0005] With the rapid development of the Internet of Things, smart devices and other fields, embedded systems have an increasing demand for software maintainability and high reliability. These systems need to be able to quickly respond to market changes and achieve rapid iteration and upgrade of functions. At the same time, since embedded systems are often deployed in complex and changing environments, higher requirements are also placed on the stability and anti-interference capabilities of the system. Therefore, in the field of embedded systems, building an easy-to-maintain and highly reliable software environment has always been the focus of technological development. Summary of the invention
[0006] The present invention provides an easy-to-maintain and highly reliable embedded system software construction method, which solves the problems of complex embedded system software startup process, high system resource occupation, poor maintainability and difficult upgrade in the prior art.
[0007] The technical solution of the present invention is achieved in this way:
[0008] A method for constructing easy-to-maintain and highly reliable embedded system software, comprising:
[0009] The LINUX kernel and the RAM-ROOTFS root file system are encapsulated into a single boot image through the UBOOT tool; wherein the RAM-ROOTFS root file system uses the BUSYBOX tool set as the only binary executable file;
[0010] Configure the LIB directory and BOOTUP directory in the root directory of the main partition of the board. The LIB directory is used to store the C / C++ runtime library. The START script of the onboard program is configured in the BOOTUP directory for the startup process and initialization operation of the onboard program.
[0011] Designing a ZPK package with the same directory structure as the main partition of the board, for maintenance and expansion of embedded system software;
[0012] Adapt the RAM-ROOTFS startup script to realize the function of automatically detecting, loading and executing ZPK packages during the startup process.
[0013] The RAM-ROOTFS root file system is configured as:
[0014] The RAM-ROOTFS root file system exports the basic LINUX commands through the symbolic link function of BUSYBOX, and implants extended commands that follow the standard input and output specifications of LINUX commands into BUSYBOX.
[0015] The ZPK package is configured as:
[0016] The ZPK package is loaded into the embedded system by local loading through any mountable storage device or remote downloading through the network;
[0017] The content of the ZPK package is in compressed and encrypted form, and is decompressed and decrypted using the extended commands in BUSYBOX;
[0018] The LIB and BOOTUP directories in the ZPK package can be decompressed separately to the memory disk for quick access when the program is running;
[0019] The START script sets the decompression mode according to the memory capacity and package size, and chooses one-time decompression or step-by-step decompression as needed.
[0020] The adapted RAM-ROOTFS startup script includes:
[0021] Add ZPK package retrieval and verification logic to the startup script to check whether the ZPK package exists and verify its integrity and authenticity;
[0022] Extend the commands in BUSYBOX to support the commands handled by the ZPK package of the ZPK package.
[0023] The automatic detection, loading and execution of the ZPK package during the startup process includes:
[0024] Retrieve ZPK packages at a specified location according to preset priority;
[0025] If a valid ZPK package is successfully retrieved, the LIB and BOOTUP directories are extracted to the memory disk, and a symbolic link is created for the extracted START script;
[0026] Import the C / C++ runtime library path into the environment variable and transfer execution rights to the symbolic link pointing to the START script;
[0027] If no valid ZPK package is detected, the onboard program is booted according to the default startup process.
[0028] Software construction methods include:
[0029] Configure dual boot images, including the main image KERNEL and the disaster recovery image MIRROR, both of which use the packaging format supported by UBOOT with CRC verification;
[0030] After the image is successfully loaded and verified, the boot mode is selected through the BOOT_SEL parameter passed in by UBOOT. The value of BOOT_SEL can be 0, 1 or 2, and each value corresponds to a different boot mode;
[0031] When BOOT_SEL is 0, the system ignores further checks on the boot image and enters debug mode, which is only used during development;
[0032] When BOOT_SEL is 1, it means that the main image KERNEL is complete and the system starts from the main image KERNEL;
[0033] When BOOT_SEL is 2, it means that the primary image KERNEL may be damaged, while the disaster recovery image MIRRO is complete, and the system starts from the disaster recovery image MIRROR.
[0034] Software construction methods include:
[0035] When the system does not detect the ZPK package and BOOT_SEL is 1, if the disaster recovery image MIRROR is inconsistent with the primary image KERNEL data at this time, the system will copy the primary image KERNEL to the disaster recovery image MIRROR to complete the update;
[0036] When BOOT_SEL is 2, the system will copy the disaster recovery image MIRROR to the primary image KERNEL for repair.
[0037] An easy-to-maintain and highly reliable embedded system comprising:
[0038] The boot image is encapsulated by the LINUX kernel and the RAM-ROOTFS root file system through the UBOOT tool; the only binary executable file in the RAM-ROOTFS root file system uses the BUSYBOX tool set;
[0039] The root directory of the main partition of the board includes a LIB directory and a BOOTUP directory, and the BOOTUP directory is equipped with a START script of the onboard program;
[0040] The system supports software maintenance and expansion through ZPK packages with the same directory structure as the main partition of the board, and has a RAM-ROOTFS startup script to realize automatic detection and execution of ZPK packages.
[0041] A computer-readable storage medium stores a computer program, wherein the computer program implements the above method steps when executed by a processor.
[0042] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the above method steps are implemented when the processor executes the computer program.
[0043] Compared with the prior art, the present invention has the following beneficial effects:
[0044] 1. By encapsulating the LINUX kernel and the streamlined RAM-ROOTFS root file system into a single boot image and using the UBOOT tool for booting, the startup process of the embedded system is greatly simplified, the loading and configuration work at startup is reduced, and the startup speed of the system is improved;
[0045] 2. Use BUSYBOX toolset as the only binary executable file in RAM-ROOTFS root file system, and integrate additional commands in BUSYBOX, so as to realize lightweight implementation of system commands, significantly reduce the occupation of system resources and the size of boot image, so that embedded system can run more efficiently under limited hardware resources, and also improve the boot speed;
[0046] 3. The dual-image management strategy is introduced to follow complementarity in updating and repairing, ensuring that the system can be started reliably under any operating conditions. Even if the main image is damaged, the system can be quickly restored through the disaster recovery image, further enhancing the stability and fault tolerance of the system;
[0047] 4. The ZPK package mechanism is introduced into the boot image, which makes the embedded system software have literally infinite possibilities for change, gets rid of the limitations of traditional structures, and makes maintenance and expansion more flexible and efficient. Developers can build and deploy ZPK packages as needed to achieve rapid updates and deployments of system software without tedious manual operations. At the same time, the design of ZPK packages follows a unified directory structure and script rules, which improves the modularity and reusability of the system.
[0048] 5. The logically complementary dual-boot images combined with ZPK's unlimited expansion capabilities enable the system to achieve extremely high reliability and long-term maintainability. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0050] Figure 1 A schematic diagram of the structure of starting a mirror image in one embodiment of the present invention;
[0051] Figure 2 A flowchart of system startup and booting in one embodiment of the present invention;
[0052] Figure 3 This is a dual-boot mirroring operation flow chart in one embodiment of the present invention;
[0053] Figure 4 The figure is a flow chart of the cyclic iteration of the dual-boot image in one embodiment of the present invention. DETAILED DESCRIPTION
[0054] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0055] In a first aspect of the present application, there is provided a method for constructing easy-to-maintain and highly reliable embedded system software, comprising the following steps:
[0056] S1. Encapsulate the LINUX kernel and RAM-ROOTFS root file system into a single boot image using the UBOOT tool, such as Figure 1As shown; wherein, the RAM-ROOTFS root file system uses the BUSYBOX toolset as the only binary executable file.
[0057] Specifically, UBOOT stands for Unified Boot Loader, which is an open source boot loader, mainly used in the startup process of embedded systems, supports multiple processor architectures and embedded platforms, and can initialize hardware devices, load the operating system kernel and root file system when the system starts; the LINUX kernel is the core of the LINUX system, responsible for managing system resources, providing hardware abstraction layer, etc.; ROOTFS is the root file system, which is one of the core parts of the LINUX system, and it contains the basic files and directory structures necessary for the startup and operation of the operating system. BUSYBOX is a highly integrated tool set that provides a large number of lightweight implementations of LINUX commands.
[0058] In step S1, a lightweight RAM-ROOTFS is created based on BUSYBOX. This root file system contains necessary system commands, configuration files, and startup scripts. The statically compiled BUSYBOX is used as the only binary executable file to ensure the independence and portability of the system.
[0059] The streamlined RAM-ROOTFS only contains BUSYBOX in binary form and some configurations and scripts in plain text form, and the size can be completely controlled within hundreds of KB. Since all libraries are compiled into executable files, no additional library files are required, and the system startup image will not fail during operation due to missing or damaged library files, which improves the reliability of the system.
[0060] It should be noted that in order to further reduce the size of the boot image and improve system reliability, the LINUX kernel can be configured and trimmed to remove all unnecessary functions and modules and retain only the most basic components required for system operation, thereby reducing the kernel size and improving the boot speed and system stability.
[0061] The streamlined LINUX kernel is then integrated with RAM-ROOTFS, and the integrated kernel and RAM-ROOTFS are encapsulated into a single boot image using the tools provided by the UBOOT boot loader. This boot image contains all the information and code required to start the system, and has an independent integrity check (such as CRC check) to ensure data integrity and reliability during transmission and storage.
[0062] In summary, by effectively integrating the LINUX kernel with RAM-ROOTFS, a streamlined, efficient and reliable embedded system boot image is created, which simplifies the system boot process and reduces the loading and configuration work during system startup.
[0063] The streamlined LINUX kernel and BUSYBOX-based RAM-ROOTFS reduce the system's complexity and potential risk points, and improve the system's stability and reliability.
[0064] S2. Configure a LIB directory and a BOOTUP directory under the root directory of the main partition of the board card. The LIB directory is used to store the C / C++ runtime library. The START script of the onboard program is configured under the BOOTUP directory for the startup process and initialization operation of the onboard program.
[0065] Among them, C / C++ runtime libraries are stored in the LIB directory. These library files are required for the program to run and are used to support applications written in C / C++ language. By storing the runtime library files in the LIB directory, it is ensured that they are correctly loaded when needed, thereby supporting the execution of the application.
[0066] The START script in the BOOTUP directory serves as the general boot script for onboard programs. It is responsible for controlling the startup process and initialization operations of onboard programs. After the LINUX kernel starts, it will first execute this START script to start and configure various services and functions required by the onboard programs. This design allows developers to organize and manage all scripts and configuration files related to the startup of onboard programs in the BOOTUP directory, thereby providing a clear and maintainable startup process control mechanism.
[0067] S3. Design a ZPK package with the same directory structure as the main partition of the board, for maintenance and expansion of embedded system software.
[0068] Specifically, the ZPK package includes the following key directories and files: LIB directory, which stores C / C++ runtime libraries; BOOTUP directory, which contains a script file named START. ZPK and onboard programs are at the same level and have the same directory structure.
[0069] When the system starts, it will retrieve and load the ZPK package according to the set logic. If a valid ZPK package is found, the system will decompress the LIB and BOOTUP directories in the package to the memory disk and create a symbolic link for the decompressed START script. At this time, the execution right of the system will be transferred to the START script of this ZPK.
[0070] The ZPK START script contains additional logic and functions to support the specific operations provided in the ZPK package, and replaces the original onboard START general boot script to become the main executor of the current system startup, initialization and configuration. By executing this ZPK START script, the system can load and run the programs and data provided in the ZPK package to achieve specific maintenance, update or expansion functions.
[0071] The design of the ZPK package makes it possible to achieve flexible, efficient and reliable maintenance and updating of embedded system software by only building and deploying it according to the established directory structure and script rules when updating, expanding or maintaining an embedded system. This improves the modularity and reusability of the embedded system software and reduces the cost of development and maintenance.
[0072] S4. Adapt the RAM-ROOTFS startup script to realize the functions of automatically detecting, loading and executing ZPK packages during the startup process.
[0073] Specifically, by automatically detecting, loading and executing ZPK packages, the maintenance and update process of embedded system software is greatly simplified. Developers no longer need to manually perform system upgrades, function expansions or configuration changes.
[0074] In some embodiments, the RAM-ROOTFS root file system is configured as:
[0075] The RAM-ROOTFS root file system exports the basic LINUX commands through the symbolic link function of BUSYBOX, and implants extended commands that follow the standard input and output specifications of LINUX commands in BUSYBOX to ensure compatibility with standard system commands.
[0076] In some embodiments, the ZPK package is configured to:
[0077] The ZPK package is loaded into the embedded system by locally loading through any mountable storage device or by remote downloading through the network.
[0078] Specifically, mountable storage devices such as USB flash drives, optical disks, SD cards, hard disks, etc., can be used to download ZPK packages through mountable storage devices or networks, so that users can easily maintain and expand embedded system software. For example, when it is necessary to update the system or add new functions, users can download the corresponding ZPK package and load it onto the embedded device. The device will automatically detect and load the ZPK package when it starts, and then execute the START script therein to complete the required initialization and configuration operations. This method greatly simplifies the maintenance and update process of embedded system software and improves the reliability and maintainability of the system.
[0079] The content of the ZPK package is in compressed and encrypted form, and is decompressed and decrypted using extended commands in BUSYBOX.
[0080] Specifically, this compression and encryption processing method improves security and reliability, making the maintenance and update process of embedded systems safer, more reliable and more efficient. BUSYBOX, as a lightweight tool set, has been embedded in RAM-ROOTFS. Therefore, using the commands extended from BUSYBOX to compress and decrypt ZPK packages can avoid introducing additional dependent libraries or tools, thereby maintaining the simplicity and efficiency of the system.
[0081] The LIB and BOOTUP directories in the ZPK package can be decompressed separately to the memory disk for quick access when the program is running.
[0082] Specifically, by decompressing the LIB and BOOTUP directories separately, the system can quickly load these necessary library files and boot scripts without decompressing the entire ZPK package, which improves the system startup speed and responsiveness, especially in resource-constrained embedded systems.
[0083] The START script sets the decompression mode according to the memory capacity and package size, and chooses one-time decompression or step-by-step decompression as needed.
[0084] Specifically, when the memory capacity is sufficient and the ZPK package size is not large, one-time decompression can quickly complete the initialization and improve the system startup speed. When the memory capacity is limited or the ZPK package size is large, on-demand step-by-step decompression can gradually load the necessary data and programs according to actual needs to ensure the stable operation of the system.
[0085] Based on this information and the actual memory capacity of the system, the START script can intelligently select the appropriate decompression mode. This design makes the system more flexible and efficient, and can adaptively adjust the data decompression strategy.
[0086] It should be noted that, in order to ensure the stability, reliability and security of the system, in addition to the functions that need to act directly on the board partition data, the general programs in the ZPK package are limited to only allowing access to the memory disk where they are decompressed, except for system repair and data analysis and update. Through this restricted access, unauthorized programs or malicious software are prevented from tampering with or destroying the data on the board storage medium, thereby improving the security of the system. Since the programs in the ZPK package cannot directly access the data on the board storage medium, even if the programs in the ZPK package have errors or exceptions, they will not cause damage to the original board program data, thereby protecting the integrity of the data.
[0087] It should be noted that in order to ensure the flexibility and reliability of applications in different environments and configurations, all applications use relative paths to access files. Using relative paths makes it easier to move applications from one location to another without having to worry about changes in file paths. When the system needs to be updated or upgraded, only the relevant files need to be updated or replaced without modifying the file paths in a large number of applications. This ensures the flexibility and reliability of applications in different environments and configurations, and the effect of running after decompressing the ZPK is the same as running on the board.
[0088] In some embodiments, the adapting of the startup script of RAM-ROOTFS includes:
[0089] Add ZPK package retrieval and verification logic to the startup script to check whether the ZPK package exists and verify its integrity and authenticity;
[0090] Extend the commands in BUSYBOX to support the commands handled by the ZPK package of the ZPK package.
[0091] like Figure 2 In some embodiments, the automatic detection, loading and execution of the ZPK package during the boot process includes:
[0092] Retrieve ZPK packages at the specified location with preset priority.
[0093] Specifically, the system will search for ZPK packages in designated locations (such as USB flash drives, agreed package download partitions, etc.), which can be configured according to specific application scenarios and user needs. Set search priorities, for example, let manual methods (such as inserting USB flash drives) take precedence over automatic methods (such as automatic program downloads), so as to ensure that even if the user provides an incorrect ZPK package, it can be quickly intervened and cleared manually.
[0094] If a valid ZPK package is successfully retrieved, extract the LIB and BOOTUP directories to the ramdisk and create a symbolic link for the extracted START script.
[0095] Specifically, for the decompressed START script, the system will create a symbolic link for it. A symbolic link is a special type of file that contains a reference to another file or directory. The purpose of creating a symbolic link is to facilitate access and execution of the START script, ensuring that necessary initialization operations can be automatically performed when the system starts.
[0096] Import the C / C++ runtime library path to the environment variable and transfer execution rights to the symbolic link pointing to the START script.
[0097] Specifically, C / C++ runtime libraries are necessary for program operation. They contain the implementation of various functions and resources used in the program execution process. The operation of importing the C / C++ runtime library path into the environment variable ensures that the system can correctly find and load the required runtime library files. After the system successfully decompresses the C / C++ runtime library files in the LIB directory of the ZPK package to the memory disk, in order to allow the START script and other programs to find and use these library files, the library file path needs to be added to the system's environment variables. This can be achieved by modifying the system's environment variable settings.
[0098] If no valid ZPK package is detected, the onboard program is booted according to the default startup process.
[0099] Specifically, in the default startup process, the system will mount the main file system and create a symbolic link for the START script to ensure that the system can run as expected. The default process and the ZPK loading process are combined to form a symbolic link to the same start script.
[0100] It should be noted that during the process of retrieving the ZPK package, the system will only identify and load one ZPK package. If there are multiple ZPK packages on the path of the same priority (for example, all USB flash drives are manually inserted), the system will report an error and terminate the retrieval process. This is to ensure that the system will not be confused or erroneous due to the existence of multiple ZPK packages, thereby eliminating the inconsistency between the expected ZPK package and the actually activated ZPK package.
[0101] It should be noted that in addition to the basic search path and priority settings, the system also supports users to customize other search rules. For example, users can define specific conditions such as manufacturer, type, version, etc. to filter and select ZPK packages according to actual needs. This increases the flexibility and scalability of the system, allowing users to customize the search strategy of ZPK packages according to their own needs.
[0102] It should be noted that before loading the ZPK package, the system will first perform a decryption operation. If the decryption fails due to incorrect decryption key or other reasons, the system will report an error and terminate the retrieval process. This is done to ensure that only correctly encrypted ZPK packages can be loaded and executed by the system, thereby enhancing the security of the system.
[0103] It should be noted that after the START script begins to execute, all programs run by it are called ZPK parts. Whether it is the original program on the board or the program loaded through the ZPK package, they will be run as ZPK parts. This ensures the consistency of all parts during operation and avoids conflicts caused by incompatibility between different program versions.
[0104] The operation of ZPK parts depends on their own C / C++ runtime library. Each ZPK part has the same environment when executing, making the development and maintenance of ZPK parts simpler and more direct. Developers do not need to worry about dependencies or version conflicts between different parts.
[0105] like Figure 3 In some embodiments, the embedded system software construction method includes:
[0106] Configure dual boot images, including the main image KERNEL and the disaster recovery image MIRROR, both of which use the packaging format supported by UBOOT with CRC verification;
[0107] After the image is successfully loaded and verified, the boot mode is selected through the BOOT_SEL parameter passed in by UBOOT. The value of BOOT_SEL can be 0, 1 or 2, and each value corresponds to a different boot mode;
[0108] When BOOT_SEL is 0, the system ignores further checks on the boot image and enters debug mode, which is only used during development;
[0109] When BOOT_SEL is 1, it means that the main image KERNEL is complete and the system starts from the main image KERNEL;
[0110] When BOOT_SEL is 2, it means that the primary image KERNEL may be damaged, while the disaster recovery image MIRRO is complete, and the system starts from the disaster recovery image MIRROR.
[0111] The native UBOOT will cause the problem of permanent system downtime when the LINUX core image is damaged, and there is a certain probability that it will be encountered when updating and maintaining the LINUX core image. In order to solve this problem, the UBOOT boot process is modified in the method proposed in this embodiment to enable it to support dual-image booting, namely the main image KERNEL and the disaster recovery image MIRROR. The mirror boot process enhances the reliability and maintainability of the system by introducing dual images and CRC verification mechanisms. Even if the main image KERNEL is damaged, the system can be normally started through the disaster recovery image MIRROR, ensuring the continuous operation capability of the device. At the same time, the introduction of the BOOT_SEL parameter provides greater flexibility for debugging and maintenance of the system.
[0112] like Figure 4 In some embodiments, the embedded system software construction method includes:
[0113] When the system does not detect the ZPK package and BOOT_SEL is 1, if the disaster recovery image MIRROR is inconsistent with the primary image KERNEL data, the system will copy the primary image KERNEL to the disaster recovery image MIRROR to complete the update of the disaster recovery image;
[0114] When BOOT_SEL is 2, the system will copy the disaster recovery image MIRROR to the main image KERNEL for repair. This usually means that the main image KERNEL may be damaged or unavailable for some reason (such as storage medium damage, system error, etc.). In order to ensure the rapid recovery of the system, the system will perform an image repair operation, that is, copy the data of the disaster recovery image MIRROR to the main image KERNEL, thereby repairing the main image KERNEL and making it usable as a boot image again.
[0115] The dual-image management strategy ensures that the embedded system can quickly resume operation through the disaster recovery image MIRROR even if the main image KERNEL is damaged. This not only improves the reliability and stability of the system, but also greatly simplifies the system maintenance and update process. In addition, by regularly checking and updating the disaster recovery image MIRROR, it can be ensured that there is always a reliable backup available when the system fails.
[0116] It should be noted that in the dual-mirror management strategy of this embodiment, in order to ensure the stability of the system and the security of the data, except for the repair operation required due to the detection of damage to the main mirror KERNEL (i.e. copying the disaster recovery mirror MIRROR to the main mirror KERNEL), any direct changes to the KERNEL must be completed in the extended function of the ZPK package; similarly, except for the need to update the disaster recovery mirror MIRROR to keep it consistent with the main mirror KERNEL, direct changes to the disaster recovery mirror MIRROR shall not be made under any circumstances.
[0117] This design ensures that the KERNEL and MIRROR cannot be written at the same time in a single operation, thus avoiding the potential risk of both images being destroyed at the same time. This not only enhances the security of the system, but also improves the stability and maintainability of the system.
[0118] This design combined with the dual-image management strategy forms a self-healing, safe and iterative logical closed loop. In this closed loop, the main image KERNEL and the disaster recovery image MIRROR back up and support each other. When a problem occurs in the main image, the system can quickly switch to the disaster recovery image and start the repair operation; at the same time, through the deployment and application of the ZPK package, developers can upgrade and expand the system without interfering with the normal operation of the system, making the maintenance and update of the embedded system simpler, more efficient and reliable.
[0119] In a second aspect of the present application, an easy-to-maintain and highly reliable embedded system is provided, comprising:
[0120] The boot image is encapsulated by the LINUX kernel and the RAM-ROOTFS root file system through the UBOOT tool; the only binary executable file in the RAM-ROOTFS root file system uses the BUSYBOX tool set;
[0121] The root directory of the main partition of the board is equipped with a LIB directory and a BOOTUP directory, and the BOOTUP directory is equipped with a START general boot script of the onboard program; the LIB directory is used to store the C / C++ runtime library, and the START general boot script is used for the startup process and initialization operation of the onboard program;
[0122] The system supports software maintenance and expansion through ZPK packages with the same directory structure as the main partition of the board, and has a RAM-ROOTFS startup script to realize automatic detection and execution of ZPK packages.
[0123] According to a second aspect of the present application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, wherein the computer program implements the above-mentioned method steps when executed by a processor.
[0124] In one embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0125] In a third aspect of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above method steps when executing the computer program. It should be understood that the size of the sequence number of each step in the above embodiment does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.
[0126] In the description of the present specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish descriptions and cannot be understood as indicating or suggesting relative importance. It should also be understood that although the terms "first", "second", etc. are used to describe various elements in some embodiments of the present application in the text, these elements should not be limited by these terms. These terms are only used to distinguish one element from another element. For example, the first table can be named as the second table, and similarly, the second table can be named as the first table without departing from the scope of the various described embodiments. The first table and the second table are both tables, but they are not the same table.
[0127] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0128] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for constructing easy-to-maintain and highly reliable embedded system software, characterized in that: include: The LINUX kernel and the RAM-ROOTFS root file system are encapsulated into a single boot image through the UBOOT tool; wherein the RAM-ROOTFS root file system uses the BUSYBOX tool set as the only binary executable file; Configure the LIB directory and BOOTUP directory in the root directory of the main partition of the board. The LIB directory is used to store the C / C++ runtime library. The START script of the onboard program is configured in the BOOTUP directory for the startup process and initialization operation of the onboard program. Designing a ZPK package with the same directory structure as the main partition of the board, for maintenance and expansion of embedded system software; Adapt the RAM-ROOTFS startup script to realize the function of automatically detecting, loading and executing ZPK packages during the startup process; Automatically detect, load, and execute ZPK packages during startup, including: Retrieve ZPK packages at a specified location according to preset priority; If a valid ZPK package is successfully retrieved, the LIB and BOOTUP directories are extracted to the memory disk, and a symbolic link is created for the extracted START script; Import the C / C++ runtime library path into the environment variable and transfer execution rights to the symbolic link pointing to the START script; If no valid ZPK package is detected, the onboard program is booted according to the default startup process.
2. The software construction method according to claim 1, characterized in that: The RAM-ROOTFS root file system is configured as: The RAM-ROOTFS root file system exports the basic LINUX commands through the symbolic link function of BUSYBOX, and implants extended commands that follow the standard input and output specifications of LINUX commands into BUSYBOX.
3. The software construction method according to claim 1, characterized in that: The ZPK package is configured as: The ZPK package is loaded into the embedded system by local loading through any mountable storage device or remote downloading through the network; The content of the ZPK package is in compressed and encrypted form, and is decompressed and decrypted using the extended commands in BUSYBOX; The LIB and BOOTUP directories in the ZPK package can be decompressed separately to the memory disk for quick access when the program is running; The START script sets the decompression mode according to the memory capacity and package size, and chooses one-time decompression or step-by-step decompression as needed.
4. The software construction method according to claim 1, characterized in that: The adapted RAM-ROOTFS startup script includes: Add ZPK package retrieval and verification logic to the startup script to check whether the ZPK package exists and verify its integrity and authenticity; Expand the commands in BUSYBOX to support the processing commands of ZPK packages.
5. The software construction method according to claim 1, characterized in that: include: Configure dual boot images, including the main image KERNEL and the disaster recovery image MIRROR, both of which use the packaging format supported by UBOOT with CRC verification; After the image is successfully loaded and verified, the boot mode is selected through the BOOT_SEL parameter passed in by UBOOT. The value of BOOT_SEL can be 0, 1 or 2, and each value corresponds to a different boot mode; When BOOT_SEL is 0, the system ignores further checks on the boot image and enters debug mode, which is only used during development; When BOOT_SEL is 1, it means that the main image KERNEL is complete and the system starts from the main image KERNEL; When BOOT_SEL is 2, it means that the primary image KERNEL may be damaged, while the disaster recovery image MIRRO is complete, and the system starts from the disaster recovery image MIRROR.
6. The software construction method according to claim 5, characterized in that: include: When the system does not detect the ZPK package and BOOT_SEL is 1, if the disaster recovery image MIRROR is inconsistent with the primary image KERNEL data at this time, the system will copy the primary image KERNEL to the disaster recovery image MIRROR to complete the update; When BOOT_SEL is 2, the system will copy the disaster recovery image MIRROR to the primary image KERNEL for repair.
7. An easy-to-maintain and highly reliable embedded system, characterized in that: include: The boot image is encapsulated by the LINUX kernel and the RAM-ROOTFS root file system through the UBOOT tool; wherein the only binary executable file in the RAM-ROOTFS root file system adopts the BUSYBOX tool set; The root directory of the main partition of the board includes a LIB directory and a BOOTUP directory, and the BOOTUP directory is equipped with a START script of the onboard program; The system supports software maintenance and expansion through ZPK packages with the same directory structure as the main partition of the board, and has a RAM-ROOTFS startup script to realize automatic detection and execution of ZPK packages; Automatically detect, load, and execute ZPK packages during startup, including: Retrieve ZPK packages at a specified location according to preset priority; If a valid ZPK package is successfully retrieved, the LIB and BOOTUP directories are extracted to the memory disk, and a symbolic link is created for the extracted START script; Import the C / C++ runtime library path into the environment variable and transfer execution rights to the symbolic link pointing to the START script; If no valid ZPK package is detected, the onboard program is booted according to the default startup process.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the method steps of any one of claims 1 to 7 when executed by a processor.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method steps of any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Double-mirror image Flash-based router starting method and device
CN108415733A
Linux system starting method and device, terminal equipment and storage medium
CN117850886A
