Data preset method, electronic device, and storage medium

By generating and burning backup partition image files and boot communication partition image files, data is directly pre-set to the backup partition, and then pre-set from the backup partition to the user data partition. This solves the problem of the system firmware becoming larger due to the pre-setting of encrypted user data partition data, and achieves a simplified data pre-setting process and the convenience of restoring factory settings.

CN118244980BActive Publication Date: 2026-06-05FUZHOU ROCKCHIP SEMICON

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
FUZHOU ROCKCHIP SEMICON
Filing Date
2024-03-11
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Existing technologies cannot prevent the system firmware from permanently increasing in size when pre-setting data in encrypted user data partitions, and existing methods suffer from problems such as increased system firmware size or complexity in data pre-setting.

Method used

By obtaining the backup partition image file and the boot communication partition image file, a backup partition is generated and burned to the device. Data is directly pre-set to the backup partition, and then data is pre-set from the backup partition to the user data partition, avoiding the need to embed the pre-set data into the system firmware.

Benefits of technology

It enables data pre-setting of encrypted user data partitions, avoids permanent increase in system firmware size, simplifies the data pre-setting process, and allows data to be re-installed using the pre-set data compressed package in the backup partition after a factory reset.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118244980B_ABST
    Figure CN118244980B_ABST
Patent Text Reader

Abstract

The present application relates to a data presetting method, an electronic device and a storage medium. The data presetting method comprises: obtaining a backup partition image file and a boot communication partition image file containing backup information, the backup partition image file and the boot communication partition image file being generated according to a preset data directory of a user data partition, a boot communication partition image and a preset data image configuration file; burning the backup partition image file and the boot communication partition image file to a backup partition of the device; and performing data presetting on the user data partition based on the backup partition image file and the boot communication partition image file in the backup partition. The present application directly presets data to the backup partition, and then presets data from the backup partition to the user data partition. Even in the case of encrypted user data partition, data presetting can be achieved, thereby achieving data presetting on the encrypted user data partition without causing the system firmware to permanently increase in size.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of embedded technology, and more particularly to data pre-setting methods, electronic devices, and storage media. Background Technology

[0002] Persistent memory storage devices such as eMMC (embedded multimedia cards) and solid-state drives (SSDs) are core components of electronic devices. These devices store firmware and user data, with the area storing user data called the user data partition (e.g., "data"). In certain scenarios, to protect the data in the user data partition (e.g., "data"), it is typically encrypted. Once the device encrypts the user data partition, a matching encryption / decryption system is required to access the data. To ensure data security, when an end user first uses the device, encryption services and systems usually require that the user data partition be a clean, recently erased and formatted partition before encryption. During system startup, the system maps the physical block device corresponding to the user data partition (e.g., / dev / block / by-name / data) to a virtual block device (e.g., / dev / block / dm-1) using the operating system kernel's device mapping mechanism (e.g., device mapper). When data is written to the virtual block device, each data block is first encrypted and then stored on the physical block device. Similarly, when reading data from a virtual block device, each piece of data is first decrypted, and then the decrypted data is returned.

[0003] When electronic devices leave the factory, the user data partition is typically erased and formatted with a file system so that end users can use a complete and clean user data partition. In other words, the user data partition does not have any user data pre-installed at the factory. However, some manufacturers want to pre-install certain data on the user data partition before the device leaves the factory (i.e., during the production process and before it is finally shipped to the end user) to meet the product definition they have made for the devices they have developed.

[0004] There are generally two types of existing data provisioning methods for user data partitioning.

[0005] The first type of method requires the user data partition to be unencrypted. This method boots the device into recovery mode during startup, where data is pre-configured. This allows the device to directly use the pre-configured data in the user data partition after it enters the normal system. Recovery mode typically cannot support complex encryption / decryption systems. This means that this method cannot pre-configure data in encrypted user data partitions. Encryption of the user data partition requires that it be a clean, recently erased and formatted partition before encryption, and cannot pre-store any user data. All user-created data must be automatically encrypted by the corresponding encryption system before being written to the encrypted user data partition.

[0006] While the second method supports encrypted user data partitions, it requires that the data to be pre-installed into the user data partition be first built into the system firmware (such as the Android system, vendor, or ODM firmware). Then, after the system boots normally and the corresponding encryption / decryption system functions correctly, the data to be pre-installed into the user data partition is copied from the system firmware to the user data partition, thus completing the data pre-installation. The biggest problem with this method is that it increases the size of the device's system firmware. Data to be pre-installed into the user data partition is typically quite large, leading to an unacceptably large system firmware size. This means that a full FOTA upgrade will result in a larger FOTA upgrade package. A larger FOTA upgrade package means that more time and space resources are required for upgrade package generation, storage, transmission, and the actual upgrade. Furthermore, the data to be pre-installed into the user data partition is usually ordinary data, not inherently part of the system firmware. Mixing ordinary pre-installed data with the system firmware is clearly a poor design from a software engineering perspective.

