Business program execution method and device, embedded equipment and medium

By dividing the root file system into two parts and loading only one part in the volatile memory, combined with the advantages of non-volatile memory, the problem of high cost of volatile memory in embedded devices is solved, the device cost is reduced and the performance is improved.

CN120704758AActive Publication Date: 2025-09-26NEW H3C TECH CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202510750778.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-05
Publication Date
2025-09-26
Estimated Expiration
2045-06-05

AI Technical Summary

Technical Problem

The high cost of volatile memory in embedded devices increases the overall cost of the device, and the slow read and write speed of non-volatile memory affects business performance.

Method used

The root file system is divided into a first sub-root file system and a second sub-root file system. Only the first sub-root file system is loaded into the volatile memory, and the second sub-root file system is still stored in the non-volatile memory. A complete root file system is obtained by superposition, and the service program is executed using it.

Benefits of technology

It reduces the space requirement of volatile memory, thereby reducing the cost of embedded devices, and extends the life of non-volatile memory by reducing the number of read and write times, thereby improving business performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120704758A_ABST
    Figure CN120704758A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a service program execution method and device, embedded equipment and a medium, relates to the technical field of computers, and is applied to the embedded equipment, the embedded equipment comprises a nonvolatile memory and a volatile memory, a first sub-root file system and a second sub-root file system are stored in the nonvolatile memory, and the first sub-root file system and the second sub-root file system are stored in the volatile memory. The method comprises the following steps: after the embedded equipment is started, loading a first sub-root file system to a volatile memory; superposing the first sub-root file system and the second sub-root file system to obtain a root directory; and executing a service program by using the first sub-root file system and the second sub-root file system under the root directory. According to the scheme, the cost of the embedded equipment can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, embedded device, and medium for executing a business program. Background Art

[0002] Before an embedded device starts, the root file system (RootFS) is stored in a non-volatile memory (such as an embedded MultiMediaCard (EMMC)). After the embedded device starts, the Linux operating system needs to load the files included in the RootFS into a volatile memory (such as memory). The central processing unit (CPU) executes the business program by running the loaded files and uses the remaining space in the volatile memory to cache the business program data.

[0003] To ensure the normal execution of business programs, the volatile memory on the embedded device needs a larger capacity, but the price per unit capacity of volatile memory is higher, resulting in a higher cost of volatile memory on the embedded device, and thus a higher cost of the embedded device. Summary of the Invention

[0004] The purpose of the embodiments of the present application is to provide a method, apparatus, embedded device, and medium for executing a business program to reduce the cost of embedded devices. The specific technical solution is as follows:

[0005] In a first aspect, an embodiment of the present application provides a service program execution method, which is applied to an embedded device, wherein the embedded device includes a non-volatile memory and a volatile memory, and the non-volatile memory stores a first sub-root file system and a second sub-root file system. The method includes:

[0006] After the embedded device is started, loading the first sub-root file system into the volatile memory;

[0007] Overlaying the first sub-root file system and the second sub-root file system to obtain a root directory;

[0008] The service program is executed using the first sub-root file system and the second sub-root file system under the root directory.

[0009] In some embodiments, the step of loading the first sub-root file system into the volatile memory includes:

[0010] creating a temporary root directory in the volatile memory;

[0011] Mounting the first sub-root file system to the first subdirectory under the temporary root directory;

[0012] The first sub-root file system in the first sub-directory is loaded into the second sub-directory in the temporary root directory.

[0013] In some embodiments, the method further comprises:

[0014] Mounting the second sub-root file system to the third sub-directory under the temporary root directory;

[0015] The step of superimposing the first sub-root file system and the second sub-root file system to obtain a root directory includes:

[0016] Superimposing the second subdirectory and the third subdirectory to obtain a fourth subdirectory under the temporary root directory;

[0017] The fourth subdirectory is determined as a root directory.

[0018] In some embodiments, before loading the first sub-root file system into the volatile memory, the method further includes:

[0019] Verifying the first sub-root file system and the second sub-root file system;

[0020] After the verification is passed, the preset files in the non-volatile memory are loaded into the volatile memory, wherein the preset files include an operating system, a tool set program, and a script file;

[0021] Using the operating system, starting the tool set program;

[0022] The script file is run using the tool set program to execute the step of loading the first sub-root file system into the volatile memory.

[0023] In some embodiments, the step of executing a service program using the first sub-root file system and the second sub-root file system under the root directory includes:

[0024] executing a first service program using a first file included in the first sub-root file system under the root directory; and / or,

[0025] Loading a second file included in the second sub-root file system under the root directory into the volatile memory; executing a second service program using the second file; and / or,

[0026] The third file included in the second sub-root file system under the root directory is loaded into the volatile memory; and a third service program is executed using the third file and the fourth file included in the first sub-root file system under the root directory.

[0027] In some embodiments, the first sub-root file system includes a readable and writable file and a first read-only file with a usage frequency greater than or equal to a preset frequency, and the second sub-root file system includes a second read-only file with a usage frequency less than the preset frequency; and / or

[0028] The non-volatile memory includes a first partition and a second partition, the first sub-root file system is stored in the first partition, and the second sub-root file system is stored in the second partition.

[0029] In a second aspect, an embodiment of the present application provides a service program execution device, which is applied to an embedded device, wherein the embedded device includes a non-volatile memory and a volatile memory, wherein the non-volatile memory stores a first sub-root file system and a second sub-root file system, and the device includes:

[0030] A loading module, configured to load the first sub-root file system into the volatile memory after the embedded device is started;

[0031] an overlay module, configured to overlay the first sub-root file system and the second sub-root file system to obtain a root directory;

[0032] The execution module is configured to execute a service program by utilizing the first sub-root file system and the second sub-root file system under the root directory.

