A service program execution method and device, an embedded device, and a medium

By dividing the root file system into two parts and loading only a portion into volatile memory, the high cost of volatile memory in embedded devices is solved by combining the advantages of non-volatile memory, thereby reducing device costs and improving performance.

CN120704758BActive Publication Date: 2026-07-21NEW H3C TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NEW H3C TECH CO LTD
Filing Date
2025-06-05
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

The high cost of volatile memory in embedded devices increases the overall cost of the device, while 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 volatile memory, while the second sub-root file system is still stored in non-volatile memory. The two are then superimposed to form a complete root file system, which is used to execute business programs.

Benefits of technology

This reduces the space requirements of volatile memory, thereby lowering the cost of embedded devices, and extends the lifespan of non-volatile memory by reducing the number of read and write operations, thus improving the performance of the device.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120704758B_ABST
    Figure CN120704758B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a service program execution method and device, an embedded device and a medium, relates to the technical field of computers, is applied to an embedded device, the embedded device comprises a nonvolatile memory and a volatile memory, the first sub-root file system and the second sub-root file system are stored in the nonvolatile memory, and the method comprises the following steps: loading the first sub-root file system to the volatile memory after the embedded device starts; superimposing 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.The scheme can reduce the cost of the embedded device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a business program execution method, apparatus, embedded device, and medium. Background Technology

[0002] Before the embedded device boots up, the root filesystem (RootFS) is stored in non-volatile memory (such as an embedded multimedia card (EMMC)). After the embedded device boots up, the Linux operating system needs to load the files included in the RootFS into volatile memory (such as RAM). The central processing unit (CPU) executes business programs by running the loaded files and uses the remaining space in the volatile memory to cache the data of the business programs.

[0003] To ensure the normal execution of business programs, the volatile memory in embedded devices needs to have a large capacity. However, the price per unit capacity of volatile memory is high, which leads to a high cost of volatile memory in embedded devices, and consequently, a high cost of embedded devices. Summary of the Invention

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

[0005] In a first aspect, embodiments of this application provide a business program execution method applied to an embedded device, the embedded device including a non-volatile memory and a volatile memory, the non-volatile memory storing a first sub-root file system and a second sub-root file system, the method comprising:

[0006] After the embedded device starts up, the first sub-root file system is loaded into the volatile memory;

[0007] The root directory is obtained by overlaying the first sub-root file system and the second sub-root file system;

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

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

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

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

[0012] Load the first sub-root file system under the first subdirectory into the second subdirectory under the temporary root directory.

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

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

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

[0016] The second subdirectory and the third subdirectory are combined to obtain the fourth subdirectory under the temporary root directory;

[0017] The fourth subdirectory is designated as the root directory.

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

[0019] Verify the first and second sub-root file systems;

[0020] After the verification is passed, the preset files in the non-volatile memory are loaded into the volatile memory. The preset files include the operating system, toolset programs, and script files.

[0021] Using the operating system, start the toolset program;

[0022] The script file is run using the toolset to perform the step of loading the first sub-root file system into the volatile memory.

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

[0024] Using the first files included in the first sub-root file system under the root directory, execute the first business program; and / or,

[0025] Load the second files included in the second sub-root file system under the root directory into the volatile memory; execute the second business program using the second files; and / or,

[0026] Load the third file included in the second sub-root file system under the root directory into the volatile memory; use the third file and the fourth file included in the first sub-root file system under the root directory to execute the third business program.

[0027] In some embodiments, the first sub-root file system includes readable and writable files 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, with the first sub-root file system stored in the first partition and the second sub-root file system stored in the second partition.

[0029] Secondly, embodiments of this application provide a business program execution apparatus applied to an embedded device, the embedded device including a non-volatile memory and a volatile memory, the non-volatile memory storing a first sub-root file system and a second sub-root file system, the apparatus comprising:

[0030] A loading module is used to load the first sub-root file system into the volatile memory after the embedded device starts up;

[0031] The overlay module is used to overlay the first sub-root file system and the second sub-root file system to obtain the root directory;

[0032] The execution module is used to execute business programs using 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 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.

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

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

[0036] In some embodiments, the apparatus 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, load a preset file from the non-volatile memory into the volatile memory, the preset file including an operating system, a toolset program, and a script file; start the toolset program using the operating system; and run the script file using the toolset program.