[0007] Therefore, how to pre-configure data for encrypted user data partitions without embedding the pre-configured data into the system firmware, thus permanently increasing the size of the system firmware, has become one of the problems that need to be solved. Summary of the Invention

[0008] This invention provides a data pre-setting method, electronic device, and storage medium that enable data pre-setting of encrypted user data partitions without causing the system firmware to permanently increase in size.

[0009] In one aspect of the present invention, a data pre-configuration method is provided. The method includes: acquiring a backup partition image file and a boot communication partition image file containing backup information, wherein the backup partition image file and the boot communication partition image file are generated based on a pre-configured data directory, a boot communication partition image, and a pre-configured data image configuration file to be pre-configured into a user data partition as needed; burning the backup partition image file and the boot communication partition image file to a backup partition of a device; and pre-configuring data in the user data partition based on the backup partition image file and the boot communication partition image file in the backup partition.

[0010] In another aspect of the invention, an electronic device is provided. The electronic device includes a memory configured to store an executable program; and a processor configured to execute the program to perform the data presetting method described above.

[0011] In another aspect of the invention, a computer-readable medium is provided. This medium stores a computer program that is executed by a processor to implement the data presetting method described above.

[0012] According to the present invention, a backup partition image file and a boot communication partition image file containing backup information are obtained. These two files are generated based on a preset data directory, a boot communication partition image, and a preset data image configuration file that need to be pre-configured into the user data partition. The backup partition image file and the boot communication partition image file are then burned to the device's backup partition. Data is pre-configured into the user data partition based on these two files. This invention directly pre-configures data into the backup partition and then from the backup partition into the user data partition. Even in scenarios where the user data partition is encrypted, data pre-configuration can still be achieved, thus enabling data pre-configuration of encrypted user data partitions without permanently increasing the size of the system firmware. Attached Figure Description

[0013] Figure 1 This is a flowchart of the data presetting method according to an embodiment of the present invention;

[0014] Figure 2 This is a flowchart illustrating a data pre-setting method according to an embodiment of the present invention;

[0015] Figure 3 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0016] To explain in detail the technical content, objectives, and effects of the present invention, the following description is provided in conjunction with the embodiments and accompanying drawings.

[0017] In existing technologies, one approach is to guide the device into recovery mode during the device startup process and complete the data pre-setting in recovery mode. However, this approach cannot pre-set data for encrypted user data partitions. Another approach is to first embed the data that needs to be pre-set to the user data partition into the system firmware. Then, after the system starts up normally and the corresponding encryption and decryption system works properly, the data that needs to be pre-set to the user data partition is copied from the system firmware to the user data partition. However, this results in the system firmware becoming unacceptably large.

[0018] To address at least the aforementioned technical problems, this disclosure provides a data pre-configuration method. According to embodiments of this disclosure, a backup partition image file and a boot communication partition image file containing backup information are obtained. These two images are generated based on a pre-configured data directory, a boot communication partition image, and a pre-configured data image configuration file to be pre-configured into the user data partition as needed. The backup partition image file and the boot communication partition image file are then burned to the device's backup partition. Data pre-configuration is performed on the user data partition based on these two images. In this way, data is directly pre-configured into the backup partition, and then from the backup partition to the user data partition. Even in scenarios where the user data partition is encrypted, data pre-configuration can still be achieved, thus enabling data pre-configuration of encrypted user data partitions without permanently increasing the size of the system firmware.

[0019] In the following, the technical solutions according to this disclosure will be described with reference to specific embodiments and in conjunction with the accompanying drawings.

[0020] Figure 1 This is a flowchart illustrating a data pre-setting method 100 according to an embodiment of the present disclosure. (Refer to...) Figure 1 The method 100 includes the following steps 102 to 106.

[0021] In step 102, a backup partition image file and a boot communication partition image file containing backup information are obtained. The backup partition image file and the boot communication partition image file are generated according to the preset data directory, boot communication partition image and preset data image configuration file that need to be preset to the user data partition.

[0022] In some embodiments, before step 102, the method 100 may further include: creating the backup partition image file and the boot communication partition image. In some embodiments, creating the backup partition image file and the boot communication partition image includes: generating a preset data image preset file based on the name, size, and file system type of the backup partition; generating a preset data directory according to a preset directory hierarchy; receiving the boot communication partition image; and generating the backup partition image file and the boot communication partition image file based on the preset data directory, the boot communication partition image, and the preset data image preset file. In this way, the preset data directory, the boot communication partition image, and the preset data image preset file include relevant information about the preset data and the backup partition, facilitating the subsequent generation of a backup partition image file for data pre-setting and a boot communication partition image file containing backup information.