[0033] In some embodiments, the loading module is specifically used to create a temporary root directory in the volatile memory; mount the first sub-root file system to a first subdirectory under the temporary root directory; and load the first sub-root file system under the first subdirectory to a second subdirectory under the temporary root directory.

[0034] In some embodiments, the apparatus further comprises: a mounting module, configured to mount the second sub-root file system to a third sub-directory under the temporary root directory;

[0035] The superposition module is specifically configured to superimpose the second subdirectory and the third subdirectory to obtain a fourth subdirectory under the temporary root directory; and determine the fourth subdirectory as the root directory.

[0036] In some embodiments, the device further includes: a startup module, configured to verify the first sub-root file system and the second sub-root file system before loading the first sub-root file system into the volatile memory; after the verification is passed, loading the preset file in the non-volatile memory into the volatile memory, the preset file including an operating system, a tool set program, and a script file; using the operating system, starting the tool set program; and using the tool set program to run the script file.

[0037] In some embodiments, the execution module is specifically used to execute a first business program using a first file included in the first sub-root file system under the root directory; and / or, load a second file included in the second sub-root file system under the root directory into the volatile memory; and execute a second business program using the second file; and / or, load a third file included in the second sub-root file system under the root directory into the volatile memory; and execute a third business program using the third file and a fourth file included in the first sub-root file system under the root directory.

[0038] In some embodiments, the first sub-root file system includes a readable and writable file and a first read-only file with a usage frequency greater than or equal to a preset frequency, and the second sub-root file system includes a second read-only file with a usage frequency less than the preset frequency; and / or

[0039] The non-volatile memory includes a first partition and a second partition, the first sub-root file system is stored in the first partition, and the second sub-root file system is stored in the second partition.

[0040] In a third aspect, an embodiment of the present application provides an embedded device comprising a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor, and the processor is prompted by the machine-executable instructions to implement any of the methods provided in the first aspect above.

[0041] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any one of the methods provided in the first aspect is implemented.

[0042] In a fifth aspect, an embodiment of the present application further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any one of the methods provided in the first aspect.

[0043] Beneficial effects of the embodiments of the present application:

[0044] In the technical solution provided in the embodiment of the present application, the root file system is divided into a first sub-root file system and a second sub-root file system and stored in a non-volatile memory. After the embedded device is started, only the first sub-root file system is loaded into the volatile memory, while the second sub-root file system is still stored in the non-volatile memory. Afterwards, the first sub-root file system and the second sub-root file system are superimposed to obtain a complete root file system and root directory, and the complete root file system under the root directory is used to execute business programs. By applying the technical solution provided in the embodiment of the present application, some files included in the root file system are retained in the non-volatile memory, that is, the non-volatile memory is used instead of the volatile memory, which saves the space of the volatile memory and reduces the capacity required for the volatile memory on the embedded device, thereby reducing the cost of the volatile memory and the cost of the embedded device.

[0045] Of course, it is not necessary to achieve all the advantages described above at the same time when implementing any product or method of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other embodiments can also be obtained based on these drawings.

[0047] Figure 1 A structural diagram of an embedded device;

[0048] Figure 2 A schematic diagram of the operation of a system or business on a computer or server;

[0049] Figure 3 A first flow chart of the method for executing a business program provided in an embodiment of the present application;

[0050] Figure 4 A second flow chart of the method for executing a business program provided in an embodiment of the present application;

[0051] Figure 5 A third flow chart of the method for executing a business program provided in an embodiment of the present application;

[0052] Figure 6 A schematic diagram of file mounting and switching provided in an embodiment of the present application;

[0053] Figure 7 A schematic diagram of merging sub-root file systems provided in an embodiment of the present application;

[0054] Figure 8A schematic diagram of the structure of a business program execution device provided in an embodiment of the present application;

[0055] Figure 9 A schematic diagram of the structure of an embedded device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0056] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field based on this application are within the scope of protection of this application.

[0057] To facilitate understanding, the terms appearing in the embodiments of this application are explained below.

[0058] Non-volatile storage media: A type of storage medium used to store computer data. Its characteristic is that the stored data is not lost even after a device power outage or system shutdown. Due to the characteristics of non-volatile storage media, non-volatile memory can retain information for a long time. Common non-volatile memory types include EMMC and flash memory (FLASH).

[0059] EMMC: An embedded non-volatile memory widely used in various electronic devices such as smartphones, tablets, laptops, and other consumer electronics. EMMC combines NAND Flash (Not AND Flash Memory, NAND Flash) and a flash controller in a single integrated circuit package, simplifying system design and integration.

[0060] FLASH: A non-volatile storage technology that electronically erases and rewrites data. This storage technology is widely used in various electronic devices due to its efficiency and durability. FLASH does not require power to retain stored data and offers higher speeds and a smaller physical size than traditional magnetic storage devices. FLASH includes NAND Flash and NOR Flash.

[0061] Volatile storage media: A type of storage medium that requires a continuous power supply to retain stored data. Once the power is cut off or the device is turned off, the data stored on this medium is lost. Due to the characteristics of volatile storage media, volatile memory is primarily used to store data that needs to be read and written quickly in computer systems.

[0062] Memory: A critical hardware component in a computer system that temporarily stores data, instructions, and programs currently being used by the processor. It is the core of computer operation, providing the processor with fast access and data exchange capabilities. The speed and capacity of memory directly impact computer performance. Memory is a volatile memory, including dynamic random access memory (DRAM) and synchronous dynamic random access memory (SDRAM).

[0063] DRAM: A common type of volatile memory widely used in computers and other electronic devices to provide fast data access capabilities. It is also generally referred to as memory.

[0064] SDRAM: An improved type of DRAM, widely used in computers and electronic devices. Compared to traditional DRAM, SDRAM features synchronous operation, meaning its operation is synchronized with the computer's clock signal, thereby improving data transfer efficiency and speed. It is also generally referred to as memory.

