Embedded software design method and device, equipment, storage medium and product
By dividing the program data of the embedded software into resource valid data and code valid data, and linking it to Flash and RAM to run, the problem of insufficient RAM memory is solved, and the software's running speed and user experience are improved.
Patent Information
- Application Number
- CN202510144262.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-07
- Publication Date
- 2025-05-30
AI Technical Summary
The embedded software has insufficient RAM memory, which leads to slowing down the software's operation and degrading user experience.
The program data is divided into resource valid data and code valid data through preset link files, and is linked to preset Flash and RAM to run, reducing memory usage and improving running speed.
It effectively reduces the memory usage of RAM, ensures the running speed of the software, and solves the problem of insufficient RAM memory.
Smart Images

Figure CN120066519A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of software development, and particularly to an embedded software design method, device, equipment, storage medium and product. Background Art
[0002] With the continuous enhancement of chip performance and the continuous increase in the functions of embedded devices, more and more devices support UI (User Interface) display. Therefore, a large number of pictures, fonts, and bitmap information are used in the UI development process.
[0003] Since the executable file compiled from pictures, fonts, and bitmap information is too large, and in order to improve the running speed of the software and the user experience, most embedded software is executed in RAM (Random Access Memory). However, as the software functions and UI become more and more rich, the compiled executable file will also become larger and larger, thus resulting in insufficient RAM memory.
[0004] The above content is only used to assist in understanding the technical solution of this application, and does not represent an admission that the above content is prior art. Summary of the Invention
[0005] The main purpose of this application is to provide an embedded software design method, aiming to solve the technical problem of insufficient RAM memory of embedded software.
[0006] To achieve the above purpose, this application proposes an embedded software design method, and the method includes:
[0007] Obtain the program data required for designing the GUI;
[0008] Based on a preset link file, divide the program data into resource valid data and code valid data;
[0009] Link the resource valid data to a preset Flash for running, and link the code valid data to a preset RAM for running to obtain the execution program of the GUI.
[0010] In one embodiment, the step of dividing the program data into resource valid data and code valid data based on a preset link file includes:
[0011] Based on a preset connection file, divide the program data into resource data and code resources;
[0012] Perform padding removal processing on the resource data to obtain resource valid data, and perform padding removal processing on the code resources to obtain code valid data.
[0013] In one embodiment, the step of splitting the program data into resource data and code resources based on a preset connection file includes:
[0014] Read the first link area of the Flash and the second link area of the RAM from the preset link file;
[0015] Based on the first connection area, split out the resource data that needs to be linked to the preset Flash from the program data;
[0016] Based on the second connection area, split out the code data that needs to be linked to the preset RAM from the program data.
[0017] In one embodiment, before the step of linking the resource valid data to run in the preset Flash, it further includes:
[0018] Obtain the occupied space of the interrupt vector table and the code segment in the code valid data;
[0019] Perform a subtraction calculation on the preset code space in the preset Flash and the occupied space to obtain the filling space required by the preset Flash.
[0020] In one embodiment, the step of linking the resource valid data to run in the preset Flash includes:
[0021] Fill the filling space with data to obtain filling data;
[0022] Merge the filling data and the resource valid data to obtain a complete executable file in bin format;
[0023] Link the executable file to the starting address of the preset Flash to run.
[0024] In one embodiment, the preset RAM includes a first start address and a second start address. The step of linking the code valid data to run in the preset RAM includes:
[0025] Identify the interrupt vector table and the code segment from the code valid data;
[0026] Link the interrupt vector table to the first start address in the preset RAM;
[0027] Connect the code segment to the second start address in the preset RAM.
[0028] In one embodiment, after the step of linking the resource valid data to run in the preset Flash and linking the code valid data to run in the preset RAM to obtain the execution program of the GUI, it further includes:
[0029] After receiving the instruction to start the GUI, a preset bootloader is retrieved;
[0030] Based on the bootloader, the code segment in the code valid data is run in the preset RAM;
[0031] Based on the interrupt vector table in the code valid data, the program in the resource valid data is correspondingly run in the preset Flash to run the execution program of the GUI.
[0032] In one embodiment, the step of running the code segment in the code valid data in the preset RAM includes:
[0033] Retrieve the resource data required to run the execution program from the preset Flash;
[0034] Distinguish global variables and static variables from the resource data;
[0035] Store the global variables and the static variables at the stack start address in the preset RAM, and the stack start address is the storage space required for the stack during the operation of the GUI planned in the preset RAM.
[0036] In one embodiment, after the step of correspondingly running the program in the resource valid data in the preset Flash based on the interrupt vector table in the code valid data to run the execution program of the GUI, the following steps are further included:
[0037] Detect the size of the filled space of the file to be executed in the preset Flash;
[0038] If the filled space does not meet the preset linking condition, a new link file will be obtained and the resource valid data will be re-written to the preset Flash.
[0039] In one embodiment, the resource valid data includes at least one of the following:
[0040] The picture data required for the GUI;
[0041] The bitmap data required for the GUI;
[0042] The font data required for the GUI.
[0043] In addition, to achieve the above object, the present application also proposes an embedded software design device, and the embedded software design device includes:
[0044] A first acquisition module, configured to acquire the program data required for designing the GUI;
[0045] A splitting module, configured to split the program data into resource valid data and code valid data based on a preset link file;
[0046] A linking module, configured to link the resource valid data to run in a preset Flash and link the code valid data to run in a preset RAM, so as to obtain an execution program of the GUI.
[0047] In one embodiment, the splitting module is further configured to split the program data into resource data and code resources based on a preset connection file; perform padding removal processing on the resource data to obtain resource valid data, and perform padding removal processing on the code resources to obtain code valid data.
[0048] In one embodiment, the splitting module is further configured to read a first link area of the Flash and a second link area of the RAM from a preset link file; based on the first connection area, split out the resource data that needs to be linked to the preset Flash from the program data; based on the second connection area, split out the code data that needs to be linked to the preset RAM from the program data.
[0049] In one embodiment, the apparatus further includes:
[0050] A second acquisition module, configured to acquire the occupied space of the interrupt vector table and the code segment in the code valid data;
[0051] A calculation module, configured to perform a difference calculation between a preset code space in the preset Flash and the occupied space to obtain the padding space required by the preset Flash.
[0052] In one embodiment, the linking module is further configured to perform data padding on the padding space to obtain padding data; merge the padding data and the resource valid data to obtain a complete executable file in bin format; link the executable file to the starting address of the preset Flash to run.
[0053] In one embodiment, the preset RAM includes a first start address and a second start address,
[0054] The linking module is further configured to identify the interrupt vector table and the code segment from the code valid data; link the interrupt vector table to the first start address in the preset RAM; link the code segment to the second start address in the preset RAM.
[0055] The apparatus further includes:
[0056] A receiving module, configured to call a preset bootloader after receiving an instruction to start the GUI;
[0057] A first running module, configured to run a code segment in the code valid data in the preset RAM based on the bootloader.
[0058] A second running module, configured to run a program in the resource valid data correspondingly in the preset Flash based on an interrupt vector table in the code valid data, so as to run an execution program of the GUI.
[0059] In addition, to achieve the above object, the present application further provides an embedded software design device, where the device includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the embedded software design method as described above.
[0060] In addition, to achieve the above object, the present application further provides a storage medium, where the storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium, and when the computer program is executed by a processor, the steps of the embedded software design method as described above are implemented.
[0061] In addition, to achieve the above object, the present application further provides a computer program product, where the computer program product includes a computer program, and when the computer program is executed by a processor, the steps of the embedded software design method as described above are implemented.
[0062] One or more technical solutions proposed by the present application have at least the following technical effects:
[0063] Since all program data of the GUI (Graphical User Interface) is connected to the RAM for execution, it will cause the memory space of the RAM to be insufficient. Therefore, after obtaining the program data required for designing the GUI, through a preset link file, the program data is split into resource valid data and code valid data, and then the resource valid data is linked to the preset Flash, and the code valid data is linked to the preset RAM, so as to reduce the memory occupation of the preset Flash and the preset RAM, and the execution program of the GUI is separately linked and run, which can reduce the memory occupation of the RAM, and using the RAM to run the code segment can also ensure the running speed of the GUI, and using the Flash to run the program related to the resource data can solve the problem of the RAM being occupied. Therefore, while ensuring the running speed of the software, the memory occupation of the RAM is reduced. Description of the Drawings
[0064] The drawings here are incorporated into the description and form a part of the description, showing embodiments consistent with the present application, and are used together with the description to explain the principles of the present application.
[0065] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the accompanying drawings required in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0066] Figure 1 It is a schematic flowchart provided for Embodiment 1 of the embedded software design method of the present application;
[0067] Figure 2 It is a schematic diagram of scatter loading proposed for the embedded software design method of the present application;
[0068] Figure 3 It is a schematic flowchart provided for Embodiment 2 of the embedded software design method of the present application;
[0069] Figure 4 It is a schematic flowchart provided for Embodiment 3 of the embedded software design method of the present application;
[0070] Figure 5 It is a schematic diagram of bin file filling and downloading proposed for the embedded software design method of the present application;
[0071] Figure 6 It is a schematic flowchart provided for Embodiment 4 of the embedded software design method of the present application;
[0072] Figure 7 It is a schematic diagram of the module structure of the embedded software design device in the embodiment of the present application;
[0073] Figure 8 It is a schematic diagram of the device structure of the hardware operating environment involved in the embedded software design method in the embodiment of the present application.
[0074] The realization of the purpose of the present application, functional features and advantages will be further described with reference to the embodiments and the accompanying drawings. Detailed implementation manners
[0075] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0076] To better understand the technical solutions of the present application, the following will be described in detail in combination with the drawings in the specification and the specific implementation manners.
[0077] The main solution of the embodiment of this application is that a computer obtains program data required for designing a GUI; based on a preset link file, the program data is segmented into resource valid data and code valid data; the resource valid data is linked to a preset Flash for running, and the code valid data is linked to a preset RAM for running, so as to obtain an execution program of the GUI.
[0078] In this embodiment, for the convenience of description, the computer is used as the execution subject for elaboration below.
[0079] Since the executable file compiled according to picture, font, and bitmap information is too large, and in order to improve the running speed of the software and the user experience, most embedded software is executed in the RAM. However, as the software functions and UI become more and more rich, the compiled executable file will also become larger and larger, so it will cause insufficient RAM memory.
[0080] This application provides a solution. Since connecting all the program data of the GUI to the RAM for execution will cause insufficient memory space in the RAM, after obtaining the program data required for designing the GUI, through the preset link file, the program data is segmented into resource valid data and code valid data, and then the resource valid data is linked to the preset Flash, and the code valid data is linked to the preset RAM, so as to reduce the memory occupation of the preset Flash and the preset RAM. Moreover, separating the link and running of the execution program of the GUI can reduce the occupation of the RAM memory. And using the RAM to run the code segment can also ensure the running speed of the GUI. Using the Flash to run the program related to the resource data can solve the problem of RAM occupation. Therefore, while ensuring the running speed of the software, the occupation of the RAM memory is reduced.
[0081] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication, and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device, a computer, etc. that can implement the above functions. Taking the computer as an example, this embodiment and the following embodiments are described below.
[0082] Based on this, the embodiment of this application provides an embedded software design method, referring to Figure 1 , Figure 1 which is the flowchart of the first embodiment of the embedded software design method of this application.
[0083] In this embodiment, the embedded software design method includes steps S10 to S30:
[0084] Step S10, obtain program data required for designing a GUI;
[0085] It should be noted that the GUI is an interface that interacts with users through graphical elements (such as windows, icons, menus, buttons, etc.); in an embedded system, the GUI is usually used to provide an intuitive operation interface to enhance the user experience; the implementation of the GUI requires a large number of resources such as pictures, bitmaps, and fonts. Program data is all data related to GUI design, including code, resource files (such as pictures, bitmaps, fonts, etc.), and configuration information, etc. Program data is the basis for generating the GUI execution program.
[0086] It can be understood that since obtaining the program data required for designing the GUI is the basis for generating the final execution program, all program data related to GUI design, including resource files such as pictures, bitmaps, fonts, and code files, can be obtained from the design tool or development environment.
[0087] Step S20, based on a preset link file, split the program data into resource valid data and code valid data;
[0088] Optionally, the resource valid data includes at least one of the following:
[0089] The picture data required by the GUI;
[0090] The bitmap data required by the GUI;
[0091] The font data required by the GUI.
[0092] It should be noted that the preset link file is a configuration file used to specify the code and resource link addresses during the software compilation process. It defines the layout of program data in the storage medium (such as Flash) and the running memory (such as RAM), and is the key configuration file for implementing the scatter loading technology. The resource valid data is the GUI resource data after being processed to remove the redundant padding parts, such as pictures, bitmaps, and fonts. These data are linked to Flash to provide the resource support required by the GUI during runtime. The code valid data is the code data after being processed to remove the redundant padding parts, including the interrupt vector table, code segment (Text segment), and global variables and static variables, etc. These data are linked to RAM to improve the running speed of the program.
[0093] It can be understood that by using the preset link file, the program data is split into two parts, namely, resource valid data and code valid data. The resource valid data mainly includes resources such as pictures, bitmaps, and fonts required by the GUI, while the code valid data includes the interrupt vector table, code segment, and global variables and static variables, etc. Through the splitting process, the redundant padding data is removed to optimize the use of RAM storage space.
[0094] Step S30: Link the effective resource data to run in a preset Flash and link the effective code data to run in a preset RAM to obtain the execution program of the GUI.
[0095] It should be noted that the preset Flash is a non-volatile storage medium, commonly used in embedded systems to store program codes and resource data. It supports the XIP (Execute In Place) function, allowing programs to be directly executed at the storage location without first being loaded into the RAM. The preset RAM is a volatile storage medium, usually used to store the runtime data and codes of programs. Due to its fast read and write speed, it is commonly used to improve the execution efficiency of programs. The execution program refers to a program that can run on the target hardware after being compiled, linked, and optimized.
[0096] It can be understood that by linking the effective resource data to the preset Flash and directly running it at the storage location using the XIP function of the Flash, the memory occupancy is reduced. At the same time, by linking the effective code data to the preset RAM and utilizing the high-speed read and write characteristics of the RAM to improve the running speed of the program. In this way, both the running efficiency of the program and the optimization of the storage space are taken into account, thereby achieving the reduction of the RAM memory occupancy while ensuring the software running speed.
[0097] In the specific implementation, since the code is linked to both the RAM and the flash, and the address span between the two is relatively large, when the compiler finally links the program, the unused space between the two will be filled with 0x00, resulting in a very large compiled bin file, far exceeding the storage space of the FLASH. To solve this problem, the ielftool.exe tool can be used to split the bin file, that is, all the filled files by the compiler are removed and split into valid bin file segments (effective resource data and effective code data). That is, in the bat script, call the ielftool tool in the IAR installation directory to use the -bun-multi instruction to split the large object.bin containing the filling information into multiple valid bin files without filling. The splitting is based on the link areas specified in the link file and split into small valid bin file segments.
[0098] It can be immediately seen that according to the XIP and scatter loading technologies, the GUI bitmap information and other text data are respectively linked to the flash and the RAM. That is, it is compatible with the software running in the RAM, does not affect the software running speed, and achieves the purpose of saving RAM space, reducing the use of RAM, which can not only save costs but also solve the problem that the product functions cannot be iterated due to insufficient RAM space when the software runs in the RAM.
[0099] Further, the preset RAM includes a first start address and a second start address, and step S30 includes:
[0100] Identify the interrupt vector table and the code segment from the code valid data;
[0101] Link the interrupt vector table to the first start address in the preset RAM;
[0102] Link the code segment to the second start address in the preset RAM.
[0103] It should be noted that the first start address refers to the starting address allocated to the interrupt vector table in the preset RAM. This address is usually located in the low address area of the RAM, facilitating the processor to quickly access the interrupt vector table. The second start address refers to the starting address allocated to the code segment in the preset RAM. This address is usually located after the interrupt vector table and is used to store the executable code of the program.
[0104] It can be understood that the code valid data usually contains multiple parts, among which the interrupt vector table and the code segment are the core parts of the program operation. By analyzing the structure of the code valid data, the specific positions of the interrupt vector table and the code segment can be identified. This process is usually completed by the compiler or linker to ensure that the interrupt vector table and the code segment can be correctly loaded into the RAM.
[0105] It can be understood that by linking the interrupt vector table to the first start address in the preset RAM, it is ensured that the processor can quickly access the interrupt vector table and jump to the corresponding interrupt handler when an interrupt occurs. Linking the code segment to the second start address in the preset RAM enables the executable code of the program to be quickly loaded and executed, improving the response speed of the software, thereby improving the operation efficiency of the program and reducing the startup time and running latency of the program.
[0106] In a specific implementation, refer to Figure 2 , link information such as pictures, bitmaps, and fonts used in the GUI to a certain address range in the FLASH, such as within 6M starting from the address 0x60680200, link the code segment and other const data to a range in the RAM, such as within 8M starting from the address 0x70000000. Among them, the interrupt vector table and the code segment (Text segment) are linked separately, the stack is allocated 1M of space respectively, the start addresses are 0x70800000 and 0x70900000 respectively, the static area for storing initialized global variables and static variables, etc. is 0x70a00000, and the storage addresses for uninitialized global variables and static variables are 0x70A06400.
[0107] This embodiment provides an embedded software design method. Since all the program data of the GUI is connected to the RAM for execution, it will cause the memory space of the RAM to be insufficient. Therefore, after obtaining the program data required for designing the GUI, through a preset link file, the program data is split into resource valid data and code valid data, and then the resource valid data is linked to a preset Flash, and the code valid data is linked to a preset RAM, so as to reduce the memory occupation of the preset Flash and the preset RAM. Moreover, separating the execution programs of the GUI for linked operation can reduce the occupation of the RAM memory. And using the RAM to run the code segment can also ensure the running speed of the GUI. Using the Flash to run the programs related to the resource data can solve the problem of RAM occupation. Therefore, while ensuring the software running speed, the occupation of the RAM memory is reduced.
[0108] Based on the first embodiment of this application, in the second embodiment of this application, the same or similar content as that in the above-mentioned embodiment one can be referred to the above introduction and will not be repeated hereinafter. On this basis, please refer to Figure 3 , before step S20, the embedded software design method further includes steps S21 to S22:
[0109] Step S21, based on a preset link file, split the program data into resource data and code resources;
[0110] Step S22, perform padding removal processing on the resource data to obtain resource valid data, and perform padding removal processing on the code resources to obtain code valid data.
[0111] It should be noted that the resource data is static data related to the GUI display, such as pictures, bitmaps, fonts, etc. These data usually occupy a large storage space but do not need to be modified frequently. In this embodiment, the resource data is stored in a non-volatile storage medium (such as Flash). The code resources are the executable code part in the embedded software, including the interrupt vector table, code segment (Text segment), initialized global variables and static variables, etc. These data need to be accessed quickly during runtime. Therefore, in this embodiment, they are stored in a volatile storage medium (such as RAM). The padding removal processing is an operation to remove redundant padding bytes (usually 0x00) in the program data during the compilation and linking process.
[0112] It can be understood that since the compiler may fill blank bytes between different storage areas during the linking process to align the addresses, these padding bytes will increase the size of the finally generated binary file (bin file). Through the padding removal processing, the use of the storage space can be optimized.
[0113] It can be understood that through the padding removal process, redundant padding bytes in the program data are removed, significantly reducing the size of the finally generated bin file, enabling the embedded system to more efficiently utilize the limited RAM storage space.
[0114] It can be understood that the resource valid data is stored in the Flash and directly run using the Flash's XIP (Execute In Place) function, reducing the occupancy of the RAM. At the same time, the code valid data is stored in the RAM, taking advantage of the high-speed read and write characteristics of the RAM to improve the running speed of the program. Through the optimization of this storage and running method, the balance between storage space and running efficiency can be achieved.
[0115] In the specific implementation, in embedded software development, program data usually includes resource data and code resources. Among them, the resource data is mainly used to support the display function of the GUI, such as pictures, bitmaps, and fonts, etc.; the code resources include the executable code of the program, the interrupt vector table, global variables, and static variables, etc. The storage address range and size of the resource data and code resources are clearly specified through a preset link file. For example, the resource data can be allocated to a specific address range in the Flash, while the code resources are allocated to a specific address range in the RAM. During the compilation and linking process, the compiler may fill blank bytes (usually 0x00) between different storage areas to align the addresses or meet the requirements of the storage medium. Although these padding bytes are technically necessary, they will increase the size of the finally generated bin file. Therefore, the padding removal process is adopted to remove these redundant padding bytes and only retain the valid data actually required for storage and running. After the padding removal process, the resource data is optimized into resource valid data, and the code resources are optimized into code valid data. These valid data are respectively stored in the Flash and the RAM, which not only reduces the waste of storage space but also improves the running efficiency of the program.
[0116] Furthermore, step S21 further includes:
[0117] Read the first link area of the Flash and the second link area of the RAM from the preset link file;
[0118] Based on the first connection area, split out the resource data that needs to be linked to the preset Flash from the program data;
[0119] Based on the second connection area, split out the code data that needs to be linked to the preset RAM from the program data.
[0120] It should be noted that the first link area is the area in the preset connection text that specifies the data to be stored in the Flash. This data includes static resources such as pictures, bitmaps, and fonts required during the operation of the GUI. The second link area is the area in the preset connection text that specifies the data to be stored in the RAM. This data includes code segments, interrupt vector tables, global variables, and static variables required for the operation of the GUI.
[0121] It can be understood that by precisely dividing the storage areas of the Flash and the RAM through the preset link file, the resource data and the code data are stored in the most suitable storage media respectively, so as to reduce the occupancy of the RAM. At the same time, the large-capacity storage capacity of the Flash is fully utilized, and the problem of limited RAM storage space in the embedded system is solved.
[0122] It can be understood that storing the code data in the RAM and taking advantage of the high-speed read and write characteristics of the RAM significantly improves the running speed of the program. At the same time, storing the resource data in the Flash and taking advantage of the XIP characteristic of the Flash avoids the overhead of frequently loading the resource data into the RAM, and further avoids the occupancy of the RAM storage space by the resource data generated during the operation of the GUI.
[0123] Based on the first embodiment and the second embodiment of the present application, in the third embodiment of the present application, the same or similar content as the above embodiments can be referred to the above introduction and will not be repeated hereinafter. On this basis, please refer to Figure 4 , before step S30, the embedded software design method further includes steps S01 to S02:
[0124] Step S01, obtaining the occupied space of the interrupt vector table and the code segment in the valid code data;
[0125] Step S02, calculating the difference between the preset code space in the preset Flash and the occupied space to obtain the filling space required by the preset Flash.
[0126] It should be noted that the interrupt vector table is a table used to store the entry addresses of interrupt handlers in an embedded system. The code segment is the part of the program that contains executable instructions, including the machine code required for the program to run. It is the core of the program logic. The code segment is stored in RAM for fast execution. The occupied space is the actual storage space size of the code valid data (including the interrupt vector table and the code segment) in the storage medium, which can be obtained by calculating the number of bytes of the code valid data, reflecting the minimum storage space required for the program to run. The preset code space refers to the storage area size allocated to the code valid data (including the interrupt vector table and the code segment) in the preset Flash. The padding space refers to the difference between the preset code space and the actual occupied space of the code valid data in the preset Flash. This part of the space is usually used to fill bytes (such as 0x00) to ensure that the storage address of the code data in the Flash is consistent with the running address.
[0127] It can be understood that when an interrupt occurs in the system, the processor will jump to the corresponding interrupt handler according to the address in the interrupt vector table. The interrupt vector table is the basis for the program to run and must be correctly placed in memory to ensure the normal response of the system.
[0128] It can be understood that by accurately calculating the occupied space of the code valid data and determining the size of the padding space, the redundant storage space in the Flash can be minimized, which not only improves the storage efficiency but also reserves space for the expansion of other functions in the embedded system.
[0129] It can be understood that the calculation of the padding space and the addition of padding bytes ensure that the storage address of the code data in the Flash is consistent with the running address. When using the XIP function, it can avoid running errors caused by inconsistent addresses.
[0130] In the specific implementation, by calculating the number of bytes of the interrupt vector table and the code segment, their actual occupied space in the storage medium can be obtained; to ensure that the storage address of the code data in the Flash is consistent with the running address, it is necessary to calculate the difference between the preset code space and the occupied space of the code valid data, that is, the padding space. The padding space is used to fill bytes (such as 0x00) to align the storage position of the code data and ensure that the program can run correctly.
[0131] Furthermore, step S30 also includes:
[0132] Fill the padding space with data to obtain padding data;
[0133] Merge the padding data with the resource valid data to obtain a complete executable file in bin format;
[0134] Link the to-be-executed file to run at the starting address of the preset Flash.
[0135] It should be noted that data filling refers to the process of inserting specific bytes (usually 0x00) into the filling space. The purpose of filling is to ensure that the layout of code data and resource data in the storage medium is consistent with the expected running address, and to avoid running errors caused by address mismatches. The filled data is the byte data actually stored in the filling space after data filling processing. Among them, these byte data do not directly participate in the program running functionally. The to-be-executed file in bin format refers to the binary format program file generated after compilation, linking, and optimization processing. This file can be directly loaded and executed by the hardware of the embedded device and is the final form of program running. The starting address of the preset Flash refers to the starting address of the Flash storage area defined in the preset link file. The resource data and filled data of the program will be stored starting from this address to ensure that the program can be correctly loaded and executed during running.
[0136] It can be understood that by accurately calculating the filling space and performing data filling, the waste of storage space is avoided. At the same time, merging the resource data and filled data into a complete bin file ensures that the storage address and running address of the resource data and code data in the storage medium are consistent, avoiding running errors caused by address mismatches, and improving the reliability and stability of the program.
[0137] In specific implementation, refer to Figure 5 , after merging the interrupt vector table and the text segment, calculate the size X after merging. Then, subtract X from the reserved code segment space of 6M, which is the space to be filled. The size after filling is exactly 6M. Then, merge the bin file compiled from the GUI font bitmap into a complete bin file, where X is the filled part. The purpose of filling is to place the resources of the GUI at the address of 0x60680200, and the complete bin file is downloaded at the address of 0x60080200.
[0138] Based on the above-mentioned embodiments and the second embodiment of the present application, in the fourth embodiment of the present application, for the same or similar content as the above-mentioned embodiments, reference can be made to the above introduction and will not be repeated hereinafter. On this basis, please refer to Figure 6 , after step S30, the embedded software design method further includes steps S1 to S3:
[0139] Step S1, after receiving the instruction to start the GUI, retrieve the preset bootloader;
[0140] Step S2, based on the bootloader, run the code segment in the code valid data in the preset RAM;
[0141] Step S3: Based on the interrupt vector table in the code valid data, run the program in the resource valid data in the corresponding preset Flash to run the execution program of the GUI.
[0142] It should be noted that the Bootloader is the first piece of code that runs when an embedded system starts. It is mainly used to initialize the hardware environment and load the operating system or application program into a specified storage area (such as RAM) for running.
[0143] It can be understood that by initializing the hardware environment through the Bootloader and loading the code segment into RAM for running, the startup speed and running efficiency of the system are significantly improved. At the same time, using the XIP function of Flash to run the resource data further optimizes the access speed of the resources.
[0144] It can be understood that by reasonably allocating the storage locations of the code data and resource data, the stable operation of the system is ensured. Utilizing the Bootloader further enhances the startup reliability of the system and avoids running errors caused by failed hardware initialization.
[0145] It can be understood that during the software iteration process, if it is necessary to adjust the size of the code segment or resource data, only the corresponding storage location needs to be updated. This flexibility enables the system to better adapt to the requirements of function expansion and performance optimization.
[0146] In a specific implementation, in embedded software development, the code valid data usually contains multiple parts. Among them, the interrupt vector table and the code segment are the core parts for program running. By analyzing the structure of the code valid data, the specific locations of the interrupt vector table and the code segment can be identified. This process can be completed by the compiler or linker to ensure that the interrupt vector table and the code segment can be correctly loaded into RAM.
[0147] The first start address in the preset RAM is usually a fixed low-address area used to store the interrupt vector table. By linking the interrupt vector table to the first start address, it can be ensured that the processor can quickly jump to the corresponding interrupt handler when an interrupt occurs, thereby improving the response speed of the system.
[0148] The code segment contains the executable instructions of the program and is the core logical part of the program running. The second start address in the preset RAM is usually located after the interrupt vector table and is used to store the code segment. By linking the code segment to the second start address, it can be ensured that the code part of the program can be quickly loaded and executed, thereby improving the running efficiency of the program.
[0149] Furthermore, step S2 further includes:
[0150] Call the resource data required to run the execution program from the preset Flash;
[0151] Distinguish global variables and static variables from the resource data;
[0152] Store the global variables and the static variables at the stack start address in the preset RAM, where the stack start address is the storage space required for the stack during the operation of the GUI planned in the preset RAM.
[0153] It should be noted that a global variable is a variable that can be accessed throughout the life cycle of a program. It is initialized when the program starts and retains its value during the running process. The initial value of a global variable is usually stored in Flash and loaded into RAM during runtime. A static variable is a variable defined in a certain module or function of a program, and its life cycle is the same as the running cycle of the program. The initial value of a static variable is usually stored in Flash and loaded into RAM during runtime. A stack is a memory area used to store temporary data during the running of a program. It supports the last-in-first-out (LIFO) data access method and is usually used to store local variables, return addresses, etc. when a function is called. The stack start address is the starting address allocated to the stack in the preset RAM. The stack is an area used to store temporary data (such as local variables, return addresses, etc. when a function is called) during the running of a program, and the stack start address is usually located in the high-address area of RAM.
[0154] It can be understood that storing global variables and static variables at the stack start address in the preset RAM ensures that the program can quickly access these variables during the running process. This optimization significantly improves the running efficiency of the program and reduces performance problems caused by variable access latency.
[0155] It can be understood that by reasonably managing the storage locations of resource data and variables, it is ensured that the program can run at the correct memory address, reducing running errors caused by address conflicts or access errors and improving the overall reliability of the system.
[0156] Further, after step S3, the embedded software design method further includes:
[0157] Detect the size of the filled space of the file to be executed in the preset Flash;
[0158] If the filled space does not meet the preset linking condition, obtain a new link file and re-store the resource valid data into the preset Flash.
[0159] It is understandable that during the software iteration process, the functions and resource requirements of the program may change. The present invention ensures that the system can adapt to new storage requirements by dynamically adjusting the link file, thereby improving the scalability of the system and being able to flexibly handle the problem of insufficient storage space that may occur during the program iteration process.
[0160] It is understandable that by ensuring that the padding space meets the preset link conditions, program running errors caused by unreasonable storage layouts can be avoided, thereby enhancing the reliability of the system.
[0161] It is understandable that by dynamically adjusting the storage layout of resource data, the storage space of the preset Flash can be utilized more efficiently, reducing the waste of storage space caused by fixed storage layouts.
[0162] It should be noted that the above examples are only for understanding the present application and do not constitute a limitation on the embedded software design method of the present application. Based on this technical concept, more forms of simple transformations are within the protection scope of the present application.
[0163] The present application also provides an embedded software design device. Please refer to Figure 7 , the embedded software design device includes:
[0164] A first acquisition module 10, configured to acquire program data required for designing the GUI;
[0165] A splitting module 20, configured to split the program data into resource valid data and code valid data based on a preset link file;
[0166] A linking module 30, configured to link the resource valid data to run in a preset Flash and link the code valid data to run in a preset RAM to obtain an execution program of the GUI.
[0167] Optionally, the splitting module 20 is further configured to split the program data into resource data and code resources based on a preset connection file; perform padding removal processing on the resource data to obtain resource valid data, and perform padding removal processing on the code resources to obtain code valid data.
[0168] Optionally, the splitting module 20 is further configured to read a first link area of the Flash and a second link area of the RAM from a preset link file; based on the first connection area, split out the resource data that needs to be linked to the preset Flash from the program data; based on the second connection area, split out the code data that needs to be linked to the preset RAM from the program data.
[0169] Optionally, the device further includes:
[0170] The second acquisition module 40 is configured to acquire the occupied space of the interrupt vector table and the code segment in the valid code data;
[0171] The calculation module 50 is configured to calculate the difference between the preset code space in the preset Flash and the occupied space, so as to obtain the filling space required by the preset Flash.
[0172] Optionally, the linking module 30 is further configured to perform data filling on the filling space to obtain filling data; merge the filling data with the valid resource data to obtain a complete executable file in bin format; link the executable file to the starting address of the preset Flash to run.
[0173] Optionally, the preset RAM includes a first start address and a second start address;
[0174] The linking module 30 is further configured to identify the interrupt vector table and the code segment from the valid code data; link the interrupt vector table to the first start address in the preset RAM; connect the code segment to the second start address in the preset RAM.
[0175] Optionally, the device further includes:
[0176] The receiving module 60 is configured to, after receiving an instruction to start the GUI, retrieve a preset bootloader;
[0177] The first running module 70 is configured to run the code segment in the valid code data in the preset RAM based on the bootloader;
[0178] The second running module 80 is configured to run the program in the valid resource data in the preset Flash corresponding to the interrupt vector table in the valid code data, so as to run the execution program of the GUI.
[0179] Optionally, the first running module 70 is further configured to call and run the resource data required for running the execution program from the preset Flash; distinguish global variables and static variables from the resource data; store the global variables and the static variables in the stack start address in the preset RAM, and the stack start address is the storage space required for the stack during the running of the GUI planned in the preset RAM.
[0180] Optionally, the second running module 80 is further configured to detect the size of the filling space of the executable file in the preset Flash; if the filling space does not meet the preset linking condition, a new linking file will be obtained, and the valid resource data will be re-written into the preset Flash.
[0181] Optionally, in the device, the resource valid data includes at least one of the following:
[0182] Picture data required by the GUI;
[0183] Bitmap data required by the GUI;
[0184] Font data required by the GUI.
[0185] The embedded software design device provided by the present application adopts the embedded software design method in the above embodiment, and can solve the technical problem of insufficient RAM memory of the embedded software. Compared with the prior art, the beneficial effects of the embedded software design device provided by the present application are the same as those of the embedded software design method provided by the above embodiment, and other technical features in the embedded software design device are the same as the features disclosed in the above embodiment method, and will not be elaborated here.
[0186] The present application provides an embedded software design device, and the embedded software design device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the embedded software design method in the first embodiment above.
[0187] The following refers to Figure 8 , which shows a schematic structural diagram of an embedded software design device suitable for implementing the embodiments of the present application. The embedded software design device in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The shown embedded software design device is only an example, and should not bring any limitation to the functions and usage scope of the embodiments of the present application.
[0188] As Figure 8As shown, the embedded software design device may include a processing device 1001 (such as a central processing unit, a graphics processing unit, etc.), which may perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. In the RAM 1004, various programs and data required for the operation of the embedded software design device are also stored. The processing device 1001, the ROM 1002, and the RAM 1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems may be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 may allow the embedded software design device to communicate with other devices wirelessly or wireline to exchange data. Although the figure shows an embedded software design device having various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or had alternatively.
[0189] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program codes for performing the methods shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network through the communication device, or installed from the storage device 1003, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above functions defined in the methods of the embodiments disclosed in the present application are executed.
[0190] The embedded software design device provided by the present application adopts the embedded software design method in the above embodiments, and can solve the technical problem of insufficient RAM memory of the embedded software. Compared with the prior art, the beneficial effects of the embedded software design device provided by the present application are the same as those of the embedded software design method provided by the above embodiments, and other technical features in the embedded software design device are the same as those disclosed in the method of the previous embodiment, and will not be elaborated here.
[0191] It should be understood that each part disclosed in this application can be implemented by hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in a suitable manner in any one or more embodiments or examples.
[0192] As mentioned above, the above is only the specific implementation manner of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art within the technical scope disclosed in this application can easily think of changes or substitutions, which should all be covered within the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.
[0193] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., computer programs) stored thereon, and the computer-readable program instructions are used to execute the embedded software design method in the above embodiments.
[0194] The computer-readable storage medium provided by this application can be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM) or flash memory, optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this embodiment, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, device, or device. The program code contained on the computer-readable storage medium can be transmitted by any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0195] The above computer-readable storage medium can be included in an embedded software design device; it can also exist separately and not be assembled into an embedded software design device.
[0196] The above computer-readable storage medium carries one or more programs, which, when executed by an embedded software design device, cause the embedded software design device to: obtain program data required for designing a GUI; divide the program data into resource valid data and code valid data based on a preset link file; link the resource valid data to run in a preset Flash and link the code valid data to run in a preset RAM, so as to obtain an execution program of the GUI.
[0197] Computer program code for performing the operations of this application can be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, and C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, by using an Internet service provider to connect through the Internet).
[0198] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0199] The modules involved in the embodiments described in this application can be implemented in software or in hardware. Among them, the name of the module does not constitute a limitation on the unit itself in some cases.
[0200] The readable storage medium provided by this application is a computer-readable storage medium. The computer-readable storage medium stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned embedded software design method, and can solve the technical problem of insufficient RAM memory of embedded software. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by this application are the same as those of the embedded software design method provided by the above embodiment, and will not be elaborated here.
[0201] This application also provides a computer program product, including a computer program, and the steps of the above-mentioned embedded software design method are implemented when the computer program is executed by a processor.
[0202] The computer program product provided by this application can solve the technical problem of insufficient RAM memory of embedded software. Compared with the prior art, the beneficial effects of the computer program product provided by this application are the same as those of the embedded software design method provided by the above embodiment, and will not be elaborated here.
[0203] The above are only partial embodiments of this application, and do not limit the patent scope of this application accordingly. Any equivalent structural transformation made by using the content of the specification and drawings of this application under the technical concept of this application, or any direct / indirect application in other related technical fields, is included in the patent protection scope of this application.
Claims
1. An embedded software design method, characterized in that: The method includes: Get the program data needed to design the GUI; Based on a preset link file, the program data is divided into resource valid data and code valid data; The resource valid data is linked to the preset Flash for execution, and the code valid data is linked to the preset RAM for execution, so as to obtain the execution program of the GUI.
2. The method according to claim 1, characterized in that The step of dividing the program data into resource valid data and code valid data based on the preset link file includes: Based on a preset connection file, the program data is divided into resource data and code resources; The resource data is processed by padding removal to obtain resource valid data, and the code resource is processed by padding removal to obtain code valid data.
3. The method according to claim 2, characterized in that The step of dividing the program data into resource data and code resources based on the preset connection file includes: Read the first link area of the Flash and the second link area of the RAM from the preset link file; Based on the first connection area, dividing the resource data that needs to be linked to the preset Flash from the program data; Based on the second connection area, code data that needs to be linked to the preset RAM is separated from the program data.
4. The method according to claim 1, characterized in that Before the step of linking the resource valid data to the preset Flash for execution, the method further includes: Obtaining the occupied space of the interrupt vector table and the code segment in the effective data of the code; A difference calculation is performed between a preset code space in a preset Flash and the occupied space to obtain a padding space required by the preset Flash.
5. The method according to claim 4, characterized in that The step of linking the resource valid data to the preset Flash for execution comprises: Filling the filling space with data to obtain filling data; Merge the fill data with the resource valid data to obtain a complete bin format file to be executed; The to-be-executed file is linked to the start address of the preset Flash and runs.
6. The method according to claim 1, characterized in that The step of linking the resource valid data to the preset Flash for execution, and linking the code valid data to the preset RAM for execution, and obtaining the execution program of the GUI further comprises: After receiving the instruction to start the GUI, calling a preset boot loader; Based on the boot loader, running the code segment in the code valid data in the preset RAM; Based on the interrupt vector table in the code valid data, the program in the resource valid data is correspondingly run in the preset Flash to run the execution program of the GUI.
7. An embedded software design device, characterized in that: The device comprises: A first acquisition module is used to acquire program data required for designing a GUI; A segmentation module, used for segmenting the program data into resource valid data and code valid data based on a preset link file; The link module is used to link the resource valid data to the preset Flash for running, and link the code valid data to the preset RAM for running, so as to obtain the execution program of the GUI.
8. An embedded software design device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the embedded software design method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the embedded software design method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the embedded software design method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Software upgrading method and system for embedded equipment
CN108874417A
Method and device for processing Web resource files in embedded device
CN1996304A