Upgrading method and device of electronic equipment and electronic equipment
By dynamically adjusting the compression parameters, the generation and decompression process of upgrading packages is optimized according to the memory capacity of electronic devices, and the problem of low upgrade efficiency in the existing technology is solved and a more efficient upgrade process is achieved.
Patent Information
- Application Number
- CN202411934518.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-25
AI Technical Summary
The upgrade efficiency of the prior art is low in the process of upgrading electronic equipment, mainly because the decompression efficiency is not considered, resulting in a slow upgrade speed.
By obtaining the memory capacity of the electronic device, dynamically adjusting the compression parameters to optimize the generation and decompression process of the upgrade package. The specific method includes determining the window size, hash chain length, data block size and decompression block size based on the memory capacity, thereby improving the compression rate and decompression speed.
By dynamically adjusting the compression parameters, the generated upgrade package is more adapted to the performance of electronic devices, optimizes the transmission and decompression efficiency of the upgrade package, and improves the overall upgrade efficiency.
Smart Images

Figure CN119883316A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data processing technology, and specifically relates to an upgrading method and device of an electronic device and the electronic device. Background Art
[0002] Nowadays, with the increase of software functions, software version upgrades are becoming more and more common, and the upgrade packages are getting larger and larger. In the Over-the-Air Technology (OTA) upgrade process in related technologies, the same compression strategy is used for each project and image, and patches are generated and compressed using binary differences, and the smallest data is selected to be written into the upgrade package. However, this technology only focuses on the compression rate, but does not consider the decompression efficiency, which results in a slow upgrade speed and low upgrade efficiency. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide an electronic device upgrade method, device and electronic device, which can solve the technical problem of low existing upgrade efficiency.
[0004] In a first aspect, an embodiment of the present application provides a method for upgrading an electronic device, the method comprising:
[0005] Obtaining the memory capacity of the electronic device;
[0006] Determining compression parameters based on the memory capacity of the electronic device;
[0007] Compressing the upgrade data of the electronic device according to the compression parameter to obtain an upgrade package;
[0008] The upgrade package is sent to the electronic device, where the upgrade package is used for the electronic device to complete the upgrade.
[0009] In a second aspect, an embodiment of the present application provides an upgrade device for an electronic device, the device comprising:
[0010] An acquisition module, used to acquire the memory capacity of the electronic device;
[0011] A first determining module, used to determine a compression parameter according to a memory capacity of the electronic device;
[0012] A compression module, used for compressing the upgrade data of the electronic device according to the compression parameter to obtain an upgrade package;
[0013] The upgrade module is used to send the upgrade package to the electronic device, and the upgrade package is used to complete the upgrade of the electronic device.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the method provided in the first aspect are implemented.
[0015] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method provided in the first aspect are implemented.
[0016] In a fifth aspect, an embodiment of the present application provides a chip, the chip including a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the method provided in the first aspect.
[0017] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method provided in the first aspect.
[0018] In the electronic device upgrade method, device and electronic device of the present application, the memory capacity of the device can be obtained to dynamically adjust the compression parameters so that the generated upgrade package is more suitable for the performance of the electronic device. In this way, the upgrade package can be optimized by adjusting the compression parameters so that the upgrade can be carried out efficiently on different electronic devices, thereby improving the overall upgrade efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 This is one of the flowcharts of the method for upgrading an electronic device provided in some embodiments of the present application;
[0020] Figure 2 This is a second flow chart of an electronic device upgrade method provided in some embodiments of the present application;
[0021] Figure 3 This is a third flow chart of an electronic device upgrade method provided by some embodiments of the present application;
[0022] Figure 4 This is a fourth flowchart of an upgrade method for an electronic device provided in some embodiments of the present application;
[0023] Figure 5 It is a structural schematic diagram of an upgrading device for an electronic device provided by an embodiment of the present application;
[0024] Figure 6 is a structural schematic diagram of an electronic device provided by another embodiment of the present application;
[0025] Figure 7 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0026] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0027] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way are interchangeable where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0028] In order to solve the above technical problems, the present application provides an electronic device upgrade method. The following is a detailed description of the electronic device upgrade method provided by the present application embodiment through specific embodiments and application scenarios in conjunction with the accompanying drawings.
[0029] like Figure 1 As shown, Figure 1 : is a flow chart of an electronic device upgrade method provided by an embodiment of the present application. The present application embodiment provides an electronic device upgrade method, which is applied to a server. The method may include:
[0030] S101, determining a compression parameter according to a memory capacity of the electronic device;
[0031] In the Over-the-Air Technology (OTA) upgrade process in this embodiment, there is a system or application to be upgraded in the electronic device, and the server can generate an upgrade package containing the updated content and send the upgrade package to the electronic device through the network. After receiving the upgrade package, the electronic device decompresses the upgrade package and writes the updated content to the specified location to replace the old system or application data.
[0032] Before the electronic device is upgraded, the server may communicate with the electronic device to obtain the memory capacity information of the device; the server may also create an upgrade package based on each model of the electronic device, and the memory capacity of each model of the electronic device is fixed.
[0033] In this embodiment, in order to reduce the size of the upgrade package and thus reduce the transmission time, a compression algorithm may be used to compress the upgrade data to obtain the upgrade package during the production of the upgrade package. The compression parameters refer to the setting items for controlling the compression process, such as the window size, data block size, and decompression block size, etc., which are used to optimize the compression rate, decompression speed, and memory usage.
[0034] Therefore, after determining the memory capacity of the electronic device, the server can dynamically adjust the compression parameters of the compression algorithm according to the memory capacity of the electronic device to improve the efficiency of upgrade package creation and decompression.
[0035] Specifically, in some embodiments, the compression parameters include a window size and a hash chain length, and determining the compression parameters according to the memory capacity of the electronic device includes:
[0036] When the memory capacity is greater than the first capacity value, the window size is determined as the first window size, and the hash chain length is determined as the first length;
[0037] When the memory capacity is less than or equal to the first capacity value and greater than the second capacity value, the window size is determined as the second window size, and the hash chain length is determined as the second length;
[0038] When the memory capacity is less than or equal to the second capacity value and greater than a third capacity value, the window size is determined to be a third window size, and the hash chain length is determined to be a third length;
[0039] The first window size is larger than the second window size, the second window size is larger than the third window size, the first length is larger than the second length, and the second length is larger than the third length.
[0040] In this embodiment, the compression parameters include window size and hash chain length. The window size is the range in which the compression algorithm searches for repeated data patterns in the data stream. A larger window can improve the compression rate, but it takes up more memory. The hash chain length is the length of the linked list corresponding to each hash value in the compression algorithm. The hash chain length is used to quickly find duplicate data. The longer the hash chain length, the less hash conflicts there are, but it takes up more memory.
[0041] Specifically, when the memory capacity is greater than the first capacity value, the window size and the hash chain length are respectively set to the first window size and the first length; when the memory capacity is between the second capacity value and the first capacity value, the window size and the hash chain length are respectively set to the second window size and the second length; when the memory capacity is between the third capacity value and the second capacity value, the window size and the third length are respectively set. Furthermore, the first window size is greater than the second window size, the second window size is greater than the third window size, the first length is greater than the second length, and the second length is greater than the third length.
[0042] Through this mechanism, the system can dynamically adjust the window size and hash chain length according to the different memory capacities, ensuring efficient operation under different hardware configurations. Larger windows and longer hash chains can be used with larger memory capacities to improve processing capabilities, while smaller window sizes and hash chain lengths can be appropriately reduced to reduce memory consumption and increase processing speed. This flexible adjustment helps optimize the use of memory resources and improve the overall performance and stability of the system.
[0043] In some embodiments, the compression parameter includes a data block size, and determining the compression parameter according to a memory capacity of the electronic device includes:
[0044] In a case where the memory capacity is greater than a first capacity value, determining the data block size to be a first value;
[0045] When the memory capacity is less than or equal to the first capacity value and greater than the second capacity value, determining the data block size as a third value;
[0046] When the memory capacity is less than or equal to the second capacity value and greater than the third capacity value, determining the data block size as a fifth value;
[0047] The first value is greater than the third value, and the third value is greater than the fifth value.
[0048] In this embodiment, the data block size is the size of the small blocks into which the data is divided, and is used for block compression and transmission of the upgrade data. A larger data block size can improve the compression rate, but has higher memory requirements.
[0049] Therefore, when the memory capacity is greater than the first capacity value, the data block size is set to the first value; when the memory capacity is between the second capacity value and the first capacity value, the data block size is set to the third value; when the memory capacity is between the third capacity value and the second capacity value, the data block size is set to the fifth value. In addition, the first value is greater than the third value, and the third value is greater than the fifth value.
[0050] This compression strategy optimizes the use of memory and computing resources by dynamically adjusting the data block size according to the memory capacity. When the memory capacity is large, a larger data block size can be used to improve the compression efficiency; when the memory capacity is small, a smaller data block size is selected to avoid excessive memory usage, thereby maintaining system stability and performance.
[0051] In some embodiments, the compression parameter includes a decompression block size, and determining the compression parameter according to a memory capacity of the electronic device includes:
[0052] In a case where the memory capacity is greater than the first capacity value, determining the decompression block size to be a second value;
[0053] When the memory capacity is less than or equal to the first capacity value and greater than the second capacity value, determining the decompression block size as a fourth value;
[0054] When the memory capacity is less than or equal to the second capacity value and greater than the third capacity value, determining the decompression block size as a sixth value;
[0055] The second value is greater than the fourth value, and the fourth value is greater than the sixth value.
[0056] In this embodiment, the decompression block size is the unit data amount for decompression and writing each time. A larger decompression block size can speed up the decompression speed, but requires more memory support.
[0057] Therefore, when the memory capacity is greater than the first capacity value, the decompression block size is set to the second value; when the memory capacity is between the second capacity value and the first capacity value, the decompression block size is set to the fourth value; when the memory capacity is between the third capacity value and the second capacity value, the decompression block size is set to the sixth value. In addition, the second value is greater than the fourth value, and the fourth value is greater than the sixth value.
[0058] This strategy optimizes memory and processing speed during the decompression process by dynamically adjusting the decompression block size. When the memory capacity is large, a larger decompression block size can be used to speed up the decompression speed; when the memory capacity is small, a smaller decompression block size is selected to avoid memory overflow and improve system stability.
[0059] In this embodiment, the electronic device may be determined as one of a high-memory model, a medium-memory model, and a low-memory model based on the memory capacity of the electronic device.
[0060] If the memory capacity of the electronic device is greater than the first capacity value, the electronic device can be determined as a high-memory model. The high-memory model has sufficient memory to support improving the compression rate and reducing hash conflicts. Therefore, the window size of the high-memory model can be determined as the highest first window size, the hash chain length of the high-memory model can be determined as the longest first length, the data block size of the high-memory model can be determined as the largest first value, and the decompression block size can be determined as the largest second value.
[0061] If the memory capacity of the electronic device is less than or equal to the first capacity value and greater than the second capacity value, the electronic device can be determined as a medium memory model, the memory of the medium memory model is between the high memory model and the low memory model, and has a certain amount of memory to support the improvement of compression rate and reduce hash conflicts. Therefore, the window size of the medium memory model can be determined as a moderate second window size, the hash chain length of the medium memory model can be determined as a moderate second length, the data block size of the medium memory model can be determined as a moderate third value, and the decompression block size can be determined as a moderate fourth value.
[0062] If the memory capacity of the electronic device is less than or equal to the second capacity value, the electronic device can be determined as a low-memory model. The memory of the medium-memory model is low, and it is necessary to sacrifice compression rate and hash conflict to occupy as little memory as possible. Therefore, the window size of the low-memory model can be determined as the smallest third window size, the hash chain length of the low-memory model can be determined as the smallest third length, the data block size of the low-memory model can be determined as a moderate fifth value, and the decompression block size can be determined as a moderate sixth value.
[0063] For example, the window size of the high-memory model can be set to a maximum of 128M, the hash chain length can be set to a maximum of 128M, the data block size can be set to a maximum of 128M, and the decompression block size can be set to a maximum of 512K. This setting can bring a higher compression rate, but it requires more memory of the electronic device. The window size of the medium-memory model can be set to a moderate 64M, the hash chain length can be set to a moderate 64M, the data block size can be set to a moderate 64M, and the decompression block size can be set to a moderate 256K. This setting can enable the medium-memory model to obtain a good compression rate and a balanced decompression speed, and ensure that the memory usage is moderate. For low-memory models, the window size can be set to a minimum of 32M, the hash chain length can be set to a minimum of 32M, the data block size can be set to a minimum of 32M, and the decompression block size can be set to a minimum of 128K. Although this brings a lower compression rate and decompression speed, it reduces the memory requirements of the electronic device.
[0064] Through the above method, the compression parameters can be dynamically adjusted according to the memory capacity of different electronic devices, so that high-memory devices can obtain higher compression rates and decompression speeds, while low-memory devices can successfully complete decompression within memory limitations, thereby improving overall upgrade efficiency and device compatibility.
[0065] S102: compress the upgrade data of the electronic device according to the compression parameter to obtain an upgrade package.
[0066] In the embodiment of the present application, after determining the compression parameter according to the memory capacity of the electronic device, the server can compress the upgrade data of the electronic device based on the compression parameter to obtain an upgrade package. The upgrade package is a compressed file containing all update contents and is used to upgrade the electronic device.
[0067] Specifically, in some embodiments, the compression parameters include a window size, a hash chain length, and a data block size, and compressing the upgrade data of the electronic device according to the compression parameters to obtain an upgrade package includes:
[0068] Divide the upgrade data into blocks according to the size of the data blocks to obtain multiple data blocks;
[0069] Compressing at least part of the multiple data blocks according to the window size and the hash chain length to obtain multiple compressed data blocks;
[0070] The multiple compressed data blocks are encapsulated to obtain the upgrade package.
[0071] In this embodiment, after determining the window size, hash chain length and data block size based on the memory capacity of the electronic device, the upgrade data of the electronic device can be compressed based on the window size, hash chain length and data block size.
[0072] Specifically, the upgrade data may be first divided into a plurality of data blocks according to a set data block size, and then at least some of the data blocks may be compressed using a set window size and a hash chain length, wherein the window size defines a range within which the compression algorithm searches for repeated data patterns in each data block, and the hash chain length determines the length of the linked list of each hash value in the hash table.
[0073] After compressing at least part of the data blocks, the compressed at least part of the data blocks and the uncompressed data blocks may be integrated and packaged to generate a final data packet.
[0074] In the above method, the upgrade data can be divided into blocks according to the data block size, and the data blocks can be compressed according to the window size and the hash chain length to generate an upgrade package suitable for the electronic device. This not only reduces the size of the upgrade package, improves the transmission and decompression efficiency, but also dynamically adjusts the parameters according to the memory capacity of the electronic device to ensure that different devices can complete the upgrade smoothly.
[0075] In some embodiments, compressing at least part of the multiple data blocks according to the window size and the hash chain length to obtain multiple compressed data blocks includes:
[0076] Determining a mirror type of a first mirror among the plurality of data blocks;
[0077] Determine a dictionary size corresponding to the first image according to the image type;
[0078] For any first data block in the first image, the first data block is compressed according to the window size, the hash chain length, and the dictionary size to obtain a first compressed data block.
[0079] In this embodiment, the dictionary size refers to the size of the cache space used to store and match repeated data patterns in the compression algorithm. The dictionary records the repeated patterns that have appeared in the data stream, which is convenient for rapid matching and replacement when the same or similar patterns are encountered later, so as to improve the compression rate. Therefore, a larger dictionary size allows the algorithm to store more repeated patterns, so that more compressible data can be found when compressing data blocks, and the corresponding compression effect will be better. However, a larger dictionary size also occupies more running memory.
[0080] In this embodiment, a mirror is a file image containing complete system or application data, which is used for installation, recovery or upgrade of a device. There are usually multiple mirrors in the upgrade data. For any first mirror that needs to be upgraded, the mirror type of the first mirror can be determined, and then the dictionary size corresponding to the first mirror is set according to the mirror type.
[0081] And for each first data block in the first image, the first data block is compressed according to the set window size, hash chain length and dictionary size to obtain a first compressed data block.
[0082] Specifically, the image size of the first image can be determined based on the image type of the first image. The larger the image size, the more data and repeated patterns it contains, so a larger dictionary is required to store and match these repeated patterns, thereby improving the compression rate. A larger dictionary can find duplicate data in a larger range, making the compressed image smaller. Therefore, after determining the image type, the size of the image of the image type can be determined, and the dictionary size can be set based on the size of the image.
[0083] For example Figure 2 As shown, S201 is executed first. Before making an OTA upgrade package, the memory size of the electronic device can be first determined, and the electronic device can be divided into three types of devices: low memory, medium memory, and high memory. Then S202 can be executed, that is, according to the classification of the electronic device, the corresponding compression parameters are selected, and the compression parameters include window size, hash chain length, data block size, and decompression block size. Then S203 is executed, and all first images that need to be upgraded can be traversed, and S204 is executed to determine whether each first image is a large image such as system or vendor. If the image type of the first image is a large image such as system or vendor, S205 is executed to set the dictionary size corresponding to the first image to 512MB, so as to find more repeated patterns during compression and further reduce the compressed volume. If the image type of the first image is a small image such as boot or recovery, S206 is executed, and the dictionary size corresponding to the first image can be set to 128M. The volume of these images is small, and even if the dictionary size is increased, the compression rate is not significantly improved, and setting a smaller dictionary size can save memory. Then, S207 is executed to check whether there is any missing image after all images are traversed and parameters are set. If the parameters of all images are set, the parameter setting process ends, otherwise, all first images that need to be upgraded are continuously traversed.
[0084] In the above method, by setting a suitable dictionary size for different types of images, a higher compression rate can be achieved when compressing the upgrade package, thereby improving the upgrade efficiency. At the same time, the memory usage on the device side is controlled, making the decompression and installation process smoother.
[0085] In some embodiments, compressing at least part of the multiple data blocks according to the window size and the hash chain length to obtain multiple compressed data blocks includes:
[0086] For any second data block corresponding to the replacement instruction among the multiple data blocks, when the data block size of the second data block is larger than the compressed data block size, compress the second data block according to the first compression algorithm to obtain a second compressed data block, wherein the compressed data block size is the data block size after the second data block is compressed according to the first compression algorithm;
[0087] In a case where the data block size of the second data block is less than or equal to the compressed data block size, the second data block is retained.
[0088] In this embodiment, in the process of splitting the upgrade data into data blocks, the compression methods of the upgrade data corresponding to different instructions are different. For example, the upgrade package may include four instructions, namely, a replace instruction, a zero instruction, a binary difference merge (bsdiff) instruction, and a source copy (source_copy) instruction.
[0089] The replace instruction is used to instruct the specified data in the upgrade package to be written directly to the specified address of the electronic device. The zero instruction is used to instruct the data at the specified address of the electronic device to be cleared, that is, the data in this area is reset to a null value. The bsdiff instruction is used to instruct the differential data in the upgrade package to be merged with the existing data at the specified address of the device and then written to generate updated data. The source_copy instruction is used to instruct the data at the specified address in the electronic device to be copied to a new address.
[0090] Taking the compression process of the upgrade data corresponding to the replacement instruction in this embodiment as an example, for the upgrade data corresponding to the replacement instruction, the upgrade data corresponding to the replacement instruction can be split according to the set data block size to obtain the second data block, wherein the data block size of the second data block can be 2MB. For any second data block, it can be determined whether its uncompressed data block size is larger than the compressed data block size after compression according to the first compression algorithm. If the uncompressed data block size is larger than the compressed data block size after compression, then the second data block can be compressed according to the first compression algorithm to obtain a second compressed data block, and the second compressed data block is written into the upgrade package; if the uncompressed data block size is less than or equal to the compressed data block size, then there is no need to compress the second data block, the second data block is retained, and the second data block can be directly written into the upgrade package.
[0091] For example, Figure 3As shown, S301 can be executed first to set the data block size, then S302 can be executed to divide the data block according to the data block size, and then S303 can be executed to configure the parameters of the zstd algorithm. After the parameter configuration is completed, S304 can be executed to compress the data block according to the zstd algorithm, and a replace_zstd instruction can be added. Then, for each second data block, S305 can be executed, that is, to determine whether the size of the compressed data block compressed according to the zstd algorithm is greater than the size of the uncompressed data block. If the size of the compressed data block compressed according to the zstd algorithm is less than the size of the uncompressed data block, S306 is executed to select the replace_zstd instruction to write the compressed second compressed data block into the upgrade package; if the size of the compressed data block compressed according to the zstd algorithm is greater than or equal to the size of the uncompressed data block, S307 is executed to select the original replace instruction to directly write the original second data block into the upgrade package.
[0092] In this embodiment, each data block can be compressed and compared in size, and a smaller data block and corresponding instructions can be selected to be written into the upgrade package, thereby reducing the size of the upgrade package as much as possible and optimizing the transmission and decompression process.
[0093] S103: Send the upgrade package to the electronic device, where the upgrade package is used to complete the upgrade of the electronic device.
[0094] In the embodiment of the present application, after the server generates the upgrade package, it can be sent to the electronic device through the network, and the electronic device can receive and decompress the upgrade package, and write the upgrade data in the upgrade package to the designated location of the electronic device to complete the update of the electronic device. In the process of decompressing the upgrade package, the electronic device can use the decompression parameters set in advance, thereby improving the decompression speed and reducing memory consumption.
[0095] In this application, the memory capacity of the device can be obtained and the compression parameters can be dynamically adjusted to make the generated upgrade package more suitable for the performance of the electronic device. In this way, the upgrade package can be optimized by adjusting the compression parameters, so that the upgrade can be carried out efficiently on different electronic devices, thereby improving the overall upgrade efficiency.
[0096] The embodiment of the present application provides another method for upgrading an electronic device, which is applied to the electronic device and may include:
[0097] Receive the upgrade package sent by the server;
[0098] Determine the decompression block size corresponding to the upgrade package;
[0099] Decompressing the data in the upgrade package into multiple decompressed data blocks according to the decompression block size;
[0100] Each of the decompressed data blocks is written into the electronic device.
[0101] In this embodiment, after the upgrade package is generated in the server, the upgrade package can be sent to the electronic device, and the electronic device receives the upgrade package containing the updated content from the server. Subsequently, the electronic device can determine the decompression block size for decompressing the upgrade package, and the decompression block size is the amount of data of the upgrade data processed each time by decompression. After determining the decompression block size, the electronic device can decompress the compressed data in the upgrade package block by block into multiple decompressed data blocks according to the decompression block size. Subsequently, according to different instructions in the upgrade package, such as replace instructions, zero instructions, binary difference merge (bsdiff) instructions, and source copy (source_copy) instructions, the decompressed decompressed data blocks can be written to the specified location of the electronic device to overwrite the original data to complete the update operation of the electronic device.
[0102] For example, in the process of using the upgrade package, in the process of writing the upgrade data corresponding to the replace instruction, the electronic device can select the corresponding writing module according to the instruction type in the upgrade package to decompress and write the data. If the compression method is to compress according to the zstd algorithm, then the ZstdExtend writing module corresponding to the zstd algorithm can be selected to complete the writing of the decompressed data.
[0103] In the above manner, by decompressing according to the decompression block size corresponding to the upgrade package, the decompression and writing process is processed in blocks, which not only ensures efficient decompression of the upgrade package data, but also optimizes the writing efficiency during the upgrade process.
[0104] In some embodiments, the electronic device includes a writing thread and a decompression thread, and writing each of the decompressed data blocks to the electronic device includes:
[0105] When the cache capacity in the electronic device is less than the capacity threshold, the decompression thread decompresses the upgrade package into a plurality of decompressed data blocks, and stores the plurality of decompressed data blocks in sequence into the cache of the electronic device;
[0106] When the cache capacity reaches the capacity threshold, the decompression thread stops decompressing the upgrade package, the writing thread writes the decompressed data blocks in the cache to the corresponding positions of the electronic device, and clears the cache.
[0107] In this embodiment, the process of decompressing data and writing data can be separated into two independent threads, wherein the decompression thread is responsible for decompressing the data in the upgrade package into multiple decompressed data blocks, and the writing thread is responsible for writing the decompressed data blocks into corresponding positions of the electronic device.
[0108] like Figure 4 As shown, in the decompression thread, the decompression thread first executes S401 to read the data stream from the upgrade package, and then executes S402, that is, decompresses the data according to the set decompression block size to obtain the decompressed data block, and executes S403 to write each decompressed data block into the cache in sequence. When the capacity of the cache is greater than the capacity threshold, it can be considered that the cache of the electronic device is full, the decompression thread sends a signal to the write thread, and suspends further decompression, waiting for the write thread to execute S405, that is, clear the cache. Once the write thread executes S406, all the data in the cache is written to the corresponding position of the electronic device and the cache is cleared, then the decompression thread continues to execute S404 to process the remaining data until all data are decompressed.
[0109] In the write thread, the write thread listens to the signal of the decompression thread. When the capacity of the cache is greater than the capacity threshold, the write thread writes the decompressed data blocks in the cache to the specified location of the electronic device and clears the cache. The write thread releases the cache space after each write, allowing the decompression thread to continue writing new decompressed data blocks. This process continues to cycle until all decompressed data blocks are written to the specified location of the device.
[0110] Through the above method, the decompression and writing operations can be parallelized. The decompression thread and the writing thread exchange data through the shared cache. The decompression thread fills the cache, and the writing thread reads from the cache and writes to the device. Only when the cache is full will the decompression thread stop working, until the writing thread writes the data in the cache to the corresponding position of the electronic device and clears the cache, and the decompression thread continues to work.
[0111] This method of separating decompression and writing can reduce waiting time and improve the overall performance and upgrade efficiency of electronic equipment upgrades.
[0112] In addition, the Zstd algorithm is used for compression and decompression in the embodiment of the present application. Compared with the traditional xz and bzip2 algorithms, the Zstd algorithm has a faster decompression speed while maintaining a similar compression ratio. Specifically, the decompression speed of Zstd is 10-15 times that of xz and 20 times that of bzip2. Since the upgrade package needs to be decompressed and new data needs to be written during the mobile phone upgrade process, the decompression speed has an important impact on the overall upgrade time. After adopting the Zstd algorithm, the upgrade time of the entire full package has been increased by more than 60%, and the speed of making the upgrade package has also increased by 40%, significantly optimizing the efficiency of the upgrade process.
[0113] Figure 5 is a schematic diagram of the structure of an upgrade device for an electronic device provided by another embodiment of the present application, such as Figure 5 As shown, the upgrading device of the electronic device may include:
[0114] A first determining module 501, configured to determine a compression parameter according to a memory capacity of the electronic device;
[0115] A compression module 502, configured to compress the upgrade data of the electronic device according to the compression parameter to obtain an upgrade package;
[0116] The upgrade module 503 is used to send the upgrade package to the electronic device, and the upgrade package is used for the electronic device to complete the upgrade.
[0117] In this application, the memory capacity of the device can be obtained and the compression parameters can be dynamically adjusted to make the generated upgrade package more suitable for the performance of the electronic device. In this way, the upgrade package can be optimized by adjusting the compression parameters, so that the upgrade can be carried out efficiently on different electronic devices, thereby improving the overall upgrade efficiency.
[0118] In another optional example, the first determining module 501 includes:
[0119] A first determining unit, configured to determine the window size as a first window size and the hash chain length as a first length when the memory capacity is greater than a first capacity value;
[0120] A second determining unit, configured to determine the window size as a second window size and the hash chain length as a second length when the memory capacity is less than or equal to the first capacity value and greater than a second capacity value;
[0121] A third determining unit, configured to determine the window size as a third window size and the hash chain length as a third length when the memory capacity is less than or equal to the second capacity value and greater than a third capacity value;
[0122] The first window size is larger than the second window size, the second window size is larger than the third window size, the first length is larger than the second length, and the second length is larger than the third length.
[0123] In another optional example, the first determining module 501 further includes:
[0124] A fourth determining unit, configured to determine the data block size as a first value when the memory capacity is greater than the first capacity value;
[0125] A fifth determining unit, configured to determine the data block size as a third value when the memory capacity is less than or equal to the first capacity value and greater than the second capacity value;
[0126] A sixth determining unit, configured to determine the data block size as a fifth value when the memory capacity is less than or equal to the second capacity value and greater than a third capacity value;
[0127] The first value is greater than the third value, and the third value is greater than the fifth value.
[0128] In another optional example, the first determining module 501 further includes:
[0129] A seventh determining unit, configured to determine the decompressed block size as a second value when the memory capacity is greater than the first capacity value;
[0130] An eighth determining unit, configured to determine the decompressed block size as a fourth value when the memory capacity is less than or equal to the first capacity value and greater than the second capacity value;
[0131] A ninth determining unit, configured to determine the decompressed block size as a sixth value when the memory capacity is less than or equal to the second capacity value and greater than a third capacity value;
[0132] The second value is greater than the fourth value, and the fourth value is greater than the sixth value.
[0133] In another optional example, the compression module 502 includes:
[0134] A block division unit, used for dividing the upgrade data into blocks according to the size of the data blocks to obtain multiple data blocks;
[0135] A compression unit, configured to compress at least some of the multiple data blocks according to the window size and the hash chain length to obtain multiple compressed data blocks;
[0136] The packaging unit is used to encapsulate the multiple compressed data blocks to obtain the upgrade package.
[0137] In another optional example, the compression unit further includes:
[0138] A first determining subunit, configured to determine a mirror type of a first mirror among the plurality of data blocks;
[0139] A second determining subunit, configured to determine a dictionary size corresponding to the first image according to the image type;
[0140] The first compression subunit is used to compress any first data block in the first image according to the window size, the hash chain length and the dictionary size to obtain a first compressed data block.
[0141] In another optional example, the compression unit further includes:
[0142] a second compression subunit, configured to compress any second data block corresponding to the replacement instruction among the plurality of data blocks according to a first compression algorithm when a data block size of the second data block is larger than a compressed data block size, wherein the compressed data block size is a data block size after the second data block is compressed according to the first compression algorithm;
[0143] The retaining subunit is used to retain the second data block when the data block size of the second data block is less than or equal to the compressed data block size.
[0144] In another optional example, an upgrade device for an electronic device is also provided, and the upgrade device for the electronic device includes:
[0145] A first receiving module, used for receiving an upgrade package sent by a server;
[0146] A second determining module, used to determine the decompressed block size corresponding to the upgrade package;
[0147] A decompression module, used for decompressing the data in the upgrade package into multiple decompressed data blocks according to the decompression block size;
[0148] A writing module is used to write each of the decompressed data blocks into the electronic device.
[0149] In another optional example, the writing module includes:
[0150] a decompression unit, configured to, when the cache capacity in the electronic device is less than a capacity threshold, decompress the upgrade package into a plurality of decompressed data blocks by the decompression thread, and store the plurality of decompressed data blocks in sequence in the cache of the electronic device;
[0151] The writing unit is used for, when the cache capacity reaches the capacity threshold, the decompression thread stops decompressing the upgrade package, the writing thread writes the decompressed data block in the cache to the corresponding position of the electronic device, and clears the cache.
[0152] The upgrading device of the electronic device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or it can be other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.
[0153] The upgrade device of the electronic device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an IOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0154] The electronic device upgrade device provided in the embodiment of the present application can achieve Figure 1 To avoid repetition, the various processes implemented by the method embodiment are not described here.
[0155] Alternatively, if Figure 6 As shown, an embodiment of the present application also provides an electronic device 100, including a processor 110, a memory 119, and a program or instruction stored in the memory 119 and executable on the processor 110. When the program or instruction is executed by the processor 110, each process of the upgrade method embodiment of the above-mentioned electronic device is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0156] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
[0157] Please refer to Figure 7 , Figure 7 The hardware structure diagram of an electronic device for implementing an embodiment of the present application is shown in FIG. The electronic device 100 includes, but is not limited to, a radio frequency unit 121, a network module 122, an audio output unit 123, an input unit 124, a sensor 125, a display unit 126, a user input unit 127, an interface unit 128, a memory 129, and a processor 120.
[0158] Those skilled in the art will appreciate that the electronic device 100 may also include a power source (such as a battery) for supplying power to various components, and the power source may be logically connected to the processor 120 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 7 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0159] The processor 120 is used to determine the compression parameter according to the memory capacity of the electronic device;
[0160] The processor 120 is used to compress the upgrade data of the electronic device according to the compression parameter to obtain an upgrade package;
[0161] The network module 122 is used to send the upgrade package to the electronic device, and the upgrade package is used for the electronic device to complete the upgrade.
[0162] In this application, the memory capacity of the device can be obtained and the compression parameters can be dynamically adjusted to make the generated upgrade package more suitable for the performance of the electronic device. In this way, the upgrade package can be optimized by adjusting the compression parameters, so that the upgrade can be carried out efficiently on different electronic devices, thereby improving the overall upgrade efficiency.
[0163] In another optional example, the processor 120 is further configured to:
[0164] When the memory capacity is greater than the first capacity value, the window size is determined as the first window size, and the hash chain length is determined as the first length;
[0165] When the memory capacity is less than or equal to the first capacity value and greater than the second capacity value, the window size is determined as the second window size, and the hash chain length is determined as the second length;
[0166] When the memory capacity is less than or equal to the second capacity value and greater than a third capacity value, the window size is determined to be a third window size, and the hash chain length is determined to be a third length;
[0167] The first window size is larger than the second window size, the second window size is larger than the third window size, the first length is larger than the second length, and the second length is larger than the third length.
[0168] In another optional example, the processor 120 is further configured to:
[0169] In a case where the memory capacity is greater than a first capacity value, determining the data block size to be a first value;
[0170] When the memory capacity is less than or equal to the first capacity value and greater than the second capacity value, determining the data block size as a third value;
[0171] When the memory capacity is less than or equal to the second capacity value and greater than the third capacity value, determining the data block size as a fifth value;
[0172] The first value is greater than the third value, and the third value is greater than the fifth value.
[0173] In another optional example, the processor 120 is further configured to:
[0174] In a case where the memory capacity is greater than the first capacity value, determining the decompression block size to be a second value;
[0175] When the memory capacity is less than or equal to the first capacity value and greater than the second capacity value, determining the decompression block size as a fourth value;
[0176] When the memory capacity is less than or equal to the second capacity value and greater than the third capacity value, determining the decompression block size as a sixth value;
[0177] The second value is greater than the fourth value, and the fourth value is greater than the sixth value.
[0178] In another optional example, the processor 120 is further configured to:
[0179] Divide the upgrade data into blocks according to the size of the data blocks to obtain multiple data blocks;
[0180] Compressing at least part of the multiple data blocks according to the window size and the hash chain length to obtain multiple compressed data blocks;
[0181] The multiple compressed data blocks are encapsulated to obtain the upgrade package.
[0182] In another optional example, the processor 120 is further configured to:
[0183] For any first image in the upgrade data that needs to be upgraded, determining the image type of the first image;
[0184] Determine a dictionary size corresponding to the first image according to the image type;
[0185] For any first data block in the first image, the first data block is compressed according to the window size, the hash chain length, and the dictionary size to obtain a first compressed data block.
[0186] In another optional example, the processor 120 is further configured to:
[0187] For any second data block corresponding to the replacement instruction among the multiple data blocks, when a data block size of the second data block is larger than a compressed data block size, compressing the second data block according to a first compression algorithm, wherein the compressed data block size is a data block size after the second data block is compressed according to the first compression algorithm;
[0188] In a case where the data block size of the second data block is less than or equal to the compressed data block size, the second data block is retained.
[0189] In another optional example, the input unit 124 is used to receive an upgrade package sent by a server;
[0190] The processor 120 is used to determine the decompression block size corresponding to the upgrade package;
[0191] The processor 120 is used to decompress the data in the upgrade package into multiple decompressed data blocks according to the decompression block size;
[0192] The processor 120 is configured to write each of the decompressed data blocks into the electronic device.
[0193] In another optional example, the processor 120 is further configured to:
[0194] When the cache capacity in the electronic device is less than the capacity threshold, the decompression thread decompresses the upgrade package into a plurality of decompressed data blocks, and stores the plurality of decompressed data blocks in sequence into the cache of the electronic device;
[0195] When the cache capacity reaches the capacity threshold, the decompression thread stops decompressing the upgrade package, the writing thread writes the decompressed data blocks in the cache to the corresponding positions of the electronic device, and clears the cache.
[0196] It should be understood that in the embodiment of the present application, the input unit 124 may include a graphics processor (Graphics Processing Unit, GPU) 1241 and a microphone 1242, and the graphics processor 1241 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 126 may include a display panel 1261, and the display panel 1261 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 127 includes a touch panel 1271 and at least one of other input devices 1272. The touch panel 1271 is also called a touch screen. The touch panel 1271 may include two parts: a touch detection device and a touch controller. Other input devices 1272 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0197] The memory 129 can be used to store software programs and various data. The memory 129 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 129 may include a volatile memory or a non-volatile memory, or the memory 129 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 129 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0198] The processor 120 may include one or more processing units; optionally, the processor 120 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 120.
[0199] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the upgrade method embodiment of the above-mentioned electronic device are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0200] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0201] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned electronic device upgrade method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0202] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0203] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the upgrade method embodiment of the electronic device as described above, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0204] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device 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, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0205] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0206] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A method for upgrading an electronic device, characterized in that: The method is applied to a server and includes: Determining compression parameters based on the memory capacity of the electronic device; Compressing the upgrade data of the electronic device according to the compression parameter to obtain an upgrade package; The upgrade package is sent to the electronic device, where the upgrade package is used for the electronic device to complete the upgrade.
2. The method according to claim 1, characterized in that The compression parameters include a window size and a hash chain length, and the step of determining the compression parameters according to the memory capacity of the electronic device includes: When the memory capacity is greater than the first capacity value, the window size is determined as the first window size, and the hash chain length is determined as the first length; When the memory capacity is less than or equal to the first capacity value and greater than the second capacity value, the window size is determined as the second window size, and the hash chain length is determined as the second length; When the memory capacity is less than or equal to the second capacity value and greater than a third capacity value, the window size is determined to be a third window size, and the hash chain length is determined to be a third length; The first window size is larger than the second window size, the second window size is larger than the third window size, the first length is larger than the second length, and the second length is larger than the third length.
3. The method according to claim 1, characterized in that The compression parameter includes a data block size, and determining the compression parameter according to the memory capacity of the electronic device includes: In a case where the memory capacity is greater than a first capacity value, determining the data block size to be a first value; When the memory capacity is less than or equal to the first capacity value and greater than the second capacity value, determining the data block size as a third value; When the memory capacity is less than or equal to the second capacity value and greater than the third capacity value, determining the data block size as a fifth value; The first value is greater than the third value, and the third value is greater than the fifth value.
4. The method according to claim 1, characterized in that: The compression parameter includes a decompression block size, and the step of determining the compression parameter according to the memory capacity of the electronic device includes: In a case where the memory capacity is greater than the first capacity value, determining the decompression block size to be a second value; When the memory capacity is less than or equal to the first capacity value and greater than the second capacity value, determining the decompression block size as a fourth value; When the memory capacity is less than or equal to the second capacity value and greater than the third capacity value, determining the decompression block size as a sixth value; The second value is greater than the fourth value, and the fourth value is greater than the sixth value.
5. The method according to claim 1, characterized in that The compression parameters include a window size, a hash chain length, and a data block size, and compressing the upgrade data of the electronic device according to the compression parameters to obtain an upgrade package includes: Divide the upgrade data into blocks according to the size of the data blocks to obtain multiple data blocks; Compressing at least part of the multiple data blocks according to the window size and the hash chain length to obtain multiple compressed data blocks; The multiple compressed data blocks are encapsulated to obtain the upgrade package.
6. The method according to claim 5, characterized in that The step of compressing at least part of the multiple data blocks according to the window size and the hash chain length to obtain multiple compressed data blocks includes: Determining a mirror type of a first mirror among the plurality of data blocks; Determine a dictionary size corresponding to the first image according to the image type; For any first data block in the first image, the first data block is compressed according to the window size, the hash chain length, and the dictionary size to obtain a first compressed data block.
7. The method according to claim 5, characterized in that The step of compressing at least part of the multiple data blocks according to the window size and the hash chain length to obtain multiple compressed data blocks includes: For any second data block corresponding to the replacement instruction among the multiple data blocks, when a data block size of the second data block is larger than a compressed data block size, compressing the second data block according to a first compression algorithm, wherein the compressed data block size is an estimated data block size after the second data block is compressed according to the first compression algorithm; In a case where the data block size of the second data block is less than or equal to the compressed data block size, the second data block is retained.
8. A method for upgrading an electronic device, characterized in that: The method is applied to an electronic device, comprising: Receive the upgrade package sent by the server; Determine the decompression block size corresponding to the upgrade package; Decompressing the data in the upgrade package into multiple decompressed data blocks according to the decompression block size; Each of the decompressed data blocks is written into the electronic device.
9. The method according to claim 8, characterized in that The electronic device comprises a writing thread and a decompression thread, and the step of writing each of the decompressed data blocks into the electronic device comprises: When the cache capacity in the electronic device is less than the capacity threshold, the decompression thread decompresses the upgrade package into a plurality of decompressed data blocks, and stores the plurality of decompressed data blocks in sequence into the cache of the electronic device; When the cache capacity reaches the capacity threshold, the decompression thread stops decompressing the upgrade package, the writing thread writes the decompressed data blocks in the cache to the electronic device, and clears the cache.
10. An upgrading device for an electronic device, characterized in that: include: A first determining module, used to determine a compression parameter according to a memory capacity of the electronic device; A compression module, used for compressing the upgrade data of the electronic device according to the compression parameter to obtain an upgrade package; The upgrade module is used to send the upgrade package to the electronic device, and the upgrade package is used to complete the upgrade of the electronic device.
11. An upgrading device for an electronic device, characterized in that: include: A first receiving module, used for receiving an upgrade package sent by a server; A second determining module, used to determine the decompressed block size corresponding to the upgrade package; A decompression module, used for decompressing the data in the upgrade package into multiple decompressed data blocks according to the decompression block size; A writing module is used to write each of the decompressed data blocks into the electronic device.
12. The device according to claim 11, characterized in that The writing module comprises: a decompression unit, configured to, when the cache capacity in the electronic device is less than a capacity threshold, decompress the upgrade package into a plurality of decompressed data blocks by the decompression thread, and store the plurality of decompressed data blocks in sequence in the cache of the electronic device; The writing unit is used for, when the cache capacity reaches the capacity threshold, the decompression thread stops decompressing the upgrade package, the writing thread writes the decompressed data blocks in the cache to the electronic device, and clears the cache.
13. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the method for upgrading the electronic device as described in any one of claims 1 to 9 are implemented.