Method for efficiently positioning initial address of data storage

By dividing the memory in the embedded system and using cyclic redundancy verification method, the data storage start address is quickly and stably positioned, and the problems of slow positioning speed and poor stability in the embedded system are solved, and efficient storage resource utilization and cost optimization are achieved.

CN120491891APending Publication Date: 2025-08-15JINCHENG NANJING ELECTROMECHANICAL HYDRAULIC PRESSURE ENG RES CENT AVIATION IND OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510537206.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-27
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

In embedded systems, it is difficult for the prior art to quickly and stably locate the data storage start address in nonvolatile memory, resulting in slow system response and memory vulnerability to corrupt.

Method used

The memory is divided into an address storage area and a data storage area, and the address data is stored using cyclic redundancy verification. The starting address is quickly positioned by finding the maximum value of the address data, optimize the utilization of storage resources, and reduce storage fragmentation.

Benefits of technology

It improves the speed and stability of the embedded system to quickly locate the data storage starting address, optimizes the storage space utilization, reduces storage costs, and adapts to changes in multiple storage architectures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120491891A_ABST
    Figure CN120491891A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of embedded software, and relates to a method for efficiently positioning a data storage initial address. Compared with a dichotomy method for searching the initial address of the memory, the method has the advantages that the speed of searching the initial address of the data storage is greatly increased by searching the maximum value of the address data, and in the method, the effectiveness and the stability of the method are improved by adding a data verification method. In addition, the method further facilitates optimization of utilization of storage resources, the initial address of data storage can be accurately found out through a partition mode, storage fragments are reduced, the utilization rate of storage space is improved, storage cost is reduced, and furthermore, the method has high adaptability and is suitable for various embedded external data storage architectures, and the method is suitable for popularization and application. And the storage structure and configuration can be conveniently adjusted and optimized according to the increase and change of the storage demand so as to adapt to the new storage demand, and the continuous stability and performance of the system are further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of embedded software and relates to a method for efficiently locating a data storage start address. Background Art

[0002] In embedded systems, data from the system's operations is periodically stored in non-volatile memory to analyze system performance during maintenance. When the system is powered back on, a significant amount of time is required to find the starting address of the periodic data storage, making it difficult to meet the requirements of systems with high response speeds. To avoid this problem and improve the system's response speed, the starting address of the next packet of periodic data is often stored at a fixed address in non-volatile memory. This address can then be read from the fixed address after each power-on, quickly locating the storage address of the periodic data. However, if only a single address is used and the same address is repeatedly read and written, it can easily damage the memory, making it impossible to read or write data. To improve system stability, a portion of the memory is used to cyclically store the starting address of the periodic data. This method significantly reduces the time required to query the starting address of the periodic data upon power-on and ensures storage stability. Summary of the Invention

[0003] Purpose of the Invention

[0004] This method provides a way for embedded software to search for the first address of memory storage. This method has a better search speed. The pointer is checked in this method, which reduces the time of storing the starting address of data during the power-on query cycle and ensures the stability of the method.

[0005] Technical Solution

[0006] A method for efficiently locating the starting address of data storage is disclosed. For an on-chip memory with a total storage capacity of 2M+N, the memory is divided into an address storage area and a data storage area. The address storage area is 2M in size, and the data storage area is N in size, with both M and N being positive integers. The data storage area stores the data to be stored, while the address storage area stores the address of the data storage area and cyclic redundancy check data for the corresponding address. When the memory is FLASH, the address storage area and the data storage area are divided into sectors. The address storage area alternately stores address data and check data, where the check data is the result of a cyclic redundancy check calculation for the address data. When the address data is updated, the check data is also updated synchronously and stored at the corresponding address.

[0007] Furthermore, the data to be stored is stored sequentially starting from the minimum address of the data storage area. When the data storage area is full, the data to be stored is stored again from the minimum address of the data storage area, overwriting the original data in the memory.

[0008] Furthermore, the data in the address storage area is stored from the minimum address. After the address storage area is full of data, the data to be stored is stored again from the minimum address in the address storage area, overwriting the original data in the memory.

