Root file system upgrade method, electronic device and computer-readable storage medium

By obtaining and writing the root file system upgrade package from the external device after kernel initialization, the upgrade failure problem caused by incomplete root file system of electronic devices is solved, the upgrade success rate and system stability are improved, and the device is prevented from becoming 'bricked' .

CN112685057BActive Publication Date: 2024-12-10SHENZHEN ONETHING TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011510372.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-18
Publication Date
2024-12-10
Estimated Expiration
2040-12-18

AI Technical Summary

Technical Problem

When the root file system of the electronic device is incomplete, the upgrade program cannot run normally, resulting in the device being unable to upgrade or "brick". The existing technology is difficult to effectively solve this problem.

Method used

After kernel initialization is completed, the root file system upgrade package is obtained from the external device and written to the preset partition to ensure the stability and success rate of the upgrade process.

Benefits of technology

It reduces the risk that the upgrade program cannot be started normally, reduces the impact of network abnormalities on the upgrade process, improves the upgrade success rate, prevents the equipment from becoming 'bricked', and enhances the security of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112685057B_ABST
    Figure CN112685057B_ABST
Patent Text Reader

Abstract

The present application discloses a root file system upgrade method, electronic device and computer-readable storage medium, including: executing kernel initialization; after the kernel initialization is completed, obtaining a root file system upgrade package from an external device; writing the root file system upgrade package into a preset partition to complete the upgrade. Through the above method, the present application can improve the upgrade success rate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of system upgrade, and in particular to a root file system upgrade method, an electronic device, and a computer-readable storage medium. Background Art

[0002] With the rapid development of the Internet, electronic devices have also developed rapidly. Intelligent electronic devices have been widely used in all walks of life and have become indispensable products in people's lives and work.

[0003] With the continuous improvement and change of user needs, the continuous optimization of system software, and the continuous increase of system functions, the systems of electronic devices need to be revised and updated. In order to solve problems of electronic devices, improve system functions and meet user needs, electronic device manufacturers will release a series of upgraded versions for this electronic device.

[0004] In the related art, the method of upgrading electronic devices is to use an upgrade program to download the upgraded root file system online, and upgrade according to the upgraded root file system. However, when the original root file system is incomplete, the upgrade program may not be pulled up normally or cannot enter the root file system, causing the electronic device to "become bricked", making it impossible for users to upgrade the root file system normally or "recover the brick". Summary of the invention

[0005] The present application provides a root file system upgrade method, which can upgrade the root file system of an electronic device when the root file system is incomplete.

[0006] To solve the technical problem, the present application provides a root file system upgrade method, comprising: performing kernel initialization; after the kernel initialization is completed, obtaining a root file system upgrade package from an external device; writing the root file system upgrade package into a preset partition to complete the upgrade.

[0007] To achieve the above-mentioned purpose, the present application also provides an electronic device, comprising: a memory, a bus and a processor; wherein the memory is used to store a computer program; the processor is used to couple the external device through the bus to obtain a root file system upgrade package; and the processor is used to execute the computer program.

[0008] To achieve the above object, the present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program can be executed by a processor to implement the above root file system upgrade method.

[0009] This application obtains the root file system upgrade package from an external device after the kernel initialization is completed, which can reduce the risk of the upgrade program not being able to be pulled up normally when the electronic device upgrades the root file system online, and reduce the impact of network anomalies during the online upgrade process. In addition, upgrading the root file system based on the kernel can reduce the upgrade failure caused by the high load of the electronic device system, thereby improving the upgrade success rate. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work, among which:

[0011] Figure 1 It is a flowchart of the first embodiment of the root file system upgrade method provided by the present application;

[0012] Figure 2 It is a flowchart of an implementation method of obtaining a root file system upgrade package from an external device provided by the present application;

[0013] Figure 3 It is a flowchart of an implementation method of writing a root file system upgrade package into a preset partition provided by the present application;

[0014] Figure 4 It is a flowchart of the second embodiment of the root file system upgrade method provided by the present application;

[0015] Figure 5 is a structural diagram of an electronic device disclosed in the present application;

[0016] Figure 6 It is a structural diagram of a computer-readable storage medium disclosed in this application. DETAILED DESCRIPTION

[0017] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in 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. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0018] See also Figure 1 , Figure 1 This is a flowchart of the first embodiment of the root file system upgrade method provided by the present application. Specifically, this embodiment may include the following steps:

[0019] Step S11: Execute kernel initialization.