[0037] In some embodiments, the execution module is specifically configured 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; 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; 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 readable and writable files 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, with the first sub-root file system stored in the first partition and the second sub-root file system stored in the second partition.

[0040] Thirdly, embodiments of this application provide an embedded device including a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor, which in turn cause the processor to implement any of the methods provided in the first aspect above.

[0041] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements any of the methods provided in the first aspect.

[0042] Fifthly, embodiments of this application also provide a computer program product containing instructions that, when run on a computer, cause the computer to perform any of the methods provided in the first aspect.

[0043] Beneficial effects of the embodiments in this application:

[0044] In the technical solution provided in this application, the root file system is divided into a first sub-root file system and a second sub-root file system, both stored in non-volatile memory. After the embedded device boots up, only the first sub-root file system is loaded into volatile memory, while the second sub-root file system remains stored in non-volatile memory. Then, the first and second sub-root file systems are superimposed to obtain a complete root file system and root directory. The complete root file system under the root directory is then used to execute business programs. By applying the technical solution provided in this application, some files included in the root file system are retained in non-volatile memory; that is, non-volatile memory is used instead of volatile memory, saving volatile memory space, reducing the required capacity of volatile memory on the embedded device, and thus reducing the cost of volatile memory and the cost of the embedded device.

[0045] Of course, implementing any product or method of this application does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description

[0046] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other embodiments can be obtained based on these drawings.

[0047] Figure 1 This is a schematic diagram of an embedded device.

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

[0049] Figure 3 This is a schematic diagram of a first type of business program execution method provided in an embodiment of this application;

[0050] Figure 4 This is a second flowchart illustrating the business program execution method provided in an embodiment of this application.

[0051] Figure 5 This is a third flowchart illustrating the business program execution method provided in the embodiments of this application;

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

[0053] Figure 7 This is a schematic diagram illustrating the merging of sub-root file systems provided in an embodiment of this application;

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

[0055] Figure 9 This is a schematic diagram of an embedded device provided in an embodiment of this application. Detailed Implementation

[0056] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of this application.

[0057] For ease of 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, characterized by the fact that the stored data is not lost when the device is powered off or the system is shut down. Based on these characteristics, non-volatile memory can retain information for a long period. Common non-volatile memory includes 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 Not-AND Flash Memory (NAND Flash) and a flash memory controller in a single integrated circuit package, simplifying system design and integration.

[0060] Flash memory is a non-volatile storage technology that uses electronic methods to erase and rewrite data. This storage technology is widely used in various electronic devices due to its high efficiency and durability. Flash memory does not require a power source to retain stored data, and compared to traditional magnetic storage devices, it offers higher speed and smaller physical size. Flash memory includes two types: NAND Flash and NOR Flash Memory.

[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 will be lost. Based on the characteristics of volatile storage media, volatile memory is mainly used to store data that needs to be read and written quickly in computer systems.

[0062] Memory: A crucial hardware component in a computer system used for temporary storage of data, instructions, and programs currently being used by the processor. It is a core part of computer operation, responsible for providing the processor with fast access and data exchange capabilities. Memory speed and capacity directly affect computer performance. It is volatile memory, including Dynamic Random Access Memory (DRAM) and Synchronous Dynamic Random Access Memory (SDRAM).

[0063] DRAM: A commonly used type of volatile memory, widely used in computers and other electronic devices to provide fast data access capabilities, and can also be collectively 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 synchronously controlled by the computer's clock signal, thereby improving data transfer efficiency and speed. It is also collectively referred to as memory.

[0065] CPU: The core component of a computer, responsible for executing instructions in computer programs, processing data, and controlling the operation 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, and widely used on various platforms such as servers, desktop computers, embedded systems, and mobile devices.

[0067] RootFS: In the Linux operating system, it is the root file system used to boot and run the 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 components, such as Figure 1 As shown. The hardware component includes a CPU, volatile memory (i.e., RAM, 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 forwarding chips or wireless transceivers). The software component includes operating system software and service software.

[0069] Embedded devices are cost-sensitive, and while meeting functional requirements, they typically 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 8 GB, while non-volatile memory typically ranges from 2 GB to 32 GB.

[0070] Before the embedded device boots up, RootFS is stored in non-volatile memory (such as eMMC). After the embedded device boots up, the Linux operating system needs to load the files included in RootFS into volatile memory (such as RAM). The CPU executes business programs by running the loaded files and uses the remaining space in volatile memory to cache the data of the business programs.

[0071] To ensure the normal execution of business programs, the volatile memory in embedded devices needs to have a large capacity. However, the price per unit capacity of volatile memory is high, which leads to a high cost of volatile memory in embedded devices, and consequently, a high cost of embedded devices.

[0072] The 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 hard disk). When the operating system and business programs are running, the files are loaded onto volatile storage (such as memory). The CPU runs the loaded files as processes to execute the business programs.

