A method, system, device, and medium for optimizing terminal memory.
By creating a sector mapping table and parsing differential upgrade packages, the firmware storage location was adjusted, solving the problem of wasted memory resources on embedded platforms, achieving dynamic memory optimization, and improving upgrade efficiency and resource utilization.
Patent Information
- Application Number
- CN202210867503.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-22
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2042-07-22
AI Technical Summary
On resource-constrained embedded platforms, traditional memory optimization methods cannot achieve dynamic ROM optimization during firmware differential upgrades, resulting in resource waste, large OTA package size, slow upgrade speed, and high power consumption.
By creating a linked list as a sector mapping table, the differential upgrade package is parsed, firmware information is obtained, storage location is adjusted, fragmented space is released, and dynamic memory optimization is achieved.
Significantly reduces OTA package size, speeds up upgrades, reduces energy consumption, saves communication resources, and meets the memory optimization requirements of embedded platforms.
Smart Images

Figure CN115017062B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of smart warehousing technology, specifically relating to a method, system, device, and medium for optimizing terminal memory. Background Technology
[0002] In recent years, with the advancement of communication technology, the Internet of Things (IoT) has become a trend. Among the numerous networking application needs, over 95% are based on narrowband IoT, such as the traditional GPRS method and the currently popular NB-IoT technology.
[0003] Devices used in narrowband applications are often resource-constrained, with limited computing power, program execution space, and storage space. However, as application services change, the corresponding software programs of these devices need to be updated, which is commonly referred to as OTA (Over-The-Air). This is incompatible with narrowband network transmission. Therefore, the demand for differential packet OTA is very obvious in this type of application. It can significantly reduce the OTA packet size, speed up the upgrade, reduce energy consumption, and save communication resources. In addition, because there is no operating system scheduling in firmware storage, traditional memory optimization methods cannot be used on resource-constrained embedded platforms. Dynamic ROM optimization cannot be achieved during firmware differential upgrades. The firmware can only be stored at a fixed address and cannot be automatically adjusted according to the program size, resulting in resource waste in the limited ROM. Summary of the Invention
[0004] To address the problems existing in the prior art, this invention provides a method, system, device, and medium for optimizing terminal memory. By parsing the firmware information carried in the differential upgrade package, the size of the updated firmware package is obtained. Then, based on the firmware package size and ROM space information, the storage location of the firmware package is adjusted to release fragmented space, thereby achieving dynamic memory optimization.
[0005] This invention is achieved through the following technical solution:
[0006] A method for optimizing terminal memory includes the following steps:
[0007] S1: Create a linked list as a sector mapping table, start a timer task, and calculate the initial memory space usage;
[0008] S2: Parse the received differential packets to obtain upgrade patch information;
[0009] S3: Enter the patch information into the mapping table, read the upgrade patch information through the U8 type array and integrate it with the corresponding firmware information, verify the integrated information with the mapping table, if the patch information in the mapping table is consistent with the integrated information, then write the upgrade patch; otherwise, do not write the upgrade patch.
[0010] S4: Update the upgrade patch information in the mapping table and release the upgrade patch information entered into the mapping table to complete the terminal memory optimization.
[0011] Furthermore, in step S1, the mapping table reads the information of the storage device by starting the system, and then obtains the capacity of the device through this information. The capacity, device number, used space, and base address and offset address of each sector are encapsulated into a doubly linked list. By managing the linked list nodes and offset addresses, a mapping table of the physical space and program space of the storage is obtained.
[0012] Furthermore, the mapping table in step S1 is used to store the initial internal partition information and file storage information of the system.
[0013] Furthermore, the initial memory space usage in step S1 includes the total size of the initial memory space, the size of the used space, and the size of the remaining space.
[0014] Furthermore, the upgrade patch information in step S2 includes the upgrade patch, the size of the upgrade firmware, and the version of the firmware package.
[0015] Furthermore, in step S3, the upgrade patch information read from the U8 type array is the upgrade firmware information. The upgrade firmware information read from the U8 type array is added to the upgrade patch data and then compared with the patch information in the mapping table.
[0016] Furthermore, in step S3, the upgrade patch is written to the storage address of the firmware.
[0017] A terminal memory optimization system, including
[0018] The mapping table acquisition module is used to create a linked list as a sector mapping table, start a timer task, and calculate the initial memory space usage.
[0019] The upgrade patch information acquisition module is used to parse the received differential packets to obtain upgrade patch information;
[0020] The firmware upgrade module is used to input patch information into the mapping table, read upgrade patch information through a U8 type array, and verify it with the mapping table. If the patch information in the mapping table is consistent with the upgrade patch information read from the U8 type array, the upgrade patch is written.
[0021] The mapping table update module writes upgrade patch information into the mapping table and releases the upgrade patch information entered into the mapping table, thus completing terminal memory optimization.
[0022] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements steps such as a terminal memory optimization method.
[0023] A computer-readable storage medium storing a computer program that, when executed by a processor, implements steps such as those of a terminal memory optimization method.
[0024] Compared with the prior art, the present invention has the following beneficial technical effects:
[0025] This invention provides a method, system, device, and medium for optimizing terminal memory. The method involves creating a linked list as a sector mapping table, starting a timer task, and calculating initial memory space usage. Received differential packets are parsed to obtain upgrade patch information. The patch information is entered into the mapping table. The upgrade patch information is read using a U8 type array and integrated with the corresponding firmware information. The integrated information is verified against the mapping table. If the patch information in the mapping table matches the integrated information, the upgrade patch is written; otherwise, it is not written. The upgrade patch information is updated in the mapping table, and the information entered into the mapping table is released, thus completing the terminal memory optimization. This application, by comparing upgrade package differences and transmitting only the differences, integrates them with the original firmware information, thereby significantly reducing the OTA packet size, accelerating the upgrade speed, reducing energy consumption, saving communication resources, and meeting the requirements for use on embedded platforms. Attached Figure Description
[0026] Figure 1 This is a flowchart of a terminal memory optimization method according to the present invention. Detailed Implementation
[0027] The present invention will be further described in detail below with reference to specific embodiments. These descriptions are for explanation purposes only and are not intended to limit the scope of the invention.
[0028] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0030] This invention provides
[0031] A method for optimizing terminal memory, characterized by comprising the following steps:
[0032] S1: Create a linked list as a sector mapping table, start a timer task, and calculate the initial memory space usage;
[0033] S2: Parse the received differential packets to obtain upgrade patch information;
[0034] S3: Enter the patch information into the mapping table, read the upgrade patch information through the U8 type array and integrate it with the corresponding firmware information, verify the integrated information with the mapping table, if the patch information in the mapping table is consistent with the integrated information, then write the upgrade patch; otherwise, do not write the upgrade patch.
[0035] S4: Update the upgrade patch information in the mapping table and release the upgrade patch information entered into the mapping table to complete the terminal memory optimization.
[0036] Preferably, in step S1, the mapping table is created by reading the storage device information upon system startup, obtaining the device capacity from this information, and encapsulating the capacity, device number, used space, and base and offset addresses of each sector into a doubly linked list. By managing the linked list nodes and offset addresses, a mapping table between the physical storage space and the program space is obtained. Further, the mapping table in step S1 is used to store the initial internal system partition information and file storage information. Further, the initial memory space usage in step S1 includes the total size of the initial memory space, the size of the used space, and the size of the remaining space.
[0037] Preferably, the upgrade patch information in step S2 includes the upgrade patch, the size of the upgrade firmware, and the version of the firmware package. Further, the upgrade patch information read from the U8 type array in step S3 is the upgrade firmware information; the upgrade firmware information read from the U8 type array is added to the upgrade patch data, and then compared with the patch information in the mapping table.
[0038] Preferably, in step S3, the upgrade patch is written to a specific firmware storage address based on the mapping table information.
[0039] This invention provides a preferred embodiment in which, after system startup, a linked list is created as a sector mapping table to store the current system's internal partition information and file storage information. First, a timer task is started to obtain and calculate the current total memory space size Rom_Len, the used space size Used_Len, and the remaining space size Remaining_Len. Then, a message receiving task is started to allocate heap memory Bin_Buff to store received data. Upon receiving an upgrade differential packet, the differential packet is parsed to obtain the upgrade patch UpData_Patch, the upgrade firmware size New_Bin_Len, and the firmware package version Bin_Ver. The system first performs a dynamic optimization of the upgrade process. Then, it retrieves the current firmware storage address and its size (Bin_Len) from the mapping table. It uses a U8 type array to read the firmware data and adds it to the upgrade patch data to obtain the new firmware size (Calculate_Bin_Len). If Calculate_Bin_Len is equal to the upgrade firmware size (New_Bin_Len), the upgrade verification passes. Next, it writes the new firmware package to the firmware storage address (New_Bin_Adder). After storage, it saves the updated firmware address and size to the mapping table and clears the cache space, releasing the occupied nodes in the mapping table, thus completing the dynamic optimization of the upgrade process.
[0040] Another preferred embodiment of the present invention is as follows:
[0041] A1: Read storage information, create mapping table, and enter upgrade state;
[0042] A2: Start a timer task to periodically retrieve memory information;
[0043] A3: The device to be upgraded receives the command and enters the upgrade state;
[0044] A4: Get the total ROM space size Rom_Len, used space size Used_Len, and firmware size to be upgraded Bin_Len from the mapping table;
[0045] A5: Calculate the remaining ROM space size Remaining_Len;
[0046] A6: Allocate a new heap memory Rev_Buff to store the received differential upgrade package;
[0047] A7: Parse the differential upgrade package to obtain the upgrade patch UpData_Patch, the size of the upgrade firmware New_Bin_Len, and the firmware package version Bin_Version;
[0048] A8: Request a new heap space Bin_Buff and copy the firmware to be upgraded into Bin_Buff;
[0049] A9: Apply the UpData_Patch to the firmware to be upgraded in Bin_Buff, generate the new firmware, and calculate the length of the new firmware: Calculate_Bin_Len.
[0050] A10: By comparing the new firmware size New_Bin_Len, the firmware size to be upgraded Bin_Len, and the used Used_Len, the storage address New_Bin_Adder of the new firmware is calculated.
[0051] A11: Compare the newly generated firmware length Calculate_Bin_Len with the upgrade firmware size New_Bin_Len to verify the new firmware;
[0052] A12: Copy the new firmware in Bin_Buff after verification to the new firmware storage address New_Bin_Adder, with a copy length of New_Bin_Len.
[0053] A13: Release the allocated heap space Bin_Buff, Rev_Buff;
[0054] A14: Calculate the new ROM used space New_Used_Len and the new remaining ROM space New_Remaining_Len;
[0055] A15: Update the mapping table with the new ROM used space New_Used_Len and the new remaining ROM space size New_Remaining_Len.
[0056] This invention provides a system for optimizing terminal memory, including...
[0057] The mapping table acquisition module is used to create a linked list as a sector mapping table, start a timer task, and calculate the initial memory space usage.
[0058] The upgrade patch information acquisition module is used to parse the received differential packets to obtain upgrade patch information;
[0059] The firmware upgrade module is used to input patch information into the mapping table, read upgrade patch information through a U8 type array, and verify it with the mapping table. If the patch information in the mapping table is consistent with the upgrade patch information read from the U8 type array, the upgrade patch is written.
[0060] The mapping table update module writes upgrade patch information into the mapping table and releases the upgrade patch information entered into the mapping table, thus completing terminal memory optimization.
[0061] In another embodiment of the present invention, a computer device is provided, comprising a processor and a memory. The memory stores a computer program, which includes program instructions. The processor executes the program instructions stored in the computer storage medium. The processor may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. It is the computing and control core of the terminal, suitable for implementing one or more instructions, specifically suitable for loading and executing one or more instructions from the computer storage medium to achieve a corresponding method flow or corresponding function. The processor described in this embodiment of the present invention can be used in the operation of a terminal memory optimization method.
[0062] In another embodiment of the present invention, a storage medium is provided, specifically a computer-readable storage medium (Memory), which is a memory device in a computer device used to store programs and data. It is understood that the computer-readable storage medium here can include both the built-in storage medium in the computer device and extended storage media supported by the computer device. The computer-readable storage medium provides storage space that stores the terminal's operating system. Furthermore, the storage space also stores one or more instructions suitable for loading and execution by a processor. These instructions can be one or more computer programs (including program code). It should be noted that the computer-readable storage medium here can be high-speed RAM or non-volatile memory, such as at least one disk storage device. The processor can load and execute one or more instructions stored in the computer-readable storage medium to implement the corresponding steps of the terminal memory optimization method in the above embodiments.
[0063] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0064] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0065] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0066] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0067] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for terminal memory optimization, the method comprising: The method comprises the following steps: S1: creating a linked list as a mapping table of sectors, starting a timer task, and calculating initial memory space usage; The mapping table is obtained by starting the system to read the information of the storage device, then obtaining the capacity of the device through the information, encapsulating the capacity, device number, used space, and sector base address and offset address into a double-linked list summary, and obtaining the mapping table of the stored physical space and program space through the management of the linked list node and offset address; The mapping table is used to save the initial partition information and file storage information in the system; S2: parsing the received differential package to obtain upgrade patch information; S3: recording the patch information in the mapping table, reading the upgrade patch information through a U8 type array, integrating the upgrade patch information with the corresponding firmware information, checking the integrated information with the mapping table, and writing the upgrade patch if the patch information in the mapping table is consistent with the integrated information, otherwise not writing the upgrade patch; S4: updating the mapping table to write the upgrade patch information, and releasing the recorded upgrade patch information in the mapping table, thereby completing the terminal memory optimization.
2. The method of claim 1, wherein, The initial memory space usage in the step S1 includes the total size of the initial memory space, the size of the used space, and the size of the remaining space.
3. The method of claim 1, wherein, The upgrade patch information in the step S2 includes the upgrade patch, the size of the upgrade firmware, and the version of the firmware package.
4. The method of claim 3, wherein, The upgrade patch information read by the U8 type array in the step S3 is the upgrade firmware information, and the upgrade firmware information read by the U8 type array is compared with the patch information in the mapping table after being added with the data of the upgrade patch.
5. The method of claim 1, wherein, The upgrade patch is written to the storage address of the firmware in the step S3.
6. A system for terminal memory optimization, characterized by The method for optimizing the memory of a terminal according to any one of claims 1-5 comprises a mapping table obtaining module configured to create a linked list as a mapping table of sectors, start a timer task, and calculate initial memory space usage; The mapping table is obtained by starting the system to read the information of the storage device, then obtaining the capacity of the device through the information, encapsulating the capacity, device number, used space, and sector base address and offset address into a double-linked list summary, and obtaining the mapping table of the stored physical space and program space through the management of the linked list node and offset address; The mapping table is used to save the initial partition information and file storage information in the system; an upgrade patch information obtaining module configured to parse the received differential package to obtain upgrade patch information; a firmware upgrade module configured to record the patch information in the mapping table, read the upgrade patch information through a U8 type array, and check the mapping table, and write the upgrade patch if the patch information in the mapping table is consistent with the upgrade patch information read by the U8 type array; a mapping table updating module configured to update the mapping table to write the upgrade patch information, and release the recorded upgrade patch information in the mapping table, thereby completing the terminal memory optimization.
7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor implements the steps of the method for optimizing the memory of a terminal according to any one of claims 1-5 when executing the computer program.
8. A computer-readable storage medium storing a computer program, the computer-readable storage medium comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 7. The computer program implements the steps of the method for optimizing the memory of a terminal according to any one of claims 1-5 when executed by the processor.
Citation Information
Patent Citations
Firmware updating method and device
CN107194242A
Method, device, equipment and medium for processing mapping table item
CN108491335A
Differential packet generation method, differential packet generation equipment and upgrading method
CN113721967A