A shell-based embedded Linux system application startup method and system
The shell-based embedded Linux system application startup method addresses startup exceptions and inefficiencies by detecting and correcting configuration files, enhancing robustness and efficiency in application loading.
Patent Information
- Application Number
- CN202410442175.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-12
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2044-04-12
AI Technical Summary
Existing embedded Linux system application startup methods face issues with startup exceptions and low efficiency due to timing difficulties in starting the watchdog daemon process, leading to competition problems among applications and inefficient loading of peripherals.
A shell-based embedded Linux system application startup method that involves power-on initialization, module configuration file detection using a shell script preprocessor, and correctness checks on configuration files to ensure successful loading and efficient startup.
The method reduces startup anomalies, shortens startup time, and improves efficiency by ensuring correct loading of applications through robust detection and correction of configuration files.
Smart Images

Figure CN118426858B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of system program startup, and in particular to a shell-based embedded Linux system application startup method and system. Background Art
[0002] A mature embedded device will have multiple peripheral configurations, which means that a product has diverse and differentiated detailed branches, but the basic functions are the same. During the startup of the embedded Linux system, it is inevitable to involve the loading of peripherals and the startup of applications.
[0003] Complex embedded devices, especially most IoT devices, require that the application must read the unique identifier of the peripheral before the subsequent application can rely on the startup result of the previous application. In embedded Linux systems, everything is a file. An embedded device can only be started by one process, and the main control chip can only be started by one process to interact with the peripheral. There will inevitably be competition problems between the various applications, so the application software of the embedded Linux system needs to keep the application running uninterrupted. The prior art starts the application by starting the watchdog daemon process, but because the timing of starting the watchdog daemon process is difficult to grasp, it causes abnormal startup or low startup efficiency of the application of the embedded Linux system. Summary of the invention
[0004] In order to overcome the deficiencies of the prior art, the present invention provides a shell-based embedded Linux system application startup method and system, which are used to solve the technical problems that the existing embedded Linux system application startup method is prone to startup exceptions and low startup efficiency, thereby reducing the startup exceptions of the embedded Linux system, shortening the startup time, and improving the startup efficiency.
[0005] To solve the above problems, the technical solution adopted by the present invention is as follows:
[0006] A shell-based embedded Linux system application startup method comprises the following steps:
[0007] Power on the Linux system of the embedded device and start uboot. After controlling the CPU to load RAM and ROM through uboot, the control of the CPU is handed over to the Linux kernel.
[0008] After loading the software driver through the Linux kernel, the file system is mounted and the shell script file is executed;
[0009] Loading the application environment into the Shell script preprocessor through the shell script file, and using the Shell script preprocessor to detect whether the module configuration files of the embedded device are loaded successfully;
[0010] If the loading is successful, the Shell script preprocessor is used to detect the configuration file of the application of the embedded device, and after the detection passes, the application of the embedded device is started.
[0011] As a preferred embodiment of the present invention, when detecting whether the module configuration file of the embedded device is loaded successfully, it includes:
[0012] Detect whether the configuration file of the Bluetooth module of the embedded device is loaded successfully;
[0013] If the loading is not successful, then the configuration file of the Bluetooth module is loaded again and the detection is performed again;
[0014] If the loading fails after reaching the preset number of loading times, the error information will be written into the log file;
[0015] Wherein, the module configuration file includes a configuration file of the Bluetooth module.
[0016] As a preferred embodiment of the present invention, when detecting whether the module configuration file of the embedded device is loaded successfully, it includes:
[0017] Detect whether the configuration file of the wireless temperature measurement module of the embedded device is loaded successfully;
[0018] If the loading is not successful, then the configuration file of the wireless temperature measurement module is loaded again and the test is performed again;
[0019] If the loading fails after reaching the preset number of loading times, the error information will be written into the log file;
[0020] Wherein, the module configuration file includes a configuration file of the wireless temperature measurement module.
[0021] As a preferred embodiment of the present invention, when detecting whether the configuration file of the Bluetooth module or the wireless temperature measurement module is loaded successfully, it includes:
[0022] Acquire all module configuration files, and create an initial module configuration table according to all the module configuration files, and save the module information data of all the module configuration files through the initial module configuration table;
[0023] Processing the module information data by a data loading tool to obtain module loading data, and importing the module loading data into a corresponding module database in the initial module configuration table to obtain a final module configuration table;
[0024] Wherein, the initial module configuration table and the final module configuration table are both associated with a plurality of the module databases.
[0025] As a preferred implementation mode of the present invention, after obtaining the final module configuration table, it includes:
[0026] Obtain the name of the configuration file to be loaded, determine the module loading data of the corresponding module database in the final module configuration table according to the name correspondence, and call the module operation statement of the module loading data;
[0027] The module operation statement is executed to obtain corresponding module feedback data, the module feedback data is sent to the corresponding field in the final module configuration table for storage, and whether the configuration file is loaded successfully is determined based on the module feedback data.
[0028] As a preferred embodiment of the present invention, when detecting the configuration file of the application of the embedded device, it includes:
[0029] Performing a correctness check on the configuration file of the application of the embedded device, if the configuration file of the application is incorrect, deleting the configuration file in the folder where the application is located, and mounting the configuration file in the standby folder to the folder where the application is located;
[0030] The backup folder contains the correct configuration file of the application.
[0031] As a preferred embodiment of the present invention, when the correctness of the configuration file of the application program of the embedded device is detected, it includes:
[0032] After receiving the application configuration file inspection request, the configuration file is obtained from the folder where the application is located based on the FTSENT data structure through the read function in the find command, and is recorded as the first configuration file;
[0033] Using the read function in the find command based on the FTSENT data structure, a configuration file of the corresponding application is obtained from the standby folder, which is recorded as the second configuration file;
[0034] Comparing the first configuration file with the second configuration file to obtain a similarity;
[0035] When the similarity is less than a preset threshold, it is considered that the configuration file of the application is incorrect;
[0036] The FTSENT data structure includes: the access path, root path, file name and index node information of the configuration file.
[0037] As a preferred embodiment of the present invention, when obtaining a similarity, it includes:
[0038] Get the first character string d=d1d2d3…d contained in the first configuration file m ;
[0039] Get the second character string y=y1y2y3…y contained in the second configuration file m ;
[0040] Then the similarity between the first character string and the second character string is as shown in Formula 1:
[0041]
[0042] In the formula, |m d | is the number of English words contained in string d; |m y | is the number of English words contained in string y; m d,abbre is a set of words in string d, the words whose first letters are equal to the abbreviation words composed of capital letters in string y; m y,abbre is a set of words in string y, the words whose first letters are equal to the abbreviation words composed of capital letters in string d; d is the number of times a group of words in string d matches the abbreviation letters in string y that are all uppercase letters; h y is the number of times a group of words in string y matches the abbreviation letters in string d that are all uppercase letters; is the matching coefficient of the word; v d,y is the number of characters that are common between string d and string y; k d is the length of string d, k y is the length of string y;
[0043] The matching coefficient of the word As shown in Formula 2:
[0044]
[0045] In the formula, a d,o is the length of the oth word matched in string d, a y,k is the length of the kth word matched in string y, a v is a d,o and a y,kThe length of the common characters contained in ;
[0046] Among them, when the matching coefficient of the word When it is greater than or equal to 0.8, the matched words are considered similar.
[0047] As a preferred embodiment of the present invention, when starting the application of the embedded device, it includes:
[0048] The server program of the application is started, and after detecting that the server program has been started, the client program of the application is started, and after detecting that the client program has been started, the daemon program of the application is started.
[0049] A shell-based embedded Linux system application startup system, comprising:
[0050] Initialization unit: used to power on the Linux system of the embedded device and start uboot. After controlling the CPU to load RAM and ROM through uboot, the control of the CPU is handed over to the Linux kernel.
[0051] Script execution unit: used to mount the file system after loading the software driver through the Linux kernel, and execute the shell script file;
[0052] Configuration file detection unit: used for loading the application environment into the Shell script preprocessor through the shell script file, and using the Shell script preprocessor to detect whether the module configuration file of the embedded device is loaded successfully; if the loading is successful, using the Shell script preprocessor to detect the configuration file of the application program of the embedded device;
[0053] Application program startup unit: used for starting the application program of the embedded device after the configuration file of the application program is detected and passed.
[0054] Compared with the prior art, the present invention has the following beneficial effects:
[0055] (1) Before starting the Linux system application of the embedded device, the present invention detects the configuration files of different external devices based on the module configuration table, and determines whether the configuration files of each external device are loaded successfully, so that the same system file can be adapted to multiple external device models, and lays a foundation for the correct loading of subsequent application programs, thereby improving the robustness of the embedded Linux system;
[0056] (2) Before starting the Linux system application of the embedded device, the present invention also performs a correctness check on the configuration file of the application, thereby ensuring the correct loading of the application and shortening the startup time of the embedded Linux system;
[0057] (3) The present invention greatly reduces possible startup anomalies in the embedded Linux system, shortens the startup time, and improves the startup efficiency.
[0058] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 It is a step diagram of the shell-based embedded Linux system application startup method provided by the present invention. DETAILED DESCRIPTION
[0060] The shell-based embedded Linux system application startup method provided by the present invention is as follows: Figure 1 As shown, the following steps are included:
[0061] Step S1: Power on the Linux system of the embedded device and start uboot. After the uboot controls the CPU to load RAM and ROM, the control right of the CPU is handed over to the Linux kernel.
[0062] Step S2: After loading the software driver through the Linux kernel, the file system is mounted and the shell script file is executed;
[0063] Step S3: loading the application environment into the Shell script preprocessor through the shell script file, and using the Shell script preprocessor to detect whether the module configuration files of the embedded device are loaded successfully;
[0064] Step S4: If the loading is successful, the configuration file of the application of the embedded device is detected by using the Shell script preprocessor, and after the detection passes, the application of the embedded device is started.
[0065] In the above step S3, when detecting whether the module configuration file of the embedded device is loaded successfully, it includes:
[0066] Check whether the configuration file of the Bluetooth module of the embedded device is loaded successfully;
[0067] If the loading fails, reload the configuration file of the Bluetooth module and perform the test again;
[0068] If the loading fails after reaching the preset number of loading times, the error information will be written into the log file;
[0069] The module configuration file includes a configuration file of a Bluetooth module.
[0070] In the above step S3, when detecting whether the module configuration file of the embedded device is loaded successfully, it includes:
[0071] Check whether the configuration file of the wireless temperature measurement module of the embedded device is loaded successfully;
[0072] If the loading fails, reload the configuration file of the wireless temperature measurement module and perform the test again;
[0073] If the loading fails after reaching the preset number of loading times, the error information will be written into the log file;
[0074] Among them, the module configuration file includes the configuration file of the wireless temperature measurement module.
[0075] Specifically, the microcomputer protection device with Internet of Things function is composed of a standard program device + Bluetooth module, and the status of the device can be checked through a mobile phone. The device that can collect temperature is composed of a standard microcomputer device + wireless temperature measurement module.
[0076] When the method provided by the present invention is used to start the above-mentioned microcomputer protection device and the temperature collection device, it is necessary to load and detect the configuration files of the Bluetooth module and the wireless temperature measurement module so that subsequent applications can normally start the external devices.
[0077] Specifically, the preset number of loading times is 3 times. After 3 retries, the error information is written into the log file.
[0078] Furthermore, when detecting whether the configuration file of the Bluetooth module or the wireless temperature measurement module is loaded successfully, it includes:
[0079] Obtain all module configuration files, and create an initial module configuration table based on all module configuration files, and save the module information data of all module configuration files through the initial module configuration table;
[0080] The module information data is processed by a data loading tool to obtain module loading data, and the module loading data is imported into the corresponding module database in the initial module configuration table to obtain a final module configuration table;
[0081] Among them, the initial module configuration table and the final module configuration table are both associated with multiple module databases.
[0082] Specifically, the module configuration table includes: a module configuration table name, a module configuration file name, and a module database name associated with the module configuration file.
[0083] Furthermore, after obtaining the final module configuration table, it includes:
[0084] Get the name of the configuration file to be loaded, determine the module loading data of the corresponding module database in the final module configuration table according to the name correspondence, and call the module operation statement of the module loading data;
[0085] Execute the module operation statement to obtain the corresponding module feedback data, send the module feedback data to the corresponding field in the final module configuration table for storage, and determine whether the configuration file is loaded successfully based on the module feedback data.
[0086] Specifically, after detecting the external device, check whether the configuration file config of the application is correct. If the configuration file is incorrect, the configuration file in the backup folder will be remounted to the folder where the main program is located until the configuration file config is detected normally.
[0087] In the above step S4, when the configuration file of the application of the embedded device is detected, it includes:
[0088] Check the correctness of the configuration file of the application of the embedded device. If the configuration file of the application is incorrect, delete the configuration file in the folder where the application is located, and mount the configuration file in the backup folder to the folder where the application is located;
[0089] The alternate folder contains the correct configuration files for the application.
[0090] Furthermore, when the configuration file of the application program of the embedded device is checked for correctness, it includes:
[0091] After receiving the application configuration file inspection request, the configuration file is obtained from the folder where the application is located based on the FTSENT data structure through the read function in the find command, and is recorded as the first configuration file;
[0092] The configuration file of the corresponding application is obtained from the backup folder based on the FTSENT data structure through the read function in the find command, and is recorded as the second configuration file;
[0093] Comparing the first configuration file with the second configuration file to obtain a similarity;
[0094] When the similarity is less than the preset threshold, the application configuration file is considered to be incorrect;
[0095] The FTSENT data structure includes: the access path, root path, file name and index node information of the configuration file.
[0096] Furthermore, when obtaining a similarity, it includes:
[0097] Get the first character string d=d1d2d3…d contained in the first configuration file m ;
[0098] Get the second character string y=y1y2y3…y contained in the second configuration file m ;
[0099] Then the similarity between the first string and the second string is as shown in Formula 1:
[0100]
[0101] In the formula, |m d | is the number of English words contained in string d; |m y | is the number of English words contained in string y; m d,abbre is the number of words in string d, the words whose first letters are equal to the abbreviations in string y consisting of capital letters; m y,abbre is the number of words in string y, the words whose first letters are equal to the abbreviations in string d consisting of capital letters; h d is the number of times a group of words in string d matches the abbreviation letters in string y that are all uppercase letters; h y is the number of times a group of words in string y matches the abbreviation letters in string d that are all uppercase letters; is the matching coefficient of the word; v d,y is the number of characters that are common between string d and string y; k d is the length of string d, k y is the length of string y;
[0102] The matching coefficient of the word As shown in Formula 2:
[0103]
[0104] In the formula, a d,o is the length of the oth word matched in string d, a y,k is the length of the kth word matched in string y, a v is a d,o and a y,k The length of the common characters contained in ;
[0105] Among them, when the matching coefficient of the word When it is greater than or equal to 0.8, the matched words are considered similar.
[0106] In the above step S4, when starting the application of the embedded device, it includes:
[0107] Start the server program of the application, and after detecting that the server program has been started, start the client program of the application, and after detecting that the client program has been started, start the daemon program of the application.
[0108] Specifically, the present invention can ensure that the embedded device runs accurately and efficiently through the above startup sequence (server program→client program→daemon program).
[0109] The shell-based embedded Linux system application startup system provided by the present invention comprises: an initialization unit, a script execution unit, a configuration file detection unit and an application startup unit.
[0110] Initialization unit: used to power on the Linux system of the embedded device and start uboot. After controlling the CPU to load RAM and ROM through uboot, the control of the CPU is handed over to the Linux kernel.
[0111] Script execution unit: used to mount the file system after loading the software driver through the Linux kernel and execute the shell script file.
[0112] Configuration file detection unit: used to load the application environment into the Shell script preprocessor through the shell script file, and use the Shell script preprocessor to detect whether the module configuration file of the embedded device is loaded successfully; if the loading is successful, the Shell script preprocessor is used to detect the configuration file of the application program of the embedded device.
[0113] Application startup unit: used to start the application of the embedded device after the configuration file of the application passes the detection.
[0114] The above-mentioned embodiments are only preferred embodiments of the present invention and cannot be used to limit the scope of protection of the present invention. Any non-substantial changes and substitutions made by technicians in this field on the basis of the present invention shall fall within the scope of protection required by the present invention.
Claims
1. A shell-based embedded Linux system application startup method, characterized in that: The following steps are involved: Power on the Linux system of the embedded device and start uboot. After controlling the CPU to load RAM and ROM through uboot, the control of the CPU is handed over to the Linux kernel. After loading the software driver through the Linux kernel, the file system is mounted and the shell script file is executed; Loading the application environment into the Shell script preprocessor through the shell script file, and using the Shell script preprocessor to detect whether the module configuration files of the embedded device are loaded successfully; If the loading is successful, the configuration file of the application of the embedded device is detected by using the Shell script preprocessor, and after the detection passes, the application of the embedded device is started; When detecting whether the module configuration file of the embedded device is loaded successfully, it includes: Acquire all module configuration files, and create an initial module configuration table according to all the module configuration files, and save the module information data of all the module configuration files through the initial module configuration table; Processing the module information data by a data loading tool to obtain module loading data, and importing the module loading data into a corresponding module database in the initial module configuration table to obtain a final module configuration table; Wherein, the initial module configuration table and the final module configuration table are both associated with a plurality of the module databases; After obtaining the final module configuration table, including: Obtain the name of the configuration file to be loaded, determine the module loading data of the corresponding module database in the final module configuration table according to the name correspondence, and call the module operation statement of the module loading data; The module operation statement is executed to obtain corresponding module feedback data, the module feedback data is sent to the corresponding field in the final module configuration table for storage, and whether the configuration file is loaded successfully is determined based on the module feedback data.
2. The shell-based embedded Linux system application startup method according to claim 1, characterized in that: When detecting whether the module configuration file of the embedded device is loaded successfully, it includes: Detect whether the configuration file of the Bluetooth module of the embedded device is loaded successfully; If the loading is not successful, then the configuration file of the Bluetooth module is loaded again and the detection is performed again; If the loading fails after reaching the preset number of loading times, the error information will be written into the log file; Wherein, the module configuration file includes a configuration file of the Bluetooth module.
3. The shell-based embedded Linux system application startup method according to claim 1, characterized in that: When detecting whether the module configuration file of the embedded device is loaded successfully, it includes: Detect whether the configuration file of the wireless temperature measurement module of the embedded device is loaded successfully; If the loading is not successful, then the configuration file of the wireless temperature measurement module is loaded again and the test is performed again; If the loading fails after reaching the preset number of loading times, the error information will be written into the log file; Wherein, the module configuration file includes a configuration file of the wireless temperature measurement module.
4. The shell-based embedded Linux system application startup method according to claim 1, characterized in that: When detecting the configuration file of the application of the embedded device, it includes: Performing a correctness check on the configuration file of the application of the embedded device, if the configuration file of the application is incorrect, deleting the configuration file in the folder where the application is located, and mounting the configuration file in the standby folder to the folder where the application is located; The backup folder contains the correct configuration file of the application.
5. The shell-based embedded Linux system application startup method according to claim 4, characterized in that: When the configuration file of the application program of the embedded device is checked for correctness, it includes: After receiving the application configuration file inspection request, the configuration file is obtained from the folder where the application is located based on the FTSENT data structure through the read function in the find command, and is recorded as the first configuration file; Using the read function in the find command based on the FTSENT data structure, a configuration file of the corresponding application is obtained from the standby folder, which is recorded as the second configuration file; Comparing the first configuration file with the second configuration file to obtain a similarity; When the similarity is less than a preset threshold, it is considered that the configuration file of the application is incorrect; The FTSENT data structure includes: the access path, root path, file name and index node information of the configuration file.
6. The shell-based embedded Linux system application startup method according to claim 5, characterized in that: When obtaining a similarity, it includes: Get the first string contained in the first configuration file ; Get the second string contained in the second configuration file ; Then the similarity between the first character string and the second character string is as shown in Formula 1: (1); In the formula, Is a string The number of English words included; Is a string The number of English words included; Is a string The number of words contained in a set, the words whose first letters are combined equal to the string abbreviations consisting of capital letters in Is a string The number of words contained in a set, the words whose first letters are combined equal to the string abbreviations consisting of capital letters in Is a string A set of words in a string The number of times the abbreviation consists of all capital letters; Is a string A set of words in a string The number of times the abbreviation consists of all capital letters; is the matching coefficient of the word; Is a string and string Number of identical characters; Is a string Length, Is a string Length; The matching coefficient of the word , as shown in Formula 2: (2); In the formula, Is a string The first matching The length of words, Is a string The first matching The length of words, yes and The length of the common characters contained in ; Among them, when the matching coefficient of the word When it is greater than or equal to 0.8, the matched words are considered similar.
7. The shell-based embedded Linux system application startup method according to claim 1, characterized in that: When starting the application of the embedded device, including: The server program of the application is started, and after detecting that the server program has been started, the client program of the application is started, and after detecting that the client program has been started, the daemon program of the application is started.
8. A shell-based embedded Linux system application startup system, characterized in that: include: Initialization unit: used to power on the Linux system of the embedded device and start uboot. After controlling the CPU to load RAM and ROM through uboot, the control of the CPU is handed over to the Linux kernel. Script execution unit: used to mount the file system after loading the software driver through the Linux kernel, and execute the shell script file; Configuration file detection unit: used for loading the application environment into the Shell script preprocessor through the shell script file, and using the Shell script preprocessor to detect whether the module configuration file of the embedded device is loaded successfully; If the loading is successful, the configuration file of the application of the embedded device is detected by using the Shell script preprocessor; An application program startup unit: used for starting the application program of the embedded device after the configuration file of the application program is detected and passed; When detecting whether the module configuration file of the embedded device is loaded successfully, it includes: Acquire all module configuration files, and create an initial module configuration table according to all the module configuration files, and save the module information data of all the module configuration files through the initial module configuration table; Processing the module information data by a data loading tool to obtain module loading data, and importing the module loading data into a corresponding module database in the initial module configuration table to obtain a final module configuration table; Wherein, the initial module configuration table and the final module configuration table are both associated with a plurality of the module databases; After obtaining the final module configuration table, including: Obtain the name of the configuration file to be loaded, determine the module loading data of the corresponding module database in the final module configuration table according to the name correspondence, and call the module operation statement of the module loading data; The module operation statement is executed to obtain corresponding module feedback data, the module feedback data is sent to the corresponding field in the final module configuration table for storage, and whether the configuration file is loaded successfully is determined based on the module feedback data.
Citation Information
Patent Citations
Method and system for enhancing reliability of Linux application system
CN105549985A