[0073] like Figure 2 As shown, ROOTFS includes 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 stored in non-volatile storage (such as hard disk). After the computer or server starts up, it loads the files required by the business program onto the volatile storage. The CPU runs the loaded files in the form of application processes (such as application process 1 to application process X) to execute the corresponding business program.

[0074] This method maximizes the use of disk space to store ROOTFS. However, embedded devices and computers or servers have significant hardware differences, leading to the following technical drawbacks when applied to embedded devices: 1) Files included in RootFS are stored in uncompressed form on the non-volatile memory of computers or servers. However, the non-volatile memory capacity of embedded devices is limited, and after deducting the space required for use, the remaining space cannot directly accommodate the uncompressed ROOTFS; 2) To ensure the high-performance operation of business programs, embedded devices need to frequently load and run files. However, the read / write speed of the non-volatile memory of embedded devices is much slower than that of memory, affecting business performance; 3) Computers or servers commonly use hard disks for non-volatile memory, while embedded devices mainly use eMMC or FLASH memory. The number of read / write operations is much less than that of hard disks, and the lifespan is limited. The failure of the non-volatile memory at the end of its lifespan will directly lead to the failure of the embedded device at the end of its lifespan.

[0075] To address the aforementioned problems, this application provides a business program execution method applied to an embedded device. The embedded device includes non-volatile memory and volatile memory, wherein the non-volatile memory stores a first sub-root file system and a second sub-root file system. See also... Figure 3 , Figure 3 This is a schematic diagram of a first type of business program execution method provided in an embodiment of this application. The business program execution method includes the following steps.

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

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

[0078] Step S33: Execute the business program using the first and second sub-root file systems under the root directory.

[0079] In the technical solution provided in this application, the root file system is divided into a first sub-root file system and a second sub-root file system, both stored in non-volatile memory. After the embedded device boots up, only the first sub-root file system is loaded into volatile memory, while the second sub-root file system remains stored in non-volatile memory. Then, the first and second sub-root file systems are superimposed to obtain a complete root file system and root directory. The complete root file system under the root directory is then used to execute business programs. By applying the technical solution provided in this application, some files included in the root file system are retained in non-volatile memory; that is, non-volatile memory is used instead of volatile memory, saving volatile memory space, reducing the required capacity of volatile memory on the embedded device, and thus reducing the cost of volatile memory and the cost of the embedded device.

[0080] In this embodiment, the embedded device can be a router, switch, wireless access point, set-top box, camera, or other similar device. The hardware component can include a CPU, volatile memory, non-volatile memory, device interface, and functional hardware. The software component can include operating system software and business software. The operating system can be Linux, as detailed above. Figure 1 The relevant descriptions herein do not limit the scope of embedded devices. The non-volatile memory of embedded devices can be eMMC or FLASH, etc.; the volatile memory, also known as RAM, 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 Linux operating system's RootFS. RootFS can be divided into a first sub-root file system and a second sub-root file system. To reduce the number of read / write operations on the non-volatile memory and extend its lifespan, RootFS can be divided based on whether the included files are readable / writable and their usage frequency. The first sub-root file system can include readable / writable files from RootFS and read-only files with a usage frequency greater than or equal to a preset frequency (referred to as first read-only files). The second sub-root file system can include read-only files from RootFS with a usage frequency less than the preset frequency (referred to as second read-only files). In other words, the first sub-root file system includes readable / writable files and some frequently used read-only files, while the second sub-root file system only includes the remaining less frequently used read-only files, minimizing the number of read / write operations on the non-volatile memory. The value of the preset frequency and the division method of RootFS are not limited here.