[0009] Furthermore, the method is applicable to a single Nvm storage architecture, a single EEPROM storage architecture, an Nvm+Flash storage architecture, an EEPROM+Flash storage architecture or an Nvm+EEPROM storage architecture.

[0010] Furthermore, the length of the address storage area is much smaller than the length of the data storage area.

[0011] Furthermore, the verification method is a cyclic redundancy check.

[0012] Further, the specific steps are as follows:

[0013] (8) After the controller is powered on, it reads all the address data and check data in the address storage area, calculates the check value of each address data according to the cyclic redundancy check algorithm, and then compares the calculated check value with the check data in the memory. If the check passes, the address data is considered valid; (9) Calculate the maximum value AddrMax and the minimum value AddrMin of all valid address data, and record the address where the minimum value is located as PointStart.

[0014] (10) When the minimum value AddrMin of all valid address data is greater than the length N of the data storage area, all address data Addr in the address storage area need to be recalculated. n , the calculation method is:

[0015] Addr n = Addr n % N, formula (1)

[0016] Where N is the length of the data storage area.

[0017] And calculate the address data Addr according to the cyclic redundancy check algorithm n Check value Check n Finally, the address data Addr n Check and verify data n Write to the original address to complete the update of all data in the address storage area.

[0018] (11) When there is data to be stored, a packet of data is written to the controller each time. The number of packets is a, and the maximum value of a should not be greater than N / 2. The address to be written is AddrStart, and the calculation method is:

[0019] AddrStart= AddrMax %N formula (2)

[0020] Where N is the length of the data storage area.

[0021] (12) Update AddrMax=AddrMax+a, and calculate the cyclic redundancy check value of the updated AddrMax as AddrMaxCheck, and store AddrMax and AddrMaxCheck in the PointStart address and PointStart+1 address of the address storage area respectively.

[0022] (13) Update PointStart = (PointStart + 2) % 2M + BaseAddr, where is the base address of the address storage area;

[0023] (14) When AddrMax is greater than or equal to twice the length of the data storage area, that is, AddrMax>

[0024] 2*N, recalculate all address data in the address storage area Addr n , n is the serial number of the address data, n = 1-M, the calculation method is the same as formula 2 in step (4), and the address data Addr is calculated according to the cyclic redundancy check algorithm n Check value Check n Finally, the address data Addr n Check and verify data n Store it in the original address and complete the update of all data in the address storage area.

[0025] (15) Repeat steps (4) to (7) until the controller is powered off.

[0026] The beneficial effects of this application are:

[0027] The present invention provides a method for quickly finding the starting address of periodically stored data in an external memory of an embedded system. Compared to searching for the starting address of a memory using a binary search method, the method greatly improves the speed of finding the first address of data storage by searching for the maximum value of address data. In addition, the method improves the effectiveness and stability of the method by adding a data verification method. In addition, the method also helps to optimize the utilization of storage resources. By partitioning, the starting address of data storage can be accurately found, reducing storage fragmentation, improving the utilization rate of storage space, and reducing storage costs. Furthermore, the method has strong adaptability and is applicable to a variety of embedded external data storage architectures. In addition, the method can conveniently adjust and optimize the storage structure and configuration according to the growth and changes in storage requirements to adapt to new storage requirements, further improving the system's sustained stability and performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 A schematic diagram for allocating memory space;

[0029] Figure 2 It is a flow chart of the present invention. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical solutions and advantages of the implementation of the present invention clearer, the technical solutions in the embodiments of the present invention will be described in more detail below in conjunction with the embodiments of the present invention. In the examples, the same or similar reference numerals throughout represent the same or similar originals or elements with the same or similar functions. The described embodiments are part of the embodiments of the present invention, not all of the embodiments. The embodiments described below by reference are illustrative and intended to be used to explain the present invention, and should not be understood as limiting the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. The following is a detailed description in conjunction with the embodiments of the present invention.

[0031] The method for efficiently locating a data storage address comprises the following steps:

[0032] Step 1: The embedded controller is powered on and reads the data in the pointer area and verifies it, and calculates the maximum and minimum values of the verified data;

[0033] Step 2: Check the maximum value of the correct data and perform a modulo operation on the length of the data area (NM). The result is the starting address of the controller for periodic storage.

