One-key recovery method and device based on embedded Linux industrial personal computer
By setting the GPIO button in the embedded Linux industrial control machine and detecting its status, the automatic recovery of the industrial control machine is realized, and the problems of complex recovery process and security risks in the existing technology are solved, and the recovery efficiency and system stability are improved. .
Patent Information
- Application Number
- CN202411512900.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-02-18
AI Technical Summary
In the prior art, the system recovery process of embedded Linux industrial control machines is complex, requiring users to have a certain technical background and lack of automated operations, resulting in low recovery efficiency and security risks.
Set a GPIO button in the embedded Linux industrial control machine to determine whether to restore the factory system by detecting the status of the GPIO pin. When the button is pressed, the system will detect whether it is inserted into the U disk, and read the rootfs.img file or the contents in the backup partition in the U disk, write to the root file system partition, and restart.
It realizes system recovery without manual operation by users, simplifies the recovery process, improves recovery efficiency, reduces security risks, and ensures the stability and data security of the industrial control machine.
Smart Images

Figure CN119473409A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of embedded Linux technology, and for example, to a method and device for one-key recovery based on an embedded Linux industrial computer. Background Art
[0002] With the rapid development of my country's science and technology industry, domestic embedded Linux industrial computers have been widely used in various fields. However, due to the problems that industrial computers may face during use, such as system damage, configuration file loss, virus infection, etc., the industrial computers cannot work properly. In order to improve the reliability and maintainability of industrial computers, it is of great significance to study a one-key factory system recovery method for domestic embedded Linux industrial computers.
[0003] In the prior art, the system recovery process is complicated. Once an industrial computer encounters a system problem, the recovery process usually requires the user to have a certain technical background and manually perform multiple steps. This not only increases the difficulty of recovery, but may also cause further problems during the operation. In addition, there is a lack of automated operation. Existing recovery methods often rely on user intervention and cannot achieve automated recovery. This is not only time-consuming and error-prone, but also inefficient, especially when a large number of industrial computers need to be restored. Another issue is security. Some existing recovery methods may involve modifying system core files, which may bring security risks, such as system instability and data loss.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of this application. Summary of the invention
[0005] In order to provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. The summary is not an extensive review, nor is it intended to identify key / critical components or delineate the scope of protection of these embodiments, but rather serves as a prelude to the detailed description that follows.
[0006] The present disclosure provides a method for one-key recovery based on an embedded Linux industrial computer, the method comprising:
[0007] Partition the embedded Linux storage device in advance and add a backup partition to store the original root file system.
[0008] A button is set in the embedded Linux industrial computer and connected to a GPIO pin on the CPU end to determine whether to restore the factory system based on the state of the GPIO pin;
[0009] When it is determined to restore the factory system based on the status of the GPIO pin, first check whether the USB disk is inserted. If the USB disk is already connected and the rootfs.img file exists in the USB disk, read the corresponding file to a fixed memory address, and then write the data read in the memory to the partition of the root file system;
[0010] After all data is written to the root file system, reboot.
[0011] In some embodiments, the method further comprises:
[0012] If there is no USB flash drive, or the rootfs.img file does not exist in the USB flash drive, the contents of the backup partition will be automatically read into the memory, and then the data read from the memory will be written into the partition of the root file system.
[0013] In some embodiments, the method further comprises:
[0014] FPGA / MCU is used on the mainboard of the industrial computer to monitor the GPIO pin. If the button is pressed, the FPGA side monitors the falling edge signal of the corresponding level.
[0015] In some embodiments, determining to restore the system to factory default based on the state of the GPIO pin includes:
[0016] When uboot starts, monitor whether the connected GPIO pin is in the pressed state and start timing. The detection is performed every preset time period for a preset duration. If the button is always in the pressed state during this process, the factory system recovery process is entered.
[0017] In some embodiments, an FPGA / MCU is used on the mainboard of the industrial computer to monitor the GPIO pin. If the button is pressed, the FPGA side monitors the falling edge signal of the corresponding level, including:
[0018] Setting the GPIO pin to input mode so as to monitor the state change of the GPIO pin;
[0019] If the button is pressed, the preset jitter elimination algorithm is used to monitor the falling edge signal of the corresponding level.
[0020] In some embodiments, the method further comprises:
[0021] When the USB flash drive is connected and the rootfs.img file exists in the USB flash drive, read the corresponding file to a fixed memory address, and then write the data read in the memory to the partition of the root file system, use a mutex lock or a read-write lock mechanism to write the data read in the memory to the partition of the root file system.
[0022] The present disclosure provides a device for one-key recovery based on an embedded Linux industrial computer, the device comprising:
[0023] A processing module is used to partition the storage device of the embedded Linux in advance and add a backup partition to store the original root file system;
[0024] A setting module is used to set a button in the embedded Linux industrial computer, connected to a GPIO pin on the CPU end, so as to determine whether to restore the factory system based on the state of the GPIO pin;
[0025] The processing module is also used to, when it is determined based on the state of the GPIO pin that the factory system is to be restored, first detect whether a USB flash drive is inserted, and if the USB flash drive has been connected and there is a rootfs.img file in the USB flash drive, read the corresponding file to a fixed memory address, and then write the data read in the memory to the partition of the root file system;
[0026] The restart module is used to turn off the recovery indicator light and restart after all data is written to the root file system.
[0027] In some embodiments, the storage medium stores program instructions, and when the program instructions are run, the method for one-key recovery based on an embedded Linux industrial computer in the above embodiment is executed.
[0028] The method, device and storage medium for one-key recovery based on an embedded Linux industrial computer provided by the embodiments of the present disclosure can achieve the following technical effects:
[0029] The one-key recovery method of the factory system disclosed in the present invention simplifies the recovery process, does not require manual operation by the user, and reduces the user's learning cost and operation difficulty. Through one-key recovery, the user only needs to perform key operations to complete the recovery operation, which greatly improves the recovery efficiency, avoids directly modifying the system core files, reduces security risks, and ensures the stability and data security of the industrial computer. In addition, the recovery image can be easily updated, which improves the user experience of the industrial computer. The interface is simple and easy to use, and the operation is simple, which greatly improves the user experience and reduces the user's fear of technical operations.
[0030] The above general description and the following description are exemplary and explanatory only and are not intended to limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] One or more embodiments are exemplarily described by corresponding drawings, which do not limit the embodiments. Elements with the same reference numerals in the drawings are shown as similar elements, and the drawings do not constitute a scale limitation, and wherein:
[0032] Figure 1 It is a flowchart of a method for one-key recovery based on an embedded Linux industrial computer provided by an embodiment of the present disclosure;
[0033] Figure 2 It is a flowchart of another method for one-key recovery based on an embedded Linux industrial computer provided by an embodiment of the present disclosure;
[0034] Figure 3 It is a schematic diagram of the structure of a device for one-key recovery based on an embedded Linux industrial computer provided by an embodiment of the present disclosure;
[0035] Figure 4 The present invention provides a schematic diagram of a system structure for one-key recovery based on an embedded Linux industrial computer. DETAILED DESCRIPTION
[0036] In order to be able to understand the features and technical contents of the embodiments of the present disclosure in more detail, the implementation of the embodiments of the present disclosure is described in detail below in conjunction with the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present disclosure. In the following technical description, for the convenience of explanation, a full understanding of the disclosed embodiments is provided through multiple details. However, one or more embodiments can still be implemented without these details. In other cases, to simplify the drawings, well-known structures and devices can be simplified for display.
[0037] The terms "first", "second", etc. in the embodiments of the present disclosure are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged where appropriate, so as to describe the embodiments of the present disclosure described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions.
[0038] Unless otherwise stated, the term "plurality" means two or more.
[0039] In the embodiment of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B indicates: A or B.
[0040] The term "and / or" is a description of the association relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or, A and B.
[0041] The term "correspondence" may refer to an association relationship or a binding relationship. The correspondence between A and B means that there is an association relationship or a binding relationship between A and B.
[0042] The following describes a method, device and storage medium for one-key recovery based on an embedded Linux industrial computer provided by an embodiment of the present disclosure in conjunction with the accompanying drawings.
[0043] Figure 1 It is a flowchart of a method for one-key recovery based on an embedded Linux industrial computer provided by an embodiment of the present disclosure.
[0044] like Figure 1 As shown, the one-key recovery method based on the embedded Linux industrial computer may include:
[0045] S01, partition the storage device of embedded Linux in advance and add a backup partition to store the original root file system;
[0046] S02, setting a button in the embedded Linux industrial computer and connecting it to a GPIO pin on the CPU end, so as to determine whether to restore the factory system based on the state of the GPIO pin;
[0047] S03, when it is determined based on the state of the GPIO pin that the factory system is to be restored, first detect whether the USB disk is inserted, if the USB disk is already connected and there is a rootfs.img file in the USB disk, read the corresponding file to a fixed memory address, and then write the data read in the memory to the partition of the root file system;
[0048] S04, after all data is written into the root file system, restart.
[0049] The one-key recovery method of the factory system disclosed in the present invention simplifies the recovery process, does not require manual operation by the user, and reduces the user's learning cost and operation difficulty. Through one-key recovery, the user only needs to perform key operations to complete the recovery operation, which greatly improves the recovery efficiency, avoids directly modifying the system core files, reduces security risks, and ensures the stability and data security of the industrial computer. In addition, the recovery image can be easily updated, which improves the user experience of the industrial computer. The interface is simple and easy to use, and the operation is simple, which greatly improves the user experience and reduces the user's fear of technical operations.
[0050] In some embodiments, if there is no USB flash drive, or the rootfs.img file does not exist in the USB flash drive, the content in the backup partition is automatically read into the memory, and then the data read in the memory is written into the partition of the root file system.
[0051] In some embodiments, the method further comprises:
[0052] Use FPGA / MCU on the mainboard of the industrial computer to monitor the GPIO pins. If the button is pressed, the FPGA side monitors the falling edge signal of the corresponding level.
[0053] In some embodiments, determining to restore the system to factory default based on the state of the GPIO pin includes:
[0054] When uboot starts, monitor whether the connected GPIO pin is in the pressed state, and count the time. Check once every preset time period for a preset time. If the button is always pressed during this process, the factory system recovery process will be started. The preset time period can be 50ms, and the preset time can be 5s. In addition, the recovery indicator light can be turned on at this time, and the user can stop pressing the restore button.
[0055] In some embodiments, an FPGA / MCU is used on the mainboard of the industrial computer to monitor the GPIO pins. If a button is pressed, the FPGA side monitors the falling edge signal of the corresponding level, including:
[0056] Set the GPIO pin to input mode to monitor the state change of the GPIO pin;
[0057] If the button is pressed, the preset jitter elimination algorithm is used to monitor the falling edge signal of the corresponding level.
[0058] In some embodiments, the method further comprises:
[0059] When the USB flash drive is connected and the rootfs.img file exists in the USB flash drive, read the corresponding file to a fixed memory address, and then write the data read in the memory to the partition of the root file system, use a mutex lock or a read-write lock mechanism to write the data read in the memory to the partition of the root file system.
[0060] In addition, in some embodiments, after all data is written to the root file system in S04, the recovery indicator light may be turned off and a reboot may be performed.
[0061] Figure 2 It is a flowchart of another method for one-key recovery based on an embedded Linux industrial computer provided by an embodiment of the present disclosure.
[0062] Combination Figure 2 ,right Figure 1 The one-key recovery method is further described in the following. In a specific example, the one-key recovery method based on the embedded Linux industrial computer may include:
[0063] Step 1: MCU / FPGA is always in the state of detecting the button. If the button is pressed, the motherboard will restart and enter the uboot startup. If the button is not pressed, the original state will be maintained.
[0064] Step 2: When the button is pressed, it restarts and enters uboot. uboot will detect whether the button is pressed for 5 seconds. If it is pressed for more than 5 seconds, it will quickly enter the system recovery state. If it is not pressed continuously, it will enter the normal boot state.
[0065] Step 3: If the system enters the recovery state, first determine whether to perform USB recovery. If there is a USB flash drive and the rootfs.img file exists in the USB flash drive, read all the contents of the img and write them to the partition of the root file system. After completion, restart. If there is no USB flash drive or the rootfs.img file does not exist in the USB flash drive, read the contents of the backup partition and write the contents of the backup partition to the root file system partition. After completion, restart and enter the system.
[0066] The one-key recovery method of the factory system disclosed in the present invention simplifies the recovery process, does not require manual operation by the user, and reduces the user's learning cost and operation difficulty. Through one-key recovery, the user only needs to perform key operations to complete the recovery operation, which greatly improves the recovery efficiency, avoids directly modifying the system core files, reduces security risks, and ensures the stability and data security of the industrial computer. In addition, the recovery image can be easily updated, which improves the user experience of the industrial computer. The interface is simple and easy to use, and the operation is simple, which greatly improves the user experience and reduces the user's fear of technical operations.
[0067] Figure 3 is a schematic diagram of a device structure for performing one-key recovery based on an embedded Linux industrial computer provided by an embodiment of the present disclosure, such as Figure 3 As shown, the device for performing one-key recovery based on an embedded Linux industrial computer may include:
[0068] The processing module 301 is used to partition the storage device of the embedded Linux in advance and add a backup partition to store the original root file system;
[0069] The setting module 302 is used to set a button in the embedded Linux industrial computer, connected to a GPIO pin on the CPU end, so as to determine whether to restore the factory system based on the state of the GPIO pin;
[0070] The processing module 301 is also used to, when it is determined based on the state of the GPIO pin that the factory system is to be restored, first detect whether a USB flash drive is inserted, if the USB flash drive has been connected and there is a rootfs.img file in the USB flash drive, read the corresponding file to a fixed memory address, and then write the data read in the memory to the partition of the root file system;
[0071] The restart module 303 is used to restart after all data is written into the root file system.
[0072] In some embodiments, if there is no USB flash drive, or the rootfs.img file does not exist in the USB flash drive, the content in the backup partition is automatically read into the memory, and then the data read in the memory is written into the partition of the root file system.
[0073] In some embodiments, an FPGA / MCU is used on the mainboard of the industrial computer to monitor the GPIO pins. If a button is pressed, the FPGA side monitors the falling edge signal of the corresponding level.
[0074] In some embodiments, determining to restore the system to factory default based on the state of the GPIO pin includes:
[0075] When uboot starts, monitor whether the connected GPIO pin is in the pressed state and start timing. The detection is performed every preset time period for a preset duration. If the button is always in the pressed state during this process, the factory system recovery process is entered.
[0076] In some embodiments, an FPGA / MCU is used on the mainboard of the industrial computer to monitor the GPIO pins. If a button is pressed, the FPGA side monitors the falling edge signal of the corresponding level, including:
[0077] Set the GPIO pin to input mode to monitor the state change of the GPIO pin;
[0078] If the button is pressed, the preset jitter elimination algorithm is used to monitor the falling edge signal of the corresponding level.
[0079] In some embodiments, when a USB flash drive has been connected and a rootfs.img file exists in the USB flash drive, the corresponding file is read to a fixed memory address, and then the data read in the memory is written to the partition of the root file system. A mutex lock or a read-write lock mechanism is used to write the data read in the memory to the partition of the root file system.
[0080] Combination Figure 4 As shown, the embodiment of the present disclosure also provides a system 400 for one-key recovery based on an embedded Linux industrial computer, including a processor 404 and a memory 401. Optionally, the system may also include a communication interface 402 and a bus 403. Among them, the processor 404, the communication interface 402, and the memory 401 can communicate with each other through the bus 403. The communication interface 402 can be used for information transmission. The processor 404 can call the logic instructions in the memory 401 to execute the method for one-key recovery based on the embedded Linux industrial computer of the above embodiment.
[0081] In addition, the logic instructions in the memory 401 described above may be implemented in the form of software functional units and when sold or used as independent products, may be stored in a computer-readable storage medium.
[0082] The memory 401 is a computer-readable storage medium that can be used to store software programs and computer executable programs, such as program instructions / modules corresponding to the method in the embodiment of the present disclosure. The processor 404 executes the functional application and data processing by running the program instructions / modules stored in the memory 401, that is, the one-key recovery method based on the embedded Linux industrial computer in the above embodiment is implemented.
[0083] The memory 401 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 401 may include a high-speed random access memory and may also include a non-volatile memory.
[0084] The embodiment of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured to execute a method for one-key recovery based on an embedded Linux industrial computer.
[0085] The computer-readable storage medium mentioned above may be a transient computer-readable storage medium or a non-transitory computer-readable storage medium.
[0086] The technical solution of the embodiment of the present disclosure can be embodied in the form of a software product, which is stored in a storage medium and includes one or more instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method of the embodiment of the present disclosure. The aforementioned storage medium may be a non-transient storage medium, including: a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, and other media that can store program codes, or a transient storage medium.
[0087] The above description and the accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent possible changes only. Unless explicitly required, separate components and functions are optional, and the order of operations may vary. Parts and features of some embodiments may be included in or replace parts and features of other embodiments. As used in the description of the embodiments, unless the context clearly indicates otherwise, the singular forms of "a", "an" and "the" are intended to include plural forms as well. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of one or more associated listings. In addition, when used in this application, the term "comprise" and its variants "comprises" and / or including (comprising) refer to the existence of stated features, wholes, steps, operations, elements, and / or components, but do not exclude the existence or addition of one or more other features, wholes, steps, operations, elements, components and / or these groups. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the existence of other identical elements in the process, method or device comprising the elements. In this article, each embodiment may focus on the differences from other embodiments, and the same or similar parts between the embodiments may refer to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.
[0088] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. Technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. Technicians can clearly understand that for the convenience and simplicity of description, the specific working process of the systems, devices and units described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0089] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices, equipment, etc.) can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units can be only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to implement this embodiment. In addition, each functional unit in the embodiment of the present disclosure may be integrated in a processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit.
[0090] The flowchart and block diagram in the accompanying drawings show the possible architecture, functions and operations of the system, method and computer program product according to the embodiment of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. In the description corresponding to the flowchart and block diagram in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in a different order from the order disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified functions or actions, or may be implemented by a combination of dedicated hardware and computer instructions.
Claims
1. A one-key recovery method based on an embedded Linux industrial computer, characterized in that: The method comprises: Partition the embedded Linux storage device in advance and add a backup partition to store the original root file system. A button is set in the embedded Linux industrial computer and connected to a GPIO pin on the CPU end, so as to determine whether to restore the factory system based on the state of the GPIO pin; When it is determined to restore the factory system based on the status of the GPIO pin, first check whether the USB disk is inserted. If the USB disk is already connected and the rootfs.img file exists in the USB disk, read the corresponding file to a fixed memory address, and then write the data read in the memory to the partition of the root file system; After all data is written to the root file system, reboot.
2. The method according to claim 1, characterized in that The method further comprises: If there is no USB flash drive, or the rootfs.img file does not exist in the USB flash drive, the contents of the backup partition will be automatically read into the memory, and then the data read from the memory will be written into the partition of the root file system.
3. The method according to claim 1, characterized in that The method further comprises: FPGA / MCU is used on the mainboard of the industrial computer to monitor the GPIO pin. If the button is pressed, the FPGA side monitors the falling edge signal of the corresponding level.
4. The method according to claim 3, characterized in that Determine whether to restore the system to factory default based on the status of the GPIO pins, including: When uboot starts, monitor whether the connected GPIO pin is in the pressed state and start timing. The detection is performed every preset time period for a preset duration. If the button is always in the pressed state during this process, the factory system recovery process is entered.
5. The method according to claim 4, characterized in that The FPGA / MCU is used on the mainboard of the industrial computer to monitor the GPIO pin. If the button is pressed, the FPGA side monitors the falling edge signal of the corresponding level, including: Setting the GPIO pin to input mode so as to monitor the state change of the GPIO pin; If the button is pressed, the preset jitter elimination algorithm is used to monitor the falling edge signal of the corresponding level.
6. The method according to claim 1, characterized in that The method further comprises: When the USB flash drive is connected and the rootfs.img file exists in the USB flash drive, read the corresponding file to a fixed memory address, and then write the data read in the memory to the partition of the root file system, use a mutex lock or a read-write lock mechanism to write the data read in the memory to the partition of the root file system.
7. A device for one-key recovery based on an embedded Linux industrial computer, characterized in that: The device comprises: A processing module is used to partition the storage device of the embedded Linux in advance and add a backup partition to store the original root file system; A setting module is used to set a button in the embedded Linux industrial computer, connected to a GPIO pin on the CPU end, so as to determine whether to restore the factory system based on the state of the GPIO pin; The processing module is also used to, when it is determined based on the state of the GPIO pin that the factory system is to be restored, first detect whether a USB flash drive is inserted, and if the USB flash drive has been connected and there is a rootfs.img file in the USB flash drive, read the corresponding file to a fixed memory address, and then write the data read in the memory to the partition of the root file system; The restart module is used to restart after all data is written to the root file system.
8. A storage medium storing program instructions, characterized in that: When the program instructions are run, the method for one-key recovery based on an embedded Linux industrial computer as described in any one of claims 1 to 6 is executed.