Summary of the invention
In view of this, fundamental purpose of the present invention is to provide a kind of method that realizes firmware update, makes the firmware update of embedded system simple and convenient.
Second purpose of the present invention is to provide a kind of system that realizes firmware update, makes the firmware update of embedded system simple and convenient.
In order to realize above-mentioned first purpose, the invention provides a kind of method that realizes firmware update, this method comprises:
Under the firmware update pattern, loading firmware update module in embedded system, described firmware update module is set up Virtual File Allocation Table FAT;
With after embedded system is connected, carry out the device enumeration process at host computer, host computer is identified as described embedded system the equipment that can carry out data storage operations based on the memory device agreement according to described virtual FAT;
Carry out the firmware update process, described host computer copies firmware program to embedded system, and described firmware update module receives the firmware program from host computer, and stores this firmware program according to described virtual FAT.
Preferably, described virtual FAT can comprise: FAT boot sector FAT HEADER, only comprise 2 FAT list areas of the data head of FAT list area, and only comprise the catalogue and the file name area of 1 filename content, and the virtual data district.
Preferably, described firmware update module can be carried in the guidance system BOOT of described embedded system, the FAT HEADER of described virtual FAT, FAT list area and catalogue and file name area are all set up in described BOOT, and described virtual data district is mapped in the storage space of described embedded system.
Described firmware update module further can be carried out verification to firmware program after receiving firmware program from host computer, and check results is returned to described host computer by described virtual FAT, and verification by the time storing firmware program.
Preferably, described firmware update module returns to described host computer with check results by virtual FAT, generate the feedback of status file according to check results, described generation feedback of status file is for being filled in check results in the catalogue and file name area in the virtual FAT with the form of character string; After generating the feedback of status file, data change in the firmware update module notice host computer virtual FAT, and host computer refreshes automatically, shows with the feedback of status file of check results as filename.
Preferably, described device enumeration process comprises: host computer reads FAT HEADER, and the firmware update module is returned FAT HEADER content; Host computer reads FAT list area and catalogue and file name area content according to the FAT HEADER content of returning, and the firmware update module is returned FAT list area and the catalogue and the file name area content of simplification according to the length of the FAT list area that identifies among the FAT HEADER and catalogue and file name area.
Preferably, verification by the time, described firmware update module stores described firmware program in the virtual data district in the storage space that is mapped in described embedded system; When verification was not passed through, described firmware update module abandoned described firmware program.
Preferably, the described equipment that carries out data storage operations is general movable memory equipment;
Described memory device agreement is general movable memory equipment agreement.
Preferably, described firmware update module is the USB flash disk system, and described general movable memory equipment agreement is the software and hardware agreement of USB flash disk, and described host computer is identified as USB flash disk with embedded system;
Described host computer is connected with embedded system by USB cable.
In order to realize above-mentioned second purpose, the invention provides a kind of system that realizes firmware update, this system comprises host computer and embedded system, be provided with the firmware update module in the embedded system, described firmware update module is loaded under the firmware update pattern, and sets up Virtual File Allocation Table FAT after loading;
Host computer is connected with embedded system under being in the firmware update pattern, and is used for after connection described embedded system being identified as the equipment that can carry out data storage operations according to described virtual FAT based on the memory device agreement;
Described host computer also is used for copying firmware program to described embedded system, and described firmware update module is used to receive the firmware program from host computer, and stores the storage space of this firmware program to embedded system according to described virtual FAT.
Preferably, the virtual FAT in the described firmware update module comprises: FAT HEADER, only comprise 2 FAT list areas of the data head of FAT list area, and only comprise the catalogue and the file name area of 1 filename content, and the virtual data district.
Described firmware update module is further used for the firmware program from host computer is carried out verification, and generating the feedback of status file according to check results, described generation feedback of status file is for being filled in check results in the catalogue and file name area in the virtual FAT with the form of character string;
After generating the feedback of status file, the firmware update module is further used for notifying data change in the host computer virtual FAT;
Described host computer is further used for refreshing automatically, shows with the feedback of status file of check results as filename.
Preferably, described firmware update module loading is in the guidance system BOOT of described embedded system, the FAT HEADER of described virtual FAT, FAT list area and catalogue and file name area all are arranged among the described BOOT, and described virtual data district is mapped in the storage space of described embedded system.
Preferably, described firmware update module is the USB flash disk system, the software and hardware agreement that described memory device agreement is a USB flash disk, and described host computer is identified as USB flash disk with embedded system;
Described host computer is connected by USB cable with USB flash disk system in the described embedded system.
As can be seen from the above technical solutions, the present invention has the firmware update module of Virtual File Allocation Table FAT by being provided with in embedded system, after connecting between host computer and the embedded system, host computer can be discerned embedded system automatically based on the memory device agreement, and the operation by execute file copy, can copy firmware program to embedded system, make the firmware update module carry out the operation of firmware update, firmware program be stored in the storage space of embedded system.Therefore with prior art in must cooperate with host computer by the master routine of embedded system just can finish firmware update different be, the present invention is directed to different embedded systems does not need to adopt special transmission line and privately owned protocol client software, makes the firmware update of embedded system simple and convenient.
Embodiment
In order to make the purpose, technical solutions and advantages of the present invention clearer, the present invention is done detailed description further below in conjunction with drawings and Examples.
At first be necessary the memory device agreement is described.The memory device agreement that is adopted herein is meant that host computer is general, is used for memory device is discerned, and the standard agreement that communicates with memory device.Those skilled in that art are known, host computer is in order to discern the memory device of some type, generally all pre-configured memory device agreement, these memory device agreements become in the industry standard agreement because of its versatility, and after memory device was connected to host computer, host computer need not other application program control, can carry out device enumeration to this memory device automatically, identification equipment, and can in use carry out the operation of data access to this memory device.For instance, all have the software and hardware agreement of USB flash disk as present computer, after USB flash disk was inserted the USB interface of computer, computer can automatically identify USB flash disk, thereby in the operating system of computer, by the mode of opened file folder, USB flash disk was carried out file operation.In addition, equipment such as some MP3 players, mobile phone also can need not under the situation of special install driver at present, are discerned the style of writing part accessing operation of going forward side by side by computer.
Memory device here and memory device agreement comprise existing and following general memory device that will have and memory device agreement now.Described memory device and memory device agreement can be existing or following general movable memory equipment that will have and general movable memory equipment agreement.
Core concept of the present invention is, utilize host computer to possess the performance of discerning external unit according to described memory device agreement automatically, make host computer that embedded system is identified as the equipment that can carry out data storage operations automatically, finish complicated firmware update process to the simple operations of this equipment copied files by host computer.
The operation of described herein " copy ", not only comprise the traditional process that file is copied to another file from a file, also comprise file is moved to another file from a file, or file pasted another file after file is sheared, or the like similar process.
Below, at first a kind of system of firmware update that realizes provided by the present invention is described.Fig. 1 is for realizing the system architecture synoptic diagram of firmware update.As shown in Figure 1, this system comprises: host computer 100 and embedded system 110.Wherein, host computer 100 is to be the host computer that can carry out the equipment of data storage operations with the recognition of devices that is connected automatically according to the memory device agreement; Be provided with firmware update module 111 in the embedded system 100, and storage space 112.
Firmware update module 111 is set up virtual FAT after being loaded, and can carry out device enumeration process and firmware update process based on memory device agreement and virtual FAT and host computer 100.
Below with reference to existing FAT the virtual FAT in the firmware update module of the present invention is described.
The file allocation table FAT of present known standard is an example with FAT16, as shown in Figure 2, is divided into: FAT HEADER 201,2 FAT list areas 202 and 203, catalogue and file name area 204 and data field 205.
Wherein, FAT HEADER 201 generally is used for identifying the FAT system, also can be used to identify the length of FAT list area 202 and 203, catalogue and file name area 204 and data field.Whether FAT list area 202 and 203 is used for writing down each sector and uses, and their position relation.Catalogue and file name area 204 are used for log file name and pathname, the start element of each file, file attribute etc. under the record root directory.During the locating file position, operating system just can have been known the particular location of file and size according to catalogue and file name area 204 and FAT table 202 and 203.Data field 205 is used for storing data.
Because the information that comprises among the file allocation table FAT of standard is a lot, generally its shared storage space is very big, has many times all reached 500k.Therefore existing this standard FAT will take a large amount of memory headrooms.
The present invention makes virtualization process to FAT, promptly only after entering the firmware update pattern, embedded system just can just can be set up virtual FAT in the process of firmware update module work with the firmware update module loading in internal memory, the content of virtual FAT just can be buffered in the internal memory; And under non-firmware update pattern, virtual FAT can not be loaded or remove from the internal memory of embedded system because of the firmware update module, and is not established or is removed simultaneously.Thereby reach the process that virtual FAT can help to realize carrying out based on the memory device agreement firmware update on the one hand, do not take the purpose of the memory headroom of embedded system on the other hand again.
In addition, in order to simplify the structure of embedded system, described firmware update module 111 can be carried among the BOOT of embedded system, and the firmware update process of embedded system will not rely on the master routine of system like this, and work alone.
But very little because present embedded system is distributed to the memory headroom of BOOT, generally about 30k, therefore the FAT of existing standard can not be arranged in the BOOT of present embedded system.For can be in BOOT the loading firmware update module, the virtual FAT of setting up in the firmware update module 111 can adopt the file allocation table FAT of the simplification after virtual.That is: keep the FATHEADER district; 2 FAT list areas only comprise the data head of FAT list area, only account for the 3-4 byte, and the remainder data in the FAT list area is represented with 0, do not take up room, and can also represent that all sectors are not used simultaneously, and 0 address of data field is the storage address of firmware program so; Catalogue and file name area only keep 1 filename content, are 32 bytes, and this document name content is the filename content of feedback of status file, and before firmware update, this filename content is empty.The data field of this virtual FAT is mapped directly in the storage space 112 of embedded device, becomes a virtual data district.So just the virtual FAT of simplifying can be put among the BOOT, being about to the FATHEADER district of virtual FAT, 2 FAT list areas and catalogue and file name area is put among the BOOT, only take BOOT memory headroom seldom, and the virtual data district actually exists in the storage space 112 of embedded device, and it does not take the memory headroom of BOOT.
Further, host computer 100 is connected with embedded system 110 under being in the firmware update pattern, and is used for described embedded system 110 being identified as the equipment that can carry out data storage operations according to described memory device agreement and virtual FAT after connection;
Described host computer 100 also is used for copying firmware program to described embedded system 110, described firmware update module 111 is used to receive the firmware program from host computer 100, and firmware program carried out verification, check results is returned to described host computer 100 by described virtual FAT, and verification by the time store the storage space 112 of this firmware program according to described virtual FAT to embedded system.
Described host computer is generally PC, also can be for discerning other equipment of firmware update module.
Described firmware update module 111 returns to described host computer 100 with check results by described virtual FAT: in checking procedure, length and check code according to firmware program come checking data, and, send data to host computer 100 then and change notice according to check results generation feedback of status file.
Wherein, whether the feedback of status file of described generation is used for characterizing verification successful, and verification succeeds then generates and characterizes correct feedback of status file; The verification failure then generates and characterizes wrong feedback of status file.
Described feedback of status file is filled in the catalogue and file name area of described virtual FAT with the form of character string.
Host computer 100 receives after data that firmware update module 111 sends change notice, refreshes automatically, shows with the feedback of status file of check results as filename.
As a kind of mode of concrete enforcement, described firmware update module 111 can be USB flash disk system, the software and hardware agreement that described memory device agreement is a USB flash disk; Host computer connects with adopting the USB transmission line being connected of embedded system.
Below the method for realization firmware update provided by the present invention is done detailed description.Fig. 3 is for realizing the method flow diagram of firmware update.As shown in Figure 3, this method may further comprise the steps:
Step 301: under the firmware update pattern, loading firmware update module in embedded system, the firmware update module is set up virtual FAT.
Step 302: connect host computer and embedded system, carry out the device enumeration process, and described embedded system is identified as the equipment that can carry out data storage operations according to memory device agreement and virtual FAT.
Step 303: carry out the firmware update process, described host computer copies firmware program to embedded system, and described firmware update module receives the firmware program from host computer, and stores this firmware program according to described virtual FAT.
Described step 303 can comprise that further the firmware update module is carried out verification to firmware program, and check results is returned to host computer by described virtual FAT.After the step 303, this method can further include: host computer refreshes automatically, shows check results.
Above-mentioned is the main flow process of method provided by the present invention, and below with from PC download firmware program, the firmware update module is an example for the USB flash disk system, and the method for realization firmware update provided by the present invention is described in detail.Fig. 4 is the method flow diagram of embodiment provided by the present invention.As shown in Figure 4, this method may further comprise the steps:
Step 401: under the firmware update pattern, load the USB flash disk system in the BOOT of embedded system, the USB flash disk system sets up virtual FAT.
Those skilled in the art should expect, in order to make embedded system enter the firmware update pattern, can the mode of operation selector switch be set for embedded system, with PC with before embedded system is connected, the mode of operation selector switch is selected to common duty, and then PC is with after embedded system is connected, will be according to known step, enter normal duty, this step can be prior art, and the present invention does not give unnecessary details; When selecting the mode of operation selector switch to the firmware update state, then embedded system enters the firmware update pattern.
The USB flash disk system can be a software module, is stored in advance in the storage space of embedded system, when system switches to firmware update pattern following time, just loads this USB flash disk system in BOOT.
After the USB flash disk system is loaded, will set up virtual FAT.
Virtual FAT in the USB flash disk system can adopt the FAT12/FAT16 of simplification.Keep the FATHEADER district; 2 FAT list areas only comprise the data head of FAT list area, only account for the 3-4 byte; Catalogue and file name area only keep 1 filename content, are 32 bytes.
Like this, in fact the virtual FAT of setting up in BOOT includes only FAT HEADER district, 2 FAT list areas and catalogue and file name area, and the virtual data district of virtual FAT is mapped in the storage space 112 of embedded system.
In the present embodiment, embedded system 110 can be PMP (Portable MultiMedia Player such as MP3 player, palm PC, portable media player) equipment, the internal memory of embedded system 110 can adopt internal memory RAM such as SRAM, SDRAM, and storage space 112 can adopt nonvolatile memory NOR FLASH or NAND FLASH etc.
When the USB flash disk system communicates by letter with host computer, it is the USB device host-host protocol of employing standard, this agreement is general by present computing machine, so present embodiment is when carrying out firmware update, can no longer need special proprietary protocol client software, follow proprietary protocol and communicate, make the firmware update of embedded system more convenient and simple.
Step 402: connect PC and embedded system.
Connect PC and embedded system by USB cable in this step, connect back PC end and can show formatted USB flash disk.Described PC end shows the process of formatted USB flash disk, is the enumeration process of USB flash disk system: the PC end at first reads FAT HEADER, and the USB flash disk system returns FAT HEADER content; The PC end can read FAT list area or catalogue and file name area content according to FAT HEADER content then, the USB flash disk system returns FAT list area or the catalogue and the file name area content of simplification according to the length of the FAT list area, catalogue and the file name area that identify among the FAT HEADER, replaces with 0 data for the reduced data that does not take storage space.PC finishes enumerating of USB flash disk system after having read these data.
After enumeration process is finished, can demonstrate the device symbols of expression embedded system on the PC, such as: open " my computer " or " windows explorer " in the windows operating system, can see the USB flash disk identifier that an expression embedded system wherein newly occurred.Double-click the root directory that this identifier can enter into embedded system, enter the memory location that root directory will be a firmware program this moment.
Step 403:, firmware program is copied to the storage space of embedded system from PC by the USB flash disk system.
Firmware program in this step generally is the data block of the good firmware program of packing.The data length and the check code that wherein comprise firmware program are used for determining the end of firmware program copy and the checking data after the copy end.
The implementation procedure that this step is concrete is as follows:
In the time of need carrying out firmware update, after host computer received and copies firmware program in the embedded system instruction, host computer passed through transmission line according to the mode of sector block operations with the data block of firmware program; Embedded system is by its USB flash disk system, receives the data block of the firmware program that host computer sends over, and analyzes, separate firmware program after, be stored to the address and be the storage space of 0 embedded system.
When the length that copies the data field to had reached the length of the firmware program data that comprise in the packing firmware program, the copy of firmware program finished.The data field of described USB flash disk system is mapped in the storage space of embedded system, and this step has copied firmware program the storage space of embedded system to from PC in fact exactly.
For the user, the operation of this step is in the windows of PC operating system, has copied the firmware program in other disk in the embedded system storage space, and its operation is with the same to the operation of another disk with the document copying of a disk.
Step 404: checking data generates the feedback of status file in the USB flash disk system.
When the USB flash disk system receives firmware program, to carry out the verification of firmware program data according to data length that comprises in the firmware program and check code earlier, verification succeeds generates in the USB flash disk system and characterizes correct feedback of status file, and firmware program is stored into the storage space of embedded system; The verification failure then generates in the USB flash disk system and characterizes wrong feedback of status file, and the firmware program data of copy are abandoned.
The feedback of status file that generates is filled in the catalogue and the file name area of 32 bytes in the USB flash disk system with the form of character string.As verification succeeds, can generate " success.txt " in catalogue and file name area, the verification failure then can generate " fail.txt " in catalogue and file name area.
Step 405: data change in the notice PC end USB flash disk system, and the PC end refreshes automatically.
After checking data and feedback of status file generate, the USB flash disk system will change virtual FAT again according to new data.Change to the intrasystem data of PC end notice USB flash disk then, after the PC end is notified, refresh automatically, show the feedback of status file of USB flash disk system.For example, after the PC end refreshes automatically, under the root directory of embedded system on the PC end, can see the file of file " success.txt " or " fail.txt " by name.The feedback of status document analysis firmware update success of the USB flash disk system that the user can show according to PC or the reason of failure.