[0034] Step 3: When the minimum value of the correct data is greater than the length of the data area (NM), perform a modulo operation on all the correct data in the pointer area and store the result in the original address;

[0035] Step 4: When the controller runs periodically, the storage mode of the pointer area is set to a circular queue, and the maximum value of the correct data is checked to be at the end of the queue;

[0036] Step 5: The starting address of the controller periodically stores data as the modulo of the maximum value in the circular queue and the length of the data area (NM).

[0037] Step 6: After the controller has stored a packet of data, it updates the maximum value in the circular queue, which is the maximum value in the current circular queue plus the length of a packet of data;

[0038] Step 7: When the updated maximum value is greater than or equal to (2*(NM)-1), the updated maximum value and all the correctly verified data in the circular queue are modulo the data area length (NM), and the result is stored in the original address.

[0039] Step 8: Write the updated maximum value to the head of the circular queue.

[0040] Example

[0041] Assuming the external memory's address range is 0-1023, with 0-999 as the data storage area, the data storage area length N = 1000. For periodic data storage, 1000-1023 is the address storage area, with a length of 2M = 24, and the base address BaseAddr is 1000. This is the starting address of periodic data storage. Assuming the periodic data packet length is 8, the address storage area data is as follows:

[0042]

[0043]

[0044] The specific steps to find it are as follows:

[0045] Step 1: Read the values of addresses 1-8 and check the values of 1-8. The values of addresses 1-8 are 65599, 65615, 65631, 65503, 65519, 65535, 65551, and 65567 respectively. The values of checksums 1-8 are 5571, 20666, 55904, 21448, 49056, 13833, 48339, 13690, 47430, 12527, 47669, and 13212.

[0046] Step 2: Calculate the checksums of 65599, 65615, 65631, 65503, 65519, 65535, 65551, and 65567 using the CRC16 algorithm, which are 55571, 20666, 55904, 2144,9, 49056, 13833, 48339, 13690, 47430, 12527, 47669, and 13212, respectively.

[0047] Step 3: Compare the calculated check value with the read check value. The read check value of 4 is 21449, which is inconsistent with the calculated 21448. Therefore, the data of address 4 is not accepted.

[0048] Step 4: Calculate the maximum and minimum values of the data at addresses 1-3 and addresses 5-8. The maximum value AddrMax is 1047, and the minimum value AddrMin is 967. The address PointStart corresponding to the minimum value AddrMin is 1008.

[0049] Step 5: After entering the cycle, when a packet of data needs to be stored, the storage start address AddrStart is 1047%1000=47, that is, the packet of data is stored starting from the data storage area address 47.

[0050] Step 6: Update the maximum address value AddrMax to 1047+8=1055, and calculate the CRC16 checksum of AddrMax to 21449.

[0051] Step 7: Store 1055 into the PointStart address 1008 of the address data area, and store 21449 into the PointStart+1 address 1009 of the address data area.

[0052] Step 8: Update PointStart to (1008+2)%+1000=1010,

[0053] Step 9: Repeat steps 5-8.

[0054] In addition, unless otherwise defined, the technical or scientific terms used in the description of this application should have the ordinary meanings understood by those of ordinary skill in the art to which this application belongs. The words "upper," "lower," "left," "right," "center," "vertical," "horizontal," "inner," and "outer" used in the description of this application are only used to indicate relative directions or positional relationships, and do not imply that the device or component must have a specific orientation, be constructed, or operate in a specific orientation. When the absolute position of the described object changes, its relative positional relationship may also change accordingly. Therefore, they should not be understood as limitations on this application. The words "first," "second," "third," and similar terms used in the description of this application are used only for descriptive purposes to distinguish different components and should not be understood to indicate or imply relative importance. The words "one," "an," or "the" used in the description of this application should not be understood as absolute limitations on quantity, but should be understood as meaning the presence of at least one. The words "include" or "comprises" used in the description of this application mean that the element or object listed before the word includes the elements or objects listed after the word and their equivalents, but does not exclude other elements or objects.