[0020] The execution subject of this step is the processor in the electronic device. After the electronic device is powered on, the processor obtains the kernel initialization instruction, runs the boot program in response to the kernel initialization instruction, and the boot program loads the kernel to perform kernel initialization.

[0021] The electronic device may be a set-top box, a personal computer, a smart phone, a tablet computer, a PDA or a portable computer.

[0022] Step S12: After the kernel initialization is completed, the root file system upgrade package is obtained from the external device.

[0023] The external device may be an external storage device, such as a USB flash drive, a plug-in hard disk, a smart memory card, a secure digital card, a flash memory card, etc. The root file system upgrade package may be a ghost image file, or an ISO image file, etc.

[0024] In this embodiment, after the kernel initialization is completed and it is determined that there is an external device connected to the electronic device, the root file system upgrade package is obtained from the external device.

[0025] Specifically, see Figure 2 , Figure 2 This is a flow chart of an implementation method of obtaining a root file system upgrade package from an external device provided by the present application. This implementation method may include the following steps:

[0026] S121: Detect whether there is an external device connected.

[0027] The electronic device has a port for connecting to an external device, and the port of the electronic device includes an identification pin. When the external device is connected to the electronic device through the port of the electronic device, the identification pin is triggered to generate an identification signal. The electronic device determines that an external device is connected according to the identification signal; when the port of the electronic device does not generate the identification signal, it can be determined that no external device is connected.

[0028] After the kernel initialization is completed, the external device is first identified so that the electronic device can upgrade the root file system through the external device when the root file system is incomplete.

[0029] S122: If an external device is connected, check whether there is a root file system upgrade package.

[0030] When an external device is identified, the electronic device establishes a communication connection with the external device to mount the external device in the file system in the kernel and detect whether there is a root file system upgrade package in the external device. Mounting refers to a process in which the operating system makes computer files and directories on a storage device (such as a hard disk, CD-ROM or shared resources) accessible to users through the computer's file system. In this embodiment, the external device is mounted in the file system in the kernel, that is, the kernel can access files in the external device.

[0031] Taking the external device as a USB device as an example, the electronic device first enumerates the external device, and the electronic device can read various descriptor information from the USB device. After obtaining the various descriptor information, the electronic device establishes a communication connection with the USB device, thereby being able to access the USB device.

[0032] Specifically, after the electronic device establishes a communication connection with the external device, it detects whether there is a designated upgrade package directory in the external device; if there is a designated upgrade package directory in the external device, it detects whether there is a root file system upgrade package in the designated upgrade package directory.

[0033] The designated upgrade package directory is named as an agreed specific name. By accessing the designated upgrade package directory, the electronic device does not need to access other directories in the external device, which can shorten the time spent on the upgrade and reduce the load of the electronic device.

[0034] S123: If the root file system upgrade package exists, obtain the root file system upgrade package.

[0035] When it is detected that there is a root file system upgrade package in the external device, the root file system upgrade package is controlled to be transmitted to the electronic device.

[0036] When the electronic device fails to identify the external device and fails to find the root file system upgrade package, the application layer program (upgrade program) of the root file system on the electronic device is started to obtain the root file system upgrade package through the upgrade program.

[0037] In the present application, after the kernel initialization is completed, the external device is first identified and mounted. After the external device is mounted, the root file system upgrade package is obtained from the external device. Compared with obtaining the root file system upgrade package online, the efficiency of obtaining the root file system upgrade package can be improved, and the problem of inefficiency in obtaining the root file system upgrade package caused by network anomalies can be improved.

[0038] Step S13: Write the root file system upgrade package into the preset partition to complete the upgrade.

[0039] The root file system upgrade package is written into the preset partition, and the root file system upgrade package is installed in the preset partition to complete the root file system upgrade of the electronic device.

[0040] See also Figure 3 , Figure 3 This is a flow chart of an implementation method of writing a root file system upgrade package into a preset partition provided by the present application. This implementation method includes the following steps:

[0041] Step S1311: Query the partition flag corresponding to the original root file system.

[0042] The partition flag is used to mark the storage location of the original root file system in the hardware disk of the electronic device.

[0043] Step S1312: Determine a preset partition in other partitions different from the partition where the original root file system is located.

[0044] The preset partition is set in another partition different from the partition where the original root file system is located. In this way, even if the upgrade fails, the partition where the original root file system is located will not be affected, ensuring that the electronic device can still start and run normally.

[0045] For example, if partition A is currently used as the original root file system partition, another partition (such as partition B) is used as the default partition. In this way, if the upgrade fails, since the data in partition A has not been changed, the electronic device can still start normally according to the data in partition A after powering on and restarting.