[0023] In some embodiments, the preset data directory is compressed to obtain a preset data compressed package. If the size of the preset data compressed package is smaller than the size of the backup partition, an original backup partition image file is generated. The size of the original backup partition image file is smaller than the size of the backup partition but larger than the size of the preset data compressed package. The original backup partition image file is formatted according to the file system type of the backup partition to obtain a read-write file system backup partition image file containing the file system type. The read-write file system backup partition image file is mounted to a preset mount directory, and the preset data compressed package is copied to a preset path of the preset mount directory; the read-write file system backup partition image file is unmounted. The read-write file system backup partition image file containing the preset data compressed package is renamed according to the name of the backup partition to obtain a backup partition image file. A preset instruction for the encrypted data area of ​​the backup partition is written at a first preset position of the boot communication partition, and backup partition information is written at a second preset position of the boot communication partition to generate a boot communication partition image file containing backup information. In this way, a pre-configured data compressed package with a preset name is pre-configured into a read-write file system backup partition image file, so that the pre-configured data can be burned to the backup partition later.

[0024] In some embodiments, before writing the backup partition information to the second preset location of the boot communication partition, the method further includes: generating backup partition information based on the magic number of the backup partition information, the backup body digital digest algorithm type, the backup body digital digest ciphertext size, the backup body digital digest ciphertext, and the backup body. This approach allows for the pre-installation of preset data into the backup partition based on the generated backup partition information, eliminating the need to embed it into the system firmware and preventing the system firmware from becoming too large.

[0025] In step 104, the backup partition image file and the boot communication partition image file are burned to the backup partition of the device.

[0026] In step 106, data is preset in the user data partition based on the backup partition image file and the boot communication partition image file in the backup partition.

[0027] In some embodiments, backup partition information is read from the boot communication partition according to a preset instruction for the encrypted data area of ​​the backup partition located at a preset position in the boot communication partition. Based on the name of the backup partition in the backup body and the file system type of the backup partition in the backup partition information, the file system capacity of the backup partition is expanded to the actual size of the backup partition. The user data partition is erased and formatted, and the preset instruction for the encrypted data area of ​​the backup partition is cleared, and the device is restarted. The corresponding preset data in the backup partition is written to the mount directory representing the user data partition to complete the data preset of the user data partition. In some embodiments, the corresponding preset data compressed package in the backup partition is decompressed to the mount directory representing the user data partition, and the decompressed data is encrypted by a data encryption / decryption service to write the encrypted data to the user data partition to complete the data preset of the encrypted user data partition. In some embodiments, according to a factory reset instruction located at a preset position in the boot communication partition, the user data partition is erased and formatted, and the corresponding preset data compressed package in the backup partition is decompressed to the mount directory representing the user data partition to complete the data preset of the user data partition at the factory. In this way, data can be pre-configured for encrypted user data partitions without causing the system firmware to become permanently larger.

[0028] In some embodiments, upon startup, if a backup partition encrypted data area preset instruction or a factory reset instruction exists at the first preset location of the boot communication partition, the device is booted into recovery mode. In recovery mode, if the backup partition encrypted data area preset instruction exists at the first preset location of the boot communication partition, the backup partition information is read from the second preset location of the boot communication partition, and the file system capacity of the backup partition is expanded to the actual size of the backup partition based on the backup partition information. The user data partition is then re-erased and formatted, and the preset completion marker at the third preset location of the boot communication partition is cleared. The backup partition encrypted data area preset instruction at the first preset location of the boot communication partition is cleared, the encrypted data preset process and recovery mode are exited, and the device is restarted to perform data preset on the user data partition. If the factory reset instruction exists at the first preset location of the boot communication partition, a factory reset operation is performed. This factory reset operation re-erases and formats the user data partition, but does not re-erase and format the backup partition. The backup partition information is read from the second preset position in the boot communication partition, and the magic number of the backup partition information is checked to see if it matches the preset magic number. If they do not match, the factory reset instruction in the first preset position in the boot communication partition is cleared, and the factory reset process is exited. If they match, the preset completion mark in the third preset position in the boot communication partition is cleared, the factory reset instruction in the first preset position in the boot communication partition is cleared, the factory reset process is exited, and the device is restarted to preset data in the user data partition. In some embodiments, when performing the factory reset operation, the factory reset instruction is written to the first preset position in the boot communication partition, and then the device is restarted. In this way, the device determines whether to perform a factory reset or a data preset based on whether the first preset position in the boot communication partition contains a factory reset instruction or a backup partition encrypted data area preset instruction. When performing a factory reset, it is simple and convenient because the backup partition already contains a preset data compressed package, so after the factory reset, the preset data compressed package in the backup partition can be used to re-install data into the user data partition.