[0055] In addition, it should be noted that, unless otherwise clearly stipulated and limited, the words "install", "connect", "connect" and similar terms used in the description of this application should be understood in a broad sense. For example, the connection can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, an indirect connection through an intermediate medium, or a connection between two components. Technical personnel in the field can understand their specific meanings in this application according to the specific circumstances.

[0056] The above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Within the spirit and principles of the present invention, any technician familiar with the profession may use the technical content disclosed above to change or modify it into an equivalent embodiment with equivalent changes and apply it to other fields. However, any simple modification, equivalent change and modification made to the above embodiment based on the technical essence of the present invention without departing from the content of the technical solution of the present invention, any modification, equivalent replacement, improvement, etc. made should be included in the scope of protection of the present invention.

Claims

1. A method for efficiently locating the starting address of data storage, characterized in that: For an on-chip memory with a total storage capacity of 2M+N, it is divided into an address storage area and a data storage area, where the size of the address storage area is 2M, the size of the data storage area is N, and the values of M and N are both positive integers; the data storage area stores the data to be stored, and the address storage area stores the address of the data storage area and the cyclic redundancy check data of the corresponding address; when the memory is FLASH, the address storage area and the data storage area are divided according to sectors; the address data and the check data are stored alternately in the address storage area, where the check data is the cyclic redundancy check calculation result of the address data, and when the address data is updated, the check data is also updated synchronously and stored in the corresponding address at the same time.

2. The method according to claim 1, wherein The data to be stored is stored in sequence starting from the minimum address of the data storage area. When the data storage area is full, the data to be stored is stored again from the minimum address of the data storage area, overwriting the original data in the memory.

3. The method according to claim 1, wherein The data in the address storage area is stored from the minimum address. After the data in the address storage area is full, the data to be stored is stored again from the minimum address in the address storage area, overwriting the original data in the memory.

4. The method according to claim 1, wherein The method is applicable to a single Nvm storage architecture, a single EEPROM storage architecture, an Nvm+Flash storage architecture, an EEPROM+Flash storage architecture or an Nvm+EEPROM storage architecture.

5. The method according to claim 1, wherein The length of the address storage area is much smaller than the length of the data storage area.

6. The method according to claim 1, wherein The verification method is cyclic redundancy check.

7. The method according to claim 1, wherein The specific steps are as follows: (1) After the controller is powered on, it reads all the address data and check data in the address storage area, calculates the check value of each address data according to the cyclic redundancy check algorithm, and then compares the calculated check value with the check data in the memory. If the check passes, the address data is considered valid; (2) Calculate the maximum value AddrMax and the minimum value AddrMin of all valid address data, and record the address of the minimum value as PointStart; (3) When the minimum value AddrMin of all valid address data is greater than the length N of the data storage area, all address data Addr in the address storage area need to be recalculated. n , the calculation method is: Addr n = Addr n % N, Formula (1) Where N is the length of the data storage area; And calculate the address data Addr according to the cyclic redundancy check algorithm n Check value Check n Finally, the address data Addr n Check and verify data n Write to the original address to complete the update of all data in the address storage area; (4) When there is data to be stored, a packet of data is written to the controller each time. The number of packets is a, and the maximum value of a should not be greater than N / 2. The address to be written is AddrStart, and the calculation method is: AddrStart= AddrMax %N formula (2) Where N is the length of the data storage area; (5) Update AddrMax = AddrMax + a, calculate the cyclic redundancy check value of the updated AddrMax as AddrMaxCheck, and store AddrMax and AddrMaxCheck in the PointStart address and PointStart+1 address of the address storage area respectively; (6) Update PointStart = (PointStart + 2) % 2M + BaseAddr, where is the base address of the address storage area; (7) When AddrMax is greater than or equal to twice the length of the data storage area, that is, AddrMax>2*N, all address data in the address storage area are recalculated. n , n is the serial number of the address data, n = 1-M, the calculation method is the same as formula 2 in step (4), and the address data Addr is calculated according to the cyclic redundancy check algorithm n Check value Check n Finally, the address data Addr n Check and verify data n Store it in the original address and complete the update of all data in the address storage area.

8. The method according to claim 7, wherein The method further includes (8), looping through steps (4) to (7) until the controller is powered off.