[0046] In some implementations, in order to improve the security of the root file system upgrade package and reduce the risk of the electronic device being rooted into the background after the root file system is cracked, the root file system upgrade package can be encrypted and protected. Therefore, when installing the root file system upgrade package, the electronic device needs to first decrypt the root file system upgrade package to obtain the data therein.

[0047] See also Figure 3 , Figure 3 This is a flow chart of an implementation method of writing a root file system upgrade package into a preset partition provided by the present application. This implementation method includes the following steps:

[0048] Step S1313: Determine whether the root file system upgrade package is in an encrypted state.

[0049] If the root file system upgrade package is in an encrypted state, execute S1314; if the root file system upgrade package is not in an encrypted state, that is, the root file system upgrade package is plain text file data, execute S1315.

[0050] Step S1314: decrypt the root file system upgrade package to obtain file data, and write the file data into the preset partition.

[0051] The root file system upgrade package can be encrypted by a symmetric encryption algorithm or an asymmetric encryption algorithm. Among them, the asymmetric encryption algorithm is more difficult to crack, so it is more secure. Encrypting the file data to obtain an encrypted file system upgrade package can improve the security of the file data, thereby reducing the risk of the root permissions of the electronic device being cracked due to file data leakage.

[0052] For example, an agreed secret key is stored in the electronic device, and the secret key is used to decrypt the root file system upgrade package to obtain plain text file data, and the file data is written into the preset partition.

[0053] The root file system upgrade package may be first transmitted to the electronic device and then decrypted to obtain the file data, or may be decrypted in an external device to obtain the file data and then the file data is transmitted and written into the preset partition.

[0054] Step S1315: Obtain the checksum of the file data and the checksum carried in the header of the root file system upgrade package.

[0055] When file data is transferred or written to the preset partition, data loss or distortion may occur. In order to ensure the security of the electronic device system upgrade, it is possible to verify whether the file data in the preset partition is consistent with the file data corresponding to the root file system upgrade package.

[0056] In order to reduce the amount of computation required to verify whether the file data in the preset partition is consistent with the file data corresponding to the root file system upgrade package, the verification may be performed based on the checksum of the file data.

[0057] The header of the upgrade package may also include data structure description information of the header of the root file system upgrade package, such as information describing the size of the header, the file offset, and the check value of the file data. In this application, a hash algorithm may be used to calculate the check value of the file data. Among them, the hash algorithm may specifically be MD2, MD4, MD5, HAVAL, SHA, SHA-1, HMAC, HMAC-MD5 or HMAC-SHA1, etc. This embodiment is described by taking the hash algorithm as MD5 (Message-Digest Algorithm 5) as an example. The MD5 code can transform a byte string of any length into a hexadecimal digit string of a certain length, so that large-capacity information can be "compressed" into a confidential format before signing a private key with a digital signature application. Any file has and only has a unique MD5 information value, and if the file is modified, its MD5 information value will also change accordingly.

[0058] Specifically, MD5 is used to calculate the MD5 value of the file data in the preset partition to obtain the check value of the file data in the preset partition.

[0059] Step S1316: Compare the checksum of the file data with the checksum carried in the header of the root file system upgrade package.

[0060] MD5 will generate a hash value based on the content of the file. The hash values ​​of file data with inconsistent content are different; the hash values ​​of file data with consistent content are the same. By comparing the checksum of the file data with the checksum carried in the header of the root file system upgrade package, it can be determined whether the file data written to the preset partition is complete.

[0061] Step S1317: If the comparison results are consistent, the partition flag of the preset partition is set to the partition flag corresponding to the boot partition.

[0062] The checksum value of the file data in the preset partition is consistent with the checksum value carried in the header of the root file system upgrade package, indicating that the file data in the preset partition and the file data corresponding to the root file system upgrade package in the external device are the same, and no data distortion occurs during the decryption of the root file system upgrade package and the transmission and writing of the file data.

[0063] After determining that the comparison result is consistent, the partition flag of the preset partition is set to the partition flag corresponding to the boot partition to restart and boot the root file system in the preset partition.

[0064] For example, if the partition flag of the boot partition where the original root file system is located is partition A, then the partition flag of the preset partition is set to partition A. Based on this setting, the next time the boot program starts the root file system, it will start the upgraded root file system from partition A.

[0065] If the comparison results are inconsistent, the upgrade is terminated and the original root file system is booted.