[0082] In this embodiment, to save space in the non-volatile memory, the first and second sub-root file systems can be stored in the non-volatile memory in a compressed form. 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 (such as SquashFS). No limitation is placed on the compression method used here.

[0083] For ease of file management, files can be stored in partitions on non-volatile memory. Non-volatile memory can include a first partition and a second partition; a first sub-root file system can be stored in the first partition, and a second sub-root file system can be stored in the second partition.

[0084] In this embodiment, the non-volatile memory can be formatted using a file system such as File Allocation Table File System (FATFS) or Extended File System (ExtFS). The space of the non-volatile memory can be divided into multiple partitions, each storing different types of files, with the number of partitions being greater than or equal to two. The first partition stores the first sub-root file system, and the second partition stores the second sub-root file system. The first and second partitions can include one or more actual partitions within the non-volatile memory. For ease of description, the following explanation will use the first and second partitions as examples of actual partitions within the non-volatile memory, without imposing limitations. To ensure normal data storage, the size of the first partition is greater than or equal to the space occupied by the first sub-root file system, and the size of the second partition is greater than or equal to the space occupied by the second sub-root file system.

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

[0086] In step S31 above, after the embedded device starts up, the first sub-root file system can be loaded into volatile memory. That is, all files included in the first sub-root file system are loaded into volatile memory. The files loaded into volatile memory are decompressed files and 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 non-volatile memory.

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

[0088] In this embodiment of the application, the embedded device uses the first sub-root file system loaded in volatile memory as the upper-level file system and the second sub-root file system stored in non-volatile memory as the lower-level file system. The first sub-root file system and the second sub-root file system are superimposed using a union file system to obtain the superimposed file system.

[0089] The superimposed file system contains the same files as the RootFS. Some files in the superimposed file system are already loaded into volatile memory; these files are the files included in the first child root file system. The other files in the superimposed file system are compressed and stored in non-volatile memory and are not loaded into volatile memory; these files are the files included in the second child root file system.

[0090] In this embodiment of the 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 step S33 above, the embedded device can utilize the files included in the first sub-root file system and the second sub-root file system under the root directory, load the files required by the business program to be executed into volatile memory, and use the CPU to run the files loaded into volatile memory in the form of processes to execute the business program.

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

[0093] Method 1: The files (such as the first file) required by the business program to be executed (such as the first business program) are located 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 this embodiment, all files included in the first sub-root file system are loaded into volatile memory; that is, the first file is loaded into 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] Method 2: The files (such as a second file) required by the business program to be executed (such as a second business program) are located in the second sub-root file system. The embedded device can load the second file included in the second sub-root file system under the root directory into volatile memory and use the second file to execute the second business program.

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

[0097] Method 3: The files required by the business program to be executed (such as the third business program) (such as the third file and the fourth file) are located 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 under the root directory into volatile memory, and use the third file and the fourth file included in the first sub-root file system under the root directory to execute the third business program.

[0098] In this embodiment, the embedded device can determine the third file included in the first sub-root file system and the fourth file included in the second sub-root file system required by the third business program, load the fourth file into 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 flowchart illustrating a business program execution method provided in an embodiment of this application. The business program execution method may include the following steps.

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

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

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

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

[0104] Step S45: Execute the business program using the first and second sub-root file systems under the root directory. This is the same as step S33 above.

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

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

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

[0108] In this embodiment of the application, when files are stored in a non-volatile memory partition, 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 subdirectory.

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

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

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

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

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

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

[0115] Step S55: Execute the business program using the first and second sub-root file systems under the root directory. This is the same as step S33 above.

[0116] In the technical solution provided in this application embodiment, the embedded device can also mount a second sub-root file system under the temporary root directory, associate the second sub-root file system stored in non-volatile memory with the Linux directory, so as to access the 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 subdirectory where the first sub-root file system is located and the third subdirectory where the second sub-root file system is located to obtain the root directory.

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

