Patent Publication Number: US-9846578-B2

Title: Electronic device and method for firmware updating thereof

Description:
CROSS REFERENCE TO RELATED APPLICATIONS 
     This Application is a continuation of U.S. application Ser. No. 14/711,513, filed on May 13, 2015, which claims priority to Taiwan Patent Application No. 103140938, filed on Nov. 26, 2014, the entirety of which is incorporated by reference herein. 
    
    
     BACKGROUND OF THE INVENTION 
     Field of the Invention 
     The present invention is related to a firmware update method applied to an electronic device; in particular to firmware update method which can be interrupted. 
     Description of the Related Art 
     Driven by user requirements, more and more electronic devices, especially handheld or portable electronic devices such as smartphones, personal digital assistants (PDAs), and tablet PCs or Ultra Mobile PCs (UMPCs), comprise various peripherals such as a video camera, for improving user convenience. 
     Generally, the firmware data of a peripheral device is stored in a non-volatile storage unit, such as Flash ROM, and is released with the hardware device. However, when the peripheral device is released, the manufacturer or developer will usually provide firmware with each new version, for fixing the bugs of the original version or providing new features. In some devices, the updating process of the firmware cannot be interrupted. The firmware will fail or the updating process needs to be restarted when the updating process is interrupted. 
     BRIEF SUMMARY OF THE INVENTION 
     A detailed description is given in the following embodiments with reference to the accompanying drawings. 
     An exemplary embodiment provides a firmware update method applied to a host device and a peripheral device, wherein the peripheral device includes a memory device and a controller. The firmware update method includes: transmitting a first firmware data sector to a peripheral device from the host device, wherein the first firmware data sector has a first mode parameter; and retransmitting the first firmware data sector having a second mode parameter to the peripheral device from the host device after an interruption event has occurred on the memory device during the transmission. 
     Another exemplary embodiment provides a firmware update method applied to a host device and a peripheral device, wherein the peripheral device includes a memory device and a controller. The firmware update method includes: sequentially transmitting a plurality of firmware data sectors to the peripheral device from the host device, wherein the number N of the firmware data sectors constitute firmware, and each of the firmware data sectors includes a first mode parameter; and retransmitting the firmware data sectors from 1 to N to the peripheral device after the transmission of the firmware data sectors of the firmware is interrupted at the Xth firmware data sector, wherein N is greater than X, each of the first to (X−1)th firmware data sectors transmitted in the retransmission includes a second mode parameter, and each of the Xth to Nth firmware data sectors transmitted in the retransmission includes the first mode parameter. 
     Another exemplary embodiment provides an electronic device capable of updating firmware. The electronic device capable of updating firmware includes a memory device and a controller. The a controller is configured to receive a plurality of firmware data sectors from a host device in a sequence, read at least one parameter sector of the received firmware data sector, store a program code sector of the received firmware data sector into the memory device when the parameter sector of the received firmware data sector includes a first mode parameter, and ignore the program code sector of the received firmware data sector when the parameter sector of the received firmware data sector includes a second mode parameter, wherein the firmware data sectors constitute firmware. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
       The present invention can be more fully understood by reading the subsequent detailed description and examples with references made to the accompanying drawings, wherein: 
         FIG. 1  is a schematic diagram illustrating an embodiment of an electronic device capable of updating firmware of an exemplary embodiment; 
         FIG. 2  is a schematic diagram illustrating an embodiment of a firmware data sector of an exemplary embodiment; 
         FIG. 3  is a schematic diagram illustrating an embodiment of the firmware of an exemplary embodiment; 
         FIG. 4  is a flowchart of a firmware update method according to an embodiment of the present disclosure; 
         FIG. 5A ˜ 5 B are flowcharts of a firmware update method according to another embodiment of the present disclosure; and 
         FIG. 6A ˜ 6 C are flowcharts of a firmware update method according to another embodiment of the present disclosure. 
     
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     The following description is of the best-contemplated mode of carrying out the invention. This description is made for the purpose of illustrating the general principles of the invention and should not be taken in a limiting sense. The scope of the invention is best determined by reference to the appended claims. 
     The electronic device  100  includes a host device  102  and a peripheral device  104 . The host device  102  can be implemented on various digital cameras or computer system configurations, such as smartphones, tablet computers, personal digital assistants and similar devices, but it is not limited thereto. The peripheral device  104  can be embedded in the host device  102  or connected to the host device  102 . Moreover, the peripheral device  104  can be a sensing device, an output/input device or a data storage device, but it is not limited thereto. In one embodiment, the peripheral device  104  can be a storage device, wherein the storage device follows the rule of the “Download Micro Code” of the SATA SPEC to update firmware, such that the updating process cannot be interrupted, such as power-off” during the transmission, but it is not limited thereto. In other embodiments, the firmware has to be written into the peripheral device  104  in a sequence in the updating process of the peripheral device  104 . 
     The host device  102  downloads the firmware of the peripheral device  104  from the Internet or other devices, and transmits the downloaded firmware to the peripheral device  104  to update the peripheral device  104 . It should be noted that the firmware is constituted by a plurality of program code sectors of a plurality of firmware data sectors DS 1 ˜DSN, and the host device  102  is configured to transmit the firmware data sectors DS 1 ˜DSN to the peripheral device  104  to update the peripheral device  104  in a sequence. Moreover, the host device  102  replaces a first mode parameter of each of the first to X−1th firmware data sectors with the second mode parameter when an interruption event occurs during transmission of the Xth firmware data sector DSX, wherein X is less than N, and X and N are integer greater than 1. Namely, the host device  102  is configured to determine whether an interruption event has occurred, and adjust the firmware data sectors DS 1 ˜DSN to rewrite the mode parameter of the firmware data sectors which have been transmitted to the peripheral device  104  as the second mode parameter when the interruption event has occurred, wherein the interruption event includes the peripheral device  104  losing power, the peripheral device  104  being disconnected from the host device  102  and/or the Internet being disconnected, but it is not limited thereto. Moreover, the host device  102  is further configured to retransmit the adjusted firmware data sectors DS 1 ˜DSN to the peripheral device  104  after the interruption event. For example, the host device  102  may detect whether the interruption event has recovered and whether the peripheral device  104  is reconnected to the host device  102  after the interruption event. When the interruption event is excluded and the peripheral device  104  is reconnected to the host device  102 , the host device  102  retransmits the adjusted firmware data sectors DS 1 ˜DSN with the rewritten firmware data sectors to the peripheral device  104  again, but it is not limited thereto. The host device  102  may also retransmit the adjusted firmware data sectors DS 1 ˜DSN to the peripheral device  104  after the interruption event according to a continue command. 
     The peripheral device  104  further includes a controller  1042 , a register  1044  and a memory device  1046 . The controller  1042  receives the firmware data sectors DS 1 ˜DSN which are arranged to constitute firmware from the host device  102  in a sequence, and temporarily store the firmware data sectors DS 1 ˜DSN into the register  1044 . Moreover, the controller  1042  reads the parameter sectors of the firmware data sectors DS 1 ˜DSN stored in the register  1044 , and stores the program code sectors of the firmware data sectors having the parameter sectors with the first mode parameter into the memory device  1046 , and ignores the program code sectors of the firmware data sectors which have the parameter sectors with the second mode parameter. The register  1044  is arranged to temporarily store the firmware data sectors DS 1 ˜DSN received from the host device  102 . The memory device  1046  is a non-volatile memory arranged to store the firmware for the controller  1042 . 
       FIG. 2  is a schematic diagram illustrating an embodiment of a firmware data sector of an exemplary embodiment, wherein each of the firmware data sectors DS 1 ˜DSN includes a program code sector CS 1 ˜CSN and a parameter sector PS 1 ˜PSN. In this embodiment, the parameter sectors PS 1 ˜PSN are implemented in the starting position of the firmware data sectors DS 1 ˜DSN. For example, each of the firmware data sectors DS 1 ˜DSN is 512 Bytes, wherein the parameter sectors PS 1 ˜PSN is implemented in the first 16 Bytes of the 512 Bytes of the firmware data sectors DS 1 ˜DSN, but it is not limited thereto. In other embodiments, the parameter sectors PS 1 ˜PSN may be implemented in the end of the firmware data sectors DS 1 ˜DSN or other parts of the firmware data sectors DS 1 ˜DSN. It should be noted that the program code sectors PS 1 ˜PSN of the firmware data sectors DS 1 ˜DSN constitutes firmware FW arranged to be provided to the controller  1042 , as  FIG. 3  shown. The parameter sectors PS 1 ˜PSN are arranged to record the information of the firmware data sectors DS 1 ˜DSN. In one embodiment, each of the parameter sectors PS 1 ˜PSN includes a mode parameter, the mode parameter may be the first mode parameter or the second mode parameter, wherein the first mode parameter represents that the corresponding program code sector has not been written into the memory device  1046 , and the second mode parameter represents that the corresponding program code sector has been written into the memory device  1046 , but it is not limited thereto. In other embodiments, each of the parameter sectors PS 1 ˜PSN further includes a firmware version parameter, an index, a controller version parameter, a data amount parameter and a verification parameter, etc., it is not limited thereto. 
     When each of the parameter sectors PS 1 ˜PSN includes the firmware version parameter, the index, the controller version parameter, the data amount parameter and the verification parameter, the controller  1042  is configured to read the parameter sectors of the firmware data sectors DS 1 ˜DSN to obtain the parameters. More specifically, the index is arranged to be provided to the controller  1042  to determine what number the received firmware data sector in the sequence is, such that the controller  1042  can store the program code sector of the received firmware data sector into the corresponding address of the memory device  1046  according to the number of the received firmware data sector in the sequence. Therefore, the program code sectors constitute the firmware FW in the sequence, as shown in  FIG. 3 . It should be noted that, in this embodiment, the peripheral device  104  can still store the received firmware data sectors DS 1 ˜DSN in the sequence according to the indexes of the firmware data sectors DS 1 ˜DSN when the network is not stable or the firmware data sectors DS 1 ˜DSN are not transmitting in the sequence. The data amount parameters are arranged to be provided to the controller  1042  to determine the data length of the firmware FW, wherein the controller  1042  can determine whether all of the firmware data sectors DS 1 ˜DSN are received according to the data amount parameters and the indexes. The controller version parameters are arranged to be provided to the controller  1042  to check whether the version of the controller  1042  is correct. Namely, the controller  1042  can check whether the version of the firmware data sectors DS 1 ˜DSN meets the version of the controller  1042  according to the controller version parameter. The verification parameters are arranged to be provided to the controller  1042  to verify the program code sectors CS 1 ˜CSN of the firmware data sectors DS 1 ˜DSN. For example, the verification parameters can be checksums, and the controller  1042  may check whether the program code sectors CS 1 ˜CSN are correct by the checksum algorism and the checksums. The firmware version parameter is arranged to be provided to the controller  1042  to check whether the version of the firmware FW is correct. 
     In another embodiment, the mode parameter can be the first mode parameter, the second mode parameter, or a third mode parameter, wherein the first mode parameter represents that the corresponding program code sector has not been written into the memory device  1046 , the second mode parameter represents the corresponding program code sector has been written into the memory device  1046 , and the third mode parameter is arranged to enable the controller  1042  to determine whether the corresponding program code sector has been received and written by checking the parameters of the peripheral device  104 , but it is not limited thereto. It should be noted that, in this embodiment, the controller  1042  is further configured to determine whether the received program code sector of the firmware data sector needs to be stored in the memory device  1046  according to the third mode parameter of the firmware data sector. For example, the controller  1042  determines whether the corresponding address of the memory device  1046  has the program code sector of the received firmware data sector according to the index of the parameter sector of the received firmware data sector after receiving a firmware data sector having the third mode parameter. When the corresponding address of the memory device  1046  has the program code sector of the received firmware data sector, the controller  1042  ignores (does not stores) the program code sector of the received firmware data sector. When the corresponding address of the memory device  1046  does not have the program code sector of the received firmware data sector, the controller  1042  stores the program code sector of the received firmware data sector, but it is not limited thereto. 
       FIG. 4  is a flowchart of a firmware update method according to an embodiment of the present disclosure. The firmware update method is applied to the electronic device  100  of  FIG. 1  and arranged to update the firmware of the peripheral device  104  in response to a command. The process starts at step S 400 . 
     In step S 400 , the host device  102  transmits a plurality of firmware data sectors DS 1 ˜DSN to the peripheral device  104  in sequence, wherein the number N of firmware data sectors DS 1 ˜DSN constitutes firmware FW as shown in  FIG. 3 . For example, the host device  102  transmits the firmware data sectors DS 1 ˜DSN to the peripheral device  104  in the sequence of the first firmware data sector DS 1 , the second firmware data sector DS 2 , the third firmware data sector DS 3  . . . the Nth firmware data sector DSN, wherein the firmware data sectors DS 1 ˜DSN in the sequence constitute the firmware FW. It should be noted that, in step S 400 , the process goes to step S 402  while the host device  102  finishes transmitting the firmware data sector. Moreover, in the initial transmission (the firmware data sectors DS 1 ˜DSN are transmitted to the peripheral device  104  for the first time), each of the firmware data sectors DS 1 ˜DSN transmitted by the host device to the peripheral device  104   102  has a mode parameter with a first mode parameter, wherein each of the first mode parameters represents that the corresponding firmware data sector has not been written into the memory device  1046  of the peripheral device  104 , and the firmware data sector has the specific first parameter corresponds to the specific first parameter. However, the mode parameters of firmware data sectors DS 1 ˜DSN can be selectively rewritten (replaced) by the host device  102 . For example, in step S 400 , the host device  102  transmits the first firmware data sector DS 1  to the peripheral device  104 . In the initial transmission, the mode parameter of first firmware data sector DS 1  transmitted to the peripheral device  104  from the host device  102  is the first mode parameter, such that the first firmware data sector DS 1  has not been written into the memory device  1046  of the peripheral device  104 . When the first firmware data sector DS 1  has been written into the memory device  1046  of the peripheral device  104 , the host device  102  is configured to rewrite the mode parameter of the first firmware data sector DS 1  as a second mode parameter and transmit the rewritten first firmware data sector DS 1  with the second mode parameter to the peripheral device  104 . It should be noted that the host device  102  may detect whether the interruption event has recovered and whether the peripheral device  104  is reconnected to the host device  102  after the interruption event. When the interruption event is excluded and the peripheral device  104  is reconnected to the host device  102 , the host device  102  retransmits the adjusted firmware data sectors DS 1 ˜DSN with the rewritten firmware data sectors to the peripheral device  104  again, but it is not limited thereto. The host device  102  may also retransmit the adjusted firmware data sectors DS 1 ˜DSN to the peripheral device  104  after the interruption event according to a continue command. 
     Next, in step S 402 , the peripheral device  104  temporarily stores the received firmware data sector into the register  1044 , and reads the parameter sector of the firmware data sector stored in the register  1044  by the controller  1042  to determine the mode parameter of the firmware data sector is a first mode parameter or a second mode parameter. When the mode parameter of the received firmware data sector is the first mode parameter, the process goes to S 404 . When the mode parameter of the received firmware data sector is the second mode parameter, the process returns to step S 400 , the host device  102  continues to transmit the next firmware data sector to the peripheral device  104 . Namely, when the mode parameter of the received firmware data sector is the second mode parameter, the controller  1042  ignores the firmware data sector having the second mode parameter and does not store the program code sector having the second mode parameter into the memory device  1046 . For example, the peripheral device  104  temporarily stores the received first firmware data sector DS 1  in the register  1044  and reads the parameter sector PS 1  of the first firmware data sector DS 1  stored in the register  1044  to determine the mode parameter of the firmware data sector DS 1  is a first mode parameter or a second mode parameter. When the mode parameter of the received firmware data sector DS 1  is the first mode parameter, the process goes to S 404 . When the mode parameter of the received firmware data sector DS 1  is the second mode parameter, the process returns to step S 400 , the host device  102  continues to transmit the next firmware data sector DS 2  to the peripheral device  104 . Namely, when the mode parameter of the received firmware data sector DS 1  is the second mode parameter, the controller  1042  ignores the firmware data sector DS 1  having the second mode parameter and does not store the program code sector CS 1  of the first firmware data sector DS 1  having the second mode parameter into the memory device  1046 . 
     In step S 404 , the controller  1042  of the peripheral device  104  stores the program code sector of the received firmware data sector which has the first mode parameter into the memory device  1046  in the sequence for combining the program code sectors CS 1 ˜CSN of the firmware data sectors DS 1 ˜DSN in the sequence to constitute the firmware FW in the sequence. For example, the controller  1042  of the peripheral device  104  stores the program code sector CS 1  of the received firmware data sector DS 1  which has the first mode parameter into a first address of the memory device  1046 , wherein the first address is the initial address of the firmware FW. Moreover, the controller  1042  of the peripheral device  104  stores the program code sector CS 2  of the second firmware data sector DS 2  which has the first mode parameter into a second address of the memory device  1046 , wherein the second address in next to the first address of the program code sector CS 1 , but it is not limited thereto. 
     In step S 406 , the device  102  determines whether an interruption event has occurred, wherein the interruption event includes the peripheral device  104  losing power, the peripheral device  104  becoming disconnected from the host device  102  and/or the Internet being disconnected, but it is not limited thereto. The host device  102  determines whether the interruption event has occurred by the connection of the peripheral device  104  or other methods, but it is not limited thereto. When the interruption event occurs, the process goes to step S 408 , otherwise, the process returns to step S 400 , the host device  102  continues to transmit the next firmware data sector to the peripheral device  104 . 
     In step S 408 , the host device  102  rewrites the mode parameters of the firmware data sectors which have been written into the peripheral device  104  as the second mode parameter. For example, when the transmission of the firmware data sectors DS 1 ˜DSN of the firmware FW is interrupted at the Xth firmware data sector DSM, the host device  102  replaces the first mode parameter of the mode parameters of the first to (X−1)th firmware data sectors with the second mode parameter, wherein X is less than N, and X and N are positive integers. It should be noted that the host device  102  detects whether the interruption event has recovered and whether the peripheral device  104  is reconnected to the host device  102  or whether a continue command is received when step S 408  is done. When the interruption event is excluded from the peripheral device  104  (or the host device  102 ) and the peripheral device  104  is reconnected to the host  120 , the process returns to step S 400 . In step S 400 , the host device  102  retransmits the firmware data sectors DS 1 ˜DSN to the peripheral device  104 . Namely, after step S 408  is done, the host device  102  retransmits the firmware data sectors DS 1 ˜DSN from the first firmware data sector DS 1  in the sequence to the peripheral device  104 , wherein each of the first to (X−1)th firmware data sectors DS 1 ˜DS(X−1) transmitted in the retransmission has the second mode parameter, and each of the Xth to Nth firmware data sectors DSX˜DSN transmitted in the retransmission has the first mode parameter. 
       FIG. 5A ˜ 5 B are flowcharts of a firmware update method according to another embodiment of the present disclosure. The firmware update method is applied to the electronic device  100  of  FIG. 1  and arranged to update the firmware of the peripheral device  104  in response to a command. The process starts at step S 500 . It should be noted that, in this embodiment, each of the parameter sectors PS 1 ˜PSN further includes a firmware version parameter, an index, a controller version parameter, a data amount parameter and a verification parameter, etc., but it is not limited thereto. 
     In step S 500 , the peripheral device  104  receives a plurality of firmware data sectors DS 1 ˜DSN from the host device  102  in a sequence, wherein the number N of firmware data sectors DS 1 ˜DSN constitutes firmware FW, as shown in  FIG. 3 . For example, the peripheral device  104  receives the firmware data sectors DS 1 ˜DSN from the host device  102  in the sequence of the first firmware data sector DS 1 , the second firmware data sector DS 2 , the third firmware data sector DS 3 , and so on. It should be noted that, in step S 500 , the process goes to step S 502  every time the peripheral device  104  receives a firmware data sector. 
     Next, in step S 502 , the peripheral device  104  temporarily stores the received firmware data sector in a register  1044 . 
     Next, in step S 504 , the controller  1042  reads the controller version parameter of the parameter sector of the firmware data sector stored in a register  1044  to determine whether the version of the controller  1042  is correct according to the controller version parameter of the parameter sector. Namely, the controller  1042  may determine whether the version of the controller  1042  meets the version of the firmware data sector according to the controller version parameter. When the version of the controller is correct, the process goes to step S 506 , otherwise, the process ends at step S 504 , the controller  1042  step updating the peripheral device  104 . 
     In step S 506 , the controller  1042  reads the verification parameter of the parameter sector of the firmware data sector stored in a register  1044  to verify whether the program code sector of the received firmware data sector is correct. For example, the verification parameters can be checksums, and the controller  1042  may check whether the program code sectors CS 1 ˜CSN are correct by the checksum algorism and the checksums. When the program code sector is correct, the process goes to step S 508 , otherwise, the process ends at step S 506 , the controller  1042  stops updating the peripheral device  104 . 
     In step S 508 , the controller  1042  reads the mode parameter of the parameter sector of the received firmware data sector stored in a register  1044  to determine whether the mode parameter of the received firmware data sector is a first mode parameter or a second mode parameter. When the mode parameter of the received firmware data sector is the first mode parameter, the process goes to step S 510 . When the mode parameter of the received firmware data sector is the second mode parameter, the process goes to step S 518 . 
     In step S 510 , the controller  1042  reads the firmware version parameter of the parameter sector of the received firmware data sector stored in a register  1044  to check whether the firmware version of the received firmware data sector is correct. When the firmware version is correct, the process goes to step S 512 , otherwise, the process ends at step S 510 , and the controller  1042  stops updating the peripheral device  104 . 
     In step S 512 , the controller  1042  reads the index and the data amount parameter of the parameter sector of the received firmware data sector stored in a register  1044 , wherein the controller  1042  obtains the length of the firmware FW according to the data amount parameter, and determine the address of the received firmware data sector according to the index of the parameter sector. For example, the controller  1042  may obtain the received firmware data sector&#39;s number in the sequence according to the index and obtain the address of the memory device  1046  of the received firmware data sector by calculating the number in the sequence and the length of the firmware data sector. Therefore, the controller  1042  can store the program code sectors into the corresponding address in the sequence to constitute the firmware FW in the memory device  1046  as shown in  FIG. 3 . It should be noted that the controller  1042  can also determine whether the received firmware data sector is the last firmware data sector CSN according to the data amount parameter and the index. 
     In step S 514 , the controller  1042  stores the program code sector of the received firmware data sector into the address obtained in step S 512  of the memory device  1046 . 
     Next, in step S 516 , the controller  1042  notifies the status of the transmission to the host device  102 , but it is not limited thereto. In other embodiment, step S 516  can be removed. 
     In step S 518 , the controller  1042  reads the firmware version parameter of the parameter sector of the received firmware data sector stored in a register  1044  to check whether the firmware version of the received firmware data sector is correct according to the firmware version parameter of the parameter sector. When the firmware version is correct, the process goes to step S 520 , otherwise, the process ends at step S 518 , the controller  1042  stops updating the peripheral device  104 . 
     In step S 520 , the controller  1042  reads the index and the data amount parameter of the parameter sector of the received firmware data sector stored in a register  1044  to determine the address of the received firmware data sector, wherein the controller  1042  obtains the length of the firmware FW according to the data amount parameter, and determine the address of the received firmware data sector according to the index of the parameter sector. 
     In step S 522 , the controller  1042  determines whether the address obtained in step S 520  has the corresponding program code sector. When the address obtained in step S 520  has the corresponding program code sector, the process goes to step S 526 . Namely, in step S 522 , the controller  1042  determines whether the address obtained in step S 520  has effective data to determine whether the program code sector of the firmware data sector having the second mode parameter has been written into the memory device  1046 , and ignore the firmware data sector and drop the program code sector of the firmware data sector after determining that the program code sector has been written into the memory device  1046 . 
     In step S 524 , the controller  1042  stores the program code sector of the firmware data sector into the address obtained in step S 520  of the memory device  1046 . 
     Next, in step S 526 , the controller  1042  notifies the status of the transmission to the host device  102 , but it is not limited thereto. In other embodiment, step S 516  can be removed. In another embodiment, steps S 518 ˜S 526  can also be removed. Namely, the controller  1042  ignores the received firmware data sector while determining that the mode parameter is the second mode parameter and returns to step S 500  to continue processing the next firmware data sector. 
       FIG. 6A ˜ 6 C are flowcharts of a firmware update method according to another embodiment of the present disclosure. The firmware update method is applied to the electronic device  100  of  FIG. 1 , and arranged to update the firmware of the peripheral device  104  according to an update command. In this embodiment, the mode parameter further includes a third mode parameter. The process starts at step S 600 . It should be noted that steps S 600 ˜S 606  and S 610 ˜S 626  are similar to steps S 500 ˜S 506  and S 510 ˜S 526 , steps S 600 ˜S 606  and S 610 ˜S 626  can be referred to in  FIG. 5 . 
     In step S 608 , the controller  1042  reads the mode parameter of the parameter sector of the received firmware data sector stored in a register  1044  to determine whether the mode parameter of the received firmware data sector is a first mode parameter, a second mode parameter or a third mode parameter. When the mode parameter of the received firmware data sector is the first mode parameter, the process goes to step S 610 . When the mode parameter of the received firmware data sector is the second mode parameter, the process goes to step S 618 . When the mode parameter of the received firmware data sector is the third mode parameter, the process goes to step S 628 . 
     In step S 628 , the controller  1042  reads the firmware version parameter of the parameter sector of the received firmware data sector stored in a register  1044  to check whether the firmware version of the received firmware data sector is correct according to the firmware version parameter of the parameter sector. When the firmware version is correct, the process goes to step S 630 , otherwise, the process ends at step S 528 , the controller  1042  stop updating the peripheral device  104 . 
     In step S 630 , the controller  1042  reads the index and the data amount parameter of the parameter sector of the received firmware data sector stored in a register  1044  to determine the address of the received firmware data sector, wherein the controller  1042  obtains the length of the firmware FW according to the data amount parameter, and determine the address of the received firmware data sector according to the index of the parameter sector. 
     In step S 632 , the controller  1042  determines whether the received firmware data sector needs to be written into the memory device  1046 . When the controller  1042  determines that the received firmware data sector needs to be written into the memory device  1046 , the process goes to step S 634 , otherwise, the process goes to step S 636 . For example, the controller  1042  can determine whether the received firmware data sector needs to be written into the memory device  1046  according to the operation status or the status of data writing. 
     In step S 634 , the controller  1042  stores the program code sector of the received firmware data sector into the address obtained in step S 530  of the memory device  1046 . 
     Next, in step S 636 , the controller  1042  notifies the status of the transmission to the host device  102 , but it is not limited thereto. In other embodiment, step S 636  can be removed. 
     The electronic device  100  and the firmware update method of the present invention can continue to update the firmware after an interruption event. In another embodiment, the electronic device  100  and the firmware update method of the present invention can also determine the received firmware data sector&#39;s number in the predetermined transmission sequence, such that the firmware can be successfully updated when the transmission is not in order. 
     Data transmission methods, or certain aspects or portions thereof, may take the form of a program code (i.e., executable instructions) embodied in tangible media, such as floppy diskettes, CD-ROMS, hard drives, or any other machine-readable storage medium, wherein, when the program code is loaded into and executed by a machine such as a computer, the machine thereby becomes an apparatus for practicing the methods. The methods may also be embodied in the form of a program code transmitted over some transmission medium, such as electrical wiring or cabling, through fiber optics, or via any other form of transmission, wherein, when the program code is received and loaded into and executed by a machine such as a computer, the machine becomes an apparatus for practicing the disclosed methods. When implemented on a general-purpose processor, the program code combines with the processor to provide a unique apparatus that operates analogously to application-specific logic circuits. 
     While the invention has been described by way of example and in terms of the preferred embodiments, it is to be understood that the invention is not limited to the disclosed embodiments. On the contrary, it is intended to cover various modifications and similar arrangements (as would be apparent to those skilled in the art). Therefore, the scope of the appended claims should be accorded the broadest interpretation so as to encompass all such modifications and similar arrangements.