Summary of the invention
In order to solve the shortcomings of the prior art, inserts the purpose of the present invention is to provide a kind of more veneers and burn simultaneously
Method, system and replication tool.
Firstly, to achieve the above object, proposing a kind of more veneer method for burn-recording, comprising the following steps:
The first step, each veneer distinguish electrifying startup, and each veneer independently runs level-one BOOT, respectively by each veneer
USB interface is configured to device mode;
Second step detects whether each veneer is hollow plate respectively, if so, passing through veneer USB interface reception pair
Answer the second level BOOT file of this board type;Otherwise, the second level BOOT file being stored in this veneer is read;
Third step, each veneer independently run second level BOOT, and then wiping this veneer is hollow plate;
4th step reads and parses release image, obtains the burning data of the release image;The burning data is burnt
It is written to corresponding veneer.
It further, further include that will obtain after reading and parsing release image in the 4th step of above-mentioned method for burn-recording
Burning data the step of being split as at least two Segment mirror images (section mirror image);Need successively programming each when programming
A Segment mirror image is to corresponding veneer, until by whole burning data programmings to corresponding veneer.
Further, in the 4th step of above-mentioned method for burn-recording, each Segment mirror image described in programming to corresponding list
When plate, include the steps that judging whether programming each time succeeds: if programming success, carries out the burning of next Segment mirror image
It writes;Otherwise, Segment mirror image described in programming again.
Specifically, in above-mentioned method for burn-recording, the first Segment mirror image include: mirror image head, Segment information with
And the BootLoader image file in the burning data;
Wherein, the Segment information includes the number of the Segment mirror image split by the burning data, and every
The data length length of the initial address offset of a Segment mirror image and each Segment mirror image.
And in above-mentioned method for burn-recording, the second or second later Segment mirror image includes: described after splitting
Burning data.
Specifically, the burning data is split as the Segment mirror according to the following steps in above-mentioned method for burn-recording
Picture:
S1 continuously reads corresponding data length in the burning data with fixed data length (length) for unit
The data of reading are encapsulated as a Segment mirror image by data;
S2 repeats the S1, until all skies of content read;
S3, number, the initial address of each Segment mirror image of the whole Segment mirror images of record
(offset), the data of the data length (length) of each Segment mirror image and whole Segment mirror images are long
Degree.
Further, in the third step of method for burn-recording as described above, two are independently run in each veneer
It is further comprising the steps of: the veneer is continuously monitored in time-out time before wiping this veneer and being hollow plate after grade BOOT
The reset interrupt of USB interface enumerates completion interruption, and wiping the veneer further according to the erasing instruction that the thread is sent is sky
Plate.
Secondly, to achieve the above object, it is also proposed that a kind of more veneer programming systems, including processor and with the processing
The veneer USB interface and storage medium of device connection, which is characterized in that the veneer USB interface is to multiple to burning veneer independence
Power supply, the storage medium is stored with computer program, for realizing following step when the computer program is executed by processor
It is rapid:
T1 establishes separate threads for each veneer, for controlling each veneer independence electrifying startup, independent operating one respectively
Grade BOOT, and the veneer USB interface is respectively configured as device mode;
T2 sends hollow plate detection instruction to each veneer respectively from each thread, according to each veneer feedback
Data send second level BOOT file corresponding with the board type to each hollow plate by the veneer USB interface;Or control is each non-
Empty veneer reads the second level BOOT file being stored in the veneer;
T3 controls each veneer by each thread respectively and runs second level BOOT, and wiping this veneer is hollow plate;
T4 reads and parses release image, obtains the burning data of the release image;By each thread by the burning
It records data and distinguishes programming to corresponding veneer.
Further, in above-mentioned programming system, the veneer USB interface is high-power universal serial bus concentrator USB-
HUB (universal serial bus concentrator) interface.
Meanwhile the present invention also proposes a kind of replication tool, including at least one thread, between each thread mutually solely
Vertical, the thread is used to followed the steps below respectively after burning Board Power up detecting:
V1, starting is described to run level-one BOOT to burning veneer, and the configuration USB interface to burning veneer is
Device mode;
V2 sends hollow plate detection instruction to burning veneer to described, according to the data to burning veneer feedback, to institute
It states and sends or control its corresponding second level BOOT file of reading to burning veneer;
V3, control is described to run the second level BOOT file to burning veneer, and the described erasing to burning veneer is hollow plate;
V4 reads and parses release image, obtains the burning data of the release image;Extremely by the burning data programming
It is described to burning veneer.
Beneficial effect
The present invention stands alone as the power supply of each veneer by high-power USB-HUB interface, and accesses the interface for each
Veneer establish separate threads respectively.After running programming system provided by the present invention, insertion veneer can be by the veneer
Thread automatically control realize burning, and muti-piece veneer can simultaneously burning, between each other without influence.It is artificial only to need during burning
It carries out the insertion of veneer, extract, it is easy to operate, it is capable of the efficiency of biggish raising veneer burning, reduces software maintenance
Workload.
Further, the present invention configures device mode for the veneer USB interface and remains unchanged, and can avoid system inspection
Measure multiple plug of same veneer during burning, it is ensured that the integrality of burning.Moreover, the present invention is also described
Include the length of each Segment mirror image in Segment mirror image, cooperates the programming in every each Segment mirror image
Whether the programming process is successfully judged in journey, can be further ensured that the integrality of burning.
Meanwhile the present invention can also be by board type described in each thread independent judgment, and the inhomogeneity according to each veneer
Type is sent second level BOOT file corresponding with board type by each thread respectively.The present invention can support a variety of lists automatically as a result,
Plate automatic adaptation.
Further, also by the way that the burning data of release image is split as several Segment mirror images, cooperation exists the present invention
Mirror image head and Segment information are set in the first Segment mirror image, realize the burning to the veneer of different capabilities.Meanwhile
This mode can also be effectively compressed above-mentioned burning data and be taken up space.Various types of veneer can be adapted to.
Moreover, it is contemplated that just needing burning again at this time in the presence of release image to be burnt to wrong possibility when arriving factory's batch.For
Such case, the present invention further include the steps that assigning erasing instruction before burning data described in programming.By the instruction, first will
EMMC is wiped into empty piece in veneer, is then reburned and is recorded release image, veneer is pure state before guaranteeing each burning, can effectively be prevented
Only remaining dirty data is influenced caused by current version.
Other features and advantages of the present invention will be illustrated in the following description, also, partly becomes from specification
It obtains it is clear that understand through the implementation of the invention.
Specific embodiment
Hereinafter, preferred embodiments of the present invention will be described with reference to the accompanying drawings, it should be understood that preferred reality described herein
Apply example only for the purpose of illustrating and explaining the present invention and is not intended to limit the present invention.
Fig. 1 is more veneer method for burn-recording flow charts according to the present invention, comprising the following steps:
The first step, each veneer distinguish electrifying startup, and each veneer independently runs level-one BOOT, respectively by each veneer
USB interface is configured to device mode (present invention can only use USB interface, other interfaces are without corresponding device mode);Two
Keep the mode constant in grade BOOT, the end PC processor would not detect that same veneer repeatedly plugs in burning engineering,
And then it can guarantee the stability of burning.
Second step detects whether each veneer is hollow plate respectively, if so, passing through veneer USB interface reception pair
Answer the second level BOOT file of this board type;Otherwise, the second level BOOT file being stored in this veneer is read.
Third step, each veneer independently run second level BOOT, and then wiping this veneer is hollow plate;The erasing of this step
Cheng Zhong, in fact it could happen that the case where erasing fails;If wiping successfully, i.e., flash memory in the veneer is wiped into empty piece, then it can be in success
After return to success status, waiting issues release image;Status of fail can be returned if failure, can also be re-started after judging failure
Hollow plate erasing instruction, until wiping successfully.
4th step reads and parses release image, obtains the burning data of the release image;The burning data is burnt
It is written to corresponding veneer.
It further, further include that will obtain after reading and parsing release image in the 4th step of above-mentioned method for burn-recording
Burning data the step of being split as at least two Segment mirror images (section mirror image);Need successively programming each when programming
A Segment mirror image is to corresponding veneer, until by whole burning data programmings to corresponding veneer.It does not use directly
All release image methods of burning, but it is for smaller, the nothing for DDR that burning data, which is split into multiple Segment, herein
The case where method complete burning whole burning data.Meanwhile this mode needs the institute of burning again when can also avoid burning mistake
There is mirror image, improves burning efficiency.Moreover, because burning data is split, this method burning 8G can be directly utilized
EMMC.The two method for burn-recording is identical, only increases the number of burning Segment mirror image.
Further, in the 4th step of above-mentioned method for burn-recording, each Segment mirror image described in programming to corresponding list
When plate, include the steps that judging whether programming each time succeeds: if programming success, carries out the burning of next Segment mirror image
It writes;Otherwise, Segment mirror image described in programming again.This does not have to re-start entire mirror image in burning failure clearly as a result,
Burning.While improving burning efficiency, the requirement to system DDR size is reduced indirectly.
Specifically, in the present invention, the first Segment mirror image includes: mirror image head, Segment referring to shown in Fig. 3
BootLoader image file in information and the burning data;
Wherein, the Segment information includes the number of the Segment mirror image split by the burning data, and every
The data length length of the initial address offset of a Segment mirror image and each Segment mirror image.
It not only can easily be downloaded to using the release image of Segment mirror-image structure burning shown in Fig. 3 scheme
In the EMMC flash memory of 4G, it is equally also suitable the EMMC of 8G.And it, can be with burning than veneer DDR because burning mirror image can be split
Bigger mirror image.
And in above-mentioned method for burn-recording, the second or second later Segment mirror image includes: described after splitting
Burning data.
Specifically, the burning data is split as the Segment mirror according to the following steps in above-mentioned method for burn-recording
Picture:
S1 continuously reads corresponding data in the burning data with fixed data length (length=128b) for unit
The data of reading are encapsulated as a Segment mirror image by the data of length;
S2 repeats the S1, until all skies of content read;
S3, number, the initial address of each Segment mirror image of the whole Segment mirror images of record
(offset), the data of the data length (length) of each Segment mirror image and whole Segment mirror images are long
Degree.
Using the above method, the burning data for needing to split is extracted from release image before burning, according to fixed data
Release image is split into lesser Segment mirror image by length, the next mirror of burning again after current Segment mirror image burning success
Picture re-downloads, burning if current mirror image burning failure.The method can be with compression space.In addition, in the step S1 also
The data of a subregion can be encapsulated as a Segment mirror image as unit of a subregion.It is divided according to partitioned mode
Segment can facilitate single subregion to carry out burning.
Further, in the third step of method for burn-recording as described above, two are independently run in each veneer
It is further comprising the steps of: the veneer is continuously monitored in time-out time before wiping this veneer and being hollow plate after grade BOOT
The reset interrupt of USB interface enumerates completion interruption, and wiping the veneer further according to the erasing instruction that the thread is sent is sky
Plate.
Referring to Fig. 2, to achieve the above object, the present invention goes back while proposing a kind of more veneer programming systems.Including processor
(CPU for referring mainly to PC machine) and the veneer USB interface and storage medium being connected to the processor, the veneer USB interface
To the multiple independently-powered to burning veneer, the storage medium is stored with computer program, and the computer program is located
It manages when device executes for realizing following steps:
T1 establishes separate threads for each veneer respectively, and the serial port one-to-one correspondence of thread and veneer is described each for controlling
Veneer independence electrifying startup, independent operating level-one BOOT, and the veneer USB interface is respectively configured as device mode;It should
The state of monitoring process meeting circulatory monitoring PC machine USB interface where thread has detected that the as veneer creates when veneer insertion
New thread distributes resource, realizes burning;When monitoring that veneer is extracted, the thread resources that burning is completed only are discharged.New plate as a result,
Insertion, extract existing burning process will not be interfered.
T2 sends hollow plate detection instruction to each veneer respectively from each thread, according to each veneer feedback
Data send second level BOOT file corresponding with the board type to each hollow plate by the veneer USB interface, carry out hollow plate burning
Record;Or each non-empty veneer of control reads the second level BOOT file being stored in the veneer, carries out online upgrading.
T3 controls each veneer by each thread respectively and runs second level BOOT, and wiping this veneer is hollow plate;It considers
The second level BOOT of different veneers is different, therefore, in order to realize the automatic burning of multiple veneers, needs to look into before burning second level BOOT
Board type is ask, downloads corresponding second level BOOT according to veneer feedback states.Simultaneously, it is contemplated that exist when factory's batch by version
This mirror image burns wrong possibility, just needs burning again at this time.In response to this, system needs to issue sky before burning mirror image
EMMC first is wiped then to reburn at empty piece and is recorded release image by plate erasing instruction, and veneer is pure state before guaranteeing each burning,
Prevent remaining dirty data from impacting to current version.
T4 reads and parses release image, obtains the burning data of the release image;By each thread by the burning
It records data and distinguishes programming to corresponding veneer.
Further, in above-mentioned programming system, the veneer USB interface is high-power USB-HUB interface.Using independently-powered
Relatively high power USB-HUB, can simultaneously it is independently-powered to all veneers of access, the output power of HUB need to meet veneer burning
Power consumption requirements when record.This step is to guarantee the basis of burning process easy, and veneer USB can not only be used for power supply port and again may be used at this time
As port, without additional power supply on veneer, operating procedure is simplified, burning efficiency is improved.
Further, in above-mentioned programming system, in the T3 step, each veneer is controlled by each thread respectively and is transported
It is further comprising the steps of: the list is continuously monitored in time-out time before wiping this veneer and being hollow plate after row second level BOOT
The reset interrupt of plate USB interface enumerates completion interruption, and wiping the veneer further according to the erasing instruction that the thread is sent is sky
Plate.Time-out time is the limiting time set herein, and veneer detects that two interruptions are then thought and the end PC phase within a limited period of time
Even, it needs to respond respective interrupt;If two interruptions are otherwise not detected, start kernel.
Meanwhile the present invention also proposes a kind of replication tool, including at least one thread, between each thread mutually solely
Vertical, each thread is corresponding to burning veneer with one respectively, and each thread is for detecting that its is corresponding to burning veneer
After electricity, follow the steps below:
V1, starting is described to run level-one BOOT to burning veneer, and the configuration USB interface to burning veneer is
Device mode;
V2 sends hollow plate detection instruction to burning veneer to described, according to the data to burning veneer feedback, to institute
It states and sends or control its corresponding second level BOOT file of reading to burning veneer;
V3, control is described to run the second level BOOT file to burning veneer, and the described erasing to burning veneer is hollow plate;
V4 reads and parses release image, obtains the burning data of the release image;Extremely by the burning data programming
It is described to burning veneer.
Specifically by taking cortex-m0 veneer as an example, veneer burning implementation process is as follows:
When carrying out single board design, USB controller will support device mode that can match.
When Board Power up, cured level-one BOOT (i.e. BOOTrom) can be loaded by cortex-m0 first from ROM
RAM runs level-one BOOT, initializes UART and USB, and configure device mode so that PC is able to detect that for USB interface
Veneer.
When whether detection veneer is hollow plate, first by the fixed area of flash memory EMMC in BOOTrom reading veneer to RAM, root
Hollow plate state is judged according to the partial data.It is judged as hollow plate when not being specific data, is returned when receiving hollow plate inquiry instruction empty
Piece state, is started with USB mode.That is, receiving the second level BOOT file U- of this corresponding board type by the veneer USB interface
Boot.bin.At this time the device mode of USB is not needed to reconfigure, otherwise PC may detect the single-board insert-pull of mistake
It operates (even if the veneer does not plug).
If BOOTrom detects that EMMC fixed area is specific data, it is judged as non-empty veneer, shows it is online at this time
Upgrading is run from U-Boot code is read in EMMC into DDR, compared with hollow plate burning, is omitted from replication tool and is obtained U-
The process of Boot.At this point, directly reading the second level BOOT file being stored in this veneer.
When each veneer independently runs second level BOOT (i.e. U-Boot) starting initialization veneer, it can detect in PC transmission
It is disconnected, to prevent false judgment caused by the exception of PC, it is consecutively detected USB reset interrupt in time-out time and enumerates in completion
It has no progeny and enters burning mode, wait hollow plate erasing instruction, after receiving hollow plate erasing instruction, wipe entire EMMC chip.Otherwise
Normal starting.
Release image is last read and parsed, the burning data of the release image is obtained;By the burning data programming
To corresponding veneer.Defined according to mirror-image format, release image head contains split after small mirror image write-in EMMC offset and
Length, and the information is included in first image file, first mirror image also includes simultaneously BootLoader mirror image.U-
Boot can parse EMMC is written in subsequent all mirror images offset and length after receiving first mirror image, and will
Then BootLoader returns to programming successful information from the Boot subregion of DDR write-in EMMC.Later received mirror image according to solution
The offset and length of analysis are sequentially written in the non-Boot subregion of EMMC, move in circles, until all mirror image programmings are completed.
Specific work process in terms of replication tool is as follows:
Burning mirror image is selected first, runs replication tool.Replication tool creates a course cycles and the API of PC is called (to answer
With Program Interfaces) detection USB interface state.Driver can be by USB enumeration at serial ports, when PC has detected equipment insertion
When, the serial port of thread and veneer is bound and is corresponded, and applies for one thread of asset creation.When having detected equipment extraction,
Discharge the thread resources of corresponding equipment creation.
Replication tool sends hollow plate detection instruction to veneer, and BOOTrom is different from the Query Value that U-Boot is returned, and is made with this
For hollow plate burning or the judgment basis of online upgrading.Simultaneously the instruction also can be used as veneer operation basic test, veneer without
Feedback shows operation irregularity, needs to check hardware.
Need to load U-Boot, the instruction of replication tool transmitting single plate type queries, the list fed back according to BOOTrom when hollow plate
Board type state selects the corresponding U-Boot of veneer and corresponding address ram is written.U-Boot normally starts when online upgrading,
Ignore the step.This completes the automatic adaptations of different board types.
When making burning mirror image, the EMMC address information of Segment message part in mirror image, corresponding is 4G size.
Since the extra 4G of 8G EMMC has only been allocated to data subregion, other subregions are constant, therefore to be also applied for 8G big for the mirror image
Small veneer.Replication tool is read in release image deposit PC DDR, is parsed from release image and is needed to be written EMMC's
Segment information, offset and length including Segment sum, each Segment.After being parsed, first mirror is sent
Picture size retransmits first mirror image after feeding back successful information to veneer, veneer.First mirror image includes: mirror image head, Segment letter
Breath, Segment1 image file (i.e. BootLoader image file).Segment information is parsed to veneer, is obtained
After the offset and length of EMMC is written in Segment1, programming instruction is sent by Segment1, EMMC is written from DDR, if intermediate
A certain step failure then retransmits.When mirror image after sending SegmentN (N >=2), only image file does not include mirror image head
With Segment information.Successively sent according to above-mentioned steps Segment2 ..., SegmentN, until burning complete.
The USB interface state of any time process detection PC during burning has transformation, and judgement is insertion or extracts,
New burning thread is created if insert action, discharges corresponding burning thread resources if extracting.
The advantages of technical solution of the present invention is mainly reflected in: the present invention is stood alone as each by high-power USB-HUB interface
A veneer power supply, and separate threads are established respectively for each veneer for accessing the interface.Running burning provided by the present invention
After recording system, insertion veneer can by the thread of the veneer automatically control realize burning, and muti-piece veneer can simultaneously burning, mutually
Between without influence.During burning, manually only needs to carry out the insertion of veneer, extracts, it is easy to operate, it being capable of biggish raising list
The efficiency of board burning reduces the workload of software maintenance, and can be adapted to a plurality of types of veneers.
Those of ordinary skill in the art will appreciate that: the foregoing is only a preferred embodiment of the present invention, and does not have to
In the limitation present invention, although the present invention is described in detail referring to the foregoing embodiments, for those skilled in the art
For, still can to foregoing embodiments record technical solution modify, or to part of technical characteristic into
Row equivalent replacement.All within the spirits and principles of the present invention, any modification, equivalent replacement, improvement and so on should all include
Within protection scope of the present invention.