[0118] In this embodiment of the application, when files are stored in a non-volatile memory partition, the embedded device can create a subdirectory (e.g., " / mnt / flash", referred to as the fifth subdirectory) under the temporary root directory, and create a first subdirectory (e.g., " / mnt / flash / flash1") and a third subdirectory (e.g., " / 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 of the non-volatile memory to the first subdirectory and the second partition to the third subdirectory.

[0119] In this embodiment, the embedded device can 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 according to the number of partitions included in the non-volatile memory, and mounts each partition to the corresponding subdirectory.

[0120] In step S54 above, the embedded device can create a subdirectory under the temporary root directory, which is the fourth subdirectory (e.g., " / rootfs"). The embedded device can use the second subdirectory (e.g., " / rootfs.bin") as the parent directory and the third subdirectory (e.g., " / mnt / flash / flash2") as the child directory. Based on the directory names of the files contained in the second and third subdirectories, the second and third subdirectories are merged into the fourth subdirectory.

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

[0122] Embedded devices can switch the root directory from a temporary root directory to a fourth subdirectory. In this embodiment, after switching the root directory, the embedded device can also mount other files besides the root file system included in the non-volatile memory to the root directory, that is, mount them to the fourth subdirectory. The embedded device can then use the files in the root directory to perform subsequent steps, such as executing business programs.

[0123] In some embodiments, to ensure the integrity and correctness of the data stored in the non-volatile memory, and to ensure the normal execution of the operating system and business programs, the business program execution method may further include the following steps before executing step S31: verifying the first sub-root file system and the second sub-root file system; after the verification is passed, loading a preset file from the non-volatile memory into the volatile memory, the preset file including the operating system, a toolset program, and a script file; using the operating system to start the toolset program; and using the toolset program to run the script file to execute step S31.

[0124] In this embodiment, the operating system is a Linux operating system. The toolset is a lightweight toolset integrating 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 (such as a Linux.elf file) pre-packaged with the operating system, toolset, and script file.

[0125] After the embedded device boots up, it can first run a boot program to verify the files included in the root file system stored in non-volatile memory. Specifically, it verifies the CRC value of the first child root file system and the cyclic redundancy check (CRC) value of the second child root file system. The embedded device can also verify other files stored in non-volatile memory; there are no restrictions on this.

[0126] If the CRC check passes, the embedded device can run the BOOT program, load the preset file into volatile memory, and boot the operating system. The operating system then boots the toolset. After the toolset starts, the embedded device can use it to run script files, executing steps S31-S32 (or S41-S44, S51-S54) to obtain a root directory including a first and second sub-root file system. Then, it executes step S33 (or S45, S55) to run business programs using the first and second sub-root file systems. See the above for details. Figures 3-5 Related descriptions for some parts.

[0127] The following is combined Figures 6-7 The business program execution method provided in the embodiments of this application will be described in detail.

[0128] In this embodiment, before the embedded device boots, the root file system (including readable / writable system files, read-only system files, readable / writable application files, and read-only application files) is divided into two sub-root file systems. Sub-root file system 1 (i.e., the first sub-root file system) is loaded into memory (i.e., volatile memory) and may include readable / writable files and frequently loaded read-only files; sub-root file system 2 (i.e., the second sub-root file system) is mounted in memory and may include other read-only files, such as various application files, shared software libraries, read-only data files, etc. The directories containing the files in these two sub-root file systems 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] Subroot file system 2 can be compressed and packaged into a read-only file using the SquashFS tool, named ROOTFS.SquashFS. Subroot file system 1 can be compressed and packaged into a file using tools other than SquashFS, named ROOTFS.bin.

[0130] 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 two; there is no limit to the number of partitions here. 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, such as... Figure 1 As shown, the sizes of partition 1, partition 2, the ROOTFS.SquashFS file, and the ROOTFS.bin file can all be adjusted to achieve the appropriate placement and packaging method.

[0131] The operating system, Busybox program, and custom scripts for embedded devices can be packaged into an .elf file, named Linux.elf, and stored as a regular file in another partition (such as partition n) of non-volatile memory. Partition n can also include other configuration files, data files, etc., that only need to be mounted in memory and can be loaded into memory and executed by the boot program.

