File system protection method and apparatus for internet of things device

By loading a read-only file system on the Linux kernel of an IoT device, detecting the battery power and mounting a read-write file system when external power is powered or the power is sufficient, the automatic restart and booting of IoT devices when the battery power is low is solved, protecting the file system and reducing production costs.

WO2025167211A1PCT designated stage Publication Date: 2025-08-14GUANGZHOU ROBUSTEL CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/128065
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-02-05
Filing Date
2024-10-29
Publication Date
2025-08-14

AI Technical Summary

Technical Problem

The prior art When the battery capacity of IoT devices is low, hardware circuit design is needed to achieve automatic shutdown and power-on, resulting in increased production costs and file systems are prone to damage due to sudden power outages.

Method used

By loading a read-only file system on the Linux kernel, detecting the battery power and mounting the read-write file system when the external power is powered or the battery power is sufficient, restarting the device to protect the file system and achieving automatic shutdown and power-on functions.

Benefits of technology

At the software level, the automatic restart and power-on function of IoT devices when the battery power is low is realized, avoiding file system corruption and reducing production costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024128065_14082025_PF_FP_ABST
    Figure CN2024128065_14082025_PF_FP_ABST
Patent Text Reader

Abstract

A file system protection method for an Internet of Things device, relating to the field of Internet of Things devices, and comprising the following steps: step 1: starting a Linux kernel, and loading a read-only file system; step 2: the read-only file system detecting the power supply mode and battery power level of the device, and when it is determined that the power supply mode is external power supply or the battery power level is greater than a first preset value, mounting a read / write file system; and step 3: when the read / write file system runs, detecting the power supply mode and battery power level of the device, when it is determined that the power supply mode is battery-based power supply and the battery power level is less than a second preset value, restarting the device, and performing step 1. In addition, also disclosed is a file system protection apparatus for an Internet of Things device. According to the present method, when the battery power level of an Internet of Things device is low, a file system is protected by modifying only software, without requiring extra design for a hardware circuit, so that the cost is low.
Need to check novelty before this filing date? Find Prior Art

Description

A file system protection method and device for an Internet of Things device

[0001] This application claims priority to a Chinese patent application filed with the Patent Office of China on February 5, 2024, with application number 202410163098.6 and invention name “A method and device for protecting a file system of an Internet of Things device”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of Internet of Things devices, and in particular to a file system protection method and device for Internet of Things devices. Background Art

[0003] During the operation of IoT devices or embedded devices, data is saved to storage media with file system support. Due to the characteristics of the file system, when the device suddenly loses power, the file system will be damaged with probability, resulting in device data loss. It may even become impossible to mount due to the damaged file system, requiring the file system to be reformatted.

[0004] When a laptop detects a low battery, it enters sleep mode, saving the running data to disk. However, this approach is not suitable for embedded devices, which are generally equipped with a watchdog timer to ensure that the device can be restarted and restored in the event of an abnormality. If the device enters sleep mode, the watchdog feeding service will not be able to run, causing the watchdog timer to time out and the device to restart.

[0005] In addition, the phone automatically shuts down when it detects low battery and automatically powers on when a power adapter is plugged in. This approach requires additional circuit design, increasing production costs and burdening the company.

[0006] CN103905645B discloses a mobile terminal and a shutdown method thereof, which determines whether one of the voltage and charge level of the mobile terminal's battery meets a first preset condition; when either the voltage or charge level meets the first preset condition, determines whether the current consumption of the mobile terminal meets a second preset condition; when the voltage meets the first preset condition and the current consumption of the mobile terminal meets the second preset condition, performs a shutdown operation; or when the charge level meets the first preset condition and the current consumption of the mobile terminal does not meet the second preset condition, performs a shutdown operation; the first preset condition includes: the voltage is less than a first preset value, or the charge level is less than a second preset value; the second preset condition includes: the current consumption of the mobile terminal is less than a third preset value. This method solves the problem of inappropriate shutdown due to misjudgment. However, after shutting down the device by detecting the voltage and charge level using this method, it cannot automatically restart when powered by external power, requiring manual restart by the operator. If the device is to automatically shut down when the battery is low and automatically restart when a power adapter is plugged in, additional circuitry is required, increasing enterprise costs.