[0066] This embodiment can reduce the risk of the upgrade program not being able to be normally pulled up when the electronic device upgrades the root file system online, and reduce the impact of network anomalies during the online upgrade process by first identifying and mounting the external device after the kernel initialization is completed, and obtaining the root file system upgrade package in the external device, and then writing the root file system upgrade package into the preset partition. In addition, by upgrading the root file system based on the kernel, it is possible to reduce the upgrade failure caused by the high load of the electronic device system, thereby improving the upgrade success rate.

[0067] In order to ensure that the root file system upgrade package can be successfully and accurately installed to complete the root file system upgrade of the electronic device, the present application can also verify whether there is an anti-secondary upgrade flag file in the external device and the integrity of the root file system upgrade package before writing the root file system upgrade package into the preset partition.

[0068] See also Figure 4 , Figure 4 This is a flow chart of the second embodiment of the root file system upgrade method provided by the present application. This embodiment is based on the first embodiment of the root file system upgrade method, so the same steps are not repeated here. This embodiment includes the following steps:

[0069] S21: Execute kernel initialization.

[0070] This step corresponds to S11 of the first embodiment of the root file system upgrade method.

[0071] S22: After the kernel initialization is completed, it is detected whether there is an external device connected.

[0072] This step corresponds to S121 of the first embodiment of the root file system upgrade method.

[0073] If yes, execute S23; if no, execute S29.

[0074] S23: Detect whether there is a flag file for preventing secondary upgrade in the external device.

[0075] The anti-secondary upgrade flag file is used to prevent the electronic device from being upgraded repeatedly, so as to determine whether the electronic device can be upgraded based on the external device.

[0076] If the anti-secondary upgrade flag file exists in the external device, it means that the device has been upgraded through the external device, and then S29 is executed; if it is detected that the anti-secondary upgrade flag file does not exist in the external device, then S24 is executed.

[0077] S24: Detect whether there is a root file system upgrade package.

[0078] This step corresponds to S122 of the first embodiment of the root file system upgrade method.

[0079] If yes, execute S25; if no, execute S29.

[0080] S25: Check the integrity of the root file system upgrade package.

[0081] Obtain the checksum of the root file system upgrade package and the checksum stored in the checksum file corresponding to the root file system upgrade package in the external device;

[0082] The checksum of the root file system upgrade package is compared with the checksum of the file storing the checksum to determine the integrity of the root file system upgrade package.

[0083] The present application may use a hash algorithm to calculate the checksum of the root file system upgrade package. The hash algorithm may be MD2, MD4, MD5, HAVAL, SHA, SHA-1, HMAC, HMAC-MD5 or HMAC-SHA1, etc., and any checksum calculation method provided by the prior art may also be used for calculation, which is not specifically limited here.

[0084] If yes, execute S26; if no, execute S29.

[0085] S26: Write the root file system upgrade package into the preset partition.

[0086] This step corresponds to S13 of the first embodiment of the root file system upgrade method.

[0087] S27: Writing a secondary upgrade prevention flag file into the external device.

[0088] Write an anti-secondary upgrade flag file into the external device to prevent the electronic device from performing a secondary upgrade based on the root file system upgrade package in the external device.

[0089] After writing the anti-secondary upgrade flag file into the external device, execute S28.

[0090] S28: Restart and boot the root file system in the preset partition to complete the upgrade.

[0091] S29: End the upgrade and boot the original root file system.

[0092] This embodiment avoids secondary upgrade of the electronic device by checking the anti-secondary upgrade flag file; at the same time, in order to enable the root file system upgrade package to be successfully and accurately installed to complete the root file system upgrade of the electronic device, this application verifies the integrity of the root file system upgrade package before writing the root file system upgrade package into the preset partition to avoid writing a root file system upgrade package with incomplete data.

[0093] The present application also provides an electronic device, which may be a set-top box, a personal computer, a smart phone, a tablet computer, a PDA, a portable computer, etc.

[0094] See also Figure 5 , Figure 5 It is a structural diagram of an electronic device disclosed in the present application, which may include a processor 101, a bus 102 and a memory 103.

[0095] The memory 103 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. Furthermore, the memory 103 can be used not only to store application software and various data of the electronic device, such as the code of the computer program 104, but also to temporarily store data that has been output or is to be output.

[0096] The external device may be an external storage device, such as a USB flash drive, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. The external device may be used to store various types of data, such as a root file system upgrade package, etc.

[0097] In some embodiments, the processor 101 can be a central processing unit (CPU), a controller, a microcontroller, a microprocessor or other data processing chip, which is used to run the program code or process data stored in the memory 103 to implement the root file system upgrade method provided in any of the above embodiments, such as executing the computer program 104.

