Summary of the invention
The invention provides a kind of method and system, can realize large batch of embedded device upgrading preferably, and the efficient height is simple to operate the embedded device batch upgrade.
The embodiment of the invention provides a kind of method to the embedded device batch upgrade, comprises the steps:
The self-defined Ethernet message that A, updating client begin to embedded device broadcasting upgrading, thus activate the upgrading assistant program on the embedded device;
The upgrading assistant program of B, embedded device is sent the ready self-defined Ethernet message of upgrading to updating client, and updating client sends mirror image name and the big or small self-defined Ethernet message of mirror image that carries configuration parameter distributing IP address, FTP ftp server IP address, upgrade file to embedded device;
C, embedded device are provided with its own IP address according to the configuration parameter of receiving, and download the image file of appointment from ftp server;
D, embedded device use this image file to upgrade.
Preferably, step D comprises:
Embedded device is checked the legitimacy of the image file of download, after inspection is passed through, uses this image file to upgrade.
Preferably, further comprise after the step B:
Updating client is to specifying embedded device to send the self-defined Ethernet message that requires the inquiry upgrade status;
Embedded device reports current upgrade status to updating client after receiving the self-defined Ethernet message of said inquiry upgrade status.
Preferably, the upgrading assistant program of said embedded device is sent the model of carrying embedded device in the ready self-defined Ethernet message of upgrading to updating client.
The embodiment of the invention also provides a kind of system to the embedded device batch upgrade, and this system comprises a updating client equipment, FTP ftp server, an Ethernet switch and the embedded device more than of being with upgrading assistant program; Updating client equipment is connected through said Ethernet switch with embedded device;
Said updating client equipment is used for the self-defined Ethernet message to embedded device broadcasting upgrading beginning; Receiving from the upgrading of embedded device behind the ready self-defined Ethernet message, sending mirror image name and the big or small self-defined Ethernet message of mirror image that carries configuration parameter distributing IP address, ftp server IP address, upgrade file to embedded device;
Said embedded device is used for after receiving the self-defined Ethernet message that begins from the updating client apparatus upgrading, activating the upgrading assistant program of self, and sends the ready self-defined Ethernet message of upgrading to updating client; Behind the self-defined Ethernet message of receiving from updating client equipment that carries configuration parameter, the information setting its own IP address of carrying according to configuration parameter, and download the image file of appointment from ftp server, and use this image file to upgrade;
Said ftp server is used to store the required image file of upgrading, and offers embedded device and download said image file.
Preferably, said embedded device is further used for the legitimacy of the image file of downloading is checked, uses this image file to upgrade in inspection through the back.
Preferably, said updating client is further used for to specifying embedded device to send the self-defined Ethernet message that requires the inquiry upgrade status;
Said embedded device is further used for behind the self-defined Ethernet message of receiving the inquiry upgrade status, reporting current upgrade status to updating client.
Preferably, said updating client is further used for to specifying the embedded device sending controling instruction;
Said embedded device is further used for after receiving control command, carries out corresponding operating, returns response frame and reports current upgrade status to updating client.
Preferably, said updating client equipment is PC, and said embedded device is a router.
Preferably, said ftp server is positioned at said updating client equipment, or is separate server equipment.
Can find out from above technical scheme; Realize the escalation process of embedded device in enormous quantities through unified updating client; Realize the distribution of upgrade parameter through self-defining Ethernet protocol; The inquiry of upgrade status, the control of updating apparatus, and through File Transfer Protocol realize the upgrading download of required image file.This method can solve large batch of embedded device upgrading task, and upgrading efficient is high, and updating operation is simple, and the upgrading personnel are few.Thereby reduced apparatus upgrading cost in enormous quantities to a great extent.
Embodiment
Basic thought of the present invention is: realize the distribution of upgrade parameter through self-defining Ethernet protocol; The inquiry of upgrade status; The control of updating apparatus, and through realize the upgrading download of required image file of FTP (FTP, File Transfer Protocol) agreement.
The method flow to the embedded device batch upgrade that the embodiment of the invention provides is as shown in Figure 1, comprises the steps:
Step 101: updating client begins (Start) frame to embedded device broadcasting be used to represent the to upgrade upgrading of beginning, thereby activates the upgrading assistant program on the embedded device.
Step 102: the upgrading assistant program of embedded device is sent to updating client and is used for the ready upgrading of expression upgrading and prepares frame, and updating client sends the configuration frame of configuration parameters such as the mirror image name of carrying distributing IP address, ftp server IP address, upgrade file and size to embedded device.
Step 103: embedded device is provided with its own IP address according to the configuration parameter that the configuration frame carries, and downloads the image file of appointment from ftp server.
Step 104: embedded device uses this image file to upgrade.Preferably, embedded device is checked the legitimacy of the image file of download, after inspection is passed through, uses this image file to upgrade.
Step 105: in the whole process of upgrading; Updating client can be to specifying embedded device to send the self-defined Ethernet message that requires the inquiry upgrade status; So that the upgrade case of inquiry and control embedded device, embedded device also can initiatively report updating client to some unusually.
The network topology structure sketch map that method was suitable for that Fig. 2 provides for the embodiment of the invention to the embedded device batch upgrade.
Wherein on the PC 201 updating client and ftp server are arranged.Switch 202 is PC 201 and the media that is connected of embedded device 203.Embedded device 203 is embedded devices to be upgraded.Be the relation of one-to-many between PC 201 and the embedded device 203.Ftp server also can be the independent ftp server that separates with PC 201, but this ftp server must be connected on the switch 202.In the present embodiment, embedded device 203 is a router.
The realization of this method mainly relies on the updating client on apparatus upgrading assistant program and the PC 201.The relation of updating client and embedded device to be upgraded is the relation of one-to-many, and they connect according to the upgrading topology of Fig. 1, then communicates the common whole upgrade process of accomplishing through self-defined Ethernet protocol.
The frame format of the self-defined Ethernet message in the embodiment of the invention is as shown in table 1:
Table 1
Wherein:
Type representes to carry in this self-defined Ethernet message the protocol type of Frame; Value is 0x8888 in the present embodiment; For carrying the protocol type that Frame is subordinate in the self-defined Ethernet message, the actual value that also can use other and existing protocol type not to conflict.
Version representes the version number of self-defined Ethernet protocol.
Type is concrete frame type, represents different Frames respectively according to its concrete value.
Type=START (0x00) is for frame is initiated in upgrading;
Type=READY (0x01) is for frame is prepared in upgrading;
Type=ASSIGN (0x02) is the upgrade server distributing IP, ftp server IP, port and mirror image name;
Type=REPORT (0x03), the upgrading router is reported upgrade status to updating client;
Type=QUERY (0x04), updating client active inquiry device upgrade state.
Length is a data length, if be that 0 expression does not have data.
DATA is a data content, and is different and different according to the value of Type.
1 byte |
1 byte |
1 byte |
Elongated |
Version |
Type |
Length |
Data |
Table 2
The self-defined frame format of all types of upgrading frames is following:
Upgrading beginning (START) frame
Version: value is 1, and the presentation protocol version is 1.
Type: value is 0, and the type of representing this frame is the START frame.
Length: value is 0, representes the data segment that do not have of this frame.
Data: be worth and be sky, expression START frame does not have data.
(READY) frame is prepared in upgrading
Version: value is 1, and the presentation protocol version is 1.
Type: value is 1, and the type of representing this frame is the READY frame.
Length: be worth and be unit type length, the data length of representing this frame is for sending the unit type of this READY frame.
Data: be worth model, the updating client circular own current unit type of expression on PC 201 for this equipment.
Configuration (ASSIGN) frame
Version: value is 1, and the presentation protocol version is 1.
Type: value is 2, and the type of representing this frame is the ASSIGN frame.
Length: be worth for elongated, represent the data segment, length of this frame.
Data: be worth and be following structure, expression ASSIGN frame is to the relevant upgrade parameter of devices allocation.
4 bytes |
4 bytes |
4 bytes |
4 bytes |
Elongated |
The IP address |
Mask |
Ftp server IP |
Mirror image size (byte number) |
The mirror image name |
Table 3
Report (REPORT) frame
Version: value is 1, and the presentation protocol version is 1.
Type: value is 3, and the type of representing this frame is the REPORT frame.
Length: value is 2, representes the data segment, length of this frame.
Data: be worth and be the equipment state sign indicating number, the current upgrade status sign indicating number of equipment that the updating client of expression REPORT frame on PC 201 reports.
Inquiry (QUERY) frame
Version: value is 1, and the presentation protocol version is 1.
Type: value is 4, and the type of representing this frame is the QUERY frame.
Length: value is 0, representes the data segment that do not have of this frame.
Data: be worth and be sky, expression QUERY frame does not have data, and just the updating client on the PC 201 is to the current upgrade status of embedded device inquiry.
Fig. 3 shows the reciprocal process of embedded device being carried out batch upgrade, comprises the steps:
Updating client on the step 301:PC 201 sends ether broadcasting Start frame, notifies online embedded device to prepare upgrading.
Step 302: when embedded device is received the Start frame, then respond PC 201Ready frame.This is for to PC 201 program registration, and the information of upgrading needs such as request PC 201 distributing IP addresses.Preferably, the overtime retransmission mechanism of said Ready frame band if do not receive the following a piece of news from PC 201 before the timer expired, then resends the Ready frame.
Updating client distributing IP on the step 303:PC 201, mask, ftp server ip, mirror image name and mirror image size, and notice embedded device.
Step 304: embedded device is provided with IP, and begins to download image file.
Step 305: embedded device reports PC201 with the download situation in the process of downloading image file.
Step 306: after downloading completion, embedded device is done verification to downloaded contents, and reports to PC 201 to the result of verification.
Step 307: embedded device reports own current upgrade status.
The upgrade status of embedded device is specified in updating client inquiry on the step 308-309:PC 201, and embedded device reports current upgrade status after receiving the inquiry frame.This step can be carried out in random time after the step 303.
Updating client on the step 310-311:PC 201 after embedded device is received control command, is carried out corresponding operating to specifying the embedded device sending controling instruction, returns response frame and reports current upgrade status to PC 201.This step can be carried out in random time after the step 303.Said control command includes but not limited to: suspend the upgrading of current upgrading, retry, end current upgrading immediately.
Fig. 4 shows the flow process of the embedded device end upgrading processing of the embodiment of the invention, comprises the steps:
Step 401: behind the program start, registration timeout went to step 402 after 300 seconds.
Step 402: judge whether to receive Start frame from PC 201, if, execution in step 403, otherwise, go to step 419.
Step 403: send upgrading to PC 201 and prepare frame.
Step 404-405 registered events surpassed after 6 seconds, judged whether to receive the configuration frame, if, execution in step 406, otherwise go to step 417.
Step 406: whether the inspection allocation of parameters is legal, if execution in step 407 reports mistake and returns step 403 otherwise go to step 416.
Step 407: allocation of parameters is set.
Step 408: download mirror image through FTP.
Step 409: whether inspection mirror image size is correct, if, execution in step 411, otherwise execution in step 410 reports mistake and returns step 408.
Step 411: whether the inspection mirror image is legal, if, execution in step 412, otherwise, go to step 419.
Step 412: upgrade-system.
Step 413: judge whether upgrading is successful, if, execution in step 414, otherwise execution in step 415 reports mistake and returns step 412.
Step 414: upgrade successfully in the notice upper end, the LED light of embedded device is glimmered according to predetermined rule.So far upgrading completes successfully.
Step 417: expired times progressively increase.
Step 418: whether judge expired times greater than 3, if, execution in step 419, otherwise return step 403.
Step 419: discharge resource and quit a program.
Fig. 5 shows the upgrading processing flow process of the updating client end on the PC 201, comprises the steps:
Step 501: require the user to import upgrade parameter.Perhaps, also can be with the upgrade parameter of upgrading the last time of preserving as this upgrade parameter.
Step 502: judge whether upgrade parameter is legal, if, execution in step 504, otherwise execution in step 503 is pointed out user's configuration errors and is returned step 501.
Step 504: create thread, if establishment is main thread, execution in step 507, if establishment is thread function, execution in step 505.
Step 505: duration is set is 5 seconds timer.Said timer expiry, then execution in step 506.
Step 506:, return step 505 then to specifying embedded device to send the upgrading start frame.
Step 507: receive Ether frame.
Step 508: judge that discharging is new escalation process, if, execution in step 509, otherwise execution in step 510.
Step 509: create new escalation process and create corresponding state machine, and distribute corresponding software and hardware resources.
Step 510: according to frame type matching status machine.
Step 511: judge whether coupling is successful, if, execution in step 513, otherwise execution in step 512.
Step 512: abandon this frame.
Step 513: call corresponding processing function according to the successful state machine of coupling, and return step 507.
The present invention program mainly is applicable to the upgrading of embedded device in enormous quantities, can support upgrade parameter to join, and guarantees the correctness of upgrade parameter.To the controllability of escalation process, and the correctness of assurance upgrading.This will reduce to a great extent embedded device in enormous quantities upgrade employed cost of labor with improve upgrading efficient.
The above is merely preferred embodiment of the present invention, and is in order to restriction the present invention, not all within spirit of the present invention and principle, any modification of being made, is equal to replacement, improvement etc., all should be included within the scope that the present invention protects.