[0029] In some embodiments, during system startup, a preset data encryption / decryption service is used to ensure that the user data area is encrypted according to a preset encryption method. After encryption, the physical block device corresponding to the user data area is mapped to a virtual block device through the operating system kernel's device mapping mechanism, and the virtual block device is mounted to a preset mount directory representing the user data partition. An encrypted data pre-configuration service is used to detect whether the virtual block device has been mounted in the preset mount directory representing the user data partition. If mounting is complete, a data pre-configuration process is initiated to pre-configure the user data partition. In this way, data pre-configuration of the encrypted user data partition can be achieved without embedding the pre-configured data into the system firmware, avoiding additional time and space resource consumption during a full FOTA upgrade of the system firmware.

[0030] In some embodiments, the encrypted data pre-configuration service is used to check whether the pre-configuration completion marker exists at the third preset location in the boot communication partition. If it exists, the encrypted data pre-configuration service exits. If it does not exist, the service checks whether the virtual block device has been mounted in the preset mount directory representing the user data partition. If the mounting is not complete, the service waits for a preset time and then returns to using the encrypted data pre-configuration service to check whether the pre-configuration completion marker exists at the third preset location in the boot communication partition. If the mounting is complete, the backup partition information is read from the second preset location in the boot communication partition, and the magic number of the backup partition in the backup partition information is checked to see if it matches the preset magic number. If they do not match, the service exits. If they match, the digital digest of the backup body in the backup partition information is calculated according to the digital digest algorithm corresponding to the backup body digital digest algorithm type in the backup partition information, and the calculated backup body digital digest is encrypted using a preset symmetric encryption algorithm and key for the backup partition information to obtain the ciphertext of the backup body digital digest and its size. If the calculated ciphertext size of the backup body digital digest is the same as the ciphertext size of the backup body digital digest in the backup partition information, and the calculated ciphertext size of the backup body digital digest is the same as the ciphertext size of the backup body digital digest in the backup partition information, then the block device node corresponding to the backup partition is determined according to the name of the backup partition in the backup partition information, and it is checked whether the backup partition has been mounted. If it is not mounted, the backup partition is mounted, and according to the path of the preset data compressed package of the backup body in the backup partition information in the backup partition information, it is checked whether a corresponding preset data compressed package exists. If it does not exist, the encrypted data preset service is exited. If it exists, the digital digest of the preset data compressed package in the backup partition is calculated according to the digital digest algorithm corresponding to the digital digest algorithm type of the backup body in the backup partition information. If the calculated digital digest of the preset data compressed package is the same as the digital digest of the preset data compressed package in the backup partition information, the preset data compressed package in the backup partition is decompressed to the preset mount directory representing the user data partition, and the decompressed preset data is automatically encrypted and written to the actual user data partition through the preset data encryption and decryption service. A preset completion marker is written to the third preset location in the boot communication partition to complete the data preset of the user data partition and exit the encrypted data preset service. In this way, the reliability of data preset is ensured by checking the legality of the backup partition information.

[0031] In some embodiments, after step 108, the method 100 further includes: when using the service or application of the preset data in the user data area, checking whether there is a preset completion mark in the third preset position of the boot communication partition; if there is, continuing to use the service or application of the preset data in the user data area; if there is not, waiting for a preset time, and then returning to check whether there is a preset completion mark in the third preset position of the boot communication partition.

[0032] The following will describe, through examples, the application scenarios of the data presetting method and device according to embodiments of the present invention.

[0033] Figure 2 This is a flowchart illustrating a data pre-setting method according to an embodiment of the present invention. Figure 2 As shown, the method includes steps 201 to 208.

[0034] In step 201, a preset data directory, a boot communication partition image (such as misc.img), and a preset data image file are constructed, specifically including the following (1) to (3).

[0035] (1) Generate a preset data image file based on the name (e.g., backup), size and file system type of the backup partition.

[0036] The name of the backup partition corresponds to the name of the actual physical partition on the device. The actual physical partition used as the backup partition must be an unencrypted partition with a read-write file system.

[0037] (2) Generate a preset data directory according to the preset directory hierarchy, that is, organize all preset data into the preset data directory according to the preset directory hierarchy.

[0038] (3) Receive the boot communication partition image.

[0039] In step 202, a backup partition image file and a boot communication partition image file containing backup information are generated based on the preset data directory, the boot communication partition image, and the preset data image file, specifically including the following (1) to (9).

[0040] (1) Compress the preset data directory to obtain the preset data compressed package.

[0041] Specifically, the preset data directory is compressed according to a preset compression algorithm type and named with a preset name to obtain a preset data compressed package.