[0007] The technical problem that this application needs to solve is: how to protect the file system of IoT devices when the battery is low, only by modifying the software, without the need for additional hardware circuit design.

[0008] Summary of the Invention

[0009] The main purpose of this application is to provide a file system protection method for an Internet of Things device, which mounts a read-write system through a read-only system, detects the power after starting the read-only system, confirms that the read-write system has sufficient power to operate, detects the power when the read-write system is running, restarts the device when the power is insufficient, and restarts the device to the read-only system when the power is sufficient or external power is supplied. The read-write system is mounted again, thereby realizing the function of automatically restarting the device when the power is insufficient and entering the read-only system again, and automatically starting up when the power is sufficient or external power is supplied, thereby protecting the file system.

[0010] To achieve the above objectives, the technical solutions adopted in this application are:

[0011] A file system protection method for an Internet of Things device comprises the following steps:

[0012] Step 1: Start the Linux kernel and load the read-only file system;

[0013] Step 2: The read-only file system detects the device power supply mode and battery power level, and mounts the read-write file system when it is determined that the device is powered by external power or when the battery power level is greater than a first preset value;

[0014] Step 3: After the read-write file system is running, the device power supply mode and battery power are detected. When it is determined that the device is powered by battery and the battery power is less than a second preset value, the device is restarted and step 1 is performed.

[0015] Preferably, the read-only file system is used to perform basic functions and detect the power supply mode and battery power of the device.

[0016] Preferably, the first preset value is 2% to 4%; the second preset value is 1% to 3%; and the first preset value is greater than the second preset value.

[0017] Preferably, the read-write file system contains user data and application programs.

[0018] Preferably, step 2 is specifically as follows: the read-only file system detects the power supply mode and battery power, and when it is determined that it is powered by external power or when the battery power is greater than a first preset value, the read-write file system is mounted; when the battery power is less than the first preset value, it goes into hibernation and continues to detect the power supply mode and battery power.

[0019] Preferably, the sleep time is shorter than the watchdog time.

[0020] Preferably, step 3 is specifically as follows: reading and writing the file system to run the application layer program, and detecting the power supply mode and battery power. When it is determined to be battery-powered and the battery power is less than a second preset value, restart the device and perform step 1; when it is determined to be externally powered or when the battery power is greater than the second preset value, operate the device normally.

[0021] Preferably, step 1 is specifically as follows: the device is powered on, the CPU loads the bootloader from the storage medium into the memory and starts the bootloader; after the bootloader starts, the Linux kernel is loaded from the storage medium, the Linux kernel is started, and the read-only file system is loaded.

[0022] Bootloader: The bootloader is the first code executed by the embedded system after power-on. After it completes the initialization of the CPU and related hardware, it loads the operating system image or solidified embedded application into the memory and then jumps to the space where the operating system is located to start the operating system.

[0023] Linux: is an open source operating system.

[0024] At the same time, a file system protection device for an Internet of Things device for implementing any of the above methods is also provided, characterized in that it includes:

[0025] Boot unit: used to boot the Linux kernel;

[0026] Read-only file system loading unit: used to load the read-only file system after the boot unit starts the Linux kernel;

[0027] Read-only file system: used to detect the device power supply mode and battery level, and decide whether to mount the read-write file system based on the device power supply mode and battery level;

[0028] System restart unit: used to detect the power supply mode and battery power of the device after the read and write file system is running, and restart the device when it is determined to be battery-powered and the battery power is less than a second preset value.

[0029] Preferably, the read-only file system includes the following modules:

[0030] Power supply detection module: used to detect the power supply mode and battery power of the device;

[0031] Read-write file system mounting module: used to mount the read-write file system or put the device into intermittent hibernation according to the detection results of the power supply detection module.

[0032] Compared with the existing technology, this solution has the following beneficial effects:

[0033] This file system protection method loads a small read-only file system on the Linux kernel, then mounts a read-write file system on top of the read-only file system. Furthermore, power supply mode and battery level detection are added to both the read-only and read-write file systems. When the battery level is low, the read-write file system drives the device to reboot. After the reboot, the device loads only the read-only file system and enters sleep mode. Only when external power is applied and the battery level is sufficient does the read-write file system mount. This allows the software to automatically shut down the device when the battery level is low and then automatically restart it when external power is applied or the battery level is restored to a predetermined value.