[0065] CPU: The core component of a computer, responsible for executing instructions in computer programs, processing data, and controlling the work of other hardware components. It is the "brain" of the computer, responsible for performing various calculations, logical operations, data management, and system control tasks.

[0066] Linux operating system: An open source, Unix-like operating system known for its stability, high security, and flexibility. It is widely used on various platforms such as servers, desktop computers, embedded systems, and mobile devices.

[0067] RootFS: The root file system used to boot and run the system in the Linux operating system. It is the starting point of the file system hierarchy and contains all the basic files and directories required for the operating system to start and run.

[0068] Embedded devices can include hardware and software parts, such as Figure 1 The hardware includes the CPU, volatile memory (i.e., internal memory, such as DRAM or SDRAM), non-volatile memory (such as EMMC or FLASH), device interfaces (such as Universal Serial Bus (USB) or Peripheral Component Interconnect Express (PCIE)), and functional hardware (such as a forwarding chip or wireless transceiver). The software includes operating system software and business software.

[0069] Embedded devices are cost-sensitive. As long as their functionality is met, they generally choose smaller volatile and non-volatile memory. Volatile memory of the same capacity is more expensive than non-volatile memory of the same capacity, but volatile memory offers faster read and write speeds. For example, in small embedded devices, volatile memory typically ranges from 1 gigabyte (GB) to 8GB, while non-volatile memory typically ranges from 2GB to 32GB.

[0070] Before the embedded device starts, the RootFS is stored in a non-volatile memory (such as EMMC, etc.); after the embedded device starts, the files included in the RootFS need to be loaded into a volatile memory (such as memory) through the Linux operating system. The CPU executes the business program by running the loaded files and uses the remaining space in the volatile memory to cache the data of the business program.

[0071] To ensure the normal execution of business programs, the volatile memory on the embedded device needs a larger capacity, but the price per unit capacity of volatile memory is higher, resulting in a higher cost of volatile memory on the embedded device, and thus a higher cost of the embedded device.

[0072] A computer or server can execute business programs in the following way: the files included in RootFS (such as application files, shared software library files, etc.) are placed on non-volatile storage (such as a hard disk). When the operating system and business programs are running, the files are loaded into volatile storage (such as memory), and the CPU runs the loaded files as a process to execute the business programs.

[0073] like Figure 2 As shown, various application files (such as application file 1 to application file N), shared software libraries (such as shared software library 1 to shared software library M) and other files included in ROOTFS are placed in a non-volatile memory (such as a hard disk). After the computer or server is started, the files required by the business program are loaded into the volatile memory, and the CPU runs the loaded files in the form of application processes (such as application process 1 to application process X) to implement the execution of the corresponding business program.

[0074] This method makes maximum use of the disk to store ROOTFS, but there are significant differences in hardware form between embedded devices and computers or servers. When applied to embedded devices, there are the following technical disadvantages: 1) The files included in RootFS are stored in an uncompressed form on the non-volatile memory of the computer or server, while the non-volatile memory capacity of the embedded device is limited. Excluding the space that must be used, the remaining space cannot directly accommodate all the uncompressed ROOTFS; 2) To ensure the high-performance operation of business programs, embedded devices need to frequently load and run files, while the non-volatile memory of embedded devices has a very slow read and write speed compared to the memory, affecting business performance; 3) The non-volatile memory commonly used in computers or servers is the hard disk, while the non-volatile memory of embedded devices is mainly EMMC or FLASH, which has much fewer read and write times than the hard disk and a limited lifespan. Damage to the non-volatile memory at the end of its lifespan will directly lead to damage to the embedded device at the end of its lifespan.

[0075] To solve the above problems, an embodiment of the present application provides a business program execution method, which is applied to an embedded device. The embedded device includes a non-volatile memory and a volatile memory. The non-volatile memory stores a first sub-root file system and a second sub-root file system. Figure 3 , Figure 3 This is a first flow chart of a business program execution method provided in an embodiment of the present application, and the business program execution method includes the following steps.

[0076] Step S31: After the embedded device is started, the first sub-root file system is loaded into the volatile memory.

[0077] Step S32: superimpose the first sub-root file system and the second sub-root file system to obtain a root directory.

[0078] Step S33: Execute the service program using the first sub-root file system and the second sub-root file system in the root directory.

[0079] In the technical solution provided in the embodiment of the present application, the root file system is divided into a first sub-root file system and a second sub-root file system and stored in a non-volatile memory. After the embedded device is started, only the first sub-root file system is loaded into the volatile memory, while the second sub-root file system is still stored in the non-volatile memory. Afterwards, the first sub-root file system and the second sub-root file system are superimposed to obtain a complete root file system and root directory, and the complete root file system under the root directory is used to execute business programs. By applying the technical solution provided in the embodiment of the present application, some files included in the root file system are retained in the non-volatile memory, that is, the non-volatile memory is used instead of the volatile memory, which saves the space of the volatile memory and reduces the capacity required for the volatile memory on the embedded device, thereby reducing the cost of the volatile memory and the cost of the embedded device.

[0080] In the embodiment of the present application, the embedded device may be a router, a switch, a wireless access point, a set-top box, a camera, etc. The hardware part may include a CPU, a volatile memory, a non-volatile memory, a device interface and functional hardware, and the software part may include an operating system software and a business software, etc. The operating system may be a Linux operating system. For details, see the above Figure 1 The description of this section does not limit embedded devices. The non-volatile memory of an embedded device can be EMMC or FLASH, etc.; the volatile memory, also known as internal memory, can be DRAM or SDRAM, etc. The specifications of non-volatile memory and volatile memory are not limited here.