[0042] (2) If the size of the preset data compressed package is greater than or equal to the size of the backup partition, an error message will be displayed and the data preset process will be exited.

[0043] (3) If the size of the preset data compressed package is smaller than the size of the backup partition, an original backup partition image file (such as backup_raw.img) is generated. The size of the original backup partition image file is smaller than the size of the backup partition, but larger than the size of the preset data compressed package.

[0044] (4) Format the original backup partition image file according to the file system type of the backup partition to obtain a read-write file system backup partition image file containing the file system type (such as bakcup_fs.img).

[0045] (5) Mount the read-write file system backup partition image file to the preset mount directory and copy the preset data compressed package to the preset path of the preset mount directory.

[0046] (6) Unload the read-write file system backup partition image file, thereby pre-setting the pre-configured data compressed package into the read-write file system backup partition image file.

[0047] (7) Rename the read-write file system backup partition image file containing the pre-built data compressed package according to the name of the backup partition to obtain the backup partition image file (such as backup.img).

[0048] (8) Generate backup partition information based on the magic number of backup partition information, the algorithm type of backup body digital digest, the size of backup body digital digest ciphertext, backup body digital digest ciphertext, and backup body.

[0049] The backup body consists of the backup partition's name, file system type, path to the pre-built data archive within the backup partition, and a digital digest of the pre-built data archive. A digital digest of the pre-built data archive is calculated using the corresponding digital digest algorithm for the backup body's digital digest algorithm type, and this digital digest is saved to the backup body. A digital digest of the backup body itself is then calculated using the same algorithm, and the calculated digital digest is encrypted using a pre-defined symmetric encryption algorithm and key specific to the backup partition information, resulting in the ciphertext and size of the ciphertext.

[0050] (9) Write the backup partition encrypted data area preset instruction to the first preset position of the boot communication partition, and write the backup partition information to the second preset position of the boot communication partition to generate a boot communication partition image file (such as misc.img) containing backup information.

[0051] In step 203, the backup partition image file and the boot communication partition image file are burned to the backup partition of the device.

[0052] In step 204, the device is started. In the boot program (such as uboot), it is determined whether there is a backup partition encrypted data area preset instruction or a factory reset instruction in the first preset location of the boot communication partition. If yes, step 205 is executed. If no, the boot process continues to be executed, the device is booted into the system, and step 206 is executed.

[0053] In step 205, the device is booted into recovery mode (such as recovery), specifically including the following (1) to (4).

[0054] (1) Determine whether there is a backup partition encrypted data area preset instruction in the first preset position of the boot communication partition. If yes, execute (2) to (3). If no, execute (4).

[0055] (2) Read the backup partition information from the second preset location of the boot communication partition, and expand the file system capacity of the backup partition to the actual size of the backup partition according to the backup partition information, specifically including the following (2-1) to (2-4).

[0056] (2-1) Check if the magic number of the backup partition information is the preset magic number. If not, proceed to (2-2). If yes, proceed to (2-3) to (2-4).

[0057] (2-2) Clear the preset instructions of the backup partition encrypted data area in the first preset position of the boot communication partition, and exit the encrypted data preset process and recovery mode.

[0058] (2-3) Calculate the digital digest of the backup body in the backup partition information according to the digital digest algorithm corresponding to the backup body digital digest algorithm type in the backup partition information, and encrypt the calculated backup body digital digest using a preset symmetric encryption algorithm and key for the backup partition information to obtain the backup body digital digest ciphertext and the backup body digital digest ciphertext size.

[0059] (2-4) Compare the calculated backup digital digest ciphertext size with the backup digital digest ciphertext size in the backup partition information. If they are not the same, clear the preset instruction for the encrypted data area of ​​the backup partition in the first preset position of the boot communication partition, exit the encrypted data preset process and recovery mode. If they are the same, check whether the calculated backup digital digest ciphertext is exactly the same as the backup digital digest ciphertext in the backup partition information. If not, clear the preset instruction for the encrypted data area of ​​the backup partition in the first preset position of the boot communication partition, exit the encrypted data preset process and recovery mode. If they are the same, expand the file system capacity of the backup partition to the actual size of the backup partition according to the name of the backup partition and the file system type of the backup partition in the backup partition information.

[0060] (3) Re-erase and format the user data partition (e.g., data), clear the preset completion mark in the third preset position of the boot communication partition, clear the preset instruction of the backup partition encrypted data area in the first preset position of the boot communication partition, exit the encrypted data preset process and recovery mode, and restart the device.

[0061] (4) Determine whether there is a factory reset command in the first preset position of the boot communication partition. If not, exit the factory reset process. If yes, execute (4-1) to (4-2).

[0062] (4-1) Factory reset operation, which re-erases and formats the user data partition, but does not re-erase and format the backup partition.

