Embedded code compiling test method and device, equipment and storage medium
By determining the target I/O address space and memory region information in the Windows system, and generating Makefile and linker script, the address consistency problem of embedded code compilation on the Windows system is solved, enabling effective execution and efficient testing of embedded code.
Patent Information
- Application Number
- CN202511232094.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-29
- Publication Date
- 2025-10-17
AI Technical Summary
In the process of compiling embedded software on Windows systems, existing technologies rely on manual code modification and conditional compilation, which have significant drawbacks, leading to a surge in workload, code structure corruption, high maintenance costs, logical confusion, and operational instability.
By determining the target I/O address space and memory region information from the embedded system of the target drone, a Makefile and linker script are generated and mapped to the target virtual address space. These files are then used to perform compilation and testing on a pre-defined non-embedded system.
It enables the effective execution of embedded code on the Windows system, improves the convenience and reliability of development and testing, reduces code modification omissions and maintenance risks, and ensures accurate resolution of address difference issues.
Smart Images

Figure CN120803955A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of embedded testing, in particular to a compiling test method and device for embedded code, equipment and storage medium. BACKGROUND
[0002] In the process of compiling embedded software on the Windows system, the address consistency problem is a key challenge that needs to be solved urgently. The existing technology mainly relies on two ways of manual code modification and conditional compilation to cope with it, but from the causal relationship analysis, these ways have significant defects.
[0003] First of all, the problem of manual code modification is particularly prominent. The embedded software code is large in amount and complex in structure, and the address mechanism of the Windows system and the embedded system is very different. The developer needs to manually convert the physical address operation into a form suitable for virtual memory. This not only leads to a sharp increase in workload, and it is easy to miss the modification line by line to cause compilation errors, but also destroys the source code structure, greatly increases the maintenance cost and the risk of error. Secondly, the conditional compilation method also has defects. It requires the developer to have a deep understanding of the address mechanism of the two systems and write complex conditional judgment statements. A large number of conditional statements will make the code bloated and the logic confused, which will seriously reduce the maintainability, and only distinguish at the code level, and cannot fundamentally solve the difference between the address mechanisms of the two systems. It is easy to produce difficult-to-troubleshoot faults due to address problems during running, which increases the instability of software running.
[0004] Therefore, how to make the embedded code run effectively in the Windows system is a technical problem that needs to be solved urgently. SUMMARY
[0005] Therefore, the purpose of the present application is to provide a compiling test method and device for embedded code, equipment and storage medium, which can make the embedded code run effectively in the Windows system. The specific scheme is as follows:
[0006] In the first aspect, the present application provides a compiling test method for embedded code, comprising:
[0007] determining the target IO address space corresponding to the target embedded application to be tested and the corresponding target memory region information located on the non-volatile memory from the embedded system of the target unmanned aerial vehicle;
[0008] generating the corresponding Makefile file and link script based on the target memory region information, and determining the target virtual address space corresponding to the target IO address space in the preset non-embedded system;
[0009] mapping the target IO address space into the target virtual address space so that the preset non-embedded system can access the target IO address space, and then using the Makefile file and the link script to compile and test the to-be-tested embedded code corresponding to the to-be-tested target embedded application in the preset non-embedded system.
[0010] Optionally, the generating the corresponding Makefile file and the link script based on the target memory region information comprises:
[0011] determining a target data segment based on the target memory region information; the target data segment representing a correspondence between a variable of the non-volatile memory and an address in the link script;
[0012] determining a first data segment and a second data segment from the embedded system; data in the first data segment being volatile data; data in the second data segment being non-volatile data;
[0013] determining a link script based on the first data segment, the target data segment and the second data segment;
[0014] determining a first address of the non-volatile memory from the target memory region information, and determining a loading address of the non-volatile memory based on the first address;
[0015] determining a segment alignment size based on a quantity of data segments in the link script and the first address; the segment alignment size representing an alignment requirement that a start address of a data segment in a memory of the preset non-embedded system needs to satisfy;
[0016] determining a Makefile file based on the loading address and the segment alignment size.
[0017] Optionally, the determining the link script based on the first data segment, the target data segment and the second data segment comprises:
[0018] determining an uninitialized data segment through a first preset BSS segment and based on first uninitialized data of the first data segment and a first common block;
[0019] determining a non-volatile storage data segment through a second preset BSS segment and based on a preset space capacity, second uninitialized data of the second data segment and a second common block; the preset space capacity being an address range reserved in the link script for the non-volatile data;
[0020] determining the link script based on the uninitialized data segment, the non-volatile storage data segment and the target data segment.
[0021] Optionally, the determining, in the preset non-embedded system, a target virtual address space corresponding to the target IO address space comprises:
[0022] determining, in the preset non-embedded system, a starting physical address and a space size of each IO address space in the target IO address space;
[0023] determining a target virtual address space based on the starting physical address and the space size.
[0024] Optionally, the determining a target virtual address space based on the starting physical address and the space size comprises:
[0025] converting the starting physical address into a virtual address request pointer;
[0026] applying a corresponding target virtual address space by calling a preset application programming interface function and based on the virtual address request pointer, the space size, and read-write permissions of the target IO address space.
[0027] Optionally, the compiling and testing the to-be-tested embedded code corresponding to the to-be-tested target embedded application by using the Makefile file and the link script comprises:
[0028] generating a target file based on the to-be-tested embedded code corresponding to the to-be-tested target embedded application by a compiler, and generating an executable file by a linker by using the target file;
[0029] determining redirection information from the executable file, determining target address information corresponding to the redirection information by using the Makefile file and the link script, and testing the to-be-tested embedded code based on the target address information.
[0030] In a second aspect, the present application provides a compiling and testing device for embedded code, comprising:
[0031] an information determining module configured to determine, from an embedded system of a target unmanned aerial vehicle, target IO address space corresponding to a to-be-tested target embedded application and corresponding target memory region information located on a non-volatile memory;
[0032] a space determining module configured to generate a corresponding Makefile file and a link script based on the target memory region information, and determine, in a preset non-embedded system, a target virtual address space corresponding to the target IO address space;
[0033] The code compiling test module is configured to map the target IO address space into the target virtual address space, so that the preset non-embedded system can access the target IO address space, and then the Makefile file and the link script are used to perform compiling test on the to-be-tested embedded code corresponding to the to-be-tested target embedded application in the preset non-embedded system.
[0034] In a third aspect, the present application provides an electronic device, comprising:
[0035] a memory configured to store a computer program;
[0036] a processor configured to execute the computer program to implement the above-mentioned embedded code compiling test method.
[0037] In a fourth aspect, the present application provides a computer readable storage medium configured to store a computer program; wherein the computer program is executed by a processor to implement the above-mentioned embedded code compiling test method.
[0038] In the present application, the target IO address space corresponding to the to-be-tested target embedded application and the target memory region information on the non-volatile memory are determined from the embedded system of the target UAV; the Makefile file and the link script are generated based on the target memory region information, and the target virtual address space corresponding to the target IO address space is determined in the preset non-embedded system; the target IO address space is mapped into the target virtual address space, so that the preset non-embedded system can access the target IO address space, and then the Makefile file and the link script are used to perform compiling test on the to-be-tested embedded code corresponding to the to-be-tested target embedded application in the preset non-embedded system. As can be seen from the above, the present application determines the target IO address space corresponding to the to-be-tested target embedded application and the target memory region information on the non-volatile memory from the embedded system of the target UAV; the Makefile file and the link script are generated based on the target memory region information, and the target virtual address space corresponding to the target IO address space is determined in the preset non-embedded system; the target IO address space is mapped into the target virtual address space, so that the preset non-embedded system can access the target IO address space, and then the Makefile file and the link script are used to perform compiling test on the to-be-tested embedded code corresponding to the to-be-tested target embedded application in the preset non-embedded system. In this way, the present application can enable the embedded code to run effectively in the Windows system, and enable the development and test of the embedded software in the Windows system to be more convenient, efficient and reliable. BRIEF DESCRIPTION OF DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of the provided drawings.
[0040] Figure 1 A flow chart of a compiling test method of an embedded code disclosed by the present application;
[0041] Figure 2 A schematic diagram of memory layout comparison between an embedded system and a Windows system disclosed by the present application;
[0042] Figure 3 A flow chart of a compiling test method of an embedded code disclosed by the present application;
[0043] Figure 4 A structure schematic diagram of a compiling test device of an embedded code disclosed by the present application;
[0044] Figure 5 A structure diagram of an electronic device disclosed by the present application. DETAILED DESCRIPTION
[0045] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0046] Currently, the embedded software code is large in amount and complex in structure, and the address mechanism of the Windows system and the embedded system is quite different. The developer needs to manually convert the physical address operation into a form suitable for virtual memory. This not only leads to a sharp increase in workload, and easy omission of line-by-line modification to cause compilation errors, but also destroys the source code structure, greatly increases the maintenance cost and error risk. Secondly, the conditional compilation method also has shortcomings. It requires the developer to deeply master the address mechanisms of the two systems and write complex conditional judgment statements. A large number of conditional statements will make the code bloated and the logic confused, which seriously reduces the maintainability, and only distinguishes at the code level, and does not fundamentally solve the difference in system address mechanism. It is easy to produce difficult-to-troubleshoot faults due to address problems during running, increasing the instability of software running. Therefore, the present application provides a compiling test method, device, equipment and storage medium of an embedded code, which can enable the embedded code to run effectively in the Windows system.
[0047] Referring to Figure 1 As shown in the figure, the embodiment of the application discloses a compiling test method of embedded code, which comprises the following steps:
[0048] In step S11, the target IO address space corresponding to the target embedded application to be tested and the target memory region information located on the non-volatile memory are determined from the embedded system of the target UAV.
[0049] In the embodiment, the target embedded application to be tested needs to be determined first. The application is an application program in the embedded system of the target UAV that needs to be compiled and tested. To determine the application, various methods can be used. In a specific embodiment, the target embedded application to be tested can be determined according to the task requirements of the target UAV. For example, for a UAV performing aerial photography, an embedded application related to image acquisition is taken as the target embedded application to be tested to ensure the reliability of the task-critical application. In another specific embodiment, the target embedded application to be tested can be determined according to the selection instruction input by the user through the debugging interface of the target UAV. The user can specify the application to be tested according to the test focus.
[0050] Further, the target IO address space corresponding to the target embedded application to be tested and the target memory region information located on the non-volatile memory (NVM, Non-Volatile Memory) are determined from the embedded system of the target UAV. It should be noted that the target IO address space and the target memory region information determined need to be uniquely corresponding to the target embedded application to be tested to ensure the accuracy of subsequent compiling test. The target memory region information on the non-volatile memory can be the NVM memory region starting physical address 0x90000000 and the length 0x100000.
[0051] In step S12, the Makefile file and the link script are generated based on the target memory region information, and the target virtual address space corresponding to the target IO address space is determined in the preset non-embedded system.
[0052] In the embodiment, the Makefile file (a configuration file for automatic compilation of projects) and the link script are generated based on the target memory region information, and the target virtual address space corresponding to the target IO address space is determined in the preset non-embedded system, which provides a basic configuration for subsequent compiling test of embedded code.
[0053] Determine a target data segment based on the target memory region information. The target data segment represents the correspondence between the variable and the address in the link script of the non-volatile memory, ensuring that the storage location of the variable in the memory is accurately mapped with the address defined by the link script. Then, determine a first data segment and a second data segment from the embedded system. The data in the first data segment is volatile data, and the data in the second data segment is non-volatile data. Then, determine the link script based on the first data segment, the target data segment, and the second data segment.
[0054] For the determination of the link script, specifically, determine the uninitialized data segment by the first preset BSS segment (i.e. Block Started by Symbol, used to store uninitialized global variables and static variables in the program) and based on the first uninitialized data and the first common block of the first data segment, and determine the non-volatile storage data segment by the second preset BSS segment and based on the preset space capacity, the second uninitialized data and the second common block of the second data segment. The preset space capacity is the address range reserved in the link script for the non-volatile data. Finally, determine the link script based on the uninitialized data segment, the non-volatile storage data segment, and the target data segment. The code segment of the link script can be as follows:
[0055] #define MY_SECTION(n) unsigned int __##n##__ __attribute__((used,section(".__" #n "__"))) MY_SECTION(001) MY_SECTION(002) SECTIONS { / * other segment information * / ... / * bss segment: store files that do not need to be mapped to NVM space * / .bss BLOCK(__section_alignment__): { __bss_start__ =. ; *(EXCLUDE_FILE(*t1nvm.o *t2nvm.o *t3nvm.o).sbss); *(EXCLUDE_FILE(*t1nvm.o *t2nvm.o *t3nvm.o) COMMON); __bss_end__ =. ; } / * specific data segment * / .__001__ BLOCK(__section_alignment__): { *(.__001__) } .__002__ BLOCK(__section_alignment__): { *(.__002__) } / * bss2 segment: store files that need to be mapped to NVM space * / .bss2 BLOCK(__section_alignment__): { __nvm_start__ =. ; *t1nvm.o(.bss);*t1nvm.o(COMMON); *t2nvm.o(.bss);*t2nvm.o(COMMON); *t3nvm.o(.bss);*t3nvm.o(COMMON); __nvm_temp__ =. ; . =. + 0x100000 - (__nvm_temp__ - __nvm_start__); __nvm_end__ =. ; } }
[0056] Further, for the determination of the Makefile file, specifically, a first address of the non-volatile memory is determined from the target memory area information, a loading address of the non-volatile memory is determined based on the first address. Then, a segment alignment size is determined based on a quantity of data segments in the linking script and the first address. Wherein, the segment alignment size represents an alignment requirement that a starting address of a data segment in the memory of the preset non-embedded system needs to satisfy. Finally, the Makefile file is determined based on the loading address and the segment alignment size.
[0057] In this embodiment, the starting physical address and space size of each IO address space in the target IO address space are determined in a preset non-embedded system, and the target virtual address space is determined based on the starting physical address and the space size. The preset non-embedded system may be a Windows system, and the memory layout comparison between the embedded system and the Windows system may be as follows: Figure 2 As shown. Moreover, the starting physical address and space size of each IO address space can be that the starting physical address of IO address space 1 is 0xA0000000 and the length is 0x1000000; the starting physical address of IO address space 2 is 0xA2000000 and the length is 0x1000000. Specifically, for the determination of the target virtual address space, the starting physical address is first converted into a virtual address request pointer. Then, by calling a preset application programming interface function and applying for the corresponding target virtual address space based on the virtual address request pointer, the space size and the read and write permissions of the target IO address space, the mapping of the physical address to the virtual address is realized, and an address environment is provided for the subsequent simulation test of the embedded code in a non-embedded system. Among them, the code segment for creating the target virtual address space can be as follows:
[0058] static bool allocateHardwareAddrRegion(unsigned int hardwareAddr,unsigned int size) { LPVOID addr = (LPVOID)(hardwareAddr); LPVOID allocAddress = VirtualAlloc(addr, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); return addr == allocAddress; } allocateHardwareAddrRegion(0xA0000000, 0x1000000); allocateHardwareAddrRegion(0xA2000000, 0x1000000);
[0059] Step S13, mapping the target IO address space into the target virtual address space, so that the preset non-embedded system can access the target IO address space, and then using the Makefile file and the link script to compile and test the to-be-tested embedded code corresponding to the to-be-tested target embedded application in the preset non-embedded system.
[0060] In this embodiment, the target IO address space is mapped into the target virtual address space, so that the preset non-embedded system can access the target IO address space, that is, the preset non-embedded system can access the actual IO address space through the virtual address, thereby providing an address mapping basis for cross-environment compilation and testing.
[0061] In the preset non-embedded system, the compiler generates an object file based on the to-be-tested embedded code corresponding to the to-be-tested target embedded application, and the linker generates an executable file by using the object file.
[0062] Then, redirection information is extracted from the executable file, and the redirection information can include address offsets of code and data in the memory. Then, the Makefile file and the link script are used to determine target address information corresponding to the redirection information, so as to test the to-be-tested embedded code based on the target address information, and ensure that the code can be correctly run in the preset non-embedded system.
[0063] In addition, referring to Figure 3 As shown in the figure, the automatic configuration tool is designed according to the operation process of the present application. The automatic configuration tool provides a friendly man-machine interface, and a developer can fill in the embedded system information in the man-machine interface, including NVM address space information and IO address space information. The automatic configuration tool can automatically generate a specific data segment, a Makefile automatic construction script and a link script according to the NVM address space configuration. Then, the automatic configuration tool automatically generates code for creating a virtual address space at a position of an initialization program according to the IO address space configuration, so as to realize one-key generation of an application program capable of being compiled and tested under a Windows system.
[0064] Therefore, when facing different embedded applications, a developer only needs to configure the memory space information according to actual conditions, so as to quickly adapt to a new embedded application memory layout, including different NVM address spaces and IO address distributions, thereby realizing effective compilation and testing of the source code under the Windows system with a minimum change, and ensuring that IO-related operations can be accurately and correctly executed in a simulated embedded environment.
[0065] As can be seen, the application determines target IO address space corresponding to a target embedded application to be tested and target memory region information located on a non-volatile memory from an embedded system of a target UAV; generates a corresponding Makefile file and a link script according to the target memory region information, and simultaneously determines target virtual address space corresponding to the target IO address space in a preset non-embedded system; maps the target IO address space to the target virtual address space, so that the preset non-embedded system can access the target IO address space, and then in the preset non-embedded system, the target embedded code to be tested corresponding to the target embedded application to be tested is compiled and tested by means of the Makefile file and the link script. In this way, the application can enable the embedded code to run effectively in the Windows system, and enable the development and testing of the embedded software in the Windows system to be more convenient, efficient and reliable.
[0066] Correspondingly, referring to Figure 4 The embodiment of the application provides a kind of compiling test device of embedded code, it includes:
[0067] information determining module 11, for determining target IO address space corresponding to target embedded application to be tested and corresponding target memory region information located on non-volatile memory from embedded system of target UAV;
[0068] space determining module 12, for generating corresponding Makefile file and link script based on the target memory region information, and determining target virtual address space corresponding to the target IO address space in a preset non-embedded system;
[0069] code compiling test module 13, for mapping the target IO address space to the target virtual address space, so that the preset non-embedded system can access the target IO address space, and then in the preset non-embedded system, the target embedded code to be tested corresponding to the target embedded application to be tested is compiled and tested by means of the Makefile file and the link script.
[0070] From the above, the application determines target IO address space corresponding to the target embedded application to be tested and target memory region information located on the non-volatile memory from the embedded system of the target unmanned aerial vehicle; generates corresponding Makefile file and link script according to the target memory region information, and determines target virtual address space corresponding to the target IO address space in the preset non-embedded system; maps the target IO address space to the target virtual address space, so that the preset non-embedded system can access the target IO address space, and then in the preset non-embedded system, the Makefile file and the link script are used to carry out compilation test on the embedded code to be tested corresponding to the target embedded application to be tested. In this way, the embedded code can be effectively run in the Windows system, and the development and test of the embedded software in the Windows system are more convenient, efficient and reliable.
[0071] In some embodiments, the space determination module 12 specifically includes:
[0072] A data segment determination unit configured to determine a target data segment based on the target memory region information; the target data segment representing a correspondence between variables of the non-volatile memory and addresses in the link script;
[0073] A first data segment determination unit configured to determine a first data segment and a second data segment from the embedded system; data in the first data segment being volatile data; data in the second data segment being non-volatile data;
[0074] A script determination unit configured to determine a link script based on the first data segment, the target data segment and the second data segment;
[0075] An address determination unit configured to determine a first address of the non-volatile memory from the target memory region information, and determine a load address of the non-volatile memory based on the first address;
[0076] A segment alignment determination unit configured to determine a segment alignment size based on a number of data segments in the link script and the first address; the segment alignment size representing an alignment requirement that a starting address of the data segment in the memory of the preset non-embedded system needs to meet;
[0077] A second data segment determination unit configured to determine a Makefile file based on the load address and the segment alignment size.
[0078] In some embodiments, the script determination unit specifically includes:
[0079] a data processing subunit, configured to determine an uninitialized data segment by a first preset BSS segment and based on first uninitialized data of the first data segment and a first common block;
[0080] a data segment determining subunit, configured to determine a non-volatile storage data segment by a second preset BSS segment and based on a preset space capacity, second uninitialized data of the second data segment and a second common block; the preset space capacity is an address range reserved for the non-volatile data in a link script;
[0081] a script determining subunit, configured to determine a link script based on the uninitialized data segment, the non-volatile storage data segment and the target data segment.
[0082] In some embodiments, the space determining module 12 specifically comprises:
[0083] an address determining unit, configured to determine a starting physical address and a space size of each IO address space in the target IO address space in a preset non-embedded system;
[0084] a space determining unit, configured to determine a target virtual address space based on the starting physical address and the space size.
[0085] In some embodiments, the space determining unit specifically comprises:
[0086] an address conversion subunit, configured to convert the starting physical address into a virtual address request pointer;
[0087] a space applying subunit, configured to apply a corresponding target virtual address space by calling a preset application programming interface function and based on the virtual address request pointer, the space size and read-write permissions of the target IO address space.
[0088] In some embodiments, the code compilation testing module 13 specifically comprises:
[0089] a file generating unit, configured to generate a target file based on a to-be-tested embedded code corresponding to the to-be-tested target embedded application by a compiler, and generate an executable file by a linker using the target file;
[0090] a code testing unit, configured to determine redirection information from the executable file, determine target address information corresponding to the redirection information using the Makefile and the link script, and test the to-be-tested embedded code based on the target address information.
[0091] Further, the embodiment of the present application further discloses an electronic device, Figure 5is a structural diagram of the electronic device 20 according to an exemplary embodiment, and the content in the diagram should not be considered as any limitation on the use range of the present application. The electronic device 20 can specifically include at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is configured to store a computer program, and the processor 21 is configured to load and execute the computer program to implement the related steps in the embedded code compilation test method disclosed in any of the preceding embodiments. In addition, the electronic device 20 in the embodiment can be an electronic computer.
[0092] In the embodiment, the power supply 23 is configured to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 is configured to create a data transmission channel between the electronic device 20 and external devices, and the communication protocol followed by the communication interface 24 can be any communication protocol applicable to the technical solution of the present application, which is not limited here; the input / output interface 25 is configured to obtain external input data or output data to the outside, and the specific interface type can be selected according to the specific application needs, which is not limited here.
[0093] In addition, the memory 22 as a carrier for resource storage can be a read-only memory, a random access memory, a magnetic disk, or an optical disk, etc., and the resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage mode can be temporary storage or permanent storage.
[0094] The operating system 221 is configured to manage and control each hardware device on the electronic device 20 and the computer program 222, and can be Windows OS, Unix, Linux, etc. The computer program 222 can further include computer programs for completing other specific work in addition to the computer program for completing the embedded code compilation test method executed by the electronic device 20 disclosed in any of the preceding embodiments.
[0095] Further, the present application also discloses a computer readable storage medium for storing a computer program; wherein the computer program is executed by a processor to implement the embedded code compilation test method disclosed in the preceding embodiments. For the specific steps of the method, refer to the corresponding content disclosed in the preceding embodiments, which will not be repeated here.
[0096] The embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. For the same or similar parts between the embodiments, refer to each other. For the device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and the relevant parts refer to the method part.
[0097] Those skilled in the art will further appreciate that the units and algorithms described in connection with the examples disclosed herein can be implemented in electronic hardware, computer software, or both; and that the described examples are merely illustrative of the principles of the application. Skilled artisans can implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
[0098] The steps of a method or algorithm described in connection with the examples disclosed herein can be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module can reside in RAM, flash memory, ROM, electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. The present application is not limited by these implementation possibilities.
[0099] Finally, it should be noted that the terms "comprises", "comprising", or other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises... a" does not, without more constraints, foreclose the existence of additional identical elements in the process, method, article, or apparatus that comprises the element.
[0100] The above detailed description has set forth various examples of the technology disclosed herein. The description is made for the purpose of illustrating the general principles of the technology and its practical application, and thus described arrangements are not limited to the examples given. As those skilled in the art will appreciate, other arrangements are possible and can be derived from the description above without departing from the scope of the present application.
Claims
1. A compilation and testing method for embedded code, characterized in that: include: Determine the target IO address space corresponding to the target embedded application to be tested and the corresponding target memory area information located on the non-volatile memory from the embedded system of the target UAV; Generate a corresponding Makefile file and link script based on the target memory area information, and determine a target virtual address space corresponding to the target IO address space in a preset non-embedded system; The target IO address space is mapped to the target virtual address space so that the preset non-embedded system can access the target IO address space. Then, in the preset non-embedded system, the Makefile file and the link script are used to compile and test the embedded code to be tested corresponding to the target embedded application to be tested.
2. The method for compiling and testing embedded code according to claim 1, wherein: The generating of the corresponding Makefile file and link script based on the target memory area information includes: Determining a target data segment based on the target memory area information; the target data segment represents a correspondence between a variable in the non-volatile memory and an address in a link script; Determining a first data segment and a second data segment from the embedded system; data in the first data segment is volatile data; and data in the second data segment is non-volatile data; determining a link script based on the first data segment, the target data segment, and the second data segment; Determining a first address of the non-volatile memory from the target memory area information, and determining a load address of the non-volatile memory based on the first address; Determining a segment alignment size based on the number of data segments in the link script and the first address; the segment alignment size represents an alignment requirement that a starting address of the data segment in the memory of the preset non-embedded system needs to meet; A Makefile file is determined based on the load address and the segment alignment size.
3. The method for compiling and testing embedded code according to claim 2, wherein: The determining of a link script based on the first data segment, the target data segment, and the second data segment includes: determining an uninitialized data segment by using a first preset BSS segment and based on first uninitialized data and a first common block of the first data segment; Determining a non-volatile storage data segment through a second preset BSS segment and based on a preset space capacity, second uninitialized data of the second data segment, and a second common block; the preset space capacity is an address range reserved for the non-volatile data in the link script; A link script is determined based on the uninitialized data segment, the non-volatile storage data segment, and the target data segment.
4. The method for compiling and testing embedded code according to claim 1, wherein: The determining, in the preset non-embedded system, a target virtual address space corresponding to the target IO address space includes: Determining a starting physical address and a space size of each IO address space in the target IO address space in a preset non-embedded system; A target virtual address space is determined based on the starting physical address and the space size.
5. The method for compiling and testing embedded code according to claim 4, wherein: The determining of the target virtual address space based on the starting physical address and the space size includes: Converting the starting physical address into a virtual address request pointer; The corresponding target virtual address space is applied for by calling a preset application programming interface function based on the virtual address request pointer, the space size and the read and write permissions of the target IO address space.
6. The method for compiling and testing embedded code according to any one of claims 1 to 5, characterized in that: The compiling and testing of the embedded code to be tested corresponding to the target embedded application to be tested by using the Makefile file and the link script includes: Generate an object file based on the embedded code to be tested corresponding to the target embedded application to be tested by a compiler, and generate an executable file by using the object file by a linker; Redirection information is determined from the executable file, and target address information corresponding to the redirection information is determined using the Makefile file and the link script, so as to test the embedded code to be tested based on the target address information.
7. A compilation and testing device for embedded code, characterized in that: include: An information determination module is used to determine the target IO address space corresponding to the target embedded application to be tested and the corresponding target memory area information located on the non-volatile memory from the embedded system of the target UAV; A space determination module is used to generate a corresponding Makefile file and a link script based on the target memory area information, and determine a target virtual address space corresponding to the target IO address space in a preset non-embedded system; A code compilation test module is used to map the target IO address space to the target virtual address space so that the preset non-embedded system can access the target IO address space, and then use the Makefile file and the link script in the preset non-embedded system to compile and test the embedded code to be tested corresponding to the target embedded application to be tested.
8. The embedded code compiling and testing device according to claim 7, characterized in that: The code compilation test module includes: A file generating unit is configured to generate a target file based on the embedded code to be tested corresponding to the target embedded application to be tested by a compiler, and generate an executable file by using the target file by a linker; The code compiling unit is used to determine the redirection information from the executable file, and use the Makefile file and the link script to determine the target address information corresponding to the redirection information, so as to test the embedded code to be tested based on the target address information.
9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the embedded code compilation and testing method according to any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that Used to store a computer program; wherein, when the computer program is executed by a processor, the compilation and testing method of the embedded code according to any one of claims 1 to 6 is implemented.