[0081] The non-volatile memory of the embedded device stores the RootFS of the Linux operating system, and the RootFS can be divided into a first sub-root file system and a second sub-root file system. In order to reduce the number of read and write times of the non-volatile memory and extend the life of the non-volatile memory, the RootFS can be divided according to whether the files included are readable and writable and the frequency of use. The first sub-root file system can include readable and writable files in the RootFS and read-only files with a usage frequency greater than or equal to a preset frequency (referred to as first read-only files), and the second sub-root file system can include read-only files with a usage frequency less than a preset frequency in the RootFS (referred to as second read-only files). That is, the first sub-root file system includes readable and writable files and some read-only files with a higher usage frequency, and the second sub-root file system only includes the remaining read-only files with a lower usage frequency, so as to minimize the number of times the non-volatile memory is read and written. The value of the preset frequency and the division method of the RootFS are not limited here.

[0082] In an embodiment of the present application, to save space in the non-volatile memory, the first sub-root file system and the second sub-root file system can be stored in a compressed form in the non-volatile memory. The first sub-root file system can be compressed using any compression method, such as an Image Package Envelope (IPE); the second sub-root file system can be compressed using a compressed read-only file system (Compressed Read-Only File System) (such as SquashFS). The compression method is not limited herein.

[0083] To facilitate file management, the non-volatile memory can store files by partition. The non-volatile memory can include a first partition and a second partition, the first sub-root file system can be stored in the first partition, and the second sub-root file system can be stored in the second partition.

[0084] In an embodiment of the present application, the non-volatile memory can be formatted using a file system such as a File Allocation Table File System (FATFS) and an Extended File System (ExtFS). The space of the non-volatile memory can be divided into multiple partitions, each partition stores different types of files, and the number of partitions is greater than or equal to 2. The first partition is used to store the first sub-root file system, and the second partition is used to store the second sub-root file system. The first partition and the second partition may include one or more actual partitions in the non-volatile memory. For ease of description, the following description will be based on the first partition and the second partition being an actual partition in the non-volatile memory, and does not serve as a limitation. To ensure normal storage of data, the size of the first partition is greater than or equal to the size of the space occupied by the first sub-root file system, and the size of the second partition is greater than or equal to the size of the space occupied by the second sub-root file system.

[0085] In an embodiment of the present application, the non-volatile memory may also include other partitions for storing other files, such as preset files, data files, configuration files, etc. The size of the other partitions is greater than or equal to the space occupied by the other stored files.

[0086] In step S31, after the embedded device is started, the first sub-root file system can be loaded into the volatile memory. That is, all files included in the first sub-root file system are loaded into the volatile memory. The files loaded into the volatile memory are decompressed files and are managed using a temporary file system (TmpFS). In this step, the files included in the second sub-root file system are still compressed and stored in the non-volatile memory.

[0087] In the above step S32, the embedded device can use a union file system (such as an overlay file system (OverlayFS)) to merge one or more file system layers (called "underlying file systems") with a writable layer (called "upper file system") to achieve file system overlay.

[0088] In an embodiment of the present application, the embedded device uses the first sub-root file system loaded in the volatile memory as the upper file system, and the second sub-root file system stored in the non-volatile memory as the lower file system, and uses a joint file system to superimpose the first sub-root file system and the second sub-root file system to obtain a superimposed file system.

[0089] The files included in the superimposed file system are the same as those included in the RootFS. Some of the files included in the superimposed file system have been loaded into the volatile memory, and these files are the files included in the first sub-root file system. Other files included in the superimposed file system are compressed and stored in the non-volatile memory and are not loaded into the volatile memory. These files are the files included in the second sub-root file system.

[0090] In the embodiment of the present application, the embedded device can set the directory where the superimposed file system is located, and determine the directory as the current root directory.

[0091] In the above step S33, the embedded device can use the files included in the first sub-root file system and the files included in the second sub-root file system under the root directory, and load the files required for the business program to be executed into the volatile memory, and use the CPU to run the files loaded in the volatile memory in the form of a process to execute the business program.

[0092] In the embodiment of the present application, depending on the sub-root file system where the files required by the business program to be executed are located, the embedded device can execute the business program in the following three ways.

[0093] Mode 1: The file (such as the first file) required by the business program to be executed (such as the first business program) is in the first sub-root file system. The embedded device can use the first file included in the first sub-root file system under the root directory to execute the first business program.

[0094] In the embodiment of the present application, all files included in the first sub-root file system have been loaded into the volatile memory, that is, the first file has been loaded into the volatile memory. The embedded device can determine the first file required by the first business program included in the first sub-root file system and directly use the CPU to run the first file as a process to execute the first business program.

[0095] In mode 2, the file (e.g., the second file) required by the business program to be executed (e.g., the second business program) is in the second sub-root file system. The embedded device can load the second file included in the second sub-root file system in the root directory into the volatile memory and execute the second business program using the second file.

[0096] In the embodiment of the present application, all files included in the second sub-root file system have not yet been loaded into the volatile memory. The embedded device can determine the second file required by the second business program included in the second sub-root file system, load the second file into the volatile memory, and use the CPU to run the second file as a process to execute the second business program.

[0097] In mode 3, the files (such as the third file and the fourth file) required by the service program to be executed (such as the third service program) are in the first sub-root file system and the second sub-root file system. The embedded device can load the third file included in the second sub-root file system in the root directory into the volatile memory and execute the third service program using the third file and the fourth file included in the first sub-root file system in the root directory.

[0098] In an embodiment of the present application, the embedded device can determine the third file included in the first sub-root file system required by the third business program, and the fourth file included in the second sub-root file system, and load the fourth file into the volatile memory, and use the CPU to run the third file and the fourth file in the form of a process to execute the third business program.