[0034] Secondly, by first checking the battery level using a read-only file system, the system can prevent damage to the read-write file system caused by a sudden shutdown when the battery is low. Furthermore, the read-only file system consumes less power, and using it instead of additional circuitry to achieve these functions can reduce production costs and alleviate the burden on enterprises. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] FIG1 is a flow chart of a file system protection method for an Internet of Things device according to Example 1;

[0036] FIG2 is a block diagram of a file system protection device for an Internet of Things device according to Example 2. DETAILED DESCRIPTION

[0037] To make the objectives, technical solutions, and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Generally, the components of the present application described and shown in the drawings herein can be arranged and designed in various different configurations.

[0038] Example 1

[0039] Referring to FIG1 , a file system protection method for an IoT device includes the following steps:

[0040] Step 1: The device is powered on, and the CPU loads the bootloader from the storage medium into the memory and starts the bootloader. After the bootloader starts, it loads the Linux kernel from the storage medium and starts the Linux kernel.

[0041] In this embodiment, the device used for the Internet of Things generally uses the Linux operating system. To load the Linux operating system, it is necessary to start the bootloader first, and the bootloader drives the Linux kernel before performing the next step.

[0042] After the Linux kernel boots, it loads a read-only file system, which is used to perform basic functions and detect the device's power supply mode and battery level. These basic functions include loading the basic root file system into memory and executing the init program for subsequent system initialization.

[0043] In this embodiment, the Linux kernel first loads a small read-only file system, primarily serving as a relay station to determine whether the battery level is sufficient for normal device operation. The read-only file system consumes little power. When the battery is low, the device is prevented from operating. Once the battery level is sufficient, the read-write file system is automatically mounted, achieving automatic boot-up at the software level. While the read-only file system is running, the device does not actually begin normal operation.

[0044] Step 2: The read-only file system detects the power supply mode and battery level. If it is determined to be powered by external power or the battery level is greater than a first preset value, the read-write file system is mounted. If the battery level is less than the first preset value, the system goes into hibernation and continues to detect the power supply mode and battery level. The hibernation time is less than the watchdog timer, which is 3%.

[0045] In this embodiment, the power supply modes include external power supply and battery power. External power supply includes external power supply modes such as direct connection to the mains, a mobile power supply, or battery charging using a power adapter. The read-only file system specifically operates as follows: the read-only file system primarily detects the power supply mode and battery level. When the read-only file system detects external power supply, it directly loads the read-write file system. When battery power is used, if the battery level is greater than a first preset value, the read-write file system is mounted. If the battery level is less than the first preset value, the read-only file system enters a dormant state and continues to detect the power supply mode and battery level until external power is used or the battery level is greater than the first preset value, at which point the read-write file system is mounted. However, the dormant state of the read-only file system must be less than the watchdog timer to prevent the device from restarting due to a watchdog timeout, which could cause the device to enter a power-on-restart cycle.

[0046] It should be noted that when the watchdog feeding time is reached, the read-only file system needs to wake up the read-only file system and feed the watchdog to prevent the watchdog from timing out and causing the device to restart.

[0047] The purpose of setting up a read-only file system is: First, when starting the device, the battery level of the device is initially checked to prevent the device from accidentally losing power due to a dead battery within a short period of time after operation, which would damage the read-write file system. Second, after the device is operating normally, if the read-write file system detects that the battery level is low and restarts, the device remains in the read-only file system without directly loading the read-write file system. The read-only file system is dormant until external power is supplied or the battery level exceeds a first preset value, and then the read-write file system is mounted, allowing the device to operate normally. Furthermore, at the software level, when the battery level is low, the device automatically stops operating until external power is supplied or the battery level exceeds a first preset value, and then the device automatically operates normally. The normal operation of the device refers to the normal operation of the read-write file system application layer program; the stopped operation of the device refers to the device only starting to the read-only file system stage and not loading the read-write file system. In this way, the device can automatically determine whether it is operating without adding additional circuit design, protecting the read-write file system, reducing production costs, and alleviating the burden on the enterprise.