[0132] In this embodiment, during each startup phase, the embedded device runs the BOOT program to verify the CRC values ​​of the ROOTFS.bin and ROOTFS.SquashFS files, performing verification and repair on the root file system to ensure data integrity and correctness. After successful verification, the Linux.elf file is loaded into memory, booting the Linux operating system. The operating system then boots the busybox program, which runs a self-developed script file to create a temporary root directory. All partitions in the non-volatile memory are mounted to subdirectories of this temporary root directory (such as / mnt / flash). For example, the ROOTFS.bin file is mounted to / mnt / flash / flash1, the ROOTFS.SquashFS file to / mnt / flash / flash2, and ordinary files to / mnt / flash / flash.

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

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

[0135] like Figure 7As shown, the ROOTFS.SquashFS file stored in non-volatile memory includes directories such as / bin, / sbin, / lib, and / lib64, while the ROOTFS.bin file loaded into memory includes directories such as / bin, / sbin, / lib, / lib64, / tmp, and / var. Embedded devices can execute the following commands: `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-level directory and / rootfs.bin as the upper-level directory. It uses / rootfs as the merge directory to merge the ROOTFS.SquashFS file and the ROOTFS.bin file. In other words, it merges the sub-root file system 1 and the sub-root file system 2 to obtain the complete root file system under the / rootfs directory, including the files in the / bin, / sbin, / lib, / lib64, / tmp, and / var directories.

[0137] The embedded device switches the root directory from the temporary root directory to / rootfs. The CPU runs the complete root file system under / rootfs for use by the system and application processes. Subsequently, when the embedded device starts the application program, it loads the files required by the application program from non-volatile memory into memory. This process is imperceptible to the application process. The startup speed of the application program will be slightly slower, but the running speed of the application program remains unchanged and the performance will not be degraded.

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

[0139] In this way, under the same business specifications, using non-volatile memory to replace and save on RAM reduces the memory specifications required by embedded devices, thereby reducing the specifications and cost of volatile memory hardware and ultimately lowering the cost of embedded devices. Furthermore, without changing the embedded device hardware, using non-volatile memory to replace and save on RAM reduces the space occupied by the root file system, increasing the available memory for business programs and thus increasing the business specification capacity of the embedded device.

[0140] By applying the technical solution provided in this application embodiment, since the application files and shared software libraries of the business program are all loaded into memory before execution, the process of running the business program on the embedded device still runs in memory. Therefore, the running speed of the business program remains unchanged, and the business performance remains essentially unchanged. Furthermore, loading readable and writable files into memory ensures that the lifespan of the embedded device meets product requirements. For read-only files on non-volatile memory, since the read cycle lifespan of non-volatile memory is much longer than the write cycle lifespan, it does not affect the overall lifespan of the embedded device.

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

[0142] Loading module 81 is used to load the first sub-root file system into volatile memory after the embedded device starts up;

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

[0144] Execution module 83 is used to execute business programs using the first and second sub-root file systems under the root directory.

[0145] In the technical solution provided in this application, the root file system is divided into a first sub-root file system and a second sub-root file system, both stored in non-volatile memory. After the embedded device boots up, only the first sub-root file system is loaded into volatile memory, while the second sub-root file system remains stored in non-volatile memory. Then, the first and second sub-root file systems are superimposed to obtain a complete root file system and root directory. The complete root file system under the root directory is then used to execute business programs. By applying the technical solution provided in this application, some files included in the root file system are retained in non-volatile memory; that is, non-volatile memory is used instead of volatile memory, saving volatile memory space, reducing the required capacity of volatile memory on the embedded device, and thus reducing the cost of 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 volatile memory; mount a first sub-root file system to a first sub-directory under the temporary root directory; and load the first sub-root file system under the first sub-directory to a second sub-directory under the temporary root directory.

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

[0148] The overlay module 82 can be used to overlay the second and third subdirectories to obtain a fourth subdirectory under the temporary root directory; and the fourth subdirectory is determined as the root directory.

[0149] In some embodiments, the apparatus may further include: 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, load a preset file from the non-volatile memory into the volatile memory, the preset file including an operating system, a toolset program, and a script file; start the toolset program using the operating system; and run the script file using the toolset program.

[0150] In some embodiments, the execution module 83 may be specifically used to execute a first business program using a first file included in a first sub-root file system under the root directory; and / or to load a second file included in a second sub-root file system under the root directory into volatile memory; to execute a second business program using the second file; and / or to load a third file included in a second sub-root file system under the root directory into volatile memory; and to 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 with a usage frequency greater than or equal to a preset frequency; the second sub-root file system may include a second read-only file with 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] This application also provides an embedded device, such as... Figure 9 As shown, it includes a processor 91 and a machine-readable storage medium 92, the machine-readable storage medium 92 storing machine-executable instructions that can be executed by the processor 91, the processor 91 being prompted by the machine-executable instructions to implement any of the above-described business program execution methods applied to an embedded device.

[0153] Machine-readable storage media 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 remotely 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, or discrete hardware components.

[0155] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements any of the above-described business program execution methods applied to an embedded device.

[0156] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the business program execution methods applied to an embedded device in the above embodiments.

[0157] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially 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, all or part of the processes or functions described in the embodiments of this application are generated. 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. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. 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 integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).

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

[0159] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of apparatus, embedded devices, storage media, and program products are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

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

Claims

1. A method for executing a business program, characterized in that, The method, applicable to embedded devices, includes non-volatile memory and volatile memory, wherein the non-volatile memory stores a first sub-root file system and a second sub-root file system, and comprises: After the embedded device starts up, the first sub-root file system and the second sub-root file system are verified. After the verification is passed, the preset files in the non-volatile memory are loaded into the volatile memory. The preset files include the operating system, toolset programs, and script files. Using the operating system, start the toolset program; The script file is run using the toolset to load the first sub-root file system into the volatile memory; The root directory is obtained by overlaying the first sub-root file system and the second sub-root file system; Using the first files included in the first sub-root file system under the root directory, execute the first business program; and / or, Load the second files included in the second sub-root file system under the root directory into the volatile memory; execute the second business program using the second files; and / or, Load the third file included in the second sub-root file system under the root directory into the volatile memory; use the third file and the fourth file included in the first sub-root file system under the root directory to execute the third business program.

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: 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; Load the first sub-root file system under the first subdirectory into the second subdirectory under the temporary root directory.

3. The method according to claim 2, characterized in that, The method further includes: Mount the second sub-root file system to the third subdirectory under the temporary root directory; The step of overlaying the first sub-root file system and the second sub-root file system to obtain the root directory includes: The second subdirectory and the third subdirectory are combined to obtain the fourth subdirectory under the temporary root directory; The fourth subdirectory is designated as the root directory.

4. The method according to any one of claims 1-3, characterized in that, The first sub-root file system includes readable and writable files and a first read-only file with a usage frequency greater than or equal to a preset frequency; 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, with the first sub-root file system stored in the first partition and the second sub-root file system stored in the second partition.

5. A business program execution device, characterized in that, An embedded device is used, the embedded device including non-volatile memory and volatile memory, the non-volatile memory storing a first sub-root file system and a second sub-root file system, the device comprising: The startup module is used to verify the first sub-root file system and the second sub-root file system after the embedded device starts up; after the verification is successful, load the preset files in the non-volatile memory into the volatile memory, the preset files including the operating system, toolset program, and script file; start the toolset program using the operating system; and run the script file using the toolset program. A loading module is used to load the first sub-root file system into the volatile memory; The overlay module is used to overlay the first sub-root file system and the second sub-root file system to obtain the root directory; An execution module is configured 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; 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; 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.

6. The apparatus according to claim 5, characterized in that, The loading module is specifically used to create a temporary root directory in the volatile memory; mount the first sub-root file system to the first sub-directory under the temporary root directory; and load the first sub-root file system under the first sub-directory to the second sub-directory under the temporary root directory.

7. The apparatus according to claim 6, characterized in that, The device further includes: a mounting module, used to mount the second sub-root file system to a third subdirectory under the temporary root directory; The overlay module is specifically used to overlay the second subdirectory and the third subdirectory to obtain a fourth subdirectory under the temporary root directory; and to determine the fourth subdirectory as the root directory.

8. The apparatus according to any one of claims 5-7, characterized in that, The first sub-root file system includes readable and writable files and a first read-only file with a usage frequency greater than or equal to a preset frequency; 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, with the first sub-root file system stored in the first partition and the second sub-root file system stored in the second partition.

9. An embedded device, characterized in that, The method includes a processor and a machine-readable storage medium storing machine-executable instructions that can be executed by the processor, the processor being prompted by the machine-executable instructions to perform the method of any one of claims 1-4.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method described in any one of claims 1-4.