[0099] In some embodiments, see Figure 4 , Figure 4 This is a second flow chart of the business program execution method provided in an embodiment of the present application. The business program execution method may include the following steps.

[0100] Step S41: After the embedded device is started, a temporary root directory is created in the volatile memory.

[0101] Step S42: Mount the first sub-root file system to the first sub-directory under the temporary root directory.

[0102] Step S43: Load the first sub-root file system in the first sub-directory into the second sub-directory in the temporary root directory.

[0103] Step S44: Overlay the first sub-root file system and the second sub-root file system to obtain a root directory, which is the same as step S32 above.

[0104] Step S45: Execute the service program using the first sub-root file system and the second sub-root file system in the root directory, which is the same as the above step S33.

[0105] In the technical solution provided in the embodiment of the present application, after the embedded device is started, a temporary root directory is first created, and the first sub-root file system is mounted under the temporary root directory. The first sub-root file system stored in the non-volatile memory is associated with the Linux directory to realize file access so that the first sub-root file system can be subsequently loaded into the volatile memory.

[0106] In the above step S41, after the embedded device is started, it can first create a directory in the volatile memory, such as a temporary root directory (such as " / "), and use the temporary root directory as the current root directory of the Linux operating system.

[0107] In step S42, the embedded device may create a subdirectory under the temporary root directory, and the created subdirectory is the first subdirectory (e.g., " / mnt / flash / flash1"). The embedded device may mount the first sub-root file system in the non-volatile memory to the first sub-directory, and the mounted first sub-root file system is the decompressed first sub-root file system.

[0108] In the embodiment of the present application, when the non-volatile memory partitions store files, the embedded device can mount the first sub-root file system by mounting the first partition included in the non-volatile memory to the first sub-directory.

[0109] In step S43, the embedded device may create a subdirectory under the temporary root directory, and the created subdirectory is the second subdirectory (e.g., " / rootfs.bin"). After mounting the first sub-root file system to the first sub-directory, the embedded device may load the decompressed first sub-root file system into the second sub-directory, thereby decompressing the files included in the first sub-root file system and loading them into the volatile memory.

[0110] In some embodiments, see Figure 5 , Figure 5 This is a third flow chart of the business program execution method provided in an embodiment of the present application. The business program execution method may include the following steps.

[0111] Step S51: After the embedded device is started, a temporary root directory is created in the volatile memory, which is the same as the above step S41.

[0112] Step S52: Mount the first sub-root file system to the first sub-directory under the temporary root directory, and mount the second sub-root file system to the third sub-directory under the temporary root directory.

[0113] Step S53: Load the first sub-root file system in the first sub-directory into the second sub-directory in the temporary root directory, which is the same as the above step S43.

[0114] Step S54: superimpose the second subdirectory and the third subdirectory to obtain a fourth subdirectory under the temporary root directory; and determine the fourth subdirectory as the root directory.

[0115] Step S55: Execute the service program using the first sub-root file system and the second sub-root file system in the root directory, which is the same as the above step S33.

[0116] In the technical solution provided in the embodiment of the present application, the embedded device can also mount a second sub-root file system under a temporary root directory, associate the second sub-root file system stored in the non-volatile memory with a Linux directory to access files in the non-volatile memory, and merge the first sub-root file system and the second sub-root file system according to the second sub-directory where the first sub-root file system is located and the third sub-directory where the second sub-root file system is located to obtain a root directory.

[0117] In step S52, the embedded device may create a subdirectory under the temporary root directory, which is the third subdirectory. The embedded device may also mount the second sub-root file system in the non-volatile memory to the third subdirectory, where the mounted second sub-root file system is still in a compressed state and is managed using SquashFS.

[0118] In an embodiment of the present application, when a non-volatile memory partition stores files, the embedded device can create a subdirectory (such as " / mnt / flash", referred to as the fifth subdirectory) under the temporary root directory, and create a first subdirectory (such as " / mnt / flash / flash1") and a third subdirectory (such as " / mnt / flash / flash2") under the fifth subdirectory. The embedded device can mount the first sub-root file system and the second sub-root file system by mounting the first partition included in the non-volatile memory under the first subdirectory and mounting the second partition under the third subdirectory.

[0119] In the embodiment of the present application, the embedded device may also mount all partitions included in the non-volatile memory to the volatile memory. That is, the embedded device creates a corresponding number of subdirectories under the fifth subdirectory based on the number of partitions included in the non-volatile memory, and mounts each partition to the corresponding subdirectory.

[0120] In step S54, the embedded device may create a subdirectory under the temporary root directory, and the created subdirectory is the fourth subdirectory (e.g., " / rootfs"). The embedded device may use the second subdirectory (e.g., " / rootfs.bin") as the upper directory and the third subdirectory (e.g., " / mnt / flash / flash2") as the lower directory, and merge the second and third subdirectories into the fourth subdirectory based on the directory names of the files included in the second and third subdirectories.

[0121] For example, the second subdirectory includes the / bin directory and the / sbin directory, the / bin directory includes file 1, and the / sbin directory includes file 2 and file 3; the third subdirectory includes the / bin directory, and the / bin directory includes file 4; the merged fourth subdirectory includes the / bin directory and the / sbin directory, the / bin directory includes file 1 and file 4, and the / sbin directory includes file 2 and file 3; among them, file 1, file 2, and file 3 are decompressed and loaded into the volatile memory, and file 4 is compressed and stored in the non-volatile memory.

[0122] The embedded device can switch the root directory from the temporary root directory to the fourth subdirectory. In the embodiment of the present application, after switching the root directory, the embedded device can also mount other files included in the non-volatile memory, other than the root file system, into the root directory, that is, into the fourth subdirectory. The embedded device can use the files in the root directory to perform subsequent steps, such as executing a business program.