[0048] Step 3: After the read-write file system is running, the power supply mode and battery level are detected. If it is determined that the device is powered by battery and the battery level is less than a second preset value, the device is restarted; if it is determined that the device is powered by external power or the battery level is greater than a second preset value, the device is operated normally. The second preset value is 2%.

[0049] Preferably, the read-write file system includes user data and applications. The staff sets up or operates the device in the read-write file system.

[0050] In this embodiment, the read-write file system also detects the power supply mode and battery level during normal operation. When battery power is used and the battery level is less than a second preset value, the files in the read-write file system that need to be saved are saved. After saving, the reboot command is executed to restart the device. This configuration has the advantage that when the battery level is low, the device can enter a short hibernation state in the read-only file system while waiting for external power or battery charging.

[0051] The advantages of this application are:

[0052] 1. By determining the power level and charging mode in step 3, this application can pre-save the files that need to be saved in the read-write file system before restarting, avoiding the loss of written files caused by sudden power outages, thereby protecting data security and avoiding the problem of being unable to restart or system instability after restart due to the loss of written files in the system;

[0053] 2. This application combines steps 2 and 3 to mount a read-only file system. When power is detected or the battery level exceeds a set level, the read-write file system is automatically mounted. At the software level, this acts like the dedicated startup circuit in traditional solutions that automatically powers on when power is connected.

[0054] In simpler terms, this application combines steps 2 and 3 to restart the device from a low power state and enter a read-only system, waiting for external power and restarting the device when conditions are right. From a user's perspective, this achieves an automatic startup function.

[0055] Example 2

[0056] A file system protection device for an Internet of Things device, comprising:

[0057] Boot unit: used to boot the Linux kernel;

[0058] Read-only file system loading unit: used to load the read-only file system after the boot unit starts the Linux kernel;

[0059] Read-only file system: used to detect the device power supply mode and battery level, and decide whether to mount the read-write file system based on the device power supply mode and battery level;

[0060] System restart unit: used to detect the power supply mode and battery power of the device after the read and write file system is running, and restart the device when it is determined to be battery-powered and the battery power is less than a second preset value.

[0061] Potentially, IoT devices must contain a CPU and storage media, which pre-store the bootloader, files related to the read-only file system, and files related to the read-write file system;

[0062] The operation process of the entire device is:

[0063] When the device is powered on, the CPU loads the bootloader from the storage medium into the memory and starts the bootloader. After the bootloader starts, the startup unit loads the Linux kernel from the storage medium and starts the Linux kernel. The read-only file system loading unit loads the read-only file system.

[0064] The read-only file system has pre-written code to detect the device's power mode and battery level. When the read-only file system is running, it will automatically read the device's power mode and battery level. This detection continues until the system is completely powered off, the device's battery is restored, or an external power source is connected, allowing the read-write file system to be mounted.

[0065] When the device is battery-powered and the battery level is less than a certain value, the read-only file system will not mount the read-write file system, and the device will preferably enter an intermittent sleep state. Preferably, a sleep rule code is also written into the read-write file system, that is, the sleep time is limited to less than the watchdog timer, so that the watchdog can continue to operate without restarting the device.

[0066] When the device is detected to be powered by an external power source or the battery power is restored to a certain value, the read-write file system is mounted;

[0067] After the read-write file system starts running, it means that all apps and other programs on the device can run normally;

[0068] During the reading and writing of the file system, the system restart unit will continuously detect the power supply mode and battery power of the device. When it is determined that the device is powered by battery and the battery power is less than the second preset value, the device will be restarted and the startup unit will start the Linux kernel.

[0069] The system restart unit of the present application may also exist as a part of a read-only file system, that is, the system restart unit may exist as both a part of a read-only file system and a part of a read-write file system;

[0070] If it exists as part of a read-only file system, it reuses the code program for detecting the device power supply mode and battery power in the read-only file system, and writes the judgment code of the second preset value and the related code for system restart;

[0071] If it exists as part of a read-write file system, a code program for detecting the device power supply mode and battery power level, a judgment code for the second preset value, and related code for system restart need to be written separately in the read-write file system.