[0063] (4-2) Read the backup partition information from the second preset position in the boot communication partition, check whether the magic number of the backup partition information in the backup partition information is consistent with the preset magic number. If they are inconsistent, clear the factory reset command in the first preset position in the boot communication partition and exit the factory reset process. If they are consistent, clear the preset completion mark in the third preset position in the boot communication partition, clear the factory reset command in the first preset position in the boot communication partition, exit the factory reset process, and restart the device.

[0064] When performing a factory reset operation, the factory reset command is written to the first preset location in the boot communication partition, and then the device is restarted.

[0065] In step 206, during system startup, a preset data encryption / decryption service is used to ensure that the user data area is encrypted according to a preset encryption method. After encryption, the physical block device corresponding to the user data area (e.g., / dev / block / by-name / data) is mapped to a virtual block device (e.g., / dev / block / dm-1) through the operating system kernel's device mapping mechanism (e.g., device mapper), and the virtual block device is mounted to a preset mount directory (e.g., data) representing the user data partition.

[0066] In step 207, the encrypted data pre-configuration service is used to detect whether the preset mount directory representing the user data partition has been mounted with the virtual block device. If it has been mounted, the data pre-configuration process is started to pre-configure the user data partition, specifically including the following (1) to (3).

[0067] (1) Use the encrypted data preset service to check whether there is a preset completion mark in the third preset position of the boot communication partition. If it exists, exit the encrypted data preset service. If it does not exist, execute (2).

[0068] (2) Check whether the virtual block device has been mounted in the preset mount directory representing the user data partition. If it has not been mounted, wait for a preset time and then return to execute (1). If it has been mounted, execute (3).

[0069] (3) Read the backup partition information from the second preset position in the boot communication partition, and check whether the backup partition magic number in the backup partition information is consistent with the preset magic number. If they are inconsistent, exit the encrypted data preset service. If they are consistent, execute (3-1) to (3-5).

[0070] (3-1) Calculate the digital digest of the backup body in the backup partition information according to the digital digest algorithm corresponding to the backup body digital digest algorithm type in the backup partition information, and encrypt the calculated backup body digital digest using a preset symmetric encryption algorithm and key for the backup partition information to obtain the backup body digital digest ciphertext and the backup body digital digest ciphertext size.

[0071] (3-2) If the calculated backup digital digest ciphertext size is the same as the backup digital digest ciphertext size in the backup partition information, and the calculated backup digital digest ciphertext is the same as the backup digital digest ciphertext in the backup partition information, then determine the block device node (e.g., / dev / block / by-name / backup) corresponding to the backup partition based on the backup partition name in the backup partition information, and check whether the backup partition has been mounted. If not mounted, mount the backup partition, and check whether the corresponding pre-configured data compressed package exists based on the path of the pre-configured data compressed package in the backup partition in the backup partition information. If it does not exist, exit the encrypted data pre-configuration service. If it exists, calculate the digital digest of the pre-configured data compressed package in the backup partition based on the digital digest algorithm corresponding to the backup digital digest algorithm type in the backup partition information.

[0072] (3-3) If the calculated digital digest of the preset data compressed package is the same as the digital digest of the preset data compressed package of the backup body in the backup partition information, the preset data compressed package in the backup partition is decompressed to the preset mount directory representing the user data partition, and the decompressed preset data is automatically encrypted by the preset data encryption and decryption service and written to the actual user data partition. A preset completion mark is written in the third preset position in the boot communication partition to complete the data preset of the user data partition and exit the encrypted data preset service.

[0073] (3-4) If the calculated digital digest of the pre-configured data compressed package is different from the digital digest of the pre-configured data compressed package of the backup body in the backup partition information, then exit the encrypted data pre-configuration service.

[0074] (3-5) If the calculated backup digital digest ciphertext size is different from the backup digital digest ciphertext size in the backup partition information, or if the calculated backup digital digest ciphertext is different from the backup digital digest ciphertext in the backup partition information, then exit the encrypted data preset service.

[0075] In step 208, when using the services or applications of the preset data in the user data area, check whether there is a preset completion mark in the third preset position of the boot communication partition. If there is, continue to use the services or applications of the preset data in the user data area. If there is no, wait for a preset time and then return to check whether there is a preset completion mark in the third preset position of the boot communication partition.

[0076] According to another aspect of the invention, Figure 3 This is a schematic diagram illustrating an electronic device 300 according to an embodiment of the present invention. (Refer to...) Figure 3 The electronic device 300 includes a memory 302 and a processor 304. The memory 302 is configured to store a computer program that can run on the processor 304. When the processor 304 executes the computer program, it implements the various steps of the data presetting method as described above.

[0077] According to another aspect of the present invention, a computer-readable medium is provided. The computer-readable medium stores a computer program that is executed by a processor to implement the data presetting method as described above.

