Content of the invention
The invention mainly solves the technical problem of providing a kind of acquisition methods of the journal file of mobile device, Neng Gouzhi
Connect usb interface to read journal file to external equipment, effectively improve the efficiency of debugging.
For solving above-mentioned technical problem, one aspect of the present invention is: provides a kind of daily record of mobile device
The acquisition methods of file, method includes:
The journal file that mobile device is produced in debugging process stores to the cushion space of the internal memory of mobile device,
Including:
The character string that produce mobile device in debugging process and error information store to the first buffering sky of internal memory
Interior;
Character string in first cushion space and error information are carried out being organized into journal file and storing to internal memory
Second cushion space;
Journal file in cushion space is stored to the predetermined partition of the embedded memory of mobile device;
Journal file in predetermined partition is read to external equipment.
Wherein, the buffering that journal file mobile device being produced in debugging process stores the internal memory to mobile device is empty
Further include before interior step: judge that whether corresponding global variable is that to represent that cushion space has been allocated successfully predetermined
Numerical value, if predetermined value then executes the journal file producing mobile device in debugging process and stores to mobile device
The step in cushion space deposited.
Wherein, journal file is the journal file producing in the preloading procedure of mobile device.
Wherein, the journal file in cushion space is stored to the predetermined partition of the embedded memory of mobile device
Further include before step: judge whether corresponding macro-variable is opened, if macro-variable is opened, execute in cushion space
Journal file stores the step to the predetermined partition of the embedded memory of mobile device.
Wherein, the buffering that journal file mobile device being produced in debugging process stores the internal memory to mobile device is empty
Interior step includes: judges whether cushion space overflows, if cushion space overflows, executes the daily record literary composition in cushion space
The step that part stores the predetermined partition of the embedded memory to mobile device.
Wherein, the journal file in cushion space is stored the step of the predetermined partition of the embedded memory to mobile device
Rapid inclusion: judge whether predetermined partition overflows, if predetermined partition is overflowed, stop storing journal file to predetermined partition.
Wherein, the journal file in cushion space is stored to the predetermined partition of the embedded memory of mobile device
Step: the journal file part in the second cushion space is stored to the 3rd cushion space of internal memory;Judge corresponding macro-variable
Whether open;If macro-variable is opened, judge whether the 3rd cushion space is empty;If the 3rd cushion space is sky, returning will
The step that journal file part in second cushion space stores the 3rd cushion space to internal memory;If the 3rd cushion space is not
Sky, then judge whether predetermined partition overflows;If predetermined partition is not overflowed, judge whether the file in predetermined partition is opened;If
File Open in predetermined partition, then by the journal file write predetermined partition in the 3rd cushion space, empty the 3rd buffering empty
Between and return and judge that whether the 3rd cushion space is empty step.
Wherein, the journal file that journal file produces in kernel running for mobile device.
Wherein, the step journal file in predetermined partition being read to external equipment includes: will be made a reservation for by usb interface
Journal file in subregion reads to external equipment.
The invention has the beneficial effects as follows: it is different from the situation of prior art, the present invention passes through debugging mobile device
The journal file producing in journey stores to the cushion space of the internal memory of mobile device;Again the journal file in cushion space is deposited
Store up to the predetermined partition of the embedded memory of mobile device;When needing to use journal file, by the day in predetermined partition
Will file reads to external equipment;Enable to engineer need in debugging process analyze journal file when, directly pass through usb
Journal file is read to external equipment by interface from mobile device, effectively improves the efficiency of engineer's debugging.
Specific embodiment
The present invention is described in detail with embodiment below in conjunction with the accompanying drawings.
As shown in figure 1, Fig. 1 is the schematic flow sheet of the acquisition methods of the journal file of mobile device of the present invention.The present invention
The acquisition methods of the disclosed journal file of mobile device 10 are realized based on mobile device 10 and external equipment 20, move
Dynamic equipment 10 is connected with external equipment 20, as shown in Figure 2 it is preferable that mobile device 10 passes through usb with external equipment 20
(universal serial bus, USB (universal serial bus)) data wire 30 connects.The method comprises the following steps:
Step s101: the journal file that mobile device 10 is produced in debugging process stores to the internal memory of mobile device 10
Cushion space in;
In step s101, the cushion space of internal memory is preferably ram (the random access of mobile device 10
Memory, random access memory) one memory headroom of middle distribution.
Step s102: the journal file in cushion space is stored predetermined point of the embedded memory to mobile device 10
In area.
Step s103: the journal file in predetermined partition is read to external equipment 20;
In step s103, start address, the length of journal file reading journal file is set by external equipment 20
With preserve the address to external equipment 20 for the journal file, external equipment 20 is according to the start address of journal file, journal file
Journal file is read from the predetermined partition of mobile device 10 in the address of length and preservation journal file to external equipment 20.For example,
External equipment 20 passes through to start start address, the length of journal file of flash tool (debugging acid) setting reading journal file
Battery, to the address of external equipment 20, is extracted after mobile device 10 shutdown and then is loaded on by degree and preservation journal file, outside
Equipment 20 reads the journal file of mobile device 10 by usb data wire 30.
Preferably, mobile device 10 is in the android debugging process based on mtk platform, the day first producing each stage
Will file stores to the cushion space of the internal memory of mobile device 10;Again be stored in the journal file in cushion space each stage
Store to the predetermined partition of the embedded memory of mobile device 10;Therefore external equipment 20 can be pre- from mobile device 10
Determine the journal file that subregion obtains mobile device 10.
In the present embodiment, mobile device 10 journal file is stored in predetermined partition and includes first stage, second-order
Section and phase III.When in the first stage, by calling preloader_emmc_write_test () function, by the first rank
The journal file of section is saved in the initial address of the predetermined partition of first stage.When executing second stage, by calling
Uboot_emmc_w rite_test () function, the journal file of second stage is saved in second stage predetermined partition rise
Beginning address, wherein, the initial address of the predetermined partition of second stage is the end address skew of the predetermined partition of first stage
0x1800.When executing the phase III, by calling kernel_emmc_wri te_test () function, by the day of phase III
Will file is saved in the initial address of the predetermined partition of phase III, and the initial address of the predetermined partition of phase III is second-order
The end address skew 0x1800 of the predetermined partition of section;Printk wherein in kernel_emmc_wri te_test () function
Journal file is sent to control station by () function, wherein has two main cache function in printk () function, is printk_
Buf () function and log_buf () function, wherein, printk_buf () function is used for storing character string to be exported and the letter that reports an error
Breath, log_buf () function is used for storing character string finally to be exported.Therefore, external equipment 20 pass through to obtain the first stage, the
The journal file of two-stage and phase III just can be realized reading the journal file of mobile device 10.
As shown in figure 3, Fig. 3 is the acquisition methods flow process signal of the first stage of the journal file of mobile device of the present invention
Figure.The method comprises the following steps:
Step s201: mobile device 10 execution first stage;
After mobile device 10 start, when the mobile device 10 execution first stage, mobile device 10 is carried out to ram first
Related initialization, the initialization of the hardware device such as such as bus and peripheral circuit.After initialization, ram increases the first stage pair
The global variable answered.
Step s202: judge whether global variable is to represent the predetermined value that cushion space has been allocated successfully;
Wherein, the numerical value that global variable distributes for cushion space, predetermined value is 1, certainly, in other embodiments, in advance
Fixed number value can also be other numerical value, and concrete needs set according to user.
If it is determined that global variable is predetermined value, then step s203: judge whether cushion space overflows;
Wherein, cushion space is one memory headroom being used for temporary cache journal file of ram distribution of mobile device 10,
In each cushion space correspondence different stages, cushion space herein is the cushion space of first stage.In addition, increased judgement
The step whether cushion space overflows, the cushion space in order to ensure to distribute will not affect making of next section of internal memory because of spilling
With.
If it is determined that cushion space does not spill over, then step s204: the journal file of first stage is stored to mobile device
In the cushion space of 10 internal memory;
Wherein, the journal file of first stage is the journal file producing in the preloading procedure of mobile device 10.
If it is determined that global variable is not predetermined value or if it is determined that cushion space overflows, or execution of step
S204, then step s205: judge whether first stage corresponding macro-variable is opened;
Wherein, the predetermined partition of the corresponding different phase of each macro-variable, macro-variable herein corresponds to the predetermined of first stage
Subregion.
If it is determined that macro-variable is opened, then step s206: the journal file in cushion space is stored to mobile device 10
The predetermined partition of embedded memory in;
I.e. by calling preloader_emmc_write_test () function, the journal file of first stage is saved in
The initial address of the predetermined partition of first stage.
If it is determined that macro-variable is not opened or execution of step s206, then step s301: mobile device 10 execution second
Stage.
In the present embodiment, if before ram also no initializtion, just the journal file of first stage is saved in buffering empty
Interior, the system of mobile device 10 can be led to go wrong.Therefore, can stop preserving journal file after cushion space preserves full
Operation, wherein, the present invention is assigned sufficiently long cushion space.
As shown in figure 4, the acquisition methods flow process that Fig. 4 is the second stage of the journal file of mobile device of the present invention is illustrated
Figure.The method comprises the following steps:
Step s301: mobile device 10 execution second stage.
Step s302: judge whether cushion space overflows;
Wherein, cushion space herein is the cushion space of second stage.
If it is determined that cushion space does not spill over, then step s303: the journal file of second stage is stored to mobile device
In the cushion space of 10 internal memory.
If it is determined that cushion space overflows or execution of step s303, then step s304: judge that second stage is corresponding grand
Whether variable is opened;
Wherein, the predetermined partition of the corresponding second stage of macro-variable herein.
If it is determined that macro-variable is opened, then step s305: the journal file in cushion space is stored to mobile device 10
The predetermined partition of embedded memory in;
I.e. by calling uboot_emmc_w rite_test () function, the journal file of second stage is saved in second
The initial address of the predetermined partition in stage, wherein, the initial address of the predetermined partition of second stage is predetermined point of the first stage
The end address skew 0x1800 in area.
If it is determined that macro-variable is not opened or execution of step s305, then leap to step s401: mobile device 10 is held
The row phase III.
In the present embodiment, in mobile device 10 execution second stage, assembly code is first carried out, when having executed
After start.s file, start to jump to start_armboot () function execution c code.Because ram executes in mobile device 10
Initialize successfully during the first stage, therefore in mobile device 10 execution second stage, just sending in printf () function
Journal file toward serial ports is saved in cushion space.But in order to avoid cushion space overflows, equally increased judgement buffering
The step whether space overflows is to protect cushion space.Wherein, the journal file of second stage follows gpl (general
Public license, general public licence) clause open source code project.
As shown in figure 5, Fig. 5 is the acquisition methods flow process signal of the phase III of the journal file of mobile device of the present invention
Figure.The method comprises the following steps:
Step s401: mobile device 10 execution phase III.
Step s402: the character string that produce the phase III in debugging process and error information store to the of internal memory
In one cushion space;
In step s402, printk () function can will by vprintk () function call vscnprintf () function
The character string of output and error information put into printk_buf () function.
Step s403: the character string in the first cushion space and error information are carried out being organized into journal file and storing
The second cushion space to internal memory;
In step s403, printk () function recalls emit_log_char () function by printk_buf () function
Data compilation after form journal file copy log_buf () function to.
Step s404: the journal file part in the second cushion space is stored to the 3rd cushion space of internal memory.
In step s404, printk () function recalls _ _ call_console_drivers (start, end) function
Output content is divided into some and is sent to console driving, and journal file is copied to the 3rd cushion space.
After execution of step s404, then step s405: judge whether phase III corresponding macro-variable is opened;
Wherein, the predetermined partition of the corresponding phase III of macro-variable herein.
If it is determined that macro-variable is opened, then step s406: judge whether the 3rd cushion space is empty.
If it is determined that the 3rd cushion space is sky, then return to step s404, if it is determined that the 3rd cushion space is not empty, then
Step s407: judge whether predetermined partition overflows.
If it is determined that predetermined partition does not spill over, then step s408: judge whether the file in predetermined partition is opened.
If it is determined that macro-variable is not opened or judged that predetermined partition is overflowed, or judge that the file in predetermined partition is not beaten
Open, then step s410: stop storing the journal file of phase III to predetermined partition.
If it is determined that the File Open in predetermined partition, then step s409: the journal file in the 3rd cushion space is write
Enter predetermined partition, and empty the 3rd cushion space;
I.e. by calling kernel_emmc_wri te_test () function, the journal file of phase III is saved in
The initial address of triphasic predetermined partition, the initial address of the predetermined partition of phase III is the predetermined partition of second stage
End address offsets 0x1800;After the journal file of the 3rd cushion space is all saved in predetermined partition, empty the 3rd buffering empty
Between.
After execution of step s409, continue return to step s406.
In the present embodiment, log_buf () function and printk_buf () form an annular cushion space, and join
The variable closing the use of this loop buffer space is log_start/log_end/con_start.When printk () function call
While call_consoles_drivers (start, end) function, journal file can be copied to an interim distribution the 3rd
Cushion space _ k_log_buf () function in, because the log file data in the phase III is very many, then the 3rd buffering is empty
Between _ k_log_buf () function is designed to loop configuration, and when copying journal file, will by the cushion space of loop configuration
Journal file point some copies predetermined partition to by endless form.When therefore mobile device 10 executes the phase III,
Journal file in log_buf () function copies a 3rd independent cushion space to, then by file system, daily record is civilian
Part is write in subregion.Wherein, the daily record literary composition that the journal file of phase III produces in kernel running for mobile device 10
Part.
In sum, the present invention is stored to mobile device by the journal file producing mobile device in debugging process
The cushion space of internal memory in;Again the journal file in cushion space is stored the predetermined of the embedded memory to mobile device
In subregion;When needing to use journal file, the journal file in predetermined partition is read to external equipment;Enable to engineering
When teacher needs to analyze journal file in debugging process, directly by usb interface, journal file is read to outer from mobile device
Portion's equipment, effectively improves the efficiency of engineer's debugging.
The foregoing is only embodiments of the present invention, not thereby limit the scope of the claims of the present invention, every utilization is originally
Equivalent structure or equivalent flow conversion that description of the invention and accompanying drawing content are made, or directly or indirectly it is used in other correlations
Technical field, is included within the scope of the present invention.