[0072] The core of this case lies in the close cooperation between the system restart unit and the read-only file system, which can avoid the inability to save the read-write file system in time due to sudden power outages of the device; it can also restart into the read-only file system on the basis of timely saving the read-write files, and hibernate to save power. When the external power supply is connected, it automatically enters the loading of the read-write file system to realize the automatic power-on function.

[0073] Therefore, when the system restart unit is part of a read-only file system, this solution only requires relevant code optimization in the read-only file system. The improvement method is simple and effective.

[0074] Although the embodiments of the present application have been shown and described, those skilled in the art will appreciate that various changes, modifications, substitutions, and variations may be made to the embodiments without departing from the principles and intent of the present application, and that the scope of the present application is defined by the claims and their equivalents.

Claims

1. A file system protection method for an Internet of Things device, characterized in that: The following steps are involved: Step 1: Start the Linux kernel and load the read-only file system; Step 2: The read-only file system detects the device power supply mode and battery power level, and mounts the read-write file system when it is determined that the device is powered by external power or when the battery power level is greater than a first preset value; Step 3: After the read-write file system is running, the device power supply mode and battery power are detected. When it is determined that the device is powered by battery and the battery power is less than a second preset value, the device is restarted and step 1 is performed.

2. The file system protection method for an Internet of Things device according to claim 1, characterized in that: The read-only file system is used to perform basic functions and detect the device power supply mode and battery power.

3. The file system protection method for an Internet of Things device according to claim 1, characterized in that: The first preset value is 2% to 4%; the second preset value is 1% to 3%; and the first preset value is greater than the second preset value.

4. The file system protection method for an Internet of Things device according to claim 1, characterized in that: The read-write file system contains user data and application programs.

5. The file system protection method for an Internet of Things device according to claim 1, characterized in that: The step 2 is specifically as follows: the read-only file system detects the power supply mode and the battery power level, and when it is determined that the power supply is external or when the battery power level is greater than a first preset value, the read-write file system is mounted; when the battery power level is less than the first preset value, the system goes into hibernation and continues to detect the power supply mode and the battery power level.

6. The file system protection method for an Internet of Things device according to claim 5, characterized in that: The sleep time is shorter than the watchdog time.

7. The file system protection method for an Internet of Things device according to claim 1, characterized in that: The step 3 is specifically as follows: reading and writing the file system to run the application layer program, and detecting the power supply mode and battery power. When it is determined that the device is powered by battery and the battery power is less than a second preset value, the device is restarted and step 1 is performed; when it is determined that the device is powered by external power or when the battery power is greater than the second preset value, the device is operated normally.

8. The file system protection method for an Internet of Things device according to claim 1, characterized in that: The step 1 is specifically as follows: the device is powered on, the CPU loads the bootloader from the storage medium into the memory and starts the bootloader; after the bootloader starts, the Linux kernel is loaded from the storage medium, the Linux kernel is started, and the read-only file system is loaded.

9. A file system protection device for an Internet of Things device for implementing the method according to any one of claims 1 to 8, characterized in that: include: Boot unit: used to boot the Linux kernel; Read-only file system loading unit: used to load the read-only file system after the boot unit starts the Linux kernel; Read-only file system: used to detect the device power supply mode and battery level, and decide whether to mount the read-write file system based on the device power supply mode and battery level; System restart unit: used to detect the power supply mode and battery power of the device after the read and write file system is running, and restart the device when it is determined to be battery-powered and the battery power is less than a second preset value.

10. The file system protection device for an Internet of Things device according to claim 9, characterized in that: The read-only file system includes the following modules: Power supply detection module: used to detect the power supply mode and battery power of the device; Read-write file system mounting module: used to mount the read-write file system or put the device into intermittent hibernation according to the detection results of the power supply detection module.

Citation Information

Patent Citations

  • Intelligent terminal battery capacity reserving realization method and system

    CN105554316A

  • Power-down protection circuit for embedded system and method thereof

    CN112562764A

  • Embedded Linux system power failure protection method and device and computer equipment

    CN115878377A

  • Method and device for protecting file system of Internet of Things equipment

    CN117708886A

  • System,apparatus, and method for limiting non-volatile memory

    US20050071697A1