[0123] In some embodiments, in order to ensure the integrity and correctness of the data stored in the non-volatile memory, the operating system and business programs can be executed normally. Before executing the above step S31, the above business program execution method may also include the following steps: verifying the first sub-root file system and the second sub-root file system; after the verification is passed, loading the preset file in the non-volatile memory into the volatile memory, the preset file includes the operating system, the tool set program, and the script file; using the operating system, starting the tool set program; using the tool set program to run the script file to execute step S31.

[0124] In the embodiment of the present application, the operating system is the Linux operating system. The tool set program is a lightweight tool set that integrates multiple functions, such as the busybox program. The script file is a pre-written executable file, such as a shell script file. The preset file is a file obtained by pre-packaging the operating system, tool set program, and script file (such as a Linux.elf file).

[0125] After the embedded device starts, it may first run a boot program to verify the files included in the root file system stored in the non-volatile memory. Specifically, it may verify the CRC value of the first sub-root file system and the cyclic redundancy check (CRC) value of the second sub-root file system. The embedded device may also verify other files stored in the non-volatile memory, which is not limited to this.

[0126] If the CRC value check passes, the embedded device can run the BOOT program, load the preset file into the volatile memory for execution, boot the operating system, and use the operating system boot tool set program to start. After the tool set program is started, the embedded device can use the tool set program to run the script file, execute the above steps S31 to S32 (or steps S41 to S44, steps S51 to S54), obtain the root directory including the first sub-root file system and the second sub-root file system, and execute step S33 (or step S45, step S55), and use the first sub-root file system and the second sub-root file system to execute the business program. For details, please refer to the above Figures 3 to 5 Part of the description.

[0127] The following combination Figures 6 and 7 The business program execution method provided in the embodiment of the present application is described in detail.

[0128] In an embodiment of the present application, before the embedded device is started, the root file system (including readable and writable system files, read-only system files, readable and writable business program files, and read-only business program files) is classified into two sub-root file systems. Sub-root file system 1 (i.e., the first sub-root file system) is loaded into the memory (i.e., the volatile memory) and may include readable and writable files and read-only files that need to be loaded frequently; sub-root file system 2 (i.e., the second sub-root file system) is mounted in the memory and may include other read-only files, such as various application files, shared software libraries, read-only data files, etc. The directories where the files included in these two sub-root file systems are located may overlap, that is, the directory names may be the same, but files with the same name in the same directory may only be placed in one of the sub-root file systems.

[0129] Sub-root file system 2 can be compressed and packaged into a read-only file using the SquashFS tool and named ROOTFS.SquashFS. Sub-root file system 1 can be compressed and packaged into a file named ROOTFS.bin using tools other than the SquashFS tool.

[0130] The non-volatile memory is formatted using file systems such as FAT and EXT and partitioned. The number of partitions can be greater than or equal to 2, and there is no limit on the number of partitions. Partition 1 (i.e., the first partition) stores the ROOTFS.SquashFS file, and partition 2 (i.e., the second partition) stores the ROOTFS.bin file. Figure 1 As shown in the figure, the sizes of partition 1, partition 2, ROOTFS.SquashFS file, and ROOTFS.bin file can be adjusted to achieve the appropriate placement and packaging.

[0131] The operating system, busybox program and self-developed script files of the embedded device can be packaged into an .elf file, named as Linux.elf file, and stored as a normal file in other partitions of the non-volatile memory (such as partition n). Partition n can also include other configuration files, data files, etc. that only need to be mounted in the memory, which can be loaded into the memory and executed by the boot program.

[0132] In the embodiment of the present application, at each startup stage, the embedded device runs the BOOT program to verify the CRC values ​​of the ROOTFS.bin file and the ROOTFS.SquashFS file, and verifies and repairs the root file system to ensure the integrity and correctness of the data. After the verification is passed, the Linux.elf file is loaded into the memory, the Linux operating system is booted, the operating system boots the busybox program to start, the busybox program is used to run the self-developed script file, a temporary root directory is created, and all partitions in the non-volatile memory are mounted to the subdirectory of the temporary root directory (such as the / mnt / flash directory). For example, the ROOTFS.bin file is mounted under / mnt / flash / flash1, the ROOTFS.SquashFS file is mounted under / mnt / flash / flash2, and ordinary files are mounted under / mnt / flash / flashn.

[0133] The embedded device decompresses and loads the ROOTFS.bin file under / mnt / flash / flash1 into a subdirectory (such as / rootfs.bin) of the temporary root directory. At this time, the decompressed ROOTFS.bin file is stored in the memory.

[0134] The embedded device merges the ROOTFS.SquashFS file in / mnt / flash / flash2 and the ROOTFS.bin file in / rootfs.bin into a complete root file system through OverlayFS, obtaining the directory / rootfs.

[0135] like Figure 7As shown in the figure, the ROOTFS.SquashFS file stored in the non-volatile memory includes the / bin directory, the / sbin directory, the / lib directory, the / lib64 directory, etc. The ROOTFS.bin file loaded in the memory includes the / bin directory, the / sbin directory, the / lib directory, the / lib64 directory, the / tmp directory, the / var directory, etc. The embedded device can execute the following command: mount -t overlay overlay -o lowerdir = lower directory, upperdir = upper directory, workdir = temporary directory merge directory.

[0136] The embedded device uses / mnt / flash / flash2 as the lower directory, / rootfs.bin as the upper directory, and / rootfs as the merge directory. It merges the ROOTFS.SquashFS file and the ROOTFS.bin file, that is, it merges the sub-root file system 1 and the sub-root file system 2 to obtain a complete root file system under the / rootfs directory, including files under the / bin directory, / sbin directory, / lib directory, / lib64 directory, / tmp directory, / var directory, and other directories.