[0078] In summary, the data pre-setting method, electronic device, and storage medium provided by this invention obtain a backup partition image file and a boot communication partition image file containing backup information. The backup partition image file and the boot communication partition image file are generated based on a pre-set data directory, boot communication partition image, and pre-set data image configuration file that need to be pre-set to the user data partition. The backup partition image file and the boot communication partition image file are burned to the device's backup partition. Data pre-setting is performed on the user data partition based on the backup partition image file and the boot communication partition image file in the backup partition; that is, data is directly pre-set to the backup partition, and then data is pre-set from the backup partition to the user data partition. Even in scenarios where the user data partition is encrypted, data pre-setting can still be achieved, thus enabling data pre-setting of encrypted user data partitions without permanently increasing the size of the system firmware. Furthermore, restoring factory settings is simple and convenient. Since the backup partition already contains a pre-set data compressed package, after restoring factory settings, the pre-set data compressed package in the backup partition can be used to re-install data into the user data partition.

[0079] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent modifications made based on the content of the present invention specification and drawings, or direct or indirect applications in related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A data pre-setting method, characterized in that, include: Obtain a backup partition image file and a boot communication partition image file. The backup partition image file and the boot communication partition image file are generated as needed by the preset data directory, boot communication partition image and preset data image configuration file that are preset to the user data partition. The boot communication partition image file is the boot communication partition image containing backup information. Burn the backup partition image file and the boot communication partition image file to the device's backup partition; Data presetting of the user data partition based on the backup partition image file and the boot communication partition image file in the backup partition includes: reading backup partition information from the boot communication partition according to the backup partition encrypted data area presetting instruction existing at a preset position in the boot communication partition; expanding the file system capacity of the backup partition to the actual size of the backup partition according to the name of the backup partition in the backup body in the backup partition information and the file system type of the backup partition; erasing and formatting the user data partition, clearing the backup partition encrypted data area presetting instruction, and restarting the device; Decompress the corresponding pre-set data compressed package in the backup partition to the mount directory representing the user data partition; and The decompressed data is encrypted by a data encryption / decryption service, and the encrypted data is written to the user data partition to complete the data pre-setting of the encrypted user data partition. The backup body consists of the name of the backup partition, the file system type of the backup partition, the path of the pre-set data compressed package in the backup partition, and the digital digest of the pre-set data compressed package.

2. The method according to claim 1, characterized in that, Presetting data in the user data partition based on the backup partition image file and the boot communication partition image file in the backup partition includes: Based on the factory reset command located at a preset position in the boot communication partition, erase and format the user data partition; and Extract the corresponding pre-configured data package from the backup partition to the mount directory representing the user data partition to complete the pre-configuration of the user data partition at the factory.

3. The method according to claim 1, characterized in that, Also includes: Creating the backup partition image file and the boot communication partition image includes: Generate a pre-configured data image configuration file based on the name, size, and file system type of the backup partition; Generate a preset data directory according to the preset directory hierarchy; Receive the boot communication partition image; and The backup partition image file and the boot communication partition image file are generated based on the preset data directory, the boot communication partition image, and the preset data image configuration file.

4. The method according to claim 3, characterized in that, Generating the backup partition image file and the boot communication partition image file based on the preset data directory, the boot communication partition image, and the preset data image configuration file includes: The preset data directory is compressed to obtain a preset data compressed package; If the size of the preset data compressed package is smaller than the size of the backup partition, an original backup partition image file is generated. The size of the original backup partition image file is smaller than the size of the backup partition, but larger than the size of the preset data compressed package. The original backup partition image file is formatted according to the file system type of the backup partition to obtain a readable and writable file system backup partition image file containing the file system type; Mount the read / write file system backup partition image file to a preset mount directory, and copy the preset data compressed package to a preset path of the preset mount directory; Unload the read-write file system backup partition image file; The read-write file system backup partition image file containing the preset data compressed package is renamed according to the name of the backup partition to obtain the backup partition image file; and Write the backup partition encrypted data area preset instruction at the first preset position of the boot communication partition, and write the backup partition information at the second preset position of the boot communication partition to generate a boot communication partition image file containing backup information.

5. The method according to claim 4, characterized in that, Before writing the backup partition information to the second preset location of the boot communication partition, the process also includes: Backup partition information is generated based on the magic number of the backup partition information, the algorithm type of the backup body digital digest, the size of the backup body digital digest ciphertext, the backup body digital digest ciphertext, and the backup body.