[0098] The bus 102 may be a peripheral component interconnection standard bus or an extended industry standard structure bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0099] The processor 101 is coupled to an external device and a memory 103 via a bus 102 , and is used to obtain a root file system upgrade package and execute a computer program 104 , respectively.

[0100] The electronic device provided in the embodiment of the present application can upgrade the root file system through an external device when the root file system is incomplete, effectively improving the upgrade success rate; at the same time, in the event of an upgrade failure, it can also boot the original root file system to prevent the electronic device from becoming "bricked".

[0101] The present application also provides a computer-readable storage medium, which may be a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a mobile hard disk, a CD-ROM, or any other form of storage medium known in the art.

[0102] The method of the above embodiment may exist in the form of a computer program, so the present application proposes a computer readable storage medium, see Figure 6 , Figure 6 The computer readable storage medium 600 of this embodiment stores a computer program 601, which can be executed to implement the method in the above embodiment.

[0103] The computer-readable storage medium 600 of this embodiment may be a medium that can store program instructions, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or may be a server that stores the program instructions. The server may send the stored program instructions to other devices for execution, or may execute the stored program instructions by itself.

[0104] It should be noted that the serial numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments. And the terms "including", "comprising" or any other variants thereof herein are intended to cover non-exclusive inclusion, so that the process, device, article or method including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the presence of other identical elements in the process, device, article or method including the element.

[0105] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A method for upgrading a root file system, characterized in that: include: Perform kernel initialization; After the kernel initialization is completed, obtaining a root file system upgrade package from an external device; Writing the root file system upgrade package into a preset partition to complete the upgrade of the root file system based on the kernel; Before writing the root file system upgrade package into the preset partition, the method further includes: checking the integrity of the root file system upgrade package; if the root file system upgrade package is complete, executing the step of writing the root file system upgrade package into the preset partition; if the root file system upgrade package is incomplete, terminating the upgrade and guiding the original root file system to start; The step of writing the root file system upgrade package into the preset partition comprises: determining whether the root file system upgrade package is in an encrypted state; if the root file system upgrade package is in an encrypted state, decrypting the root file system upgrade package to obtain file data, and writing the file data into the preset partition; obtaining a check value of the file data and a check value carried in a header of the root file system upgrade package; comparing the check value of the file data with the check value carried in the header of the root file system upgrade package; if the comparison result is consistent, setting the partition flag of the preset partition to the partition flag corresponding to the boot partition, so that the root file system can be booted through the preset partition; if the comparison result is inconsistent, ending the upgrade and booting the original root file system.

2. The upgrading method according to claim 1, characterized in that: After the kernel initialization is completed, obtaining the root file system upgrade package from the external device includes: After the kernel is initialized, detecting whether the external device is connected; If the external device is connected, detecting whether the root file system upgrade package exists; If the root file system upgrade package exists, obtain the root file system upgrade package.

3. The upgrading method according to claim 2, characterized in that: The detecting whether the root file system upgrade package exists includes: Check whether the specified upgrade package directory exists; If the designated upgrade package directory exists, detect whether the root file system upgrade package exists in the designated upgrade package directory.

4. The upgrading method according to claim 3, characterized in that: The checking the integrity of the root file system upgrade package includes: Obtaining a checksum value of the root file system upgrade package and a checksum value in a checksum storage file corresponding to the root file system upgrade package in the external device; The checksum of the root file system upgrade package is compared with the checksum of the checksum storage file to determine the integrity of the root file system upgrade package.

5. The upgrading method according to claim 1, characterized in that: Writing the root file system upgrade package into a preset partition includes: Query the partition flag corresponding to the original root file system to determine the partition where the original root file system is located; The preset partition is determined in other partitions different from the partition where the original root file system is located.

6. The root file system upgrade method according to claim 1, characterized in that: Before writing the root file system upgrade package into the preset partition, the method further includes: Detecting whether there is an anti-secondary upgrade flag file in the external device; If it exists, restart is performed and the root file system in the preset partition is booted.

7. An electronic device, characterized in that: include: A memory, a bus and a processor; wherein the memory is used to store a computer program; the processor is used to couple the external device through the bus to obtain a root file system upgrade package; the processor is used to execute the computer program to implement the root file system upgrade method described in any one of claims 1-6.

8. A computer-readable storage medium, characterized in that: A computer program is stored, and the computer program can be executed by a processor to implement the root file system upgrade method according to any one of claims 1 to 6.