[0137] The embedded device switches the root directory from the temporary root directory to / rootfs. The CPU then runs the complete root file system under / rootfs for use by the system and business processes. The embedded device then starts the business program and loads the required files from non-volatile storage into memory. The business process is unaware of this process, and while the business program startup speed may be somewhat slower, the business program's running speed remains unchanged and performance is not degraded.

[0138] In the technical solution provided by the embodiment of the present application, read-only files in the memory and files that are not frequently loaded (such as application files and shared software libraries) are compressed using SquashFS and stored on a non-volatile memory (such as EMMC or FLASH), and generally do not need to be loaded into the memory to run. Even if it is necessary to execute the corresponding business program and load the file into the memory, the memory occupied by the loaded file will be released after the business program is executed. Since the memory storage that needs to be occupied by this part of the file itself is converted to non-volatile memory storage, memory space is saved. For example, a 2GB root file system can select 1GB to be stored on a non-volatile memory, that is, 1GB of memory space is saved for the embedded device.

[0139] In this way, using non-volatile memory to replace and conserve memory, while maintaining the same service specifications, reduces the memory specifications required for the embedded device, lowering the specifications and costs of the volatile memory hardware, and thus reducing the cost of the embedded device. Furthermore, without changing the embedded device hardware, using non-volatile memory to replace and conserve memory reduces the space occupied by the root file system, increasing the memory available for service programs and thus increasing the service capacity of the embedded device.

[0140] By applying the technical solutions provided in the embodiments of this application, since the application files and shared software libraries of the business program are loaded into memory before execution, that is, the process running the business program on the embedded device still runs in memory, the execution speed of the business program remains unchanged, and the business performance remains essentially unchanged. In addition, loading read-write files into memory ensures that the service life of the embedded device meets product requirements. For read-only files in non-volatile memory, since the read life of non-volatile memory is much higher than the write life, it does not affect the overall life of the embedded device.

[0141] Corresponding to the above-mentioned business program execution method, the embodiment of the present application also provides a business program execution device, such as Figure 8 As shown, the device is applied to an embedded device, the embedded device includes a non-volatile memory and a volatile memory, the non-volatile memory stores a first sub-root file system and a second sub-root file system, and the device includes:

[0142] A loading module 81 is configured to load the first sub-root file system into the volatile memory after the embedded device is started;

[0143] An overlay module 82 is configured to overlay the first sub-root file system and the second sub-root file system to obtain a root directory;

[0144] The execution module 83 is configured to execute a service program using the first sub-root file system and the second sub-root file system under the root directory.

[0145] In the technical solution provided in the embodiment of the present application, the root file system is divided into a first sub-root file system and a second sub-root file system and stored in a non-volatile memory. After the embedded device is started, only the first sub-root file system is loaded into the volatile memory, while the second sub-root file system is still stored in the non-volatile memory. Afterwards, the first sub-root file system and the second sub-root file system are superimposed to obtain a complete root file system and root directory, and the complete root file system under the root directory is used to execute business programs. By applying the technical solution provided in the embodiment of the present application, some files included in the root file system are retained in the non-volatile memory, that is, the non-volatile memory is used instead of the volatile memory, which saves the space of the volatile memory and reduces the capacity required for the volatile memory on the embedded device, thereby reducing the cost of the volatile memory and the cost of the embedded device.

[0146] In some embodiments, the loading module 81 can be specifically used to create a temporary root directory in the volatile memory; mount the first sub-root file system to the first subdirectory under the temporary root directory; and load the first sub-root file system under the first subdirectory to the second subdirectory under the temporary root directory.

[0147] In some embodiments, the apparatus may further include: a mounting module, configured to mount the second sub-root file system to a third sub-directory under the temporary root directory;

[0148] The superposition module 82 may be specifically configured to superimpose the second subdirectory and the third subdirectory to obtain a fourth subdirectory under the temporary root directory; and determine the fourth subdirectory as the root directory.

[0149] In some embodiments, the device may further include: a startup module, used to verify the first sub-root file system and the second sub-root file system before loading the first sub-root file system into the volatile memory; after the verification is passed, the preset file in the non-volatile memory is loaded into the volatile memory, the preset file including the operating system, the tool set program, and the script file; using the operating system, starting the tool set program; and using the tool set program to run the script file.

[0150] In some embodiments, the execution module 83 can be specifically used to execute a first business program using a first file included in the first sub-root file system under the root directory; and / or, load a second file included in the second sub-root file system under the root directory into a volatile memory; and execute a second business program using the second file; and / or, load a third file included in the second sub-root file system under the root directory into a volatile memory; and execute a third business program using the third file and a fourth file included in the first sub-root file system under the root directory.

[0151] In some embodiments, the first sub-root file system may include a readable and writable file and a first read-only file having a usage frequency greater than or equal to a preset frequency, and the second sub-root file system may include a second read-only file having a usage frequency less than the preset frequency; and / or, the non-volatile memory may include a first partition and a second partition, the first sub-root file system may be stored in the first partition, and the second sub-root file system may be stored in the second partition.

[0152] The present application also provides an embedded device, such as Figure 9 As shown, it includes a processor 91 and a machine-readable storage medium 92, wherein the machine-readable storage medium 92 stores machine-executable instructions that can be executed by the processor 91, and the processor 91 is prompted by the machine-executable instructions to implement any of the above-mentioned business program execution methods applied to embedded devices.

[0153] The machine-readable storage medium may include non-volatile memory (NVM) and volatile memory (such as random access memory (RAM)). Optionally, the machine-readable storage medium may also be at least one storage device located away from the aforementioned processor.

[0154] The processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.

[0155] In another embodiment provided by the present application, a computer-readable storage medium is further provided, in which a computer program is stored. When the computer program is executed by a processor, any of the above-mentioned business program execution methods applied to embedded devices is implemented.

