Summary of the invention
The object of the present invention is to provide a kind of embedded system and upgrade maintaining method thereof, to solve the technical matters of MCU upgrading inconvenience.
The invention provides a kind of upgrade maintaining method of embedded system, this embedded system comprise host computer and can with the slave computer of this upper machine communication, described host computer is provided with USB (universal serial bus), and the method comprises:
When detecting that described USB (universal serial bus) has memory device to access, whether the memory device inside of upper computer detection access exists ROMPaq;
If there is ROMPaq, host computer, according to the rule pre-seted, determines the corresponding objects of this ROMPaq;
After determining the corresponding objects of this ROMPaq, host computer stops the master routine being used for controlling each slave computer, judges whether to utilize this ROMPaq to carry out upgrade maintenance for its corresponding objects, if so, then utilizes this ROMPaq to carry out upgrade maintenance for its corresponding objects.
Wherein, if there is ROMPaq, host computer, according to the rule pre-seted, determines that the corresponding objects of this ROMPaq comprises:
If there is ROMPaq, the title of this filename with host computer itself and each slave computer, according to the filename of ROMPaq, is mated, to determine the corresponding objects of this ROMPaq by host computer.
Wherein, judge whether that this ROMPaq can be utilized to carry out upgrade maintenance for its corresponding objects to be comprised:
Host computer obtains the version number of the present procedure of the corresponding objects of this ROMPaq;
Host computer is by corresponding with the version number of ROMPaq for the version number got, if the version number of ROMPaq is comparatively new, then determines and this ROMPaq can be utilized to carry out upgrade maintenance for its corresponding objects.
Wherein, if the corresponding objects of determined ROMPaq be host computer and can utilize this ROMPaq for its corresponding objects carry out upgrade maintenance time, utilize this ROMPaq to carry out upgrade maintenance for its corresponding objects and comprise:
This ROMPaq obtains to internal memory by host computer from the memory device of access, and utilizes this ROMPaq to cover current master routine, to realize the upgrade maintenance of host computer.
Wherein, if the corresponding objects of determined ROMPaq for one of them slave computer and can utilize this ROMPaq for its corresponding objects carry out upgrade maintenance time, utilize this ROMPaq to carry out upgrade maintenance for its corresponding objects and comprise:
This ROMPaq obtains to internal memory by host computer from the memory device of access, and this ROMPaq is sent to slave computer.
Wherein, the method also comprises:
When slave computer detects the ROMPaq from host computer, after carrying out handshake communication with host computer, receive this ROMPaq and put into flash memory, utilize this ROMPaq to cover current application program, carry out upgrade maintenance.
Wherein, described embedded system also comprises display device, and this display device connects host computer, and the method also comprises:
Whether current host computer and/or the slave computer carrying out upgrade maintenance of display device display, also show host computer and transmits the speed of ROMPaq from the memory device acquisition speed of ROMPaq of access, host computer and slave computer and successfully obtain and/or Successful transmissions.
Present invention offers following beneficial effect: the upgrade maintaining method embodiments providing a kind of embedded system, the cooperation of the memory device accessed by host computer and USB interface, for slave computer provides a kind of method of upgrade maintenance, solve the technical matters of slave computer updating operation inconvenience.
Second aspect present invention provides a kind of embedded system, this system comprise host computer and can with the slave computer of this upper machine communication, described host computer is provided with USB (universal serial bus),
When described upper computer detection has memory device to access to described USB (universal serial bus), whether the memory device inside detecting access exists ROMPaq; If detect to there is ROMPaq, according to the rule pre-seted, determine the corresponding objects of this ROMPaq, and after determining this corresponding objects, stop the master routine being used for controlling each slave computer, judge whether to utilize this ROMPaq to carry out upgrade maintenance for its corresponding objects; If so, this ROMPaq is then utilized to carry out upgrade maintenance for its corresponding objects.
Wherein, judge whether that this ROMPaq can be utilized to carry out upgrade maintenance for its corresponding objects to be comprised:
Host computer obtains the version number of the present procedure of the corresponding objects of this ROMPaq;
Host computer is by corresponding with the version number of ROMPaq for the version number got, if the version number of ROMPaq is comparatively new, then determines and this ROMPaq can be utilized to carry out upgrade maintenance for its corresponding objects.
Wherein, this system also comprises the display device connecting host computer;
Display device, show the current host computer and/or the slave computer that carry out upgrade maintenance, also show host computer and obtain the speed of ROMPaq, host computer and slave computer from the memory device of access and transmit the speed of ROMPaq and whether successfully obtain and/or Successful transmissions.
Other features and advantages of the present invention will be set forth in the following description, and, partly become apparent from instructions, or understand by implementing the present invention.Object of the present invention and other advantages realize by structure specifically noted in instructions, claims and accompanying drawing and obtain.
Embodiment
Describe embodiments of the present invention in detail below with reference to drawings and Examples, to the present invention, how application technology means solve technical matters whereby, and the implementation procedure reaching technique effect can fully understand and implement according to this.It should be noted that, only otherwise form conflict, each embodiment in the present invention and each feature in each embodiment can be combined with each other, and the technical scheme formed is all within protection scope of the present invention.
As shown in Figure 1, in embodiments of the present invention, embedded system comprise host computer and one or more can with the slave computer of this upper machine communication (such as slave computer 1 to 4).In general, conceptually, effector and service provider are host computers, are slave computers by effector and attendee.In the embodiment of the present invention, host computer adopts band serial communication interface (abbreviation serial ports), USB interface, display device (such as liquid crystal indicator (LiquidCrystal Display, be called for short LCD)) industrial control computer of the interface such as interface, the serial ports of host computer is used to each slave computer communication, in order to monitor upgrade maintenance process in real time, be convenient to the operation of staff, this host computer is also connected with display device.In addition, the slave computer of the embodiment of the present invention adopts the MCU microcontroller with application programming (InApplication Programming is called for short IAP) function.
Embodiments provide a kind of upgrade maintaining method of above-mentioned embedded system, this upgrade maintaining method is conducive to solving the technical matters of slave computer (such as MCU) upgrading inconvenience in prior art.As shown in Figure 2, the method comprises:
Step S101, when detecting that USB (universal serial bus) has memory device to access, upper computer detection access memory device inside whether there is ROMPaq.
After the memory device (such as USB flash disk) being applicable to USB (universal serial bus) is inserted the corresponding interface of host computer by staff, host computer can scan the memory device of this access, whether there is ROMPaq in the memory device detecting this access.
Concrete, when specific filename being detected, there is ROMPaq in the memory device can knowing this access in each filename of the memory device inside of host computer scanning access.
If step S102 exists ROMPaq, host computer, according to the rule pre-seted, determines the corresponding objects of this ROMPaq.
In general, engineering staff, for the ease of differentiating each ROMPaq, can give each ROMPaq a unique filename, and filename is generally that the host computer corresponding with it or slave computer match.The title of this filename with host computer itself and each slave computer according to the filename of ROMPaq, can be mated, to determine the corresponding objects of this ROMPaq by host computer.
Or, also can store a form or one group of upgrading catalogue in advance in host computer, in form or catalogue, record the corresponding relation of the filename of ROMPaq and host computer, slave computer.In embodiments of the present invention, host computer, after getting the filename of ROMPaq, can learn the corresponding objects of this upgrade file by inquiring about this upgrading catalogue.
Step S103, determine this ROMPaq corresponding objects after, host computer stops the master routine being used for controlling each slave computer, judge whether to utilize this ROMPaq to carry out upgrade maintenance for its corresponding objects, if so, then utilize this ROMPaq to carry out upgrade maintenance for its corresponding objects.
When after the corresponding objects determining ROMPaq, whether host computer needs to detect this ROMPaq to its corresponding objects is higher version.And now no matter the corresponding objects of ROMPaq be host computer itself or one of them slave computer, all must ensure that the corresponding objects of ROMPaq is in off position, otherwise not only possibly normally cannot upgrade, itself cause irreversible damage also likely to this corresponding objects.Therefore, host computer terminates the master routine controlling each slave computer, and this makes host computer itself also enter off position.
Host computer accesses the corresponding objects of this ROMPaq, obtains the version number of the present procedure of the corresponding objects of this ROMPaq, contrasts with the version number of ROMPaq.If the version number of ROMPaq is comparatively new, then host computer is learnt and this ROMPaq can be utilized to carry out upgrade maintenance operation to its corresponding objects; Otherwise the current state of this corresponding objects is constant by keeping.
After upgrade maintenance operation terminates, host computer reopens its master routine, to realize control to slave computer, driving, recovers normal operating conditions.
Wherein, if the corresponding objects of determined ROMPaq is host computer, and during the version of the version of this ROMPaq higher than the current master routine of host computer, host computer obtains ROMPaq by the memory device of access USB interface, be buffered in internal memory (such as random access memory (Random-Access Memory is called for short RAM)).Obtain successfully, host computer will transfer this ROMPaq to cover current master routine, carries out the upgrade maintenance operation of host computer.
In addition, if the corresponding objects of determined ROMPaq is one of them slave computer, and when the version of this ROMPaq is higher, host computer needs in the memory device of access USB interface, obtain ROMPaq and be buffered in internal memory equally.Obtain successfully, this ROMPaq is sent to corresponding slave computer by host computer, carries out upgrade maintenance operation for slave computer.
Application master routine in slave computer, when the ROMPaq from host computer being detected, is transferred to after carrying out serial ports handshake communication in slave computer default " boot boot ", now can receives this binary ROMPaq with host computer.Due to ROMPaq transmit time, be partitioned into multiple packet, this multiple packet sends in order successively, and slave computer receives these packets successively and is restored to ROMPaq according to the sequencing of each packet.In order to prevent transmitting procedure from makeing mistakes, causing the failure of slave computer upgrade maintenance, in transmitting procedure, cyclic redundancy check (CRC) code (Cyclic Redundancy Check is called for short CRC) need be carried out.This is a kind of error check code the most frequently used in data communication field, it is characterized in that the length of information field and check field can be selected arbitrarily.CRC is a kind of data transmission error-detecting function, and transmitting terminal carries out polynomial computation to data, and is attached to after frame by the result obtained, and receiving end also performs similar algorithm, to ensure the correctness that data are transmitted and integrality.
In addition, in transmitting procedure, slave computer also needs to set up retransmission mechanism.If retransmission mechanism means wherein a certain data packets failure, then will retransfer this packet, until success, just then can transmit other packets according to the order preset afterwards.Can ensure that slave computer can be received sequentially each packet according to what preset like this, ensure that slave computer can restore this ROMPaq smoothly.
Similar, received ROMPaq is put in the middle of the flash memory (FLASH) of the application master routine of self by slave computer, utilizes this ROMPaq to cover current program, to realize the upgrade maintenance to slave computer.
Host computer can process ROMPaq simultaneously, also according to actual conditions, can sequentially process each ROMPaq.In embodiments of the present invention, adopt sequentially to the mode that each slave computer is upgraded.
For the ease of operation, the management of engineering staff, display device can show the state of host computer and each slave computer thereof, therefore in whole upgrade maintenance process, whether the host computer that display device also can carry out upgrade maintenance to current or slave computer show, and can show host computer and obtain the speed of ROMPaq from the memory device of access and successfully obtain.Similar, display device also can show speed and the whether Successful transmissions that host computer and slave computer transmit ROMPaq.Whether display device also can show upgrade maintenance operation successful.
Concrete, as shown in Figure 3, for host computer, after it starts startup, will system initialization process be carried out, comprise some necessary parameters of configuration, the process such as each interface are set.Afterwards, host computer enters normal operating conditions.
Now, after the memory device access host computer that the USB interface such as USB flash disk are suitable for by staff, host computer can detect USB flash disk insert action, and whether the USB flash disk of host computer scanning afterwards judges in USB flash disk containing ROMPaq.If host computer does not detect USB flash disk insert action, whether duplicate detection there is USB flash disk insert action.
Then, the upgrading catalogue that host computer inquiry stores learns the corresponding objects of the upgrade file in USB flash disk, and what specifically correspond to host computer itself still corresponds to a certain slave computer.
If determine this ROMPaq corresponding to host computer itself, host computer will stop the master routine of self, and which version number is newer between the two to judge this current master routine and ROMPaq.If the version number of the ROMPaq in USB flash disk is comparatively new, known this ROMPaq that should utilize of host computer carries out upgrade maintenance operation to the master routine of host computer itself; Otherwise host computer can exit the process to this ROMPaq.If also have other ROMPaq in USB flash disk, host computer will go the process performing another ROMPaq.After all ROMPaq in USB flash disk are disposed, upgrade the upgrading catalogue stored, restart host computer master routine, exit the operation of whole upgrade maintenance, enter normal operating conditions.
In order to carry out upgrade maintenance operation to host computer, the ROMPaq (as .app file) in USB flash disk downloads by host computer, stored in internal memory, and this ROMPaq is covered current master routine, completes the upgrade maintenance operation of host computer.Meanwhile, display device demonstrates host computer, represent that current host computer carries out updating operation, also show the downloading process of whole ROMPaq and whether complete upgrade maintenance action.
If determine this ROMPaq corresponding to a certain slave computer, host computer needs the master routine stopping host computer equally, and access this slave computer, the version number of ROMPaq in the version number of the current program of this slave computer and USB flash disk is compared, if the version number of the ROMPaq in USB flash disk is comparatively new, the known master routine of this ROMPaq to this slave computer itself that should utilize of host computer carries out upgrade maintenance operation; Otherwise host computer can exit the process to this ROMPaq.If also have other ROMPaq in USB flash disk, host computer will go the process performing another ROMPaq.After all ROMPaq in USB flash disk are disposed, upgrade the upgrading catalogue stored, restart host computer master routine, exit the operation of whole upgrade maintenance, enter normal operating conditions.
In order to carry out upgrade maintenance operation to this slave computer, this ROMPaq is downloaded and stored in the internal memory of host computer, by serial ports, this ROMPaq is transferred to slave computer by host computer equally.Meanwhile, display device demonstrates this slave computer, represent that current slave computer carries out updating operation, also show the transmitting procedure of whole ROMPaq.
For slave computer, its " application master routine " when the ROMPaq from host computer being detected, is transferred in " boot boot ", now can receive this binary ROMPaq (as .bin file).As shown in Figure 4, open at it and after system initialization, if the ROMPaq that host computer transmits detected, handshake communication will be set up with host computer, starting to receive this binary ROMPaq.Simultaneously in order to ensure the correctness transmitted, in the process of transmission, carrying out CRC check and set up retransmission mechanism.Band EEPROM (Electrically Erasable Programmable Read Only Memo) (Electrically Erasable Programmable Read-Only Memory in slave computer, be called for short EEPROM), the state of this upgrading will be stored down, if upgrade successfully, upgrade maintenance operation can be exited, enter program, slave computer starts normal work; Otherwise if fail to upgrade successfully, slave computer will detect host computer again whether to its transmission ROMPaq.
In addition, if slave computer does not detect that host computer transmits ROMPaq to it, will judge that whether front upgrade maintenance operation is successful by EEPROM, if success, slave computer will enter program, start normally to work, otherwise, whether again detect host computer to its transmission ROMPaq.
In sum, embodiments provide a kind of upgrade maintaining method of embedded system, the cooperation of the memory device accessed by host computer and USB interface, for slave computer provides a kind of method of upgrade maintenance, solves the technical matters of slave computer updating operation inconvenience.
Although embodiment disclosed in this invention is as above, the embodiment that described content just adopts for the ease of understanding the present invention, and be not used to limit the present invention.Technician in any the technical field of the invention; under the prerequisite not departing from spirit and scope disclosed in this invention; any amendment and change can be done what implement in form and in details; but scope of patent protection of the present invention, the scope that still must define with appending claims is as the criterion.