A TWS device and its log storage and reading method, device and medium
By dividing non-Flash and non-RAM target storage spaces in TWS devices, storing log data and recording address information, the problem of log saving and reading in devices with limited resources is solved, minimizing memory usage and reducing hardware costs. .
Patent Information
- Application Number
- CN202110858024.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-28
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-07-28
AI Technical Summary
In TWS devices, it is difficult for existing technologies to effectively save offline logs without increasing the size of the executable file, especially in small embedded systems with limited resources.
By dividing the target storage space in non-Flash and non-RAM address segments, the log data of the TWS device is stored, and the address information of the target storage space is recorded in Flash to avoid log data from increasing the size of the executable file. The specific method includes dividing the target storage space in the high-order address segment of the ELF file, storing the log data, and reading the log from the target storage space based on the address information when reading the log.
It effectively reduces memory usage, avoids the increase of executable files, reserves storage space for more business logic codes, and reduces hardware requirement costs.
Smart Images

Figure CN113568872B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic technology, and in particular to a TWS device and a log storage and reading method, device and computer-readable storage medium thereof. Background Art
[0002] In recent years, TWS (True Wireless Stereo) products have become increasingly popular, and the product variety has become increasingly rich.
[0003] Take TWS earphones as an example. As earphones are required to be equipped with more and more powerful functions and the systems are becoming more and more complex, the debugging work performed by earphone developers is becoming more and more important. Usually, the debugging method of earphones adopts the method of printing logs through the serial port. When the earphones have been assembled into a whole machine without a serial port, it is required to save the log (usually called offline log at this time).
[0004] There are many ways to implement offline logs. Considering the limited resources of small embedded systems such as headphones, it is generally not recommended to save logs by directly saving strings. The usual practice is to use the property of string constants in the computer's compilation principle that they are located at the Text end. Because the string is already in the executable file, when printing the log, you only need to save the corresponding string address. After exporting the log, use the saved address to reverse search in the executable file to find the corresponding log information.
[0005] However, since the compiler will put the log information into the executable file by default in this method, the size of the executable file will increase. If there is a lot of log information, the executable file will become very large. In view of this, providing a solution to the above technical problem has become an urgent concern for those skilled in the art. Summary of the invention
[0006] The purpose of the present application is to provide a TWS device and a log saving and reading method, apparatus and computer-readable storage medium thereof, so as to effectively save offline logs without occupying executable files.
[0007] In order to solve the above technical problems, on the one hand, the present application discloses a log storage method in a TWS device, comprising:
[0008] Determine a target storage space, where the target storage space is located in a non-Flash and non-RAM address segment;
[0009] Save the log of the TWS device to the target storage space;
[0010] The address information of the target storage space is stored in the log storage area of the Flash.
[0011] Optionally, determining the target storage space includes:
[0012] A segment of addresses is divided out in the storage space of the ELF file as the target storage space.
[0013] Optionally, the step of dividing an address segment in the storage space of the ELF file as the target storage space includes:
[0014] A high-order address segment is divided out from the storage space of the ELF file as the target storage space.
[0015] Optionally, saving the log of the TWS device to the target storage space includes:
[0016] Extract the string in the log of the TWS device;
[0017] The character string is saved in the target storage space.
[0018] On the other hand, the present application also discloses a log storage device in a TWS device, comprising:
[0019] A determination module, used for determining a target storage space, wherein the target storage space is located in a non-Flash and non-RAM address segment;
[0020] A saving module, used for saving the log of the TWS device to the target storage space;
[0021] The recording module is used to store the address information of the target storage space in the log storage area of the Flash.
[0022] Optionally, when determining the target storage space, the determining module is specifically configured to:
[0023] A segment of addresses is divided out in the storage space of the ELF file as the target storage space.
[0024] Optionally, when the determining module divides an address segment in the storage space of the ELF file as the target storage space, it is specifically used to:
[0025] A high-order address segment is divided out from the storage space of the ELF file as the target storage space.
[0026] Optionally, when the saving module saves the log of the TWS device to the target storage space, it is specifically used to:
[0027] Extract a character string from the log of the TWS device; and save the character string to the target storage space.
[0028] In another aspect, the present application discloses a log reading method in a TWS device, comprising:
[0029] Read the data in the log storage area in the Flash of the TWS device;
[0030] Reading address information of a target storage space of each log from the data one by one; the target storage space is located in a non-Flash and non-RAM address segment;
[0031] The log of the TWS device is read from the target storage space according to the address information.
[0032] Optionally, the target storage space is specifically an address segment in the storage space of the ELF file.
[0033] Optionally, the target storage space is specifically a high-order address segment in the storage space of the ELF file.
[0034] Optionally, the target storage space is specifically used to store character strings in the log of the TWS product.
[0035] On the other hand, the present application also discloses a log reading device in a TWS device, comprising:
[0036] A reading module, used to read the data in the log storage area in the Flash of the TWS device;
[0037] An acquisition module, used for acquiring address information of a target storage space of each log from the data one by one; the target storage space is located in a non-Flash and non-RAM address segment;
[0038] A parsing module is used to read the log of the TWS device from the target storage space according to the address information.
[0039] On the other hand, the present application also discloses a TWS device, including:
[0040] Memory for storing computer programs;
[0041] A processor is used to execute the computer program to implement the steps of the log saving method in any TWS device as described above, or to implement the steps of the log reading method in any TWS device as described above.
[0042] On the other hand, the present application also discloses a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it is used to implement the steps of the log saving method in any one of the TWS devices described above, or to implement the steps of the log reading method in any one of the TWS devices described above.
[0043] The TWS device and its log saving and reading method, device and computer-readable storage medium provided by the present application have the following beneficial effects: the present application stores the log data in a non-Flash and non-RAM target storage space in advance, and according to the address information of the target storage space recorded in the log saving area in the Flash, the target storage space can be found to obtain the log data, which effectively avoids the increase of the executable file due to the log data, realizes the saving and reading of offline logs in a way that minimizes the memory usage, reserves the storage space for more useful business logic codes, and reduces the hardware requirement cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the prior art and the embodiments of the present application, the drawings required for use in the description of the prior art and the embodiments of the present application are briefly introduced below. Of course, the drawings described below in relation to the embodiments of the present application are only part of the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without creative work, and the obtained other drawings also belong to the protection scope of the present application.
[0045] Figure 1 It is a schematic diagram of a log storage method in a TWS device in the prior art;
[0046] Figure 2 This is a flow chart of a log saving method in a TWS device disclosed in an embodiment of the present application;
[0047] Figure 3 A schematic diagram of a log storage method in a TWS device disclosed in an embodiment of the present application;
[0048] Figure 4 A structural block diagram of a log storage device in a TWS device disclosed in an embodiment of the present application;
[0049] Figure 5 This is a flow chart of a log reading method in a TWS device disclosed in an embodiment of the present application;
[0050] Figure 6 This is a structural block diagram of a log reading device in a TWS device disclosed in an embodiment of the present application;
[0051] Figure 7 This is a structural block diagram of a TWS device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0052] The core of this application is to provide a TWS device and its log saving and reading method, device and computer-readable storage medium, so as to effectively save offline logs without occupying executable files.
[0053] In order to describe the technical solutions in the embodiments of the present application more clearly and completely, the technical solutions in the embodiments of the present application will be introduced below in conjunction with the drawings in the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0054] Currently, for small embedded TWS devices such as TWS (True Wireless Stereo) headphones, the offline log implementation method commonly used can be found in Figure 1 . Using the property that strings are often located at the Text end in the computer's compilation principle, the log string is stored in the executable file. When printing the log, you only need to save the corresponding string address. After exporting the log, use the saved address to reverse search in the executable file to find the corresponding log information.
[0055] like Figure 1 As shown, the shaded part in the executable file area (marked with "This is log") stores the log string. In the log storage area below, the storage address of the log string, namely log_address, is stored. In this way, when there is a lot of log information, the executable file will become lengthy and large, occupying too much Flash resources, especially for small embedded systems with insufficient Flash resources. In view of this, the present application provides a log storage solution in a TWS device, which can effectively solve the above problems.
[0056] See also Figure 2 As shown, the embodiment of the present application discloses a log storage method in a TWS device, which mainly includes:
[0057] S101: Determine a target storage space, where the target storage space is located in a non-Flash and non-RAM address segment.
[0058] S102: Save the log of the TWS device to the target storage space.
[0059] S103: Storing address information of the target storage space in the log storage area of the Flash.
[0060] Specifically, the log storage method in the TWS device provided in the embodiment of the present application specifically divides a storage space in the TWS device in advance, called the target storage space, for storing the logs of the TWS device. It should be emphasized that the target storage space must not be located in the valid address space of the Flash and RAM of the TWS device.
[0061] Among them, Flash is mainly used to store executable files of TWS devices. When the TWS device is turned on, the system will automatically move relevant data from Flash to memory to initialize the operation. In order to avoid increasing the executable file due to the storage of log information, and thus prevent excessive Flash resources from being occupied, especially for TWS devices with insufficient Flash resources, this application specifically stores the logs of TWS devices in a non-Flash and non-RAM target storage space.
[0062] Of course, as for the size of the target storage space, those skilled in the art can reasonably set it according to the actual needs of the TWS device, and this application does not limit this.
[0063] Since devices such as TWS headphones are small in size and have limited resources, in order to reduce memory usage, this application stores log data in a non-Flash and non-RAM target storage space, and only stores the address information of the target storage space in the log storage area in Flash. Among them, the log storage area is a storage space pre-divided in Flash, dedicated to storing the storage address information of log data, that is, the address information of the target storage space.
[0064] Obviously, if only address information is stored, the space occupied is obviously much smaller than the space required for log data. In this way, this application can not only save offline logs, but also effectively reduce the memory resource occupation of TWS devices by log data, reserve storage space for more useful business logic codes, and reduce hardware requirements and costs.
[0065] It can be seen that the log saving method in the TWS device provided in the present application stores the log data in a target storage space that is neither Flash nor RAM. The log saving area in the Flash only needs to store the address information of the target storage space, which effectively avoids the increase in the executable file due to the log data. It realizes the preservation of offline logs in a way that minimizes memory usage, reserves storage space for more useful business logic codes, and reduces hardware requirements and costs.
[0066] As a specific embodiment, the log storage method in the TWS device provided in the embodiment of the present application determines the target storage space based on the above content, including:
[0067] A segment of address is divided in the storage space of the ELF file as the target storage space.
[0068] Specifically, the present embodiment utilizes the compiling principle of computer, and the daily log data is specifically placed in the ELF segment of appointment.That is, a section of address segment in the ELF segment is divided as the target storage space.Specifically, in conjunction with the characteristic of computer compiler and linker, it can be known that the data in the target storage space in the ELF segment can not be output to the executable file, therefore, the present embodiment specifically stores the daily log data in the target storage space in the ELF segment, can effectively avoid the executable file size that the daily log data causes to increase, and then reserves storage space for more useful business logic codes, and reduces the hardware requirement cost.
[0069] For details, please refer to Figure 3 , Figure 3 Schematic diagram of a log storage method in a TWS device disclosed in an embodiment of the present application. Figure 3 As shown in the figure, the log data is saved in the ELF segment, which is not Flash and RAM; the address of this address segment is written to the log saving area in Flash. In this way, when the computer is compiled, the log data is only retained in the ELF file, and will not be output to Flash to increase the size of the executable file.
[0070] As a specific embodiment, the log saving method in the TWS device provided in the embodiment of the present application is based on the above content, and divides an address segment in the storage space of the ELF file as the target storage space, including:
[0071] A high-order address segment is divided out of the storage space of the ELF file as the target storage space.
[0072] Specifically, when dividing the target storage space from the ELF segment to store log data, the high address segment of the ELF segment can be specifically selected, for example, 0Xffffff00 can be specifically selected. Of course, those skilled in the art can also select other specific address segments, and this application does not limit this.
[0073] As a specific embodiment, the log saving method in the TWS device provided in the embodiment of the present application saves the log of the TWS device to the target storage space on the basis of the above content, including:
[0074] Extract the string from the TWS device log;
[0075] Save the string to the target storage space.
[0076] Specifically, the data generally recorded in the log is a character string content, which is used to record the relevant operation activities of the TWS device, and the relevant parameters involved therein are generally dynamically assigned during the relevant operation process of the device.
[0077] See also Figure 4 As shown, the embodiment of the present application discloses a log storage device in a TWS device, which mainly includes:
[0078] A determination module 201 is used to determine a target storage space, where the target storage space is located in a non-Flash and non-RAM address segment;
[0079] A saving module 202 is used to save the log of the TWS device to the target storage space;
[0080] The recording module 203 is used to store the address information of the target storage space in the log storage area of the Flash.
[0081] It can be seen that the log saving device in the TWS device disclosed in the embodiment of the present application stores the log data in a target storage space that is neither Flash nor RAM. The log saving area in the Flash only needs to store the address information of the target storage space, which effectively avoids the increase in the executable file due to the log data, and realizes the preservation of offline logs in a manner that minimizes memory usage, thereby reserving storage space for more useful business logic codes and reducing hardware requirements and costs.
[0082] For the specific content of the log storage device in the above-mentioned TWS device, please refer to the aforementioned detailed introduction on the log storage method in the TWS device, which will not be repeated here.
[0083] As a specific embodiment, the log storage device in the TWS device disclosed in the embodiment of the present application is based on the above content, and the determination module 201 is specifically used to determine the target storage space:
[0084] A segment of address is divided in the storage space of the ELF file as the target storage space.
[0085] As a specific embodiment, the log storage device in the TWS device disclosed in the embodiment of the present application is specifically used for:
[0086] A high-order address segment is divided out of the storage space of the ELF file as the target storage space.
[0087] As a specific embodiment, the log saving device in the TWS device disclosed in the embodiment of the present application is based on the above content. When the saving module 202 saves the log of the TWS device to the target storage space, it is specifically used to:
[0088] Extract the string from the log of the TWS device; save the string to the target storage space.
[0089] See also Figure 5 As shown, the embodiment of the present application discloses a log reading method in a TWS device, which mainly includes:
[0090] S301: Read the data in the log storage area in the Flash of the TWS device.
[0091] S302: Read the address information of the target storage space of each log from the data one by one; the target storage space is located in a non-Flash and non-RAM address segment.
[0092] S303: Read the log of the TWS device from the target storage space according to the address information.
[0093] Specifically, the log reading method in the TWS device provided in this application corresponds to the aforementioned log saving method. After the log is saved according to the log saving method, when the log needs to be read, the data stored in the log saving area can be first exported from the headset according to steps S301 to S303, and then the address information of the target storage space corresponding to each log is read one by one, and the log data is obtained from the target storage space according to the address information.
[0094] As a specific embodiment, the log reading method in the TWS device disclosed in the embodiment of the present application is based on the above content, and the target storage space is specifically an address segment in the storage space of the ELF file.
[0095] As a specific embodiment, the log reading method in the TWS device disclosed in the embodiment of the present application is based on the above content, and the target storage space is specifically a high-order address segment in the storage space of the ELF file.
[0096] As a specific embodiment, the log reading method in the TWS device disclosed in the embodiment of the present application is based on the above content, and the target storage space is specifically used to store the character string in the log of the TWS product.
[0097] Furthermore, a corresponding parsing tool may be developed to lock a target storage space from an ELF file, so as to parse and obtain a string of a log from the ELF file.
[0098] It can be seen that the log reading method in the TWS device disclosed in the embodiment of the present application stores the log data in a non-Flash and non-RAM target storage space in advance. According to the address information of the target storage space recorded in the log saving area in the Flash, the target storage space can be found to obtain the log data, which effectively avoids the increase of the executable file due to the log data, and realizes the saving and reading of offline logs in a way that minimizes memory usage, effectively ensuring the operating performance of the TWS device.
[0099] See also Figure 6 As shown, the embodiment of the present application discloses another log reading device in a TWS device, which mainly includes:
[0100] The reading module 401 is used to read the data in the log storage area in the Flash of the TWS device;
[0101] The acquisition module 402 is used to acquire the address information of the target storage space of each log from the data one by one; the target storage space is located in the address segment of non-Flash and non-RAM;
[0102] The parsing module 403 is used to read the log of the TWS device from the target storage space according to the address information.
[0103] As a specific embodiment, the log reading device in the TWS device disclosed in the embodiment of the present application is based on the above content, and the target storage space is specifically an address segment in the storage space of the ELF file.
[0104] As a specific embodiment, the log reading device in the TWS device disclosed in the embodiment of the present application is based on the above content, and the target storage space is specifically a high-order address segment in the storage space of the ELF file.
[0105] As a specific embodiment, the log reading device in the TWS device disclosed in the embodiment of the present application is based on the above content, and the target storage space is specifically used to store the character strings in the log of the TWS product.
[0106] It can be seen that the log saving device in the TWS device disclosed in the embodiment of the present application stores the log data in a non-Flash and non-RAM target storage space in advance. According to the address information of the target storage space recorded in the log saving area in the Flash, the target storage space can be found to obtain the log data, which effectively avoids the increase of the executable file due to the log data, realizes the saving and reading of offline logs in a way that minimizes memory usage, reserves storage space for more useful business logic codes, and reduces hardware requirements and costs.
[0107] For the specific content of the log storage device in the above-mentioned TWS device, please refer to the aforementioned detailed introduction on the log storage method in the TWS device, which will not be repeated here.
[0108] See also Figure 7 As shown, the embodiment of the present application discloses a TWS device, including:
[0109] Memory 501, used for storing computer programs;
[0110] The processor 502 is used to execute the computer program to implement the steps of any log saving method or log reading method in the TWS device as described above.
[0111] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, it is used to implement the steps of the log saving method or the log reading method in any of the TWS devices described above.
[0112] For the specific contents of the above-mentioned TWS device and computer-readable storage medium, please refer to the aforementioned detailed introduction on the log preservation method in the TWS device, which will not be repeated here.
[0113] In this application, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0114] It should also be noted that, in this application document, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. In addition, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0115] The technical solution provided by the present application is described in detail above. The principle and implementation method of the present application are described in detail using specific examples herein, and the description of the above embodiments is only used to help understand the method and core idea of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the present application.
Claims
1. A log storage method in a TWS device, characterized in that: include: Determine a target storage space, where the target storage space is located in a non-Flash and non-RAM address segment; Save the log of the TWS device to the target storage space; wherein the log is an offline log; Storing the address information of the target storage space in the log storage area of the Flash; The determining of the target storage space includes: Divide an address segment in the storage space of the ELF file as the target storage space; The step of dividing an address segment in the storage space of the ELF file as the target storage space comprises: A high-order address segment is divided out from the storage space of the ELF file as the target storage space; Saving the log of the TWS device to the target storage space includes: Extract the string in the log of the TWS device; The character string is saved in the target storage space.
2. A log storage device in a TWS device, characterized in that: include: A determination module, used for determining a target storage space, wherein the target storage space is located in a non-Flash and non-RAM address segment; A saving module, used to save the log of the TWS device to the target storage space; wherein the log is an offline log; A recording module, used for storing the address information of the target storage space in the log storage area of the Flash; The determining of the target storage space includes: Divide an address segment in the storage space of the ELF file as the target storage space; The step of dividing an address segment in the storage space of the ELF file as the target storage space comprises: A high-order address segment is divided out from the storage space of the ELF file as the target storage space; Saving the log of the TWS device to the target storage space includes: Extract the string in the log of the TWS device; The character string is saved in the target storage space.
3. A log reading method in a TWS device, characterized in that: include: Read the data in the log storage area in the Flash of the TWS device; Reading address information of a target storage space of each log one by one from the data; The target storage space is located in a non-Flash and non-RAM address segment; wherein the log is an offline log; Reading the log of the TWS device from the target storage space according to the address information; Wherein, the target storage space is specifically an address segment in the storage space of the ELF file; The target storage space is specifically a high address segment in the storage space of the ELF file; The target storage space is specifically used to store character strings in the logs of TWS products.
4. A log reading device in a TWS device, characterized in that: include: A reading module, used to read the data in the log storage area in the Flash of the TWS device; An acquisition module, used for acquiring address information of a target storage space of each log from the data one by one; the target storage space is located in a non-Flash and non-RAM address segment; wherein the log is an offline log; A parsing module, configured to read the log of the TWS device from the target storage space according to the address information; Wherein, the target storage space is specifically an address segment in the storage space of the ELF file; The target storage space is specifically a high address segment in the storage space of the ELF file; The target storage space is specifically used to store character strings in the logs of TWS products.
5. A TWS device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the steps of the log saving method in the TWS device as claimed in claim 1, or to implement the steps of the log reading method in the TWS device as claimed in claim 3.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, is used to implement the steps of the log saving method in the TWS device as claimed in claim 1, or to implement the steps of the log reading method in the TWS device as claimed in claim 3.
Citation Information
Patent Citations
Journal storage method based on Flash
CN102567184A
Write-in method and read method for log information of circulation movement of financial equipment
CN106408790A
Log file reading method, apparatus and system, and log file writing method, apparatus and system
CN106951521A
Log storage method, system and device
CN108829342A
Log data storage method, log data storage device and TWS earphone
CN108924683A
