Summary of the invention
The embodiment of the present application provides the method for burn-recording and device of a kind of program, solves of the existing technology above-mentioned ask
Topic, to save the free memory of Flash.
In a first aspect, providing a kind of method for burn-recording of program, this method may include:
According to burning program required memory space and default planning principles, to the free memory of target memory
Regional planning is carried out, is obtained to the corresponding burning region of burning program described in the target memory, it is described to burning program
For by the operation sequence of at least one application call;
According to the address configuration information in preset configuration information, generate to burning program file, it is described to burning program text
Part includes the initial address to burning program and the burning region;
It will be described to burning program burning file to the burning region.
One it is optional realize, according to burning program required memory space and default planning principles, to target
The free memory of memory carries out regional planning, obtains described in the target memory to the corresponding burning of burning program
Region, comprising:
To free memory continuous in the target memory and the required memory space to burning program into
Row detection;
If continuous free memory is empty not less than the required storage to burning program in the target memory
Between, then the arbitrary region for meeting the required memory space is chosen in the continuous free memory as described wait burn
Record the corresponding burning region of program.
In an optional realization, the preset configuration information further includes call parameters and data transmit-receive operation sequence;
Will it is described to burning program burning file to the burning region after, the method also includes:
According to the call parameters and the data transmit-receive operation sequence, routine call file is generated;
Establish the incidence relation that described program calls the file identification of file and the initial address in the burning region.
One it is optional realize, will it is described to burning program burning file to the burning region after, the side
Method further include:
The incidence relation of the initial address in the interface identifier of storing said program calling interface and the burning region, and
The incidence relation of the burning program of burning in the burning region and the burning region.
In an optional realization, after generating to burning program file, the method also includes:
Indication field is set in the burning region, to indicate in the burning region with the presence or absence of burning program text
Part.
In an optional realization, the target memory is flash memories Flash or read-only memory Rom.
Second aspect provides a kind of burning device of program, the apparatus may include: regional planning unit generates list
Member, burning unit;
The regional planning unit, required memory space and default planning principles for basis to burning program, to mesh
The free memory for marking memory carries out regional planning, obtains described in the target memory to the corresponding burning of burning program
Record region, it is described to burning program be by the operation sequence of at least one application call;
The generation unit, for generating to burning program file according to the address configuration information in preset configuration information,
Described to burning program file includes the initial address to burning program and the burning region;
The burning unit, being used for will be described to burning program burning file to the burning region.
In an optional realization, the regional planning unit is specifically used for continuous in the target memory
Free memory is detected with the required memory space to burning program;
If continuous free memory is empty not less than the required storage to burning program in the target memory
Between, then the arbitrary region for meeting the required memory space is chosen in the continuous free memory as described wait burn
Record the corresponding burning region of program.
In an optional realization, described device further includes establishing unit;
The preset configuration information further includes call parameters, data transmit-receive operation sequence;
The generation unit is also used to generate program tune according to the call parameters and the data transmit-receive operation sequence
Use file;
It is described to establish unit, the file identification of file and the starting point in the burning region are called for establishing described program
The incidence relation of location.
In an optional realization, described device further includes setting unit;
The setting unit, for indication field to be arranged in the burning region, to indicate to be in the burning region
It is no that there are burning program files.
In an optional realization, the target memory is flash memories Flash or read-only memory Rom.
The third aspect provides a kind of electronic equipment, which includes processor, communication interface, memory and lead to
Believe bus, wherein processor, communication interface, memory complete mutual communication by communication bus;
Memory, for storing computer program;
Processor when for executing the program stored on memory, realizes any side in above-mentioned first aspect
Method step.
Fourth aspect provides a kind of computer readable storage medium, and meter is stored in the computer readable storage medium
Calculation machine program, the computer program realize any method and step in above-mentioned first aspect when being executed by processor.
The method for burn-recording of the above embodiment of the present invention according to the required memory space to burning program and presets planning original
Then, regional planning is carried out to the free memory of target memory, obtained in target memory to the corresponding burning of burning program
Region is recorded, is by the operation sequence of at least one application call to burning program;According to the address in preset configuration information
Configuration information generates to burning program file, includes the initial address to burning program and burning region to burning program file;
It will be to burning program burning file to burning region.As it can be seen that this method passes through the planning cloth to free memory in memory
Office, improves the utilization rate of operation sequence and the utilization rate of free memory in burning region, effectively saves storage
The free memory of device.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present application, technical solutions in the embodiments of the present application carries out clear, complete
Site preparation description, it is clear that described embodiment is only some embodiments of the present application, is not whole embodiments.Based on this
Apply for embodiment, every other implementation obtained by those of ordinary skill in the art without making creative efforts
Example, shall fall in the protection scope of this application.
The method for burn-recording of program provided in an embodiment of the present invention can be applied in terminal (such as built-in terminal) or server
Controller in, such as STM32 microcontroller, wherein STM32 represents 32 8-digit microcontrollers of ARM Cortex-M kernel, and existing
There is technology to compare, this method does not need the operation sequence that application program and the application program can be called carrying out coupling compiling, and
It is that burning and passes through in target memory and provides corresponding docking on target memory alone for the operation sequence that will can call
The mode of interface realizes the respective calling of external different application, saves the free memory of target memory as a result,
And the working efficiency and available code space of terminal or server are improved, human cost and Material Cost are saved to reach
Purpose.
Wherein, target memory is that can store program, and can directly run the program, that is, is not needed the program
It is loaded into memory random access memory (random access memory, RAM), which can be flash memory storage
Device Flash or read-only memory (Read-Only Memory, ROM).For example, the internal FLASH memory Flash of STM32 is
It can store program, and do not need to load the program into memory RAM, the address of Flash originates in 0x08000000, ordinary circumstance
Under, program file is written since the address.
Preferred embodiment of the present application is illustrated below in conjunction with Figure of description, it should be understood that described herein
Preferred embodiment only for the purpose of illustrating and explaining the present invention and is not intended to limit the present invention, and in the absence of conflict, this Shen
Please in embodiment and embodiment in feature can be combined with each other.
The present processes are introduced in detail using controller as executing subject below.
Fig. 1 is a kind of flow diagram of the method for burn-recording of program provided in an embodiment of the present invention.As shown in Figure 1, the party
Method may include:
The required memory space and default planning principles of step 110, basis to burning program, can be used target memory
Memory space carries out regional planning, obtains in target memory to the corresponding burning region of burning program.
Wherein, being to burning program can be by the operation sequence of at least one application call.
Before executing the step, controller is detected to target memory and to burning program, obtains target storage
Continuous free memory in device, and the required memory space to burning program.
Later, controller is to free memory continuous in target memory and to the required memory space of burning program
It is detected;
If continuous free memory is not less than the required memory space to burning program in target memory, even
The arbitrary region for meeting the required memory space to burning program is chosen in continuous free memory as to burning program pair
The burning region answered;
Controller can be generated regional planning and successfully indicate information at this time, or generate the remaining company of the target memory
Continuous free memory information;
If continuous free memory is less than the required memory space to burning program, controller in target memory
The instruction information of regional planning failure can be generated, and terminate burning process.
Further, the different burnings to burning program of storage are interregional can be continuous, can also be discontinuous, such as Fig. 2 institute
Show, there are burning region 1, burning region 2 and burning regions 3 in the memory space of Flash, wherein burning region 1 and burning
It is continuous between region 2;It is discontinuous between burning region 3 and burning region 1 or burning region 2.
Step 120, according to the address configuration information in preset configuration information, generate to burning program file.
Preset configuration information includes address configuration information, and such as address configuration parameter, which be can be in advance
The information of input, is also possible to the information automatically updated according to the burning region in step 110, and the embodiment of the present invention is not done herein
It limits.
Controller is according to the initial address in the available burning region of address configuration information.Controller is available as a result,
To include to burning program, burning region initial address to burning program file.
It is different to burning program in order to be effectively isolated, protect consistency and stability to burning program, different burnings
Region will store different to burning program, therefore in order to guarantee that different burning regions are not overlapped, need to guarantee difference to burning journey
Ordered pair answers different address configuration parameters, and different initial addresses will be present in different burnings region in this way.
Further, controller is according to the initial address of required memory space and burning region to burning program, can be with
Obtain the termination address for waiting for burning program.Controller is available to including starting to burning program, burning region as a result,
Address and termination address to burning program file.
As shown in figure 3, since STM32 is by the application program bootloader of operating system and the application program of client
APP composition, bootloader and APP can be called to burning program, therefore there are the region bootloader (40K), APP by Flash
Region (58K) and burning region (30K).It is 0x800a000 that controller, which gets address configuration information, to needed for burning program
Memory space be 0xa000 after, determine burning region be from address is 0x800a000 size be 0xa000 region.
Therefore controller is available to including to the initial address in burning program and burning region to burning program file at this time.
Optionally, indication field, such as Flag can be arranged in controller in burning region, with indicate in burning region whether
There are burning program files, if then Flag is assigned a value of 1 there are burning program file in burning region;If in burning region not
There are burning program files, then Flag is assigned a value of 0.
Optionally, preset configuration information further includes call parameters, data transmit-receive operation sequence;
Controller can generate routine call file, as routine call connects according to call parameters, data transmit-receive operation sequence
Mouth (Application Program Interface, API), and establish file identification and the burning area of the routine call file
The incidence relation of the initial address in domain, to realize the calling to burning program in burning region.Wherein, the text of routine call file
Part mark is can be with the information of the unique identification interface, such as api interface number or api interface address (such as chain table address).It needs
Illustrate, it is different to burning program due to will be stored in different burning regions, therefore the initial address pair in different burnings region
Answer the file identification (or " interface IP address ") of different routine call files.It is alternatively possible to by the starting point in burning region
Location fixation is stored at the interface IP address of routine call interface, i.e., interface IP address is 0 relative to the offset to burning program section.
Step 130, will be to burning program burning file to burning region.
If Flag successfully will be assigned a value of 1 to burning program burning file to burning region by controller;If not successfully will
To burning program burning file to burning region, then Flag is assigned a value of 0.
Since the file identification that the initial address in different burning regions corresponds to different routine call files (referred to below as " connects
Port address "), and the initial address in different burning region corresponds to different burning programs, therefore the link table information of available table 1.
Table 1
Interface IP address |
The initial address in burning region |
Burning program |
API_1 |
0x80000001 |
Program A |
API_2 |
0x8000000F |
Program B |
API_3 |
0x800000FF |
Program C |
Wherein, when interface IP address is API_1, the initial address in burning region is 0x80000001, and the burning region
Interior burning program is program A;When interface IP address is API_2, the initial address in burning region is 0x8000000F, and the burning
Recording the burning program in region is program B;When interface IP address is API_3, the initial address in burning region is 0x800000FF,
And the burning program in the burning region is program C.
It should be noted that above-mentioned data are merely to specification interface address, the initial address in burning region and burning journey
Corresponding relationship between sequence and it is customized.
Optionally, when Flag is assigned a value of 1, controller stores the link table information, to provide chained list letter to application program
Breath.The link table information includes the incidence relation of the interface identifier of routine call file Yu the initial address in burning region, and is burnt
Record the incidence relation in region and corresponding burning program.
For example, the application program bootloader in Fig. 3 obtains C pairs of program for needing to call by inquiry linked list information
The interface IP address API_3 answered, after the call request for carrying interface IP address API_3 is issued in application program bootloader, control
Device will pass through the initial address in interface IP address API_3 corresponding API Access burning region, if detecting, Flag is assigned a value of 0, ties
Beam calls, if detecting, Flag is assigned a value of 1, calls and executes the program C in burning region.
In one example, by taking controller is STM32, target memory is Flash as an example, another kind as shown in Figure 4
The method for burn-recording of program may include:
Step 401 is detected to Flash and to burning program, and obtaining in target memory continuously can be used storage empty
Between, and to the required memory space of burning program.
Step 402 judges whether continuous free memory is not less than empty to the required storage of burning program in Flash
Between;
If so, thening follow the steps 403;
If it is not, thening follow the steps 412.
Step 403, the arbitrary region that memory space needed for meeting is chosen in continuous free memory are used as wait burn
Record the corresponding burning region of program.
Step 404, according to the address configuration information in preset configuration information, generate to burning program file.
To the initial address that burning program file includes to burning program, burning region.
Flag field is arranged in step 405 in burning region, to indicate in burning region with the presence or absence of burning program text
Part.
Step 406, the call parameters according in preset configuration information, data transmit-receive operation sequence generate routine call text
Part.
It should be noted that timing limitation, i.e. step 404- step is not present in the execution sequence of step 404- step 406
406 execution sequence can be with intermodulation.
Step 407, will be to burning program burning file to burning region.
Step 408 judges whether burning succeeds;
If so, thening follow the steps 409;
If it is not, thening follow the steps 410.
Flag is assigned a value of 1 by step 409, executes step 411 later.
Flag is assigned a value of 0 by step 410, executes step 412 later.
Step 411, storage link table information.
The link table information includes the incidence relation of the interface identifier of routine call file Yu the initial address in burning region, with
And the incidence relation in burning region and corresponding burning program, step 412 is executed later.
Step 412 terminates process.
The method for burn-recording of the above embodiment of the present invention according to the required memory space to burning program and presets planning original
Then, regional planning is carried out to the free memory of target memory, obtained in target memory to the corresponding burning of burning program
Region is recorded, is by the operation sequence of at least one application call to burning program;According to the address in preset configuration information
Configuration information generates to burning program file, includes the initial address to burning program and burning region to burning program file;
It will be to burning program burning file to burning region.As it can be seen that this method passes through the planning cloth to free memory in memory
Office, improves the utilization rate of operation sequence and the utilization rate of free memory in burning region, effectively saves storage
The free memory of device.
Corresponding with the above method, the embodiment of the present invention also provides a kind of burning device of program, as shown in figure 5, the dress
Set includes: regional planning unit 510, generation unit 520, burning unit 530;
Regional planning unit 510, required memory space and default planning principles for basis to burning program, to target
The free memory of memory carries out regional planning, obtains described in the target memory to the corresponding burning of burning program
Region, it is described to burning program be by the operation sequence of at least one application call;
Generation unit 520, for generating to burning program file according to the address configuration information in preset configuration information,
Described to burning program file includes the initial address to burning program and the burning region;
Burning unit 530, being used for will be described to burning program burning file to the burning region.
One it is optional realize, regional planning unit 510 is specifically used for continuously may be used in the target memory
It is detected with memory space and the required memory space to burning program;
If continuous free memory is empty not less than the required storage to burning program in the target memory
Between, then the arbitrary region for meeting the required memory space is chosen in the continuous free memory as described wait burn
Record the corresponding burning region of program.
In an optional realization, described device further includes establishing unit 540;The preset configuration information further includes connecing
Mouth configuration parameter, data transmit-receive information;
Generation unit 520 is also used to generate routine call according to the call parameters and the data transmit-receive operation sequence
File;
Unit 540 is established, calls the file identification of file and the starting point in the burning region for establishing described program
The incidence relation of location.
In an optional realization, described device further includes setting unit 550;
Setting unit 550, for indication field to be arranged in the burning region, with indicate in the burning region whether
There are burning program files.
In an optional realization, the target memory is flash memories Flash or read-only memory Rom.
The function of each functional unit of the burning device for the program that the above embodiment of the present invention provides, can be by above-mentioned each
Method and step realizes, therefore, the specific works mistake of each unit in the burning device of program provided in an embodiment of the present invention
Journey and beneficial effect, do not repeat again herein.
The embodiment of the invention also provides a kind of electronic equipment, as shown in fig. 6, include processor 610, communication interface 620,
Memory 630 and communication bus 640, wherein processor 610, communication interface 620, memory 630 are complete by communication bus 640
At mutual communication.
Memory 630, for storing computer program;
Processor 610 when for executing the program stored on memory 630, realizes following steps:
According to burning program required memory space and default planning principles, to the free memory of target memory
Regional planning is carried out, is obtained to the corresponding burning region of burning program described in the target memory, it is described to burning program
For by the operation sequence of at least one application call;
According to the address configuration information in preset configuration information, generate to burning program file, it is described to burning program text
Part includes the initial address to burning program and the burning region;
It will be described to burning program burning file to the burning region.
One it is optional realize, according to burning program required memory space and default planning principles, to target
The free memory of memory carries out regional planning, obtains described in the target memory to the corresponding burning of burning program
Region, comprising:
To free memory continuous in the target memory and the required memory space to burning program into
Row detection;
If continuous free memory is empty not less than the required storage to burning program in the target memory
Between, then the arbitrary region for meeting the required memory space is chosen in the continuous free memory as described wait burn
Record the corresponding burning region of program.
In an optional realization, the preset configuration information further includes call parameters, data transmit-receive operation sequence;
Will it is described to burning program burning file to the burning region after, the method also includes:
According to the call parameters and the data transmit-receive operation sequence, routine call file is generated;
Establish the incidence relation that described program calls the file identification of file and the initial address in the burning region.
In an optional realization, after generating to burning program file, the method also includes:
Indication field is set in the burning region, to indicate in the burning region with the presence or absence of burning program text
Part.
In an optional realization, the target memory is flash memories Flash or read-only memory Rom.
Communication bus mentioned above can be Peripheral Component Interconnect standard (Peripheral Component
Interconnect, PCI) bus or expanding the industrial standard structure (Extended Industry Standard
Architecture, EISA) bus etc..The communication bus can be divided into address bus, data/address bus, control bus etc..For just
It is only indicated with a thick line in expression, figure, it is not intended that an only bus or a type of bus.
Communication interface is for the communication between above-mentioned electronic equipment and other equipment.
Memory may include random access memory (Random Access Memory, RAM), also may include non-easy
The property lost memory (Non-Volatile Memory, NVM), for example, at least a magnetic disk storage.Optionally, memory may be used also
To be storage device that at least one is located remotely from aforementioned processor.
Above-mentioned processor can be general processor, including central processing unit (Central Processing Unit,
CPU), network processing unit (Network Processor, NP) etc.;It can also be digital signal processor (Digital Signal
Processing, DSP), it is specific integrated circuit (Application Specific Integrated Circuit, ASIC), existing
It is field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete
Door or transistor logic, discrete hardware components.
The embodiment and beneficial effect solved the problems, such as due to each device of electronic equipment in above-described embodiment can join
Each step in embodiment as shown in Figure 1 realizes, therefore, the specific works mistake of electronic equipment provided in an embodiment of the present invention
Journey and beneficial effect, do not repeat again herein.
In another embodiment provided by the invention, a kind of computer readable storage medium is additionally provided, which can
It reads to be stored with instruction in storage medium, when run on a computer, so that computer executes any institute in above-described embodiment
The method for burn-recording for the program stated.
In another embodiment provided by the invention, a kind of computer program product comprising instruction is additionally provided, when it
When running on computers, so that computer executes the method for burn-recording of any program in above-described embodiment.
It should be understood by those skilled in the art that, the embodiment in the embodiment of the present application can provide as method, system or meter
Calculation machine program product.Therefore, complete hardware embodiment, complete software embodiment can be used in the embodiment of the present application or combine soft
The form of the embodiment of part and hardware aspect.Moreover, being can be used in the embodiment of the present application in one or more wherein includes meter
Computer-usable storage medium (including but not limited to magnetic disk storage, CD-ROM, the optical memory of calculation machine usable program code
Deng) on the form of computer program product implemented.
It is referring to according to the method for embodiment, equipment (system) and calculating in the embodiment of the present application in the embodiment of the present application
The flowchart and/or the block diagram of machine program product describes.It should be understood that can be realized by computer program instructions flow chart and/or
The combination of the process and/or box in each flow and/or block and flowchart and/or the block diagram in block diagram.It can mention
For the processing of these computer program instructions to general purpose computer, special purpose computer, Embedded Processor or other programmable datas
The processor of equipment is to generate a machine, so that being executed by computer or the processor of other programmable data processing devices
Instruction generation refer to for realizing in one or more flows of the flowchart and/or one or more blocks of the block diagram
The device of fixed function.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,
Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or
The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one
The step of function of being specified in a box or multiple boxes.
Although the preferred embodiment in the embodiment of the present application has been described, once a person skilled in the art knows
Basic creative concept, then additional changes and modifications may be made to these embodiments.So appended claims are intended to explain
Being includes preferred embodiment and all change and modification for falling into range in the embodiment of the present application.
Obviously, those skilled in the art embodiment in the embodiment of the present application can be carried out various modification and variations without
It is detached from the spirit and scope of embodiment in the embodiment of the present application.If in this way, in the embodiment of the present application embodiment these modification
Within the scope of belonging in the embodiment of the present application claim and its equivalent technologies with modification, then also it is intended in the embodiment of the present application
It includes these modifications and variations.