6. The method according to claim 4, characterized in that, Presetting data in the user data partition based on the backup partition image file and the boot communication partition image file in the backup partition includes: If the device is started and a backup partition encrypted data area preset instruction or a factory reset instruction exists in the first preset position of the boot communication partition, the device is then booted into recovery mode. In the recovery mode, if the backup partition encrypted data area preset instruction exists in the first preset position of the boot communication partition, the backup partition information is read from the second preset position of the boot communication partition, and the file system capacity of the backup partition is expanded to the actual size of the backup partition according to the backup partition information. The user data partition is re-erected and formatted, and the preset completion mark in the third preset position of the boot communication partition is cleared. The preset instruction of the backup partition encrypted data area in the first preset position of the boot communication partition is cleared. The encrypted data preset process and recovery mode are exited, and the device is restarted to preset the data of the user data partition. If the factory reset instruction exists in the first preset location of the boot communication partition, then the factory reset operation is performed. The factory reset operation re-erases and formats the user data partition, but does not re-erase and format the backup partition. Read the backup partition information from the second preset position in the boot communication partition, and check whether the magic number of the backup partition information in the backup partition information is consistent with the preset magic number; If inconsistent, the factory reset instruction at the first preset location in the boot communication partition is cleared, and the factory reset process is exited; and If they match, the preset completion mark in the third preset position of the boot communication partition is cleared, the factory reset instruction in the first preset position of the boot communication partition is cleared, the factory reset process is exited, and the device is restarted to preset the user data partition.

7. The method according to claim 6, characterized in that, Rebooting the device to pre-configure the user data partition includes: During system startup, a preset data encryption / decryption service is used to ensure that the user data partition is encrypted according to a preset encryption method. After encryption, the physical block device corresponding to the user data partition is mapped to a virtual block device through the device mapping mechanism of the operating system kernel, and the virtual block device is mounted to a preset mount directory representing the user data partition. The encrypted data provisioning service is used to detect whether the preset mount directory representing the user data partition has already mounted the virtual block device; and If mounting is complete, the data provisioning process will be initiated to provision the user data partitions.

8. The method according to claim 7, characterized in that, Initiating the data provisioning process to provision user data partitions includes: Use the encrypted data preset service to check whether the preset completion mark exists in the third preset position of the boot communication partition; If it exists, exit the encrypted data pre-configuration service; If it does not exist, check whether the virtual block device has been mounted in the preset mount directory representing the user data partition; If the mounting is not completed, wait for a preset time, and then return to perform the encrypted data preset service to check whether the preset completion mark exists in the third preset position of the boot communication partition; If mounting is complete, the backup partition information is read from the second preset position in the boot communication partition, and the backup partition magic number in the backup partition information is checked to see if it matches the preset magic number. If there is a discrepancy, exit the encrypted data pre-configuration service; If they match, the digital digest of the backup body in the backup partition information is calculated according to the digital digest algorithm corresponding to the backup body digital digest algorithm type in the backup partition information. The calculated backup body digital digest is then encrypted using a preset symmetric encryption algorithm and key for the backup partition information to obtain the backup body digital digest ciphertext and the backup body digital digest ciphertext size. If the calculated size of the backup body digital digest ciphertext is the same as the size of the backup body digital digest ciphertext in the backup partition information, and the calculated size of the backup body digital digest ciphertext is the same as the size of the backup body digital digest ciphertext in the backup partition information, then the block device node corresponding to the backup partition is determined according to the name of the backup partition in the backup body in the backup partition information, and it is checked whether the backup partition has been mounted. If not mounted, mount the backup partition and check if there is a corresponding preset data compressed package in the backup partition according to the path of the preset data compressed package in the backup partition information. If it does not exist, exit the encrypted data provisioning service; If it exists, calculate the digital digest of the preset data compressed package in the backup partition according to the digital digest algorithm corresponding to the backup body digital digest algorithm type in the backup partition information; If the calculated digital digest of the pre-configured data compressed package is the same as the digital digest of the pre-configured data compressed package of the backup body in the backup partition information, then the pre-configured data compressed package in the backup partition is decompressed to the preset mount directory representing the user data partition, and the decompressed pre-configured data is automatically encrypted using the preset data encryption / decryption service before being written to the actual user data partition; and A preset completion marker is written to the third preset position in the boot communication partition to complete the data preset of the user data partition and exit the encrypted data preset service.

9. The method according to claim 7, characterized in that, Also includes: When using services or applications with preset data in the user data partition, check whether a preset completion marker exists in the third preset position of the boot communication partition; If it exists, continue to use the services or applications with the preset data of the user data partition; as well as If it does not exist, wait for a preset time and then return to check if a preset completion mark exists in the third preset position of the boot communication partition.

10. An electronic device, characterized in that, include: The memory is configured to store executable programs; as well as A processor is configured to execute the program to perform the method according to any one of claims 1 to 9.

11. A computer-readable medium having a computer program stored thereon, characterized in that, The computer program is executed to implement the method according to any one of claims 1 to 9.