[0156] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any of the service program execution methods applied to embedded devices in the above embodiments.

[0157] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0158] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.

[0159] Each embodiment in this specification is described in a related manner. Similar portions between embodiments can be referenced to each other. Each embodiment focuses on the differences between the other embodiments. In particular, the apparatus, embedded device, storage medium, and program product embodiments are generally similar to the method embodiments, so their descriptions are simplified. For related portions, reference can be made to the descriptions of the method embodiments.

[0160] The above description is only a preferred embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application are included in the scope of protection of the present application.

Claims

1. A method for executing a business program, characterized in that: Applied to an embedded device, the embedded device includes a non-volatile memory and a volatile memory, the non-volatile memory stores a first sub-root file system and a second sub-root file system, the method includes: After the embedded device is started, loading the first sub-root file system into the volatile memory; Overlaying the first sub-root file system and the second sub-root file system to obtain a root directory; The service program is executed using the first sub-root file system and the second sub-root file system under the root directory.

2. The method according to claim 1, characterized in that The step of loading the first sub-root file system into the volatile memory includes: creating a temporary root directory in the volatile memory; Mounting the first sub-root file system to the first subdirectory under the temporary root directory; The first sub-root file system in the first sub-directory is loaded into the second sub-directory in the temporary root directory.

3. The method according to claim 2, characterized in that The method further comprises: Mounting the second sub-root file system to the third sub-directory under the temporary root directory; The step of superimposing the first sub-root file system and the second sub-root file system to obtain a root directory includes: Superimposing the second subdirectory and the third subdirectory to obtain a fourth subdirectory under the temporary root directory; The fourth subdirectory is determined as a root directory.

4. The method according to claim 1, wherein Before loading the first sub-root file system into the volatile memory, the method further includes: Verifying the first sub-root file system and the second sub-root file system; After the verification is passed, the preset files in the non-volatile memory are loaded into the volatile memory, wherein the preset files include an operating system, a tool set program, and a script file; Using the operating system, starting the tool set program; The script file is run using the tool set program to execute the step of loading the first sub-root file system into the volatile memory.

5. The method according to claim 1, wherein The step of executing a service program by using the first sub-root file system and the second sub-root file system under the root directory includes: executing a first service program using a first file included in the first sub-root file system under the root directory; and / or, Loading a second file included in the second sub-root file system under the root directory into the volatile memory; executing a second service program using the second file; and / or, The third file included in the second sub-root file system under the root directory is loaded into the volatile memory; and a third service program is executed using the third file and the fourth file included in the first sub-root file system under the root directory.

6. The method according to any one of claims 1 to 5, characterized in that The first sub-root file system includes a readable and writable file and a first read-only file with a usage frequency greater than or equal to a preset frequency, and the second sub-root file system includes a second read-only file with a usage frequency less than the preset frequency; and / or, The non-volatile memory includes a first partition and a second partition, the first sub-root file system is stored in the first partition, and the second sub-root file system is stored in the second partition.

7. A business program execution device, characterized in that: Applied to an embedded device, the embedded device includes a non-volatile memory and a volatile memory, the non-volatile memory stores a first sub-root file system and a second sub-root file system, the apparatus includes: A loading module, configured to load the first sub-root file system into the volatile memory after the embedded device is started; an overlay module, configured to overlay the first sub-root file system and the second sub-root file system to obtain a root directory; The execution module is configured to execute a service program by utilizing the first sub-root file system and the second sub-root file system under the root directory.

8. The device according to claim 7, characterized in that The loading module is specifically configured to create a temporary root directory in the volatile memory; mount the first sub-root file system to a first subdirectory under the temporary root directory; and load the first sub-root file system under the first subdirectory to a second subdirectory under the temporary root directory.

9. The device according to claim 8, characterized in that The device further includes: a mounting module, configured to mount the second sub-root file system to a third sub-directory under the temporary root directory; The superposition module is specifically configured to superimpose the second subdirectory and the third subdirectory to obtain a fourth subdirectory under the temporary root directory; and determine the fourth subdirectory as the root directory.

10. The device according to claim 7, characterized in that The device also includes: a startup module, which is used to verify the first sub-root file system and the second sub-root file system before loading the first sub-root file system into the volatile memory; after the verification is passed, load the preset file in the non-volatile memory into the volatile memory, the preset file including an operating system, a tool set program, and a script file; use the operating system to start the tool set program; and use the tool set program to run the script file.

11. The device according to claim 7, characterized in that The execution module is specifically configured to execute a first service program using a first file included in the first sub-root file system under the root directory; and / or load a second file included in the second sub-root file system under the root directory into the volatile memory; Executing a second service program using the second file; and / or loading a third file included in the second sub-root file system under the root directory into the volatile memory; A third service program is executed using the third file and a fourth file included in the first sub-root file system under the root directory.

12. The device according to any one of claims 7 to 11, characterized in that: The first sub-root file system includes a readable and writable file and a first read-only file with a usage frequency greater than or equal to a preset frequency, and the second sub-root file system includes a second read-only file with a usage frequency less than the preset frequency; and / or, The non-volatile memory includes a first partition and a second partition, the first sub-root file system is stored in the first partition, and the second sub-root file system is stored in the second partition.

13. An embedded device, characterized in that: The method comprises a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor, and the processor is prompted by the machine-executable instructions to implement the method according to any one of claims 1 to 6.

14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Flash memory data management method and device and computer readable storage medium

    CN107479922A

  • Method, device and equipment for quickly starting embedded system

    CN111880846A

  • Kernel quick starting method and device, electronic equipment and storage medium

    CN115269025A

  • Operation method and device of file system, storage medium and electronic equipment

    CN117687964A

  • Determination method and device of root file system, electronic equipment and storage medium

    CN118643009A