[go: up one dir, main page]

CN1317641C - Firmware update method and device for checking program content to ensure compatibility of firmware update - Google Patents

Firmware update method and device for checking program content to ensure compatibility of firmware update Download PDF

Info

Publication number
CN1317641C
CN1317641C CNB03106101XA CN03106101A CN1317641C CN 1317641 C CN1317641 C CN 1317641C CN B03106101X A CNB03106101X A CN B03106101XA CN 03106101 A CN03106101 A CN 03106101A CN 1317641 C CN1317641 C CN 1317641C
Authority
CN
China
Prior art keywords
program code
peripheral device
firmware
host
content
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CNB03106101XA
Other languages
Chinese (zh)
Other versions
CN1523501A (en
Inventor
刘敦行
吴元丁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
MediaTek Inc
Original Assignee
MediaTek Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by MediaTek Inc filed Critical MediaTek Inc
Priority to CNB03106101XA priority Critical patent/CN1317641C/en
Publication of CN1523501A publication Critical patent/CN1523501A/en
Application granted granted Critical
Publication of CN1317641C publication Critical patent/CN1317641C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention provides a method and a related device for updating firmware in an electronic system. The electronic system has one host and one peripheral device, and the peripheral device has one control circuit and one flash memory, and the control circuit executes the first program code recorded in the flash memory to receive the control command of the host and control the operation of the peripheral device. Before replacing/updating the first program code with the second program code, a checking step is carried out to check whether the content of the second program code conforms to a preset content so as to judge the compatibility of the second program code. The checking step can be performed by the host and/or the control circuit, and the checking step can check whether a part of constant values and strings recorded in the second code conform to preset values, or/and check whether instructions and data at preset addresses in the second code conform to preset instructions and data, so as to determine the compatibility of the second code.

Description

检查程序内容确保固件更新相容性 的固件更新方法及装置Firmware update method and device for checking program content to ensure compatibility of firmware update

技术领域technical field

本发明提供一种固件更新的方法及相关装置,尤指一种在固件更新前检查更新用固件程序码的内容以判断其相容性、适用性的方法及相关装置。The present invention provides a firmware update method and a related device, especially a method and a related device for checking the contents of firmware program codes for updating to judge its compatibility and applicability before the firmware update.

背景技术Background technique

在现代化的信息社会中,信息、图像、数据资料都是以电子形式的信号来传输、存储及处理的,而各种各样用来存取电子信号的电子系统、装置,小至手机、大至计算机,也就成为信息建设的关键基础。一般来说,在电子装置中,多半设有一控制电路统一控制电子装置的各种操作;而在功能繁复、多样的电子装置中,由于控制的程序比较复杂,就要用特定的程序码来记录各种控制程序进行的相关步骤及过程;控制电路执行程序码,就能实现电子装置的不同功能。这样的程序码,即被称之为固件程序码;而固件程序码多半被存储于电子装置中的非易失性存储器(如闪速存储器)中,方便控制电路读取、执行。另外,像在计算机系统这种功能更为复杂多样的电子系统中,计算机的各种外围装置本身就具有控制电路及对应的固件程序码;计算机的主机本身仅需发出高层的控制指令至外围装置的控制电路,控制电路就会执行该外围装置本身的固件程序码,控制外围装置的实际操作。举例来说,计算机系统中的光盘机本身就具有其控制电路及对应的闪速存储器,以存储光盘机本身的固件程序码。当计算机的主机要读取一光盘片上的数据时,仅需向光盘机指定该笔数据在光盘片上的地址,光盘机的控制电路就会执行本身的固件程序码,协调光盘机中诸如马达(spindle)、激光读取头(pick-up head)等等机电元件的操作(如马达要达到特定的转速,读取头要移动、锁定至特定的位置,接收光盘片上反射的激光等等),实际实现主机的要求。In a modern information society, information, images, and data are transmitted, stored, and processed in the form of electronic signals, and various electronic systems and devices used to access electronic signals, ranging from mobile phones to large Even computers have become the key foundation of information construction. Generally speaking, most electronic devices are provided with a control circuit to uniformly control various operations of the electronic device; however, in electronic devices with complex functions and various functions, since the control procedures are relatively complicated, specific program codes are used to record The relevant steps and processes of various control programs; the control circuit executes the program codes to realize different functions of the electronic device. Such program codes are called firmware program codes; most of the firmware program codes are stored in non-volatile memory (such as flash memory) in the electronic device, which is convenient for the control circuit to read and execute. In addition, in electronic systems with more complex and diverse functions like computer systems, various peripheral devices of the computer themselves have control circuits and corresponding firmware program codes; the host computer itself only needs to send high-level control commands to the peripheral devices The control circuit will execute the firmware program code of the peripheral device itself to control the actual operation of the peripheral device. For example, the optical disc drive in the computer system itself has its control circuit and corresponding flash memory for storing the firmware program code of the optical disc drive itself. When the host computer of the computer wants to read the data on an optical disc, it only needs to specify the address of the data on the optical disc to the optical disc drive, and the control circuit of the optical disc drive will execute its own firmware program code to coordinate such as the motor ( spindle), laser pick-up head (pick-up head) and other electromechanical components (such as the motor must reach a specific speed, the pick-up head must move, lock to a specific position, receive the laser reflected on the optical disc, etc.), The actual implementation of the host's requirements.

请参考图1。图1为一典型电子系统10的功能方块示意图。电子系统10可以是一计算机系统,其中包括有一主机12及一或多个外围装置(图1中绘出两个外围装置14、15做为代表)。外围装置可以是只读光盘机、光盘刻录机、硬盘、外接式的闪速存储器等等;以外围装置14为例来说明典型外围装置中的配置,外围装置14中设有一控制电路16、一缓冲存储器18、一存储存储器20及一伺服硬件22。若电子系统10为一计算机系统,则主机12的典型配置就如图1中所示,其设有一中央处理器26、一北桥电路28A、一南桥电路28B及一易失性的存储器30、绘图卡32A及显示器32B。中央处理器26用来主控主机12的操作,存储器30用来暂存中央处理器26操作期间必需的数据、资料,绘图卡32A则用来处理图像数据,以将主机12操作的状况显示于显示器32B上。而北桥电路28A即用来管理、控制中央处理器26与绘图卡32A、存储器30的数据传输;南桥电路28B则通过北桥电路28A电连于中央处理器26,作为各外围装置14、15与主机12交换数据的接口。通过南桥电路28B与外围装置14、15间的电连(如通过总线),主机12与各外围装置14、15就能互相交换数据。另一方面,在外围装置14中,控制电路16用来接收主机12传来的控制指令,以控制外围装置14的操作。伺服硬件22即是受控于控制电路16,用来实现外围装置14的功能。举例来说,若外围装置14为一光盘机,伺服硬件22即包括了带动光盘片转动的马达、激光读取头等等机电元件,以存取一光盘片上的数据。缓冲存储器18、存储存储器20则用来支援控制电路16的操作;其中缓冲存储器18为一易失性的存储器(如随机存取存储器),用来暂存控制电路16操作期间的数据、资料。存储存储器20则为一非易失性的存储器(如闪速存储器),用来记录一固件的程序码24;正如前面所提到的,外围装置14的控制电路16在控制外围装置14时,会依循特定的固件程序码来进行各种控制程序,程序码24即为此固件程序码,用来记录不同控制程序进行的方式。控制电路16执行此程序码24,就能根据主机12的控制指令,控制外围装置14的操作。Please refer to Figure 1. FIG. 1 is a functional block diagram of a typical electronic system 10 . The electronic system 10 may be a computer system, which includes a host 12 and one or more peripheral devices (two peripheral devices 14 and 15 are represented in FIG. 1 ). The peripheral device can be a CD-ROM, a CD recorder, a hard disk, an external flash memory, etc.; the peripheral device 14 is used as an example to illustrate the configuration of a typical peripheral device, and the peripheral device 14 is provided with a control circuit 16, a Buffer memory 18 , a storage memory 20 and a servo hardware 22 . If the electronic system 10 is a computer system, the typical configuration of the host computer 12 is as shown in FIG. graphics card 32A and display 32B. The central processing unit 26 is used to control the operation of the host computer 12, the memory 30 is used to temporarily store necessary data and data during the operation of the central processing unit 26, and the graphics card 32A is used to process image data to display the operation status of the host computer 12 on on display 32B. The north bridge circuit 28A is used to manage and control the data transmission between the central processing unit 26 and the graphics card 32A and the memory 30; The host 12 is an interface for exchanging data. Through the electrical connection between the south bridge circuit 28B and the peripheral devices 14 and 15 (such as via a bus), the host computer 12 and the peripheral devices 14 and 15 can exchange data with each other. On the other hand, in the peripheral device 14 , the control circuit 16 is used to receive control commands from the host 12 to control the operation of the peripheral device 14 . The servo hardware 22 is controlled by the control circuit 16 to realize the functions of the peripheral device 14 . For example, if the peripheral device 14 is an optical disc drive, the servo hardware 22 includes electromechanical components such as a motor to rotate the optical disc, a laser pickup head, etc., to access data on an optical disc. The buffer memory 18 and the storage memory 20 are used to support the operation of the control circuit 16 ; the buffer memory 18 is a volatile memory (such as a random access memory) for temporarily storing data and data during the operation of the control circuit 16 . The storage memory 20 is a non-volatile memory (such as a flash memory) used to record a firmware program code 24; as mentioned above, when the control circuit 16 of the peripheral device 14 controls the peripheral device 14, Various control programs will be performed according to specific firmware program codes, and the program code 24 is this firmware program code, which is used to record the ways in which different control programs are carried out. The control circuit 16 executes the program code 24 to control the operation of the peripheral device 14 according to the control command of the host 12 .

当然,在每一个外围装置出厂时,存储存储器中均已写入固件程序码,作为预置的固件。在外围装置连接于主机之后,外围装置中的控制电路就能依据此预置的固件控制外围装置的操作。然而,此预置的固件可能有某些控制程序上的错误(bug),等到外围装置出厂后才被发现的。另外,固件研发厂商即使在外围装置出厂后,也会持续研发新的控制程序及固件程序码,以提升外围装置的操作效能,或是扩展外围装置的应用范围。以光盘机为例,采用不同的控制程序,光盘机可能就能更快地锁定激光读取头的位置,以更稳定地读取光盘片上特定部分的数据。或者,当有光盘片是采用较新规格的数据格式来记录数据时,更新固件程序码中部分控制程序进行的方式,光盘机可能就可以顺利读取较新数据格式的光盘片,扩大其支援的光盘片数据格式。在以上讨论的各种情况下,都需要更新外围装置中的固件程序码,以新的固件程序码取代外围装置中既有的固件程序码,这样才能解决预置固件程序码中的错误、提升外围装置的效能、扩大外围装置的应用范围。在现代的外围装置中,固件程序码多半都存储于可重复覆写的非易失性存储存储器中(如闪速存储器,或是电性可擦除可程序化只读存储器EEPROM),只要将存储存储器中原来的预置固件程序码擦除,写入新的固件程序码,就能以新的固件程序码取代旧的预置固件程序码,完成固件的更新。当外围装置中的控制电路执行存储存储器中新的固件程序码,就能以新的控制程序控制外围装置的操作。Of course, when each peripheral device leaves the factory, the firmware program code has been written into the storage memory as preset firmware. After the peripheral device is connected to the host, the control circuit in the peripheral device can control the operation of the peripheral device according to the preset firmware. However, the preset firmware may have some control program errors (bugs), which are not discovered until the peripheral device leaves the factory. In addition, firmware developers will continue to develop new control programs and firmware codes even after the peripheral devices leave the factory, so as to improve the operating performance of the peripheral devices or expand the application range of the peripheral devices. Taking the optical disc drive as an example, with different control programs, the optical disc drive may be able to lock the position of the laser pickup head faster, so as to more stably read data on a specific part of the optical disc. Or, when there is an optical disc that uses a data format of a newer specification to record data, update the way in which part of the control program in the firmware program code is carried out, and the optical disc drive may be able to read the optical disc with a newer data format smoothly, expanding its support CD-ROM data format. In the various situations discussed above, it is necessary to update the firmware program code in the peripheral device, and replace the existing firmware program code in the peripheral device with the new firmware program code, so as to solve the errors in the preset firmware program code and improve Improve the performance of peripheral devices and expand the application range of peripheral devices. In modern peripheral devices, most of the firmware program codes are stored in rewritable non-volatile storage memory (such as flash memory, or electrically erasable programmable read-only memory EEPROM), as long as the The original preset firmware program code in the storage memory is erased, and the new firmware program code is written in, so that the old preset firmware program code can be replaced with the new firmware program code, and the firmware update is completed. When the control circuit in the peripheral device executes the new firmware program code stored in the memory, the operation of the peripheral device can be controlled by the new control program.

一般来说,要更新外围装置中的固件程序码,主机也要进行对应的操作。请参考图2(并一并参考图1)。图2流程图中的流程100,即为公知技术中,电子系统10要对外围装置14进行固件更新时,主机12、外围装置14间协调操作的流程。图2左半边的步骤代表主机12进行的步骤,右半边的步骤代表外围装置14所进行的步骤。公知流程100中依序有下列步骤:Generally speaking, to update the firmware program code in the peripheral device, the host also needs to perform corresponding operations. Please refer to Figure 2 (and also refer to Figure 1). The process 100 in the flow chart of FIG. 2 is the process of coordinating operations between the host computer 12 and the peripheral device 14 when the electronic system 10 needs to update the firmware of the peripheral device 14 in the known technology. The steps in the left half of FIG. 2 represent the steps performed by the host 12 , and the steps in the right half represent the steps performed by the peripheral device 14 . The known process 100 has the following steps in sequence:

步骤102:开始。要开始更新外围装置14的固件程序码时,中央处理器26会开始执行一固件更新的应用程序34,启动整个固件更新的流程100,并在后续步骤中持续控制固件更新流程的进行。就如图1中所示,此应用程序34会被载入至主机12中的存储器30,由中央处理器26执行应用程序34,对外围装置14进行固件更新。固件更新的目的,以一新程序码36,取代外围装置14中既有的程序码24。Step 102: start. When updating the firmware program code of the peripheral device 14, the central processing unit 26 will start to execute a firmware update application program 34, start the entire firmware update process 100, and continue to control the progress of the firmware update process in subsequent steps. As shown in FIG. 1 , the application program 34 is loaded into the memory 30 of the host 12 , and the CPU 26 executes the application program 34 to update the firmware of the peripheral device 14 . The purpose of the firmware update is to replace the existing program code 24 in the peripheral device 14 with a new program code 36 .

步骤104:主机12执行应用程序34后,就会先对外围装置14进行装置识别,以确定应用程序34是和外围装置14搭配的应用程序,能正确地控制外围装置14进行固件更新。如前所述,主机12可能连接有多个不同的外围装置,各外围装置的结构、功能各不相同,要控制不同的外围装置分别进行固件更新,主机12所要执行的应用程序当然也各不相同;要正确地对一外围装置进行固件更新,就要使用和该外围装置对应的应用程序。而本步骤就是要确定应用程序34是和外围装置14对应的正确应用程序。一般来说,各外围装置中的固件程序码内就记录有一固件识别码,其中可包括有固件研发厂商的名称(vendor ID)、该固件程序码适用的外围装置的型号名称(model name),或是该固件程序码的版本信息等。如在外围装置14中的既有程序码24,就记录有一固件识别码24I。而当主机12在执行应用程序34时,就可依据应用程序34的指示向外围装置14发出装置识别的控制指令,要求外围装置14将固件识别码24I中的相关数据(或其他可识别外围装置14的数据、信号)传输至主机12。Step 104 : After the host 12 executes the application program 34 , it first performs device identification on the peripheral device 14 to determine that the application program 34 is an application program matched with the peripheral device 14 and can correctly control the peripheral device 14 to perform firmware update. As mentioned above, the host 12 may be connected to a plurality of different peripheral devices, and the structures and functions of each peripheral device are different. To control different peripheral devices to perform firmware updates respectively, the application programs to be executed by the host 12 are of course also different. Same; to correctly update the firmware of a peripheral device, the application program corresponding to the peripheral device must be used. And this step is to determine that the application program 34 is the correct application program corresponding to the peripheral device 14 . Generally speaking, a firmware identification code is recorded in the firmware program code of each peripheral device, which may include the name (vendor ID) of the firmware developer, the model name (model name) of the peripheral device to which the firmware program code is applicable, Or version information of the firmware program code and the like. As the existing program code 24 in the peripheral device 14, a firmware identification code 24I is recorded. And when the host 12 is executing the application program 34, it can send a device identification control command to the peripheral device 14 according to the instruction of the application program 34, requiring the peripheral device 14 to send the relevant data in the firmware identification code 24I (or other identifiable peripheral device 14 data, signal) to the host 12.

步骤106:外围装置14回应主机12于步骤104中的要求,将固件识别码24I的相关数据(或其他识别数据)回传至主机12。Step 106 : The peripheral device 14 responds to the request of the host 12 in step 104 , and returns the relevant data of the firmware identification code 24I (or other identification data) to the host 12 .

步骤108:主机12执行应用程序34时,即可根据外围装置14回传的识别数据,判断外围装置14是否是和应用程序34搭配的装置。事实上,在主机12与外围装置14进行装置识别时,很有可能会进行数次的数据、指令交换,在不影响本发明技术讨论的情形下,图2中的流程图已经部分简化装置识别的细节。根据外围装置14与主机12间的数据交换,若主机12判断出应用程序34的确能和外围装置14互相搭配,主机12即可继续固件更新的流程,发出控制指令询问外围装置14现行的操作状态是否能进行固件更新。因为在主机12执行固件更新的应用程序34时,外围装置14可能正在执行某些操作(譬如说光盘机的外围装置14可能正在存取光盘片上的数据),这样就不能进行固件更新了。故此步骤中,主机12要询问外围装置14目前的操作状态。同时,主机12也可将固件更新所用的新程序码36载入至存储器36中,准备传输给外围装置14。Step 108 : When the host 12 executes the application program 34 , it can judge whether the peripheral device 14 is a device matched with the application program 34 according to the identification data returned by the peripheral device 14 . In fact, when the host 12 and the peripheral device 14 perform device identification, it is very likely that several data and command exchanges will be performed. Without affecting the technical discussion of the present invention, the flow chart in FIG. 2 has partially simplified the device identification. details. According to the data exchange between the peripheral device 14 and the host 12, if the host 12 judges that the application program 34 can indeed be compatible with the peripheral device 14, the host 12 can continue the firmware update process and issue a control command to inquire about the current operating status of the peripheral device 14. Whether a firmware update can be performed. Because when the host computer 12 executes the application program 34 of the firmware update, the peripheral device 14 may be performing some operations (for example, the peripheral device 14 of the CD player may be accessing the data on the optical disc), so the firmware update cannot be performed. Therefore, in this step, the host 12 needs to inquire about the current operating status of the peripheral device 14 . At the same time, the host 12 can also load the new program code 36 used for firmware update into the memory 36 , ready to be transmitted to the peripheral device 14 .

步骤110:外围装置14回应主机的询问,将外围装置14目前的操作状态回传至主机12。Step 110 : the peripheral device 14 responds to the query of the host, and returns the current operating status of the peripheral device 14 to the host 12 .

步骤112:若外围装置14回传的操作状态代表其能进行固件更新,主机12就能将暂存于存储器30中的新程序码36传输至外围装置14。就像典型的网路传输一样,主机12在传输新程序码36时,会执行一预设的检查码产生演算法,根据新程序码36的内容计算出一检查码(checksum)36C,并与新程序码36一并传输至外围装置14。Step 112 : If the operating status returned by the peripheral device 14 indicates that it can perform firmware update, the host 12 can transmit the new program code 36 temporarily stored in the memory 30 to the peripheral device 14 . Just like a typical network transmission, when the host 12 transmits the new program code 36, it will execute a preset checksum generation algorithm, calculate a checksum (checksum) 36C according to the content of the new program code 36, and compare it with The new program code 36 is also transmitted to the peripheral device 14 .

步骤114:外围装置14接收主机12传来的新程序码及检查码,并将其暂存于缓冲存储器18中。图1中暂存于外围装置14缓冲存储器18内的新程序码37、检查码37C,就是外围装置14由主机12接收的新程序码及检查码。Step 114 : the peripheral device 14 receives the new program code and check code from the host 12 and temporarily stores them in the buffer memory 18 . The new program code 37 and check code 37C temporarily stored in the buffer memory 18 of the peripheral device 14 in FIG. 1 are the new program code and check code received by the host computer 12 by the peripheral device 14 .

步骤116:控制电路16同样也会执行检查码产生演算法,根据其所接收到的新程序码37计算出另一检查码39C,并将此检查码39C和由主机12传来的检查码37C进行比较。控制电路16使用的检查码产生演算法和主机12根据新程序码36产生检查码36C的检查码产生演算法是一样的;若在新程序码、检查码由主机12传输至外围装置14的过程中没有发生数据传输的错误,外围装置14接收到的新程序码37应该就等于主机12所要传输的新程序码36,而控制电路16所计算出来的检查码39C应该也会等于其所接收的检查码37C。反之,若控制电路16计算出来的检查码39C其接收到的检查码37C不一致,就代表主机12传输新程序码/检查码至外围装置14的过程中发生了数据传输的错误。若在本步骤中比较出检查码39C与检查码37C为一致的,就可进行至步骤118;反之,若两检查码不一致,就要进行至步骤120。Step 116: The control circuit 16 will also execute the check code generation algorithm, calculate another check code 39C according to the new program code 37 it receives, and combine this check code 39C with the check code 37C sent by the host computer 12 Compare. The check code generation algorithm used by the control circuit 16 is the same as the check code generation algorithm that the host computer 12 generates the check code 36C according to the new program code 36; There is no data transmission error, the new program code 37 received by the peripheral device 14 should be equal to the new program code 36 to be transmitted by the host computer 12, and the check code 39C calculated by the control circuit 16 should also be equal to the received program code 39C. Check code 37C. Conversely, if the check code 39C calculated by the control circuit 16 is inconsistent with the received check code 37C, it means that a data transmission error occurs during the host 12 transmitting the new program code/check code to the peripheral device 14 . If it is found that the check code 39C is consistent with the check code 37C in this step, then proceed to step 118 ; otherwise, if the two check codes are inconsistent, then proceed to step 120 .

步骤118:在公知技术中,控制电路16在步骤116中判断新程序码37的传输无误后,就会将存储存储器20中既有的程序码24擦除(erase),并将暂存于缓冲存储器18中的新程序码37覆写至存储存储器20中;这样一来也就完成外围装置14的固件更新了。接下来控制电路16就可以执行被写入至存储存储器20的新程序码37,以控制外围装置14的操作。当然,在固件更新成功后,外围装置14也可将更新成功的情况回传至主机12;而主机12也可再次要求外围装置14传输新程序码中的固件识别码至主机12以确认固件更新成功。在不影响本发明技术讨论的情形下,图2中已略去上述操作的细节。Step 118: In the known technology, after the control circuit 16 judges that the transmission of the new program code 37 is correct in step 116, the existing program code 24 in the storage memory 20 will be erased (erase), and will be temporarily stored in the buffer The new program code 37 in the memory 18 is overwritten into the storage memory 20; in this way, the firmware update of the peripheral device 14 is completed. Then the control circuit 16 can execute the new program code 37 written into the storage memory 20 to control the operation of the peripheral device 14 . Of course, after the firmware update is successful, the peripheral device 14 can also send back the success of the update to the host computer 12; and the host computer 12 can also request the peripheral device 14 to transmit the firmware identification code in the new program code to the host computer 12 to confirm the firmware update success. The details of the above operations have been omitted in FIG. 2 without affecting the technical discussion of the present invention.

步骤120:若在步骤116中控制电路16比较发现检查码37C、39C不一致,就可进行必要的错误处理。举例来说,控制电路16可要求主机12将新程序码36重新传输一次,重新进行步骤116中的检查码比较;或是将发生错误的情况回传至主机12,由主机12决定后续的操作。Step 120: If the control circuit 16 compares and finds that the check codes 37C and 39C are inconsistent in step 116, necessary error handling can be performed. For example, the control circuit 16 may require the host computer 12 to retransmit the new program code 36 once, and perform the check code comparison in step 116 again; or return the error situation to the host computer 12, and the host computer 12 determines the subsequent operation .

步骤122:结束固件更新的流程。Step 122: End the process of firmware update.

总结来说,在以图2中的公知流程100进行固件更新时,主机12、外围装置14间在确认互连的状态、外围装置14可以进行固件更新后,主机12只是单纯将固件更新的新程序码36传输至外围装置14,而外围装置14在进行步骤116的检查码比较而确认新程序码的传输无误后,就会进行固件更新。上述公知流程的主要缺点之一,就是无法确保固件更新用的新程序码的内容是否真的是合乎外围装置14应用的固件程序码。一般来说,固件更新的新程序码36是由主机12的使用者取得(如由网路下载),再于固件更新的过程中由应用程序34载入至主机12的存储器30中。然而,在使用者取得新程序码36的过程中就有可能出错,使得新程序码36本身为不符合外围装置14应用的固件程序码。举例来说,主机12的使用者可能是由网路下载而取得新程序码36,但网路下载的过程中可能会发生网路传输的错误,使得新程序码36本身是不完整的。或者,使用者也可能误判固件程序码的版本。如前所述,固件研发厂商可能不断释出新版本的固件程序码,外围装置14在出厂时可能已经内建了较新版本的预置程序码,但使用者在未察觉的情况下,欲取得了较旧版本的新程序码36要来为外围装置14进行固件更新;换句话说,在此情况下,图1中的既有程序码24为较新的版本,新程序码36本身反而是较旧的版本。此时若进行固件“更新”,反而会将固件程序码降级。另外,使用者也可能错误地取得不合乎外围装置14应用的固件程序码作为新程序码36。举例来说,使用者取得的新程序码36可能根本不是适用于外围装置14的固件程序码。尤其是在技术发展快速的现代社会,同一厂商可能推出多种不同型号、功能各异的同类型外围装置。如在光盘机这种常见的计算机系统外围装置中,就有各种不同读取倍速的光盘机,或是某些光盘机仅能读取光盘片的数据,有些光盘机则还能将数据刻录至光盘片;某些光盘机则支援较多不同格式光盘片的数据读取。虽然研发厂商会针对不同型号的外围装置释出不同的更新用固件程序码,但使用者可能一时不察,取得与外围装置14完全不相符的新程序码36来为外围装置14进行固件更新。除此之外,还有可能有某些恶意的破坏者,故意提供错误的固件程序码作为新程序码36,意图以固件更新的流程将错误的固件程序码植入外围装置14中,以瘫痪外围装置14的正常操作。To sum up, when firmware update is performed with the known process 100 in FIG. The program code 36 is transmitted to the peripheral device 14 , and the peripheral device 14 performs a firmware update after confirming that the transmission of the new program code is correct after performing the check code comparison in step 116 . One of the main disadvantages of the above known process is that it is impossible to ensure whether the content of the new program code used for firmware update is really the firmware program code suitable for the application of the peripheral device 14 . Generally speaking, the new program code 36 for firmware update is obtained by the user of the host 12 (for example, downloaded from the Internet), and then loaded into the memory 30 of the host 12 by the application program 34 during the firmware update process. However, it is possible for the user to make mistakes during the process of obtaining the new program code 36 , so that the new program code 36 itself is a firmware program code that does not conform to the application of the peripheral device 14 . For example, the user of the host computer 12 may obtain the new program code 36 by downloading from the network, but network transmission errors may occur during the network download process, making the new program code 36 itself incomplete. Alternatively, the user may misjudge the version of the firmware program code. As mentioned above, firmware developers may continuously release new versions of firmware program codes, and the peripheral device 14 may have built-in a newer version of preset program codes when it leaves the factory, but users may want to use it without realizing it. The new program code 36 of the older version is used to update the firmware of the peripheral device 14; in other words, in this case, the existing program code 24 in FIG. is an older version. If the firmware is "updated" at this time, the firmware program code will be downgraded instead. In addition, the user may mistakenly obtain the firmware program code that is not suitable for the application of the peripheral device 14 as the new program code 36 . For example, the new code 36 obtained by the user may not be the firmware code for the peripheral device 14 at all. Especially in the modern society with rapid technological development, the same manufacturer may launch many different types of peripheral devices of the same type with different functions. For example, in a common computer system peripheral device such as a CD-ROM, there are various CD-ROMs with different reading speeds, or some CD-ROMs can only read the data of CD-ROMs, and some CD-ROMs can also burn data. to CD-ROMs; some CD-ROMs support reading data from more CD-ROMs in different formats. Although R&D manufacturers will release different update firmware program codes for different types of peripheral devices, users may obtain new program codes 36 completely inconsistent with the peripheral device 14 to perform firmware update for the peripheral device 14 without noticing them. In addition, there may be some malicious saboteurs who intentionally provide wrong firmware program codes as the new program code 36, intending to implant the wrong firmware program codes into the peripheral device 14 in the process of firmware update, so as to paralyze the Normal operation of the peripheral device 14 .

在上述的各种情况下,主机12要用来进行固件更新的新程序码36,其实已经不合乎外围装置14的应用;但在公知的固件更新流程100中,却无法检查出新程序码36是否适用。在公知流程100中,主机12虽然会在步骤104进行装置识别,通过外围装置14检查既有的程序码24的固件识别码24I,但主机12检查的是外围装置14已在操作中的固件程序码(也就是外围装置14既有的程序码24),不会检查新程序码36是否合乎外围装置14的应用。另外,外围装置14的控制电路16会在步骤116中检查与新程序码36相关的检查码,但此步骤只能检查出新程序码36在主机12、外围装置14间传输时是否发生数据传输的错误,也不能检查出新程序码36是否适用。即使新程序码为不适用的固件程序码,只要主机12、外围装置14间的数据传输没有发生问题,流程100还是会通过步骤116,将不适用的新程序码写入至存储存储器中。换句话说,在步骤116中,即使检查码符合,也只代表主机12是将不适用的新程序码36完整正确地传输至外围装置14而成为新程序码37(见图2),新程序码37不适用的本质还是不会改变,也不能由步骤116中检查出来。虽然控制电路16在步骤116中会依据新程序码37计算出检查码39C,使得检查码39C能反映出新程序码37的内容,但步骤116中用来比较检查码39C的另一检查码37C也还是依据新程序码36所算出的,并不能代表“适用”的固件程序码所应具有的检查码(尤其是当新程序码36本身就是不适用的固件程序码时)。换句话说,当公知流程100在进行步骤116时,控制电路16本身并不能得知“适用”的固件程序码对应的检查码为何,当然也就不能在步骤116中检查比较出新程序码37是否适用。若在固件更新流程中误将错误、不适用的固件程序码植入至外围装置14中,不但无法达到固件更新的目的,还会导致外围装置14不能正确操作的严重后果。In the various situations mentioned above, the new program code 36 to be used by the host computer 12 for firmware update is not suitable for the application of the peripheral device 14; but in the known firmware update process 100, the new program code 36 cannot be detected. Is it applicable. In the known process 100, although the host 12 will perform device identification in step 104 and check the firmware identification code 24I of the existing program code 24 through the peripheral device 14, what the host 12 checks is the firmware program of the peripheral device 14 that is already in operation. Code (that is, the existing program code 24 of the peripheral device 14), will not check whether the new program code 36 is suitable for the application of the peripheral device 14. In addition, the control circuit 16 of the peripheral device 14 will check the check code related to the new program code 36 in step 116, but this step can only check whether data transmission occurs when the new program code 36 is transmitted between the host computer 12 and the peripheral device 14. error, also can not check out whether the new program code 36 is applicable. Even if the new program code is an inapplicable firmware program code, as long as there is no problem in the data transmission between the host 12 and the peripheral device 14, the process 100 will still go through step 116 to write the inapplicable new program code into the storage memory. In other words, in step 116, even if the check code matches, it only means that the host computer 12 completely and correctly transmits the inapplicable new program code 36 to the peripheral device 14 to become a new program code 37 (see FIG. 2 ). The inapplicable nature of code 37 still does not change, nor can it be checked out in step 116. Although the control circuit 16 will calculate the check code 39C according to the new program code 37 in step 116, so that the check code 39C can reflect the content of the new program code 37, another check code 37C used to compare the check code 39C in step 116 It is also calculated according to the new program code 36, and cannot represent the check code that the "applicable" firmware program code should have (especially when the new program code 36 itself is an inapplicable firmware program code). In other words, when the known process 100 is performing step 116, the control circuit 16 itself cannot know what the check code corresponding to the "applicable" firmware program code is, and of course it cannot check and compare the new program code 37 in step 116. Is it applicable. If wrong or inapplicable firmware program codes are mistakenly implanted into the peripheral device 14 during the firmware update process, not only the purpose of firmware update will not be achieved, but the peripheral device 14 will not operate correctly.

发明内容Contents of the invention

因此,本发明的主要目的,在于提供一种新的固件更新方法及相关装置,能筛选出更新用的新固件程序码是否真正适用,以克服公知技术的缺点。Therefore, the main purpose of the present invention is to provide a new firmware update method and related device, which can screen out whether the new firmware program code for update is really applicable, so as to overcome the shortcomings of the known technology.

在公知技术中,不论是在主机端或是在外围装置的装置端,都无法检查出固件更新所用的新程序码是否合乎外围装置的实际应用,因此也无法避免不适用的新程序码在公知的固件更新流程中被误植入外围装置。In the known technology, it is impossible to check whether the new program code used for firmware update is suitable for the actual application of the peripheral device, no matter at the host end or at the device end of the peripheral device. erroneously implanted in a peripheral device during the firmware update process.

在本发明中,则会在对一外围装置进行固件更新的流程中加入主机端检查步骤及/或装置端检查步骤,将更新用的新固件程序码的部分内容与一预设的内容比较,以实际判断新固件程序码是否适用。在实际实施时,可检查新固件程序码中的固件识别码(包括固件研发厂商的名称,以及该固件程序码适用的外围装置的型号名称)是否和该外围装置中既有的围件程序码的固件识别码相符,也可检查新固件程序码中是否包含有特定的指令、常数。另外,也可检查新固件程序码中特定地址的指令、数据是否合乎预期中的指令、数据,或是搜寻新固件程序码中特定指令、数据的地址是否位于预设的地址,以判断固件更新所用的新固件程序码是否合乎外围装置应用的正确固件。上述的检查步骤可在主机端、装置端分别独立进行,确保固件更新所用的新固件程序码为适用的固件程序码,避免在固件更新流程中误将不适用的固件程序码植入外围装置中。In the present invention, a host-side check step and/or a device-side check step are added to the process of updating the firmware of a peripheral device, and a part of the content of the new firmware program code for updating is compared with a preset content, To actually judge whether the new firmware program code is applicable. In actual implementation, it is possible to check whether the firmware identification code (including the name of the firmware developer and the model name of the peripheral device to which the firmware code is applicable) in the new firmware program code is consistent with the existing peripheral program code in the peripheral device. The firmware identification code of the new firmware is consistent, and it is also possible to check whether the new firmware program code contains specific instructions and constants. In addition, it is also possible to check whether the instructions and data of specific addresses in the new firmware program code are in line with the expected instructions and data, or to search whether the address of specific instructions and data in the new firmware program code is located at the preset address to determine whether the firmware is updated. Whether the new firmware code used corresponds to the correct firmware for the peripheral device application. The above inspection steps can be carried out independently on the host side and the device side to ensure that the new firmware code used for firmware update is the applicable firmware code, and avoid implanting inapplicable firmware code into the peripheral device by mistake during the firmware update process .

附图说明:Description of drawings:

图1为一典型电子系统中主机及外围装置配置的示意图。FIG. 1 is a schematic diagram of a configuration of a host computer and peripheral devices in a typical electronic system.

图2为图1中电子系统以一公知流程进行固件更新的流程示意图。FIG. 2 is a schematic flowchart of firmware update performed by the electronic system in FIG. 1 in a known process.

图3为本发明电子系统中主机及外围装置配置的示意图。FIG. 3 is a schematic diagram of the configuration of the host computer and peripheral devices in the electronic system of the present invention.

图4为图3中电子系统以本发明流程进行固件更新的流程示意图。FIG. 4 is a schematic flowchart of firmware update performed by the electronic system in FIG. 3 using the process of the present invention.

图5A至5E分别为图4中主机端/装置端检查步骤不同实施例的示意图。5A to 5E are schematic diagrams of different embodiments of the host-side/device-side checking steps in FIG. 4 .

图式的符号说明:Explanation of the symbols in the diagram:

10、50    电子系统          12、52    主机10, 50 Electronic system 12, 52 Host

14-15、54-55                外围装置14-15, 54-55 Peripherals

16、56    控制电路          18、58    缓冲存储器16, 56 Control circuit 18, 58 Buffer memory

20、60    存储存储器        22、62    伺服硬件20, 60 Storage memory 22, 62 Servo hardware

24、64    程序码24, 64 program code

24I、64I、76I、77I          固件识别码24I, 64I, 76I, 77I Firmware identification code

26、66    中央处理器26, 66 CPU

28A、68A  北桥电路          28B、68B  南桥电路28A, 68A North Bridge Circuit 28B, 68B South Bridge Circuit

30、70    存储器            32A、72A  绘图卡30, 70 memory 32A, 72A graphics card

32B、72B  显示器            34、74    应用程序32B, 72B Display 34, 74 Application

36-37、76-77、84                      新程序码36-37, 76-77, 84 New program code

36C、37C、39C、76C、77C、79C          检查码36C, 37C, 39C, 76C, 77C, 79C check code

56B       检查模块56B Inspection module

80、82    预设内容          86        源码80, 82 Default content 86 Source code

88、89    固件程序码        90A-90D   程序片段88, 89 Firmware program code 90A-90D Program fragment

92A-92C、92D1、92D2         部分内容Part of 92A-92C, 92D1, 92D2

94        指令码            95        数据94 Command Code 95 Data

100、200  流程100, 200 process

102-122、202-224            步骤102-122, 202-224 steps

具体实施方式Detailed ways

请参考图3。图3为本发明电子系统50配置的功能方块示意图。电子系统50中设有一主机52及一或多个搭配操作的外围装置(图3中绘出两个外围装置54、55做为代表),以扩充主机52本身的功能。电子系统50可以是一计算机系统;在此情况下,主机52中可设有中央处理器66、北桥电路68A、南桥电路68B、存储器70、绘图卡72A及显示器72B;外围装置54、55则可以是光盘机、光盘刻录机、硬盘机等等。以外围装置54为例来说明外围装置中的配置;外围装置54中设有一控制电路56、一用来实现外围装置54功能的伺服硬件62、一用来以易失性方式暂存数据的缓冲存储器58(如随机存取存储器),以及一用来以非易失性的方式存储数据的存储存储器60(如闪速存储器);而控制电路56中则有一检查模块56B。在主机12中,中央处理器66用来主控主机52的操作,绘图卡72A能将主机52操作的状态与结果转变为图像信号,并于显示器72B显示出来。易失性的存储器70(如随机存取存储器)用来暂存中央处理器66操作时必需的程序码及相关数据、资料。北桥电路68A即用来管理中央处理器66、存储器70及绘图卡72A间的数据传输。通过电连于北桥电路68A的南桥电路68B,主机12就能和各外围装置54、55交换指令、数据;其中南桥电路68B和各外围装置间可以用总线(如IDE、EIDE等总线)相互连接。在外围装置54方面,就如前面讨论过的,为了要控制外围装置54中进行多种操作,也会以一固件程序码来记录各种控制程序实行的方法;图3中存储于存储存储器60中的既有程序码64就是此一固件程序码。控制电路56接收主机52传来的控制指令后,就能执行存储存储器60中的程序码64来控制伺服硬件62,以实现主机52要求的功能。而缓冲存储器58则用来暂存外围装置54操作期间的数据。举例来说,若外围装置54为一光盘刻录机,伺服硬件62会包括有马达、光学读取头等机电元件;主机52要刻录至光盘片上的数据会先暂存于缓冲存储器58中,再由伺服硬件62实际将这些暂存于缓冲存储器58的数据刻录至光盘片上;而伺服硬件62由光盘片上读到的数据,也会暂存于缓冲存储器58中,再由控制电路56安排,将这些数据回传至主机52。Please refer to Figure 3. FIG. 3 is a schematic functional block diagram of the configuration of the electronic system 50 of the present invention. The electronic system 50 is provided with a host 52 and one or more cooperating peripheral devices (two peripheral devices 54 and 55 are represented in FIG. 3 ) to expand the functions of the host 52 itself. The electronic system 50 can be a computer system; in this case, a central processing unit 66, a north bridge circuit 68A, a south bridge circuit 68B, a memory 70, a graphics card 72A and a display 72B can be arranged in the main frame 52; the peripheral devices 54, 55 then It could be a CD drive, CD recorder, hard drive, etc. Take the peripheral device 54 as an example to illustrate the configuration in the peripheral device; the peripheral device 54 is provided with a control circuit 56, a servo hardware 62 for realizing the function of the peripheral device 54, and a buffer for temporarily storing data in a volatile manner A memory 58 (such as a random access memory), and a storage memory 60 (such as a flash memory) for storing data in a non-volatile manner; and a check module 56B in the control circuit 56 . In the host computer 12, the central processing unit 66 is used to control the operation of the host computer 52, and the graphics card 72A can convert the operation status and results of the host computer 52 into image signals and display them on the display 72B. The volatile memory 70 (such as random access memory) is used to temporarily store program codes and related data and materials necessary for the operation of the CPU 66 . The north bridge circuit 68A is used to manage the data transmission between the CPU 66, the memory 70 and the graphics card 72A. Through the south bridge circuit 68B electrically connected to the north bridge circuit 68A, the host computer 12 can exchange instructions and data with each peripheral device 54, 55; wherein the south bridge circuit 68B and each peripheral device can use a bus (such as IDE, EIDE and other buses) interconnected. Regarding the peripheral device 54, as previously discussed, in order to control the peripheral device 54 to carry out various operations, a firmware program code will also be used to record various control program implementation methods; in FIG. 3, it is stored in the storage memory 60 Existing program code 64 in is exactly this firmware program code. After the control circuit 56 receives the control instruction from the host 52 , it can execute the program code 64 stored in the memory 60 to control the servo hardware 62 to realize the functions required by the host 52 . The buffer memory 58 is used to temporarily store data during the operation of the peripheral device 54 . For example, if the peripheral device 54 is an optical disc recorder, the servo hardware 62 will include electromechanical components such as motors and optical pick-up heads; The servo hardware 62 actually writes the data temporarily stored in the buffer memory 58 to the optical disk; and the data read by the servo hardware 62 from the optical disk will also be temporarily stored in the buffer memory 58, and then arranged by the control circuit 56, these The data is sent back to the host 52 .

就如前面所讨论过的,外围装置会有固件更新的需要。请参考图4(并一并参考图3)。图4所示即为本发明于电子系统50中进行固件更新的流程200;于图4图面左方的步骤是在主机52这一端进行,右方的步骤是由外围装置54进行。流程200中设有下列步骤:As discussed earlier, peripheral devices may require firmware updates. Please refer to Figure 4 (and also refer to Figure 3). FIG. 4 shows the process 200 of firmware update in the electronic system 50 according to the present invention; the steps on the left in FIG. 4 are performed by the host 52 , and the steps on the right are performed by the peripheral device 54 . The process 200 has the following steps:

步骤202:开始。当电子系统50要对外围装置54进行固件更新时,主机52中的中央处理器66就会将一固件更新的应用程序74载入至存储器70中(请一并参考图3),并开始执行应用程序74,以启动整个固件更新的流程200,并在后续步骤中持续控制流程200的进行。固件更新的目的,要以一新程序码76,取代外围装置54中既有的固件程序码64。Step 202: start. When the electronic system 50 is to update the firmware of the peripheral device 54, the central processing unit 66 in the host computer 52 will load a firmware update application program 74 into the memory 70 (please refer to FIG. 3 together), and start to execute The application program 74 is used to start the entire firmware update process 200 and continue to control the progress of the process 200 in subsequent steps. The purpose of the firmware update is to replace the existing firmware program code 64 in the peripheral device 54 with a new program code 76 .

步骤204:主机52要求外围装置54进行装置识别。如前所述,各外围装置的固件程序码中,都记录有一固件识别码,记录固件研发厂商的名称(vendorID),以及该固件程序码适用的外围装置的型号名称(model name)。就如图3中所示,外围装置54在固件更新前的既有程序码64,也记录有对应程序码64的固件识别码64I。在进行装置识别时,主机52即可发出控制指令,要求外围装置54回传固件识别码64I的相关数据,以确认应用程序74是和外围装置54搭配的正确程序,能在后续步骤中正确地和外围装置54配合以进行固件更新。Step 204: The host 52 requests the peripheral device 54 to perform device identification. As mentioned above, a firmware identification code is recorded in the firmware code of each peripheral device, which records the name (vendorID) of the firmware developer and the model name (model name) of the peripheral device to which the firmware code is applicable. As shown in FIG. 3 , the existing program code 64 of the peripheral device 54 before the firmware update also records the firmware identification code 64I corresponding to the program code 64 . When performing device identification, the host computer 52 can issue a control command to require the peripheral device 54 to return the relevant data of the firmware identification code 64I to confirm that the application program 74 is the correct program for matching with the peripheral device 54, and can be correctly identified in subsequent steps. Cooperate with peripheral device 54 for firmware update.

步骤206:外围装置54中的控制电路56接收到主机52于步骤204中传来的控制指令后,就会将固件程序码64中与固件识别码64I相关的数据回传至主机52。Step 206 : After the control circuit 56 in the peripheral device 54 receives the control command from the host 52 in step 204 , it will return the data related to the firmware identification code 64I in the firmware code 64 to the host 52 .

步骤208:主机52根据外围装置54回传的固件识别码64I数据(或其他主机52要求的识别数据),就可以判断应用程序74能否配合外围装置54的固件更新。若主机52确认应用程序74的确能和外围装置54搭配,主机52就会继续执行应用程序74,以进行外围装置54固件更新的后续步骤。在此同时,中央处理器66也可将固件更新用的新程序码76载入至存储器70中(就如图3中所示)。在实施装置识别的过程中,主机52、外围装置54可能会进行数次的数据交换;在不影响本发明技术公开的情形下,图4中已适当地省略了装置识别的细节。Step 208 : The host 52 can determine whether the application program 74 can cooperate with the firmware update of the peripheral device 54 according to the firmware identification code 64I data sent back by the peripheral device 54 (or other identification data required by the host 52 ). If the host 52 confirms that the application program 74 can indeed be matched with the peripheral device 54 , the host computer 52 will continue to execute the application program 74 to perform subsequent steps of updating the firmware of the peripheral device 54 . At the same time, the CPU 66 can also load the new program code 76 for firmware update into the memory 70 (as shown in FIG. 3 ). During the process of device identification, the host 52 and the peripheral device 54 may exchange data several times; without affecting the technical disclosure of the present invention, the details of device identification have been appropriately omitted in FIG. 4 .

除了进行装置识别之外,为了进一步确认新程序码76的内容为适合外围装置54应用的固件程序码,本发明还会额外进行一主机端检查步骤,以依据新程序码76的内容,判断新程序码76是否为适用的固件程序码。主机端检查步骤进行的方式可有数种实施例。举例来说,新程序码76既然为一固件程序码,其中当然也记载了一固件识别码76I(请一并参考图3),就像外围装置54中的既有程序码64也有一对应的固件识别码64I。而在此主机端检查步骤中,主机12就能检查新程序码76中的固件识别码76I是否和既有程序码64中的固件识别码64I相符,以验证新程序码76是否和外围装置54中既有的程序码64一样由同一固件研发厂商所研发,或是适用于相同型号的外围装置。另外,固件研发厂商也能事先在固件程序码中的固定地址记录预设的控制指令或字串、数据,形成一预设内容80(见图3);等主机52进行主机端检查步骤时,就能检查新程序码76在该固定地址中是否具有预设内容80(如图3所示意的),以判断新程序码76的适用性。或者,主机52也可搜寻新程序码76中具有预设内容的部分,再检查该部分的地址是否在固件研发厂商预设的地址,以判断新程序码76的适用性。主机端检查步骤进行的各种方式及原理,会在稍后更进一步讨论。In addition to device identification, in order to further confirm that the content of the new program code 76 is a firmware program code suitable for the application of the peripheral device 54, the present invention will additionally perform a host-side checking step to judge the new program code 76 according to the content of the new program code 76. Whether the program code 76 is an applicable firmware program code. The manner in which the host-side checking step is performed can have several embodiments. For example, since the new program code 76 is a firmware program code, it certainly also records a firmware identification code 76I (please also refer to FIG. 3 ), just as the existing program code 64 in the peripheral device 54 also has a corresponding Firmware identification code 64I. In this host-side checking step, the host computer 12 can check whether the firmware identification code 76I in the new program code 76 matches the firmware identification code 64I in the existing program code 64, to verify whether the new program code 76 is consistent with the peripheral device 54 The existing program code 64 is also developed by the same firmware developer, or is applicable to the same type of peripheral device. In addition, the firmware research and development manufacturer can also record preset control instructions or character strings and data at fixed addresses in the firmware program code in advance to form a preset content 80 (see FIG. 3 ); It is possible to check whether the new program code 76 has a preset content 80 (as shown in FIG. 3 ) in the fixed address, so as to judge the applicability of the new program code 76 . Or, the host computer 52 can also search for a part with preset content in the new program code 76, and then check whether the address of this part is in the address preset by the firmware R&D manufacturer, so as to judge the applicability of the new program code 76. The various methods and principles of the host-side check step will be further discussed later.

若进行主机端检查步骤后主机52判断新程序码76为一适用的正确程序码,就能继续固件更新的流程。接下来主机52可发出指令询问外围装置54的状态是否可进行固件更新。If the host 52 judges that the new program code 76 is an applicable correct program code after performing the host-side check step, the firmware update process can continue. Next, the host 52 can issue a command to inquire whether the status of the peripheral device 54 is ready for firmware update.

步骤210:外围装置54回应主机于步骤208中的询问,将外围装置54目前的状态回传至主机52。Step 210 : The peripheral device 54 responds to the query of the host in step 208 , and returns the current status of the peripheral device 54 to the host 52 .

步骤212:主机52接收外围装置54于步骤210中回应的信号;若外围装置54正处于可进行固件更新的状态,主机52就可以开始将已载入至存储器70的新程序码74传输至外围装置54。如同步骤204、206中的装置识别,步骤210、212中对外围装置54的装置状态检查也可能会在主机52、外围装置54间进行数次的数据往来传输;在不影响本发明技术公开的情况下,图4中已适当地简化相关细节。就如图3中所示意的,在主机52要将新程序码76传输至外围装置54之前,也会以一预设的检查码产生演算法,根据新程序码76的内容计算出一检查码76C,并将其附加于检查码76,连同检查码76一起传输至外围装置54。Step 212: The host 52 receives the signal that the peripheral device 54 responds in step 210; if the peripheral device 54 is in a state where the firmware can be updated, the host 52 can start to transmit the new program code 74 loaded into the memory 70 to the peripheral device 54. Like the device identification in steps 204 and 206, the device status inspection of the peripheral device 54 in steps 210 and 212 may also carry out several data transfers between the host computer 52 and the peripheral device 54; without affecting the technical disclosure of the present invention case, the relevant details have been appropriately simplified in Figure 4. As shown in FIG. 3, before the host computer 52 transmits the new program code 76 to the peripheral device 54, a preset check code generation algorithm is used to calculate a check code based on the content of the new program code 76. 76C, append it to the checksum 76, and transmit it to the peripheral device 54 together with the checksum 76.

步骤214:外围装置54接收主机52传来的新程序码及附加的检查码,并将其暂存于缓冲存储器58中,也就是图3中所示的新程序码77及检查码77C。步骤216:外围装置54的控制电路56会利用检查码产生演算法,根据新程序码77的内容计算出一检查码79C(见图3),并验证检查码79C与外围装置54由主机52处接收到的检查码77C是否相同。若两者相同,代表主机52在将新程序码传输至外围装置54的过程中没有发生数据传输错误。Step 214: The peripheral device 54 receives the new program code and the additional check code from the host 52, and temporarily stores them in the buffer memory 58, that is, the new program code 77 and the check code 77C shown in FIG. 3 . Step 216: the control circuit 56 of the peripheral device 54 will use the check code generation algorithm to calculate a check code 79C (see FIG. 3 ) according to the content of the new program code 77, and verify the check code 79C and the peripheral device 54 by the host computer 52. Whether the received check code 77C is the same. If the two are the same, it means that the host 52 has no data transmission error during the process of transmitting the new program code to the peripheral device 54 .

在确定固件更新用的新程序码已经完整地由主机52传输至外围装置54后,本发明还会在外围装置54中另外进行一装置端检查步骤,由控制电路56实现检查模块56B的功能,以检查暂存于缓冲存储器58中的新程序码77是否为适用的固件程序码。举例来说,控制电路56可比较暂存于缓冲存储器58中的新程序码77是否和存储存储器60中的既有程序码64具有相同的固件识别码。由于新程序码77是由主机52传输过去的,在数据传输无误的情形下,新程序码77也具有和固件识别码76I相同的固件识别码77I;控制电路56比较固件识别码77I和既有固件程序码64的固件程序码64I是否相符,就能判断新程序码77是否为适用于外围装置54的固件程序码。类似于主机端检查步骤,于外围装置58中进行的装置端检查步骤也可以检查新程序码77中位于特定的预设地址的部分内容是否符合一预定内容82(如图3中所示意的);或是在新程序码77中搜寻某些预设内容是否存在,或是否位于某些特定地址。至于本发明装置端检查步骤进行的细节、原理,将在后面做进一步的说明。After confirming that the new program code used for firmware update has been completely transmitted from the host computer 52 to the peripheral device 54, the present invention also performs a device-side inspection step in the peripheral device 54, and the control circuit 56 realizes the function of the inspection module 56B. To check whether the new program code 77 temporarily stored in the buffer memory 58 is an applicable firmware program code. For example, the control circuit 56 can compare whether the new program code 77 temporarily stored in the buffer memory 58 has the same firmware identification code as the existing program code 64 in the storage memory 60 . Because the new program code 77 was transmitted by the host computer 52, under the situation that the data transmission is correct, the new program code 77 also has the same firmware identification code 77I as the firmware identification code 76I; the control circuit 56 compares the firmware identification code 77I with the existing Whether the firmware program code 64I of the firmware program code 64 is consistent can determine whether the new program code 77 is a firmware program code suitable for the peripheral device 54 . Similar to the host-side check step, the device-side check step carried out in the peripheral device 58 can also check whether the partial content at a specific preset address in the new program code 77 conforms to a predetermined content 82 (as shown in FIG. 3 ) ; Or search whether some default content exists in the new program code 77, or whether it is located at some specific addresses. As for the details and principles of the inspection step at the device end of the present invention, further description will be made later.

当然,若在进行本发明装置端检查步骤前,控制电路56发现检查码77C与控制电路56计算出来的检查码79C不符合,代表新程序码再由主机52传输至外围装置54的过程中发生数据传输的错误。此时控制电路56可将错误的情形回传至主机52,或要求主机52重新传输新程序码,直到新程序码被完整的传输至外围装置54,再进行本发明的装置端检查步骤。Of course, if the control circuit 56 finds that the check code 77C does not match the check code 79C calculated by the control circuit 56 before performing the device-side check step of the present invention, it means that the new program code is transmitted from the host computer 52 to the peripheral device 54. Error in data transmission. At this time, the control circuit 56 can return the error situation to the host 52, or require the host 52 to retransmit the new program code until the new program code is completely transmitted to the peripheral device 54, and then perform the device-side checking step of the present invention.

步骤218:若控制电路56进行装置端检查步骤后判断新程序码77的确适用于外围装置54,就能进行至步骤220;若否,则进行至步骤222。Step 218 : If the control circuit 56 judges that the new program code 77 is indeed suitable for the peripheral device 54 after performing the device-side checking step, proceed to step 220 ; otherwise, proceed to step 222 .

步骤220:通过了检查码的验证,以及本发明装置端检查步骤的验证,外围装置54一方面能确认本身已正确接收由主机52传来的新程序码77,另一方面也能确认新程序码77为外围装置54适用的固件程序码,此时控制电路56就能将存储存储器60中原先做为固件程序码的程序码64擦除,将新程序码77写入至存储存储器60中,以取代原先的程序码64,完成固件更新。接下来控制电路60就能执行存储存储器60中的新程序码77,以新的控制程序控制外围装置54的操作。当然,在固件更新完成后,外围装置54也能向主机52回报固件更新完成的状况,主机52也可要求外围装置54再度将新固件程序码中固件识别码的相关信息回传,确认固件更新已完成等等。在不影响本发明技术公开的情形下,这部分的细节流程已于图4中省略。Step 220: After passing the verification of the check code and the verification of the device-side inspection step of the present invention, the peripheral device 54 can confirm that it has correctly received the new program code 77 sent by the host 52 on the one hand, and can also confirm the new program on the other hand. The code 77 is the applicable firmware program code for the peripheral device 54. At this time, the control circuit 56 can erase the program code 64 originally used as the firmware program code in the storage memory 60, and write the new program code 77 into the storage memory 60. To replace the original program code 64, complete the firmware update. Then the control circuit 60 can execute the new program code 77 stored in the memory 60 to control the operation of the peripheral device 54 with the new control program. Of course, after the firmware update is completed, the peripheral device 54 can also report the completion of the firmware update to the host computer 52, and the host computer 52 can also request the peripheral device 54 to return the relevant information of the firmware identification code in the new firmware program code again to confirm the firmware update Done etc. In the case of not affecting the technical disclosure of the present invention, the detailed flow of this part has been omitted in FIG. 4 .

步骤222:若在步骤216中进行本发明的装置端检查步骤时,发现新程序码77并非适用的固件程序码,控制电路56就要进行错误处理。控制电路56可将新程序码不适用的情形回传至主机52,由主机52的使用者决定后续的步骤。最重要的是,此时控制电路56不会将不适用的新程序码覆写至存储存储器60,使得控制电路56在后续的过程中不会依据不适用的新程序码来控制外围装置54,而外围装置54的操作也不会因固件更新流程中的不适用固件程序码而受影响。Step 222: If it is found that the new program code 77 is not an applicable firmware program code during the device-side checking step of the present invention in step 216, the control circuit 56 will perform error handling. The control circuit 56 can report back to the host 52 that the new program code is not applicable, and the user of the host 52 decides the next steps. Most importantly, at this time, the control circuit 56 will not overwrite the inapplicable new program code to the storage memory 60, so that the control circuit 56 will not control the peripheral device 54 according to the inapplicable new program code in the subsequent process, And the operation of the peripheral device 54 will not be affected by the unsuitable firmware program code in the firmware update process.

步骤224:结束本发明固件更新的流程。Step 224: End the firmware update process of the present invention.

由以上对本发明固件更新流程的描述可知,本发明的流程200除了在固件更新的过程中进行了装置识别、检查码的确认外,还额外地进行了主机端检查步骤及装置端检查步骤。前者能在主机52在将固件更新的新程序码76传输至外围装置54之前,先检查新程序码76是否为适用于外围装置54的固件程序码。在将新程序码76顺利传输至外围装置54而成为新程序码77后,外围装置54还会进行一装置端检查步骤,以便在将程序码77实际写入至存储存储器60之前,检查程序码77是否适用于外围装置54。经由本发明主机/装置端检查步骤的实施,将可更进一步地确认固件更新流程不会误将不适用的固件程序码植入至外围装置。至于本发明主机/装置端检查步骤进行的方式,可以有数种实施例,以下将一一讨论。As can be seen from the above description of the firmware update process of the present invention, the process 200 of the present invention not only performs device identification and check code confirmation during the firmware update process, but also additionally performs host-side checking steps and device-side checking steps. The former can first check whether the new program code 76 is a firmware program code suitable for the peripheral device 54 before the host computer 52 transmits the new program code 76 for firmware update to the peripheral device 54 . After the new program code 76 is successfully transmitted to the peripheral device 54 to become the new program code 77, the peripheral device 54 also performs a device-side inspection step, so that the program code is checked before the program code 77 is actually written into the storage memory 60. 77 is applicable to the peripheral device 54. Through the implementation of the checking steps at the host/device side of the present invention, it will be further confirmed that the firmware update process will not mistakenly implant inapplicable firmware program codes into the peripheral device. As for the manner in which the checking step of the host/device side is performed in the present invention, there may be several embodiments, which will be discussed one by one below.

首先,请参考图5A(并一并参考图3)。图5A为本发明中主机/装置端检查步骤进行方式实施例之一的示意图。如同前面所提过的,固件研发厂商在固件程序码中都定义了一些关于固件本身的数据,如固件研发厂商的名称(vendor ID),该固件程序码适用的外围装置的型号名称(model name),甚至于有序号(serial number)或者是版本信息,形成一固件辨识码。即使在不同版本的固件程序码中,也都会统一记载有这些信息。如图5A所示,不论是外围装置54在固件更新前既有的固件程序码64,或者是固件更新所使用的新程序码76(或者是新程序码77),只要是共同适用于外围装置54的固件程序码,就应该具有相同形式的固件识别码。一般来说,在固件程序码中,固件识别码的相关信号是记录于固件程序码中的一段常数(constant)中。如本领域技术人员所知,固件研发厂商都是以较高层的程序语言来将外围装置的各种控制程序编写至一源码(source code)中,再经由一编译器(complier)软件的编译(compile)后,成为外围装置中控制电路可执行的二进位码的固件程序码。固件研发厂商通常在固件程序码的源码中以一常数阵列(array)_pbTBL Inquiry[]来编译该固件识别码内容,该内容可以直接以数值表示,例如0x05,或者以字元(character)编辑,例如‘A’表示本领域技术人员所知的ASCII码,经编译器编译成为外围装置中控制电路可执行的二进位码的固件程序码后,以一对应的二进位码常数存在于该固件程序码中。故在固件程序码中,一定有部分内容是用来定义此一常数的内容值。举例来说,如图5A所示,在既有程序码64的固件识别码64I中,其部分内容就是以二进位码方式来将常数-pbTBL Inquiry的值定义为{0x05,0x80,…,‘A’,‘b’,…,‘d’,‘M’,…,‘k’,‘m’,…,…},其中“Abcdefgh”就代表固件研发厂商的名称,“Modelikmh”就代表型号名称,其他数据则可用来代表固件版本等其他数据。同理,固件更新所用的新程序码76若为适用的固件程序码,其中一定也有一固件识别码76I,同样地用来定义常数_pbTBL Inquiry[]的值。当要进行本发明的主机端检查步骤时,主机52就可执行固件更新的应用程序74(如图3)而搜寻新程序码76,以检查新程序码76中是否有部分内容是用来定义常数_pbTBLInquiry的,而此常数又被定义为特定的值。同时,主机52也可以要求外围装置54回传既有程序码64中其常数_pbTBL Inquiry的值。当然,若新程序码76中根本没有定义此一常数,代表其一定不是正常的固件程序码。若新程序码76中的确有定义此常数,且新程序码76中此常数的值与既有程序码64中定义的值相符(如固件研发厂商的名称相同,型号名称相同),主机52就可在主机端检查步骤中判断新程序码76为适用的固件程序码。另外,在主机端检查步骤中,主机52也可更进一步地根据新程序码76中的版本信息来判断新程序码76(相对于既有程序码64)是不是较新版本的固件;若新程序码76版本反而较旧,主机52也可判断新程序码76为不适用的固件程序码。进一步推广此种比较的概念,本发明也可检查新程序码中某常数的值是否在某预设值的特定范围内。如在上述的例子中,就是检查新程序码中记录的版本是否大于既有程序码的版本。First, please refer to FIG. 5A (and refer to FIG. 3 together). FIG. 5A is a schematic diagram of one embodiment of the host/device checking step in the present invention. As mentioned above, firmware developers define some data about the firmware itself in the firmware program code, such as the name of the firmware developer (vendor ID), the model name of the peripheral device (model name) to which the firmware program code is applicable. ), or even serial number (serial number) or version information, form a firmware identification code. Even in different versions of firmware program codes, these information will be uniformly recorded. As shown in FIG. 5A, whether it is the existing firmware program code 64 of the peripheral device 54 before the firmware update, or the new program code 76 (or new program code 77) used for the firmware update, as long as it is commonly applicable to the peripheral device 54 firmware code, it should have the same form of firmware identification code. Generally speaking, in the firmware program code, the relevant signal of the firmware identification code is recorded in a section of constant (constant) in the firmware program code. As known to those skilled in the art, firmware developers use a higher-level programming language to write various control programs for peripheral devices into a source code, and then compile through a compiler (complier) software ( After compile), it becomes the firmware program code of binary code executable by the control circuit in the peripheral device. Firmware R&D manufacturers usually use a constant array (array)_pbTBL Inquiry[] in the source code of the firmware program code to compile the content of the firmware identification code. The content can be directly expressed in numerical values, such as 0x05, or edited in characters. For example, 'A' represents the ASCII code known to those skilled in the art. After being compiled by a compiler into a binary code firmware program code executable by the control circuit in the peripheral device, a corresponding binary code constant exists in the firmware program. code. Therefore, in the firmware program code, some content must be used to define the content value of this constant. For example, as shown in FIG. 5A, in the firmware identification code 64I of the existing program code 64, part of the content is to define the value of the constant -pbTBL Inquiry as {0x05, 0x80, ...,' in binary code mode. A', 'b', ..., 'd', 'M', ..., 'k', 'm', ..., ...}, where "Abcdefgh" represents the name of the firmware developer, and "Modelikmh" represents the model name, other data can be used to represent other data such as firmware version. Similarly, if the new program code 76 used for firmware update is an applicable firmware program code, there must also be a firmware identification code 761, which is also used to define the value of the constant _pbTBL Inquiry[]. When carrying out the host-side inspection step of the present invention, the host computer 52 can execute the application program 74 (as shown in FIG. 3 ) for updating the firmware and search for the new program code 76 to check whether some content in the new program code 76 is used to define The constant _pbTBLInquiry, and this constant is defined as a specific value. At the same time, the host 52 may also request the peripheral device 54 to return the value of the constant _pbTBL Inquiry in the existing program code 64 . Of course, if this constant is not defined at all in the new program code 76, it must not be a normal firmware program code. If this constant is indeed defined in the new program code 76, and the value of this constant in the new program code 76 matches the value defined in the existing program code 64 (as the name of the firmware research and development manufacturer is the same, the model name is the same), the host computer 52 will The new program code 76 can be determined as applicable firmware program code in the host-side checking step. In addition, in the host-side check step, the host 52 can further judge whether the new program code 76 (relative to the existing program code 64) is a newer version of firmware according to the version information in the new program code 76; The version of the program code 76 is rather old, and the host computer 52 can also determine that the new program code 76 is an inapplicable firmware program code. To further extend the concept of this comparison, the present invention can also check whether the value of a certain constant in the new program code is within a specific range of a preset value. As in the above example, it is to check whether the version recorded in the new program code is greater than the version of the existing program code.

除了将新程序码76中的固件识别码76I和既有程序码64中的固件识别码64I比较以进行主机端检查步骤外,固件研发厂商也可在释出固件更新所用的应用程序74时,直接在应用程序74中记录常数_pbTBL Inquiry应有的格式及值(或是其值的合理范围);当主机52执行应用程序74而进行主机端检查步骤时,就可以依据应用程序74中对常数_pbTBL Inquiry的要求,直接判断新程序码76是否为适用的固件程序码,不必依据固件识别码64I中的信息为比较的基准。依据上述的道理,外围装置54中的控制电路56也可在进行装置端检查步骤时,利用既有程序码64中对常数_pbTBL Inquiry的定义,检查暂存于缓冲存储器58中的新程序码77是否为适用的固件程序码。同理,在外围装置54出厂时,固件制造厂商也可在控制电路56中预先设定常数_pbTBL Inquiry应有的标准格式、内容值或内容值的合理范围(如版本编号应大于某一预设值),日后当控制电路56进行装置端检查步骤时,就可以独立判断新程序码77是否具有正确的_pbTBL Inquiry常数定义。在现行的信息业界中,在固件程序码中加入固件识别码已经是一种标准的作法,而本发明也可方便地直接利用固件识别码来判断固件更新用的新固件程序码是否适用。In addition to comparing the firmware identification code 76I in the new program code 76 with the firmware identification code 64I in the existing program code 64 to perform the host-side checking step, the firmware developer can also release the application program 74 used for firmware update, Directly record the due format and value (or the reasonable range of its value) of constant _pbTBL Inquiry in the application program 74; The requirement of the constant _pbTBL Inquiry directly judges whether the new program code 76 is an applicable firmware program code, and does not need to be a benchmark for comparison based on the information in the firmware identification code 64I. According to the above reason, the control circuit 56 in the peripheral device 54 can also use the definition of the constant _pbTBL Inquiry in the existing program code 64 to check the new program code temporarily stored in the buffer memory 58 when performing the device-side inspection step. Whether 77 is applicable firmware code. In the same way, when the peripheral device 54 leaves the factory, the firmware manufacturer can also pre-set the standard format, content value or reasonable range of the content value of the constant _pbTBL Inquiry in the control circuit 56 (such as the version number should be greater than a certain preset value). Setting value), when the control circuit 56 performs the device-side inspection step in the future, it can independently judge whether the new program code 77 has the correct _pbTBL Inquiry constant definition. In the current information industry, it is a standard practice to add a firmware identification code into the firmware program code, and the present invention can also conveniently directly use the firmware identification code to judge whether the new firmware program code used for firmware update is applicable.

请继续参考图5B(及图3)。图5B为本发明中主机/装置端检查步骤进行方式另一实施例的示意图。除了利用固件程序码中普遍已定义的固件识别码来判断固件程序码的适用性外,固件研发厂商也可在固件程序码中预先插入特别定义的字串、数据,做为日后识别固件程序码适用性的依据。如本领域技术人员所知,固件研发厂商都是以较高层的程序语言来将外围装置的各种控制程序编写至一源码(source code)中,再经由一编译器(complier)软件的编译(compile)后,成为外围装置中控制电路可执行的二进位码的固件程序码。固件研发厂商可在固件程序码的源码中以一常数阵列(array)来编译一特别定义的字串、数据,该内容可以直接以数值表示,例如0x06,或者以字元(character)编辑,例如‘A’表示本领域技术人员所知的ASCII码,经编译器编译成为外围装置中控制电路可执行的二进位码的固件程序码后,以一对应的二进位码常数存在于该固件程序码中。如图5B的实施例所示意的,固件研发厂商可在固件程序码的源码86中额外加入程序片段90A、90B,以分别定义出一字串_pbSpecString(其内容为‘M’,‘e’,‘d’,‘i’,‘a’,‘t’,‘e’,‘k’)以及一常数_pbSpecValue。请注意,程序片段90B中不仅定义了常数-pbSpecValue的值,还以指令“_at_0xFFE0”定义了该常数值应存在一特定地址0xFFE0(也就是十六进位的地址FFE0)。根据此指令,编译器就会在编译过程中将此常数值置于该特定地址。等到源码86被编译为二进位码的固件程序码88后,对应于源码86中的程序片段90A,固件程序码88中必定有部分内容92A是以二进位码来记录常数-pbSpecString的定义值;对应于程序片段90B,由固件程序码88的地址0xFFE0处开始,也有部分内容92B是以二进位码记录常数_pbSpecValue的定义值。固件程序码88释出后,也就成为固件更新用的新程序码(如图3中的新程序码76)。利用新程序码中特别定义的字串、常数,就可以实施本发明中的主机/装置端检查步骤。举例来说,主机52、控制电路56在进行主机、装置端检查步骤时,可分别检查新程序码76、77中是否记录有“Mediatek”这个字串以定义字串_pbSpecString。因为固件研发厂商释出的适用新程序码必定有部分内容是用来记录“Mediatek”以定义字串_pbSpecString,若在主机/装置端检查步骤中发现新程序码并没有记录“Mediatek”,就代表该新程序码为不适用的程序码。同理,主机52、控制电路56也可在主机/装置端检查步骤中检查新程序码是否在地址0xFFE0处存有常数_pbSpecValue正确的定义值。若新程序码中在地址0xFFE0记录的不是常数_pbSpecValue的正确定义值,就代表新程序并非适用的固件程序码。或者,也可在进行主机/装置端检查步骤时,检查常数_pbSpecValue的定义值是否存在新程序码特定地址0xFFE0处。当然,要以上述方式来实施本发明主机/装置端检查步骤时,固件制造厂商在外围装置54出厂前,就要预先设定控制电路56(图3),以使控制电路56在日后进行装置端检查步骤时,能知道要比较的目标(也就是图3中的预设内容82;如要在新程序码中寻找“Mediatek”,或是在新程序码的那个特定地址应该存有哪些特定值)。同理,固件制造厂商也要在释出固件更新的应用程序74前,预先在应用程序74中记录主机端装置检查步骤要比较的目标,让主机52能在执行应用程序74后依照上述的比较原理进行主机端检查步骤。Please continue to refer to FIG. 5B (and FIG. 3 ). FIG. 5B is a schematic diagram of another embodiment of the host/device checking step in the present invention. In addition to using the commonly defined firmware identification codes in firmware codes to judge the applicability of firmware codes, firmware developers can also pre-insert specially defined strings and data in firmware codes to identify firmware codes in the future. Basis for Applicability. As known to those skilled in the art, firmware developers use a higher-level programming language to write various control programs for peripheral devices into a source code, and then compile through a compiler (complier) software ( After compile), it becomes the firmware program code of binary code executable by the control circuit in the peripheral device. Firmware R & D manufacturers can compile a specially defined string and data in the source code of the firmware program code with a constant array (array), and the content can be directly represented by a numerical value, such as 0x06, or edited by a character (character), such as 'A' represents the ASCII code known to those skilled in the art. After being compiled by the compiler into the executable binary code of the firmware program code of the control circuit in the peripheral device, a corresponding binary code constant exists in the firmware program code middle. As shown in the embodiment of FIG. 5B , the firmware R&D manufacturer can add additional program segments 90A and 90B to the source code 86 of the firmware program code to define a string _pbSpecString (the content of which is 'M', 'e') respectively. , 'd', 'i', 'a', 't', 'e', 'k') and a constant _pbSpecValue. Please note that the program fragment 90B not only defines the value of the constant -pbSpecValue, but also defines that the constant value should be stored in a specific address 0xFFE0 (that is, the address FFE0 in hexadecimal) by the instruction "_at_0xFFE0". According to this instruction, the compiler will place this constant value at that specific address during compilation. After the source code 86 is compiled into the firmware program code 88 of the binary code, corresponding to the program segment 90A in the source code 86, there must be a part of the content 92A in the firmware program code 88 to record the defined value of the constant -pbSpecString in binary code; Corresponding to the program segment 90B, starting from the address 0xFFE0 of the firmware program code 88, there is also a part of the content 92B that records the defined value of the constant _pbSpecValue in binary code. After the firmware program code 88 is released, it becomes a new program code for firmware update (as shown in the new program code 76 in Figure 3). By using the specially defined character strings and constants in the new program code, the host/device side checking steps in the present invention can be implemented. For example, when the host 52 and the control circuit 56 are performing the checking steps of the host and the device, they can respectively check whether the string "Mediatek" is recorded in the new program code 76, 77 to define the string _pbSpecString. Because the applicable new program code released by the firmware developer must have part of the content used to record "Mediatek" to define the string _pbSpecString, if it is found that the new program code does not record "Mediatek" during the host/device side inspection steps, it will be Indicates that the new program code is an inapplicable program code. Similarly, the host 52 and the control circuit 56 can also check whether the new program code has a correct defined value of the constant _pbSpecValue at the address 0xFFE0 in the host/device checking step. If the address 0xFFE0 recorded in the new program code is not the correct defined value of the constant _pbSpecValue, it means that the new program is not applicable firmware program code. Alternatively, when performing the host/device side check step, check whether the defined value of the constant _pbSpecValue exists at the specific address 0xFFE0 of the new program code. Of course, when implementing the host/device inspection steps of the present invention in the above-mentioned manner, the firmware manufacturer will pre-set the control circuit 56 ( FIG. 3 ) before the peripheral device 54 leaves the factory, so that the control circuit 56 will be installed in the future. During the terminal inspection step, the target (that is, the preset content 82 in Fig. 3 ) can be known to be compared; if "Mediatek" is to be searched in the new program code, or which specific addresses should be stored at that specific address of the new program code value). Similarly, before the firmware update application 74 is released, the firmware manufacturer should pre-record in the application 74 the targets to be compared in the host-side device inspection step, so that the host 52 can follow the above-mentioned comparison after executing the application 74. The principle is to perform the host-side check step.

请参考图5C。图5C为本发明主机/装置端检查步骤进行方式另一实施例的示意图。除了上述以固件程序码中特别定义的常数、定值字串来进行本发明的检查步骤外,也可以根据固件程序码中特定的指令来进行本发明的检查步骤。如图5C所示,固件研发厂商在编写固件程序码的源码86时,可加入程序片段90C,以“CSEG AT FF80H”的指令将一段预设的指令码94编译至地址FF80H(也就是十六进位的地址FF80)。指令码94中定义的可以是有意义、有实际用途的控制程序,或是一些并无实际用途的冗余操作(如将两变数的值交换后再换回来)。图5C中示意的指令码94,其第一行“MOV DRTP,#0800H”即用来让一指针(pointer)DRTP指出缓冲存储器中的一个地址0800H(十六进位的地址0800);第二行“MOVX A,@DRTP”则将一暂存器A中存储的值移到指针DRTP指向的地址,等等。在将源码86编译为固件程序码88后,根据程序片段90C所指定的地址FF80H,固件程序码88就会在起始于地址FF80H的部分内容92C中,以二进位码的形式来记录指令码94。将固件程序码88释出为固件更新所用的新程序码后,就可依据新程序码是否在地址FF80H有对应指令码94的部分内容92C(或是搜寻部分内容92C是否起始于地址FF80H),来进行本发明的主机/装置端检查步骤,以判断新程序码是否为固件研发厂商所释出的适用固件程序码。类似于图5B中实施例的情况,应用程序74、控制电路56也要在事先设定好要比较的目标(如指定地址、指令码94对应的二进位码为何),方便日后进行主机/装置端检查步骤时,做为检查进行的依据。Please refer to Figure 5C. FIG. 5C is a schematic diagram of another embodiment of the host/device checking step of the present invention. In addition to performing the checking steps of the present invention with the above-mentioned constants and fixed-value strings specifically defined in the firmware program code, the checking steps of the present invention can also be performed according to specific instructions in the firmware program code. As shown in FIG. 5C, when the firmware R&D manufacturer writes the source code 86 of the firmware program code, he can add a program segment 90C, and compile a section of preset command code 94 to address FF80H (that is, sixteen carry address FF80). What is defined in the instruction code 94 can be a meaningful and practical control program, or some redundant operations that have no practical use (such as exchanging the values of two variables and then returning them). Instruction code 94 shown in Fig. 5C, its first row " MOV DRTP, #0800H " promptly is used for allowing a pointer (pointer) DRTP to point out an address 0800H (hexadecimal address 0800) in the buffer memory; The second row "MOVX A, @DRTP" moves the value stored in a temporary register A to the address pointed to by the pointer DRTP, and so on. After the source code 86 is compiled into the firmware program code 88, according to the address FF80H specified by the program segment 90C, the firmware program code 88 will record the command code in the form of binary code in the part of the content 92C starting from the address FF80H 94. After the firmware program code 88 is released as the new program code used for firmware update, it can be based on whether the new program code has a part of the content 92C corresponding to the instruction code 94 at the address FF80H (or whether the search part of the content 92C starts at the address FF80H) , to perform the checking step of the host/device side of the present invention to determine whether the new program code is the applicable firmware program code released by the firmware research and development manufacturer. Similar to the situation of the embodiment in Fig. 5B, the application program 74 and the control circuit 56 should also set the target to be compared in advance (such as the specified address, what is the binary code corresponding to the instruction code 94), so as to facilitate future host/device It is used as the basis for inspection during the terminal inspection step.

请参考图5D。图5D为本发明主机/装置端检查步骤又一实施例的示意图。如图5D所示,固件研发厂商也可在固件程序码的源码86中加入程序片段90D,以便在编译后于固件程序码88中的特定地址加入特定的值。举例来说,图5D中的程序片段90D,指令“CSEG AT 0005H”及下一行的“DBE1H”就是指定要将一位元组的数据(内容为十六进位的E1)记录于固件程序码88中的地址0005H(十六进位的地址0005);指令“CSEG AT FFFEH”及次行的“DB E2H”则将一位元组的值E2记录于地址FFFEH。将源码86编译为固件程序码88后,固件程序码88就会在地址0005H的部分内容92D1处以二进位码记录有十六进位的数值E1,在地址FFFEH的部分内容92D2处记录有十六进位的数值E2。在进行本发明的主机/装置端检查步骤时,即可检查新程序码在特定地址处是否记录有特定的值(如在地址0005H处是否为数值E1),以判断新程序码是否为固件研发厂商释出的适用固件程序码。Please refer to Figure 5D. FIG. 5D is a schematic diagram of another embodiment of the host/device side checking steps of the present invention. As shown in FIG. 5D , the firmware developer can also add a program segment 90D in the source code 86 of the firmware program code, so as to add a specific value to a specific address in the firmware program code 88 after compilation. For example, in the program segment 90D among Fig. 5D, the command "CSEG AT 0005H" and the "DBE1H" of the next line specify that the data of one byte (the content is E1 in hexadecimal) be recorded in the firmware program code 88 The address 0005H in (hexadecimal address 0005); the command "CSEG AT FFFEH" and the next line "DB E2H" will record the value E2 of a byte in the address FFFEH. After the source code 86 is compiled into the firmware program code 88, the firmware program code 88 will record the hexadecimal value E1 in binary code at part of the content 92D1 at address 0005H, and record the hexadecimal value at 92D2 at the address FFFEH The value of E2. When performing the checking step of the host/device side of the present invention, it is possible to check whether the new program code has a specific value recorded at a specific address (such as whether it is a value E1 at the address 0005H), so as to determine whether the new program code is developed by firmware Applicable firmware code released by the manufacturer.

请参考图5E。图5E为本发明主机/装置端检查步骤进行方式另一实施例的示意图。除了在源码中以程序片段插入特定的数据、指令以做为判断新程序码是否适用的依据外,本发明也可在编译后的固件程序码中插入特定的数据,做为检查步骤进行的依据。如图5E所示,一般来说,当固件程序码的源码86经过编译而成为固件程序码88后,固件程序码88除了用来记录指令、数据(如常数值)的部分内容外,还会留下一些未使用区段(unusedsegment)。这些未使用区段会被填入特定的填充数据。像在图5E中,在部分内容92E1到92E4标记为斜线的部分,都记录了有意义的程序、指令所对应的二进位码,所谓的程序码区段(code segment);被填入十六进位“F”的部分,即是所谓的未使用区段,没有用来记录任何程序、指令。像在部分内容92E2、92E3之间,就有未使用区段。另外,由于固件程序码88多半会被编译为固定大小(如512Kbyte)的程序码,以方便记录于外围装置中的存储存储器,故固件程序码88的最后一定会有一些多余、未用来记录任何程序、指令的未使用区段。当外围装置中的控制电路在执行固件程序码时,会在各个程序区段间跳跃地读取指令,不会执行到未使用区段,故本发明也可在固件程序码88中的未使用区段插入特定的数据做为标记,不仅不影响外围装置执行固件程序码的操作,而插入的标记也可当作本发明主机端/装置端检查步骤进行时检查的依据。如图5E所示,在固件程序码88中的未使用区段插入数笔数据95后,就变成了固件程序码89;而固件程序码89也就是固件研发厂商正式释出的新程序码。当要进行本发明的主机/装置端检查步骤时,就可在新程序码的未使用区段中的特定地址搜寻是否有插入的数据,判断新程序码是否适用。类似于本发明于图5B、C、D中的实施例,固件研发厂商也要事先设定固件更新的应用程序74及控制电路56,使主机52、外围装置54在进行检查步骤时,能知道比较的目标,如在未使用区端中的那个地址应该会有什么样的数据。相对于图5E的实施例是将标记的数据插入至未使用区段,在图5A至图5D的实施例中,用来当作主机端/装置端检查步骤进行依据的数据都会位于程序码区段。Please refer to Figure 5E. FIG. 5E is a schematic diagram of another embodiment of the host/device checking step of the present invention. In addition to inserting specific data and instructions into the source code as a basis for judging whether the new program code is applicable, the present invention can also insert specific data into the compiled firmware program code as a basis for checking steps . As shown in Figure 5E, generally speaking, after the source code 86 of firmware program code is compiled and become firmware program code 88, firmware program code 88 will also be left in addition to being used for recording instruction, the part content of data (such as constant value). The next number of unused segments (unusedsegment). These unused segments are filled with specific padding data. As in Fig. 5E, in the parts marked with slashes in some contents 92E1 to 92E4, meaningful programs and binary codes corresponding to instructions are recorded, the so-called program code segment (code segment); The part of the hexadecimal "F" is the so-called unused segment, which is not used to record any programs and instructions. For example, between the partial contents 92E2 and 92E3, there are unused sections. In addition, since the firmware program code 88 will probably be compiled into a program code with a fixed size (such as 512Kbyte) to facilitate recording in the storage memory in the peripheral device, there must be some redundant and unused records at the end of the firmware program code 88 Unused section of any program, instruction. When the control circuit in the peripheral device is executing the firmware program code, it will jump to read instructions between each program section, and will not execute to the unused section, so the present invention can also be used in the unused section of the firmware program code 88. Inserting specific data into the segment as a mark not only does not affect the operation of the peripheral device to execute the firmware program code, but the inserted mark can also be used as the basis for checking during the checking step of the host side/device side of the present invention. As shown in Figure 5E, after inserting several pieces of data 95 in the unused section of the firmware program code 88, it becomes the firmware program code 89; and the firmware program code 89 is the new program code officially released by the firmware developer. . When the checking step of the host/device side of the present invention is to be performed, it is possible to search for inserted data at specific addresses in the unused section of the new program code to determine whether the new program code is applicable. Similar to the embodiment of the present invention in FIG. 5B, C, and D, the firmware R&D manufacturer also needs to set the application program 74 and the control circuit 56 for firmware update in advance, so that the host computer 52 and the peripheral device 54 can know when the checking steps are performed. The target of the comparison, such as what data should be at that address in the end of the unused area. Compared with the embodiment of FIG. 5E , the marked data is inserted into the unused segment. In the embodiments of FIGS. 5A to 5D , the data used as the basis for the host-side/device-side check steps will be located in the program code area. part.

除了上述的方法,本发明主机端/装置端检查步骤尚有以下数种其他的作法。举例来说,在进行检查步骤时,可搜寻新程序码中某一特定的指示数据(如字串、常数)所在的地址,由该地址平移一段预设的平移地址后计算出一新地址,再检查新程序码于该新地址的内容是否符合另一预设内容。换句话说,当固件研发厂商在释出固件程序码时,不但要在程序码中加入指示数据,也要在该指示数据所在地址平移该平移地址的地方,加入该预设内容,以在程序码释出后,配合客户进行主机端/装置端检查步骤。另外,在进行检查步骤时,也可检查新程序码中位于不同预设地址的不同常数在经过预设的运算后,否符合一预设值。举例来说,可检查新程序码中分别位于两不同地址的常数相加后,否为一预定值。在前面曾经提到过,检查步骤可检查固件识别码中固件版本的数值大小做为固件程序码适用于否的依据,不过恶意的破坏者也可能在窜改程序码时,一并窜改固件版本的数值,意图躲过检查步骤的检查而在固件更新过程中将窜改后的固件程序码植入外围装置中。针对这种情形,固件研发厂商就可在真正的新程序码中,于另一预设的地址植入另一检查用常数,而此检查用常数和新程序码的固件版本数值相加后为一预设的定值;换句话说,在更新、固件版本数值更大的程序码中,此检查用常数也随之变小。而当进行主机端/装置端检查步骤时,主机/外围装置除了检查固件版本的数值是否大于既有固件版本的数值外,还可以在预设地址找到此检查用常数,并检查此检查用常数和新程序码中记录的固件程序版本相加的数值是否为预设的定值。这样一来,就能进一步确认固件版本数值本身是否正确。In addition to the above-mentioned methods, there are several other methods in the host-side/device-side checking steps of the present invention as follows. For example, when performing the checking step, it is possible to search for the address of a specific instruction data (such as a character string, a constant) in the new program code, and calculate a new address by shifting a section of the preset shifting address from the address, Then check whether the content of the new program code at the new address matches another preset content. In other words, when the firmware R&D manufacturer releases the firmware program code, it not only needs to add instruction data in the program code, but also adds the preset content at the place where the address of the instruction data is shifted by the translation address, so as to be included in the program code. After the code is released, cooperate with the customer to carry out the host-side/device-side inspection steps. In addition, when performing the checking step, it is also possible to check whether different constants in different preset addresses in the new program code conform to a preset value after undergoing preset calculations. For example, it can be checked whether the addition of the constants respectively located at two different addresses in the new program code is a predetermined value. As mentioned above, the check step can check the value of the firmware version in the firmware identification code as the basis for whether the firmware program code is applicable, but malicious saboteurs may also tamper with the firmware version when tampering with the program code. In order to evade the inspection of the inspection step, the tampered firmware program code is implanted into the peripheral device during the firmware update process. In view of this situation, the firmware R&D manufacturer can embed another checking constant in another preset address in the real new program code, and after adding the checking constant and the firmware version value of the new program code, it becomes A preset fixed value; in other words, in newer, firmware version codes with larger values, this checking constant also becomes smaller. When performing the host-side/device-side checking steps, the host/peripheral device can find the constant for checking at the preset address in addition to checking whether the value of the firmware version is greater than the value of the existing firmware version, and check the constant for checking Whether the value added to the firmware program version recorded in the new program code is a preset value. In this way, it is possible to further confirm whether the firmware version value itself is correct.

由上述讨论延伸,本发明主机端/装置端检查步骤也可以先搜寻两个预设内容的数据分别所在的两个地址,再检查这两个地址之间的程序码是否具有某种预设的特性。举例来说,固件研发厂商在释出适用程序码时,可在两预设内容数据之间记录一连串的数值,而这一连串的数值相加后的值为一定值(或是依据预设的规律递增或递减);或者是两预设内容数据之间的数据在经过一预设的演算法处理后,能得到一预设的标准值。这样一来,当进行主机端/装置端检查步骤时,主机/外围装置就能检查在新程序码中,此两预设内容数据间的数据是否合乎预设的规律,或是否能在以预设演算法处理后得到预设的标准值。在这种作法之下,固件研发厂商可在不同版本的固件程序码中,在两预设内容数据间加入不同的数据,但加入的数据在经过预设演算法后均能得到同一标准值。这样一来,就可避免适用程序码的比较标准暴露于程序码中。因为不同版本的适用程序码中,两预设内容数据间的数据均会相异,即使恶意破坏者分析不同版本的适用程序码,也难以归纳出特定的规律以避开本发明检查步骤的筛检。Extending from the above discussion, the checking step of the host end/device end of the present invention can also first search the two addresses where the data of the two preset contents are respectively located, and then check whether the program code between the two addresses has a certain preset characteristic. For example, when a firmware developer releases the applicable program code, a series of values can be recorded between two preset content data, and the value of this series of values added is a certain value (or according to a preset rule increment or decrement); or the data between two preset content data can obtain a preset standard value after being processed by a preset algorithm. In this way, when performing the check step of the host side/device side, the host computer/peripheral device can check whether the data between the two preset content data in the new program code conforms to the preset law, or whether it can be used in the new program code. It is assumed that the preset standard value is obtained after processing by the algorithm. Under this approach, the firmware developer can add different data between the two preset content data in different versions of the firmware program code, but the added data can get the same standard value after going through the preset algorithm. In this way, the comparison standard of the applicable program code is avoided to be exposed in the program code. Because in different versions of the applicable program code, the data between the two preset content data will be different, even if malicious saboteurs analyze different versions of the applicable program code, it is difficult to summarize specific rules to avoid the screening of the inspection step of the present invention. check.

由以上对本发明主机/装置端检查步骤的讨论可知,本发明是比较新程序码中是否有预设内容的数据(如字串、数据),或是在预设地址中是否有预设内容的数据(或预设数据是否在预设地址),以在固件更新的流程中判断固件更新所用的新程序码是否为适用的程序码。在实施本发明时(尤其是图5B至图5E的实施例),固件研发厂商可先拟定主机/装置端检查步骤进行的总体策略,以在外围装置出厂、释出固件更新的应用程序前,先设定好主机/装置端检查步骤进行时的比较目标,而在日后陆续释出更新用的固件程序码时,也要对应地在固件程序码中加入比较用的数据。这样一来,就能在外围装置要更新固件时,确保固件研发厂商所释出的适用固件程序码能通过主机/装置端检查步骤,而不适用的固件程序码会在检查步骤中被筛检出来,让不适用的固件程序码不会在固件更新流程中被误植入外围装置中。在设定外围装置54的控制电路56的比较目标时,由于控制电路56是依据既有程序码来操作的,所以比较的目标、装置端检查步骤进行的方式,也可以记录于外围装置54预建的固件程序码中。在实施本发明时,图5A至图5E的各种实施方法能单独使用,或是合并多种方法一起实施,而主机端/装置端检查步骤也可使用不同的比较目标。举例来说,主机52可使用图5B中的实施例,检查新程序码中是否有特定字串以实施主机端检查步骤,而控制电路56则能利用图5A中的实施例,以固件识别码来为依据来进行装置端检查步骤,判断新程序码是否合用。当然,在此情况下,适用的固件程序码中不但要有固件识别码以支援图5A中实施例的实施,还要有特定字串以支援图5B中实施例的实施。正由于本发明主机端/装置端检查步骤检查的依据是由固件研发厂商所预设的,故可提供一准确的比较目标,确实地检查出不适用的固件程序码。相较之下,图2中的公知流程100虽会根据固件更新用的新程序码,利用检查码产生演算法算出一检查码,但由于公知流程根本无从得知适用固件程序码对应的检查码,故无法利用检查码检查出不适用的新程序码。From the above discussion of the checking steps of the host/device side of the present invention, it can be seen that the present invention compares whether there is preset content data (such as character string, data) in the new program code, or whether there is preset content in the preset address data (or whether the preset data is at the preset address), so as to determine whether the new program code used for the firmware update is an applicable program code during the firmware update process. When implementing the present invention (especially the embodiment of FIG. 5B to FIG. 5E ), the firmware research and development manufacturer can first draw up the overall strategy for the host/device side inspection step, so that before the peripheral device leaves the factory and releases the application program for firmware update, First set the comparison target when the host/device side checking steps are carried out, and when the firmware program code for updating is released successively in the future, the comparison data should be correspondingly added to the firmware program code. In this way, when the peripheral device needs to update the firmware, it can be ensured that the applicable firmware code released by the firmware developer can pass the host/device side check step, and the unsuitable firmware code will be screened in the check step out, so that inapplicable firmware code will not be mistakenly implanted into the peripheral device during the firmware update process. When setting the comparison target of the control circuit 56 of the peripheral device 54, since the control circuit 56 operates according to the existing program code, the comparison target and the way the device-side inspection steps are carried out can also be recorded in the peripheral device 54 preset. built firmware code. When implementing the present invention, various implementation methods in FIG. 5A to FIG. 5E can be used alone, or multiple methods can be combined for implementation, and the host-side/device-side checking steps can also use different comparison targets. For example, the host 52 can use the embodiment in FIG. 5B to check whether there is a specific character string in the new program code to implement the host-side checking step, and the control circuit 56 can use the embodiment in FIG. 5A to identify the code with the firmware. The device-side inspection step is carried out on the basis to determine whether the new program code is applicable. Of course, in this case, the applicable firmware program code must not only have a firmware identification code to support the implementation of the embodiment in FIG. 5A, but also have a specific character string to support the implementation of the embodiment in FIG. 5B. Just because the checking basis of the checking step of the host end/device end of the present invention is preset by the firmware research and development manufacturer, an accurate comparison target can be provided, and inapplicable firmware program codes can be checked out reliably. In contrast, although the known process 100 in FIG. 2 calculates a checksum using a checksum generation algorithm based on the new program code for firmware update, it is impossible to know the checksum corresponding to the applicable firmware program code due to the known process. , so the inapplicable new program code cannot be checked out by using the check code.

虽然本发明示于图4的流程200在主机、装置端分别进行了主机端、装置端检查步骤,但本发明也可只由主机52进行主机端检查步骤,或是只以外围装置54中的控制电路56进行装置端检查步骤。当进行主机端检查步骤时,也不一定要如图4般在装置状态检查前才进行主机端检查步骤,也可以在应用程序74一载入新程序码后马上进行主机端检查步骤。大致来说,只要在主机52将新程序式76传输至外围装置54前进行主机端检查步骤,即可防止不适用的固件程序码被传输至外围装置54,进一步防止不适用的固件程序码被误植入外围装置中。另一方面,在外围装置54中进行装置端检查步骤,则可发挥最终把关的目的。如前所述,除了使用者误用新程序码外,也可能会有恶意的破坏者会故意以不适用的新程序码,意图瘫痪外围装置54的操作。在实施本发明后,即使不适用的新程序码被传输至外围装置54,在外围装置54中进行的装置端检查步骤,还是能阻挡不适用的新程序码取代既有的固件程序码。至于本发明中,用来进行装置端检查步骤的检查模块56B(见图3)可以是实际的硬件电路,或是由控制电路56本身执行(既有)固件程序码来实现检查模块56B的功能,进行装置端检查步骤。另外,如前所述,有许多独立操作的装置,如手机、数位相机,也都是由控制电路执行固件程序码而操作的。这些装置平常虽独立操作,但要进行固件更新时,多半还是要配合一主机(如以USB连接线连接至个人计算机)才能取得固件更新所用的新程序码,进行固件更新。而本发明当然也可应用于这种情况,保护这些独立操作的装置不会在固件更新的过程中被植入不适用的固件程序码;尤其是在装置中由装置本身自行进行的装置端检查步骤,可主动确保装置本身不会被误植入不适用的固件程序码。Although the process 200 shown in FIG. 4 of the present invention performs the check steps on the host end and the device end respectively at the host end and the device end, the present invention can also only perform the check steps on the host end by the host 52, or only use the peripheral device 54. The control circuit 56 performs a device-side checking step. When performing the host-side check step, it is not necessary to perform the host-side check step before the device status check as shown in FIG. Generally speaking, as long as the host-side check step is performed before the host 52 transmits the new program 76 to the peripheral device 54, it can prevent unsuitable firmware program codes from being transmitted to the peripheral device 54, and further prevent unsuitable firmware program codes from being transmitted to the peripheral device 54. Misplaced in a peripheral device. On the other hand, performing the device-side inspection step in the peripheral device 54 can serve the purpose of final check. As mentioned above, in addition to the misuse of the new program code by the user, there may also be malicious saboteurs who intend to paralyze the operation of the peripheral device 54 with an inapplicable new program code. After implementing the present invention, even if inapplicable new program codes are transmitted to the peripheral device 54, the device-side checking step in the peripheral device 54 can still prevent the inapplicable new program codes from replacing the existing firmware program codes. As for the present invention, the inspection module 56B (see FIG. 3 ) used to perform the device-side inspection step can be an actual hardware circuit, or the (existing) firmware program code executed by the control circuit 56 itself to realize the function of the inspection module 56B , to perform the device-side check step. In addition, as mentioned above, many independently operated devices, such as mobile phones and digital cameras, are also operated by the control circuit executing firmware program codes. Although these devices usually operate independently, when firmware updates are to be performed, most of them still need to cooperate with a host (as connected to a personal computer with a USB cable) to obtain new program codes for firmware updates and perform firmware updates. While the present invention can of course also be applied in this case, protecting these independently operated devices from being implanted with inapplicable firmware code during the firmware update process; especially in device-side checks performed by the device itself Steps that proactively ensure that the device itself is not mistakenly implanted with inappropriate firmware code.

在公知的固件更新流程中,无法针对固件更新所用的新程序码进行内容的检查,故也无法在固件更新的流程中避免不适用的新程序码被错误地植入至外围装置中。相较之下,本发明在固件更新的流程中加入了主机/装置端检查步骤,能依据新程序码的内容判断新程序码是否适用,避免不适用的新程序码被误植入外围装置中。另外,本发明也有助于不同外围装置间固件更新流程的整合。由于本发明可用主机/装置端检查步骤确认固件更新用的新程序码是否适用,就可以在主机端使用单一固件更新的应用程序做为不同外围装置固件更新的接口。在主机进行装置识别时,就可识别出要进行固件更新的外围装置的类别,并由应用程序选择对应该外围装置的主机端检查步骤,确认使用者取得的新程序码是适用的固件程序码;而不同的外围装置已各自内建对应的装置端检查步骤实施方式,可进一步确认主机传来的新程序码为适用的程序码。这样一来,就能使不同外围装置间固件更新的流程得以整合,即使使用同一固件更新的应用程序,还是可管理多种外围装置的固件更新,让使用者进行固件更新时更为简易、方便。In the known firmware update process, the content of the new program code used for the firmware update cannot be checked, so it is also impossible to prevent the inapplicable new program code from being mistakenly implanted into the peripheral device during the firmware update process. In contrast, the present invention adds a host/device-side inspection step in the firmware update process, which can determine whether the new program code is applicable based on the content of the new program code, and prevents the inapplicable new program code from being mistakenly implanted into the peripheral device . In addition, the present invention also facilitates the integration of firmware update procedures among different peripheral devices. Since the present invention can confirm whether the new program code for firmware update is applicable through the host/device side checking step, a single firmware update application program can be used on the host side as an interface for firmware update of different peripheral devices. When the host performs device identification, it can identify the type of peripheral device that needs to be updated with firmware, and the application program selects the host-side check steps corresponding to the peripheral device to confirm that the new program code obtained by the user is the applicable firmware code ; and different peripheral devices have their own built-in corresponding device-side inspection step implementation methods, which can further confirm that the new program code sent by the host is an applicable program code. In this way, the firmware update process between different peripheral devices can be integrated. Even if the same firmware update application is used, the firmware update of multiple peripheral devices can be managed, making it easier and more convenient for users to perform firmware updates. .

以上所述仅为本发明的较佳实施例,凡依本发明权利要求书所做的等效变化与修改,皆应属本发明的涵盖范围。The above descriptions are only preferred embodiments of the present invention, and all equivalent changes and modifications made according to the claims of the present invention shall fall within the scope of the present invention.

Claims (27)

1.一种于一电子系统中更新程序码的方法,其中该电子系统包含有一主机以及一外围装置;1. A method for updating program code in an electronic system, wherein the electronic system includes a host and a peripheral device; 该外围装置包含有:The peripherals include: 一控制电路,用来执行一第一程序码,以根据该主机传来的控制指令控制该外围装置的操作;A control circuit, used to execute a first program code to control the operation of the peripheral device according to the control command sent by the host; 而该方法包含有:And this method contains: 取得一第二程序码;以及obtain a second program code; and 在以该第二程序码取代该外围装置的第一程序码之前,进行一主机端检查步骤,以利用该主机检查该第二程序码的部分内容是否符合一预设内容,如果该第二程序码的部分内容符合一预设内容,则用该第二程序码取代该第一程序码;Before replacing the first program code of the peripheral device with the second program code, a host-side check step is performed to use the host to check whether part of the second program code complies with a preset content, if the second program Part of the content of the code conforms to a preset content, then replace the first program code with the second program code; 其中该预设内容是该第一程序码的部分内容,或是记录于该第一程序码中的一常数;而当进行该主机端检查步骤时,检查该第二程序码中是否具有该第一程序码的部分内容,或检查该第二程序码中记录的常数的值是否相当于该第一程序码中该常数的值,或检查该第二程序码中记录的常数的值是否在该第一程序码中该常数的值的预设范围内。Wherein the preset content is a part of the first program code, or a constant recorded in the first program code; and when performing the checking step at the host end, check whether the second program code contains the first program code Part of a program code, or check whether the value of the constant recorded in the second program code is equivalent to the value of the constant in the first program code, or check whether the value of the constant recorded in the second program code is within the The value of the constant in the first program code is within a preset range. 2.如权利要求1的方法,其中该外围装置另包含有一存储存储器,用来以非易失性的方式存储该第一程序码;而当要以该第二程序码取代该第一程序码时,将该第一程序码由该存储存储器擦除,并将该第二程序码写入至该存储存储器中。2. The method according to claim 1, wherein the peripheral device further comprises a storage memory for storing the first program code in a non-volatile manner; and when the first program code is to be replaced by the second program code When, the first program code is erased from the storage memory, and the second program code is written into the storage memory. 3.如权利要求1的方法,其中当在以一第二程序码取代该第一程序码之前而进行该主机端检查步骤时,在该控制电路执行该第二程序码以控制该外围装置的操作前,进行该主机端检查步骤。3. The method as claimed in claim 1, wherein when performing the host side checking step before replacing the first program code with a second program code, the control circuit executes the second program code to control the peripheral device Before operation, perform this host-side check step. 4.如权利要求1的方法,其中该预设内容是为固定的内容,使得当该第二程序码改变时,该预设内容亦不会改变。4. The method of claim 1, wherein the default content is a fixed content, so that when the second program code changes, the default content will not change. 5.如权利要求1的方法,其中当进行该主机端检查步骤时,由该主机读取该第二程序码中位于预设地址的部分内容,以检查该部分内容是否符合该预设内容,或搜寻该第二程序码中是否存在该预设内容。5. The method according to claim 1, wherein when performing the host-side checking step, the host reads a part of the content at a preset address in the second program code to check whether the part of the content conforms to the preset content, Or search whether the default content exists in the second program code. 6.如权利要求1的方法,其另包含有:6. The method of claim 1, further comprising: 在进行该主机端检查步骤后,若该第二程序码的部分内容不符合该预设内容,则停止以该第二程序码取代该第一程序码。After performing the host-side checking step, if part of the second program code does not conform to the preset content, stop replacing the first program code with the second program code. 7.如权利要求1的方法,其另包含有:7. The method of claim 1, further comprising: 在进行该主机端检查步骤后,若该第二程序码的部分内容符合该预设内容,则以该第二程序码取代该第一程序码,使该控制电路得以执行该第二程序码以控制该外围装置的操作。After performing the checking step on the host side, if part of the content of the second program code matches the preset content, the second program code is used to replace the first program code, so that the control circuit can execute the second program code to achieve Control the operation of the peripheral device. 8.一种于一电子系统中更新程序码的方法,其中该电子系统包含有一主机以及一外围装置;8. A method for updating program code in an electronic system, wherein the electronic system includes a host and a peripheral device; 该外围装置包含有:The peripherals include: 一控制电路,用来执行一第一程序码,以控制该外围装置的操作;a control circuit for executing a first program code to control the operation of the peripheral device; 而该方法包含有:And this method contains: 将一第二程序码由该主机传输至该外围装置;以及transmitting a second program code from the host to the peripheral device; and 在以该第二程序码取代该第一程序码之前,进行一装置端检查步骤,以利用该控制电路检查该第二程序码的部分内容是否符合一预设内容,如果该第二程序码的部分内容符合一预设内容,则用该第二程序码取代该第一程序码;Before replacing the first program code with the second program code, a device-side checking step is performed to use the control circuit to check whether part of the second program code complies with a preset content, if the second program code If part of the content matches a preset content, the first program code is replaced with the second program code; 其中该预设内容是该第一程序码的部分内容,或是记录于该第一程序码中的一常数;而当进行该装置端检查步骤时,检查该第二程序码中是否具有该第一程序码的部分内容,或检查该第二程序码中记录的常数的值是否相当于该第一程序码中该常数的值,或检查该第二程序码中记录的常数的值是否在该第一程序码中该常数的值的预设范围内。Wherein the default content is a part of the first program code, or a constant recorded in the first program code; and when performing the device-side checking step, check whether the second program code has the first program code Part of a program code, or check whether the value of the constant recorded in the second program code is equivalent to the value of the constant in the first program code, or check whether the value of the constant recorded in the second program code is within the The value of the constant in the first program code is within a preset range. 9.如权利要求8的方法,其中该外围装置另包含有一非易失性的存储存储器,用来以非易失性的方式存储该第一程序码;而当要以该第二程序码取代该第一程序码时,将该第一程序码由该存储存储器擦除,并将该第二程序码写入至该存储存储器中。9. The method according to claim 8, wherein the peripheral device further comprises a non-volatile storage memory for storing the first program code in a non-volatile manner; and when the second program code is to be replaced When the first program code is used, the first program code is erased from the storage memory, and the second program code is written into the storage memory. 10.如权利要求8的方法,其中当在以一第二程序码取代该第一程序码之前而进行该装置端检查步骤时,在该控制电路执行该第二程序码以控制该外围装置的操作前,进行该装置端检查步骤。10. The method according to claim 8, wherein when performing the device-side checking step before replacing the first program code with a second program code, the control circuit executes the second program code to control the peripheral device Before operation, perform this device-side inspection procedure. 11.如权利要求8的方法,其中该预设内容是为固定的内容,使得当该第二程序码改变时,该预设内容亦不会改变。11. The method of claim 8, wherein the default content is a fixed content, so that when the second program code changes, the default content will not change. 12.如权利要求8的方法,其中当进行该装置端检查步骤时,由该控制电路读取该第二程序码中位于预设地址的部分内容,以检查该部分内容是否符合一预设内容,或搜寻该第二程序码中是否存在该此预设内容。12. The method as claimed in claim 8, wherein when performing the device-side checking step, the control circuit reads a part of the content at a preset address in the second program code to check whether the part of the content matches a preset content , or search whether the default content exists in the second program code. 13.如权利要求8的方法,其另包含有:13. The method of claim 8, further comprising: 在进行该装置端检查步骤后,若该第二程序码的部分内容不符合该预设内容,则停止以该第二程序码取代该第一程序码。After performing the device-side checking step, if part of the second program code does not conform to the preset content, stop replacing the first program code with the second program code. 14.如权利要求8的方法,其另包含有:14. The method of claim 8, further comprising: 在进行该装置端检查步骤后,若该第二程序码的部分内容符合该预设内容,则以该第二程序码取代该第一程序码,使该控制电路得以执行该第二程序码以控制该外围装置的操作。After performing the device-side checking step, if part of the second program code matches the preset content, the second program code is used to replace the first program code, so that the control circuit can execute the second program code to Control the operation of the peripheral device. 15.如权利要求8的方法,其中该外围装置另包含有一缓冲存储器,用来以易失性的方式存储数据;而当进行该装置端检查步骤时,该控制电路是将该第二程序码暂存于该缓冲存储器中,以读取该第二程序码的部分内容而进行该装置端检查步骤。15. The method as claimed in claim 8, wherein the peripheral device further comprises a buffer memory for storing data in a volatile manner; and when performing the device-side checking step, the control circuit uses the second program code Temporarily stored in the buffer memory to read part of the second program code to perform the device-side checking step. 16.如权利要求15的方法,其中该外围装置另包含有一非易失性的存储存储器,用来以非易失性的方式存储该第一程序码;而当要以该第二程序码取代该第一程序码前而进行该装置端检查步骤时,在该第一程序码尚未被擦除而该第二程序码尚未被写入至该存储存储器前,进行该装置端检查步骤。16. The method according to claim 15, wherein the peripheral device further comprises a non-volatile storage memory for storing the first program code in a non-volatile manner; and when the second program code is to be replaced When the device side checking step is performed before the first program code, the device side checking step is performed before the first program code is erased and before the second program code is written into the storage memory. 17.如权利要求8的方法,其中该外围装置为一光盘机。17. The method of claim 8, wherein the peripheral device is an optical disk drive. 18.一外围装置,其包含有:18. A peripheral device comprising: 一控制电路,用来执行一第一程序码,以控制该外围装置的操作;a control circuit for executing a first program code to control the operation of the peripheral device; 而该控制电路中设有一检查模块,该检查模块可在该控制电路以一第二程序码取代该第一程序码之前,检查该第二程序码的部分内容是否符合一预设内容,如果该第二程序码的部分内容符合一预设内容,则用该第二程序码取代该第一程序码;And the control circuit is provided with a checking module, and the checking module can check whether part of the content of the second program code conforms to a preset content before the control circuit replaces the first program code with a second program code, if the Part of the content of the second program code conforms to a preset content, then the second program code is used to replace the first program code; 其中该预设内容是该第一程序码的部分内容,或是记录于该第一程序码中的一常数;而当该检查模块进行检查时,检查该第二程序码中是否具有该第一程序码的部分内容,或检查该第二程序码中记录的常数的值是否相当于该第一程序码中该常数的值,或检查该第二程序码中记录的常数的值是否在该第一程序码中该常数的值的预设范围内。Wherein the preset content is part of the first program code, or a constant recorded in the first program code; Part of the program code, or check whether the value of the constant recorded in the second program code is equivalent to the value of the constant in the first program code, or check whether the value of the constant recorded in the second program code is within the first program code The value of the constant in a program code is within a preset range. 19.如权利要求18的外围装置,其另包含有一非易失性的存储存储器,用来以非易失性的方式存储该第一程序码;而当该控制电路以该第二程序码取代该第一程序码时,将该第一程序码由该存储存储器擦除,并将该第二程序码写入至该存储存储器中。19. The peripheral device according to claim 18, further comprising a non-volatile storage memory for storing the first program code in a non-volatile manner; and when the control circuit is replaced by the second program code When the first program code is used, the first program code is erased from the storage memory, and the second program code is written into the storage memory. 20.如权利要求18的外围装置,其中当该控制电路以一第二程序码取代该第一程序码之前而由该检查模块进行检查时,在该控制电路执行该第二程序码以控制该外围装置的操作前,由该检查模块进行检查。20. The peripheral device according to claim 18, wherein when the control circuit replaces the first program code with a second program code and is inspected by the checking module, the control circuit executes the second program code to control the Before the operation of the peripheral device, it is checked by the check module. 21.如权利要求18的外围装置,其中该预设内容不会随该第二程序码改变而改变。21. The peripheral device as claimed in claim 18, wherein the preset content will not change when the second program code is changed. 22.如权利要求18的外围装置,其中当该检查模块进行检查时,由该控制电路读取该第二程序码中位于预设地址的部分内容,以便由该检查模块检查该部分内容是否符合一预设内容,或搜寻该第二程序码中是否存在该此预设内容。22. The peripheral device according to claim 18 , wherein when the check module checks, the control circuit reads part of the content at the preset address in the second program code, so that the check module checks whether the part of the content complies with A default content, or search whether the default content exists in the second program code. 23.如权利要求18的外围装置,其中若该检查模块检查出该第二程序码的部分内容不符合该预设内容,则该控制电路会停止以该第二程序码取代该第一程序码。23. The peripheral device according to claim 18, wherein if the check module detects that part of the second program code does not conform to the preset content, the control circuit stops replacing the first program code with the second program code . 24.如权利要求18的外围装置,其中若该检查模块检查出该第二程序码的部分内容符合该预设内容,则该控制电路会以该第二程序码取代该第一程序码,使该控制电路得以执行该第二程序码以控制该外围装置的操作。24. The peripheral device according to claim 18 , wherein if the check module checks that part of the second program code matches the preset content, the control circuit will replace the first program code with the second program code, so that The control circuit can execute the second program code to control the operation of the peripheral device. 25.如权利要求18的外围装置,其另包含有一缓冲存储器,用来以易失性的方式存储数据;而该控制电路是将该第二程序码暂存于该缓冲存储器中,并在读取该第二程序码的部分内容后由该检查模块进行检查。25. The peripheral device as claimed in claim 18, further comprising a buffer memory for storing data in a volatile manner; and the control circuit temporarily stores the second program code in the buffer memory, and reads Part of the content of the second program code is checked by the checking module. 26.如权利要求24的外围装置,其是使用于一电子系统,该电子系统中另设有一主机,而该第二程序码是由该主机传输至该外围装置。26. The peripheral device according to claim 24, which is used in an electronic system, in which a host is further provided, and the second program code is transmitted from the host to the peripheral device. 27.如权利要求24的外围装置,其另包含有一非易失性的存储存储器,用来以非易失性的方式存储该第一程序码;而当该控制电路要以该第二程序码取代该第一程序码前而由该检查模块进行检查时,在该第一程序码尚未被擦除而该第二程序码尚未被写入至该存储存储器前,由该检查模块进行检查。27. The peripheral device as claimed in claim 24, further comprising a non-volatile storage memory for storing the first program code in a non-volatile manner; and when the control circuit needs to use the second program code When the checking module checks before replacing the first program code, the checking module checks before the first program code is erased and the second program code is written into the storage memory.
CNB03106101XA 2003-02-18 2003-02-18 Firmware update method and device for checking program content to ensure compatibility of firmware update Expired - Fee Related CN1317641C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB03106101XA CN1317641C (en) 2003-02-18 2003-02-18 Firmware update method and device for checking program content to ensure compatibility of firmware update

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB03106101XA CN1317641C (en) 2003-02-18 2003-02-18 Firmware update method and device for checking program content to ensure compatibility of firmware update

Publications (2)

Publication Number Publication Date
CN1523501A CN1523501A (en) 2004-08-25
CN1317641C true CN1317641C (en) 2007-05-23

Family

ID=34282678

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB03106101XA Expired - Fee Related CN1317641C (en) 2003-02-18 2003-02-18 Firmware update method and device for checking program content to ensure compatibility of firmware update

Country Status (1)

Country Link
CN (1) CN1317641C (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI571811B (en) * 2015-11-05 2017-02-21 財團法人資訊工業策進會 Variable definition modification device and method for process model integration systems

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100490587C (en) * 2004-06-08 2009-05-20 明基电通股份有限公司 Method for improving mobile phone production flow
CN101634937B (en) * 2008-07-21 2011-10-19 群联电子股份有限公司 Data access method, storage system using the method and its controller
TWI540508B (en) * 2013-11-01 2016-07-01 慧榮科技股份有限公司 Firmware loading system and firmware loading method
CN108364384B (en) * 2018-02-05 2020-12-25 中科富创(北京)科技有限公司 Intelligent express delivery cabinet lock control plate restart verification method, storage device and processing device
CN111766797A (en) * 2019-04-02 2020-10-13 海盗船存储器公司 Microcontroller, memory module and method for updating firmware of microcontroller

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6357021B1 (en) * 1999-04-14 2002-03-12 Mitsumi Electric Co., Ltd. Method and apparatus for updating firmware
JP2003005991A (en) * 2001-06-25 2003-01-10 Toshiba Tec Corp Firmware update system, firmware distribution program and electronic device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6357021B1 (en) * 1999-04-14 2002-03-12 Mitsumi Electric Co., Ltd. Method and apparatus for updating firmware
JP2003005991A (en) * 2001-06-25 2003-01-10 Toshiba Tec Corp Firmware update system, firmware distribution program and electronic device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI571811B (en) * 2015-11-05 2017-02-21 財團法人資訊工業策進會 Variable definition modification device and method for process model integration systems

Also Published As

Publication number Publication date
CN1523501A (en) 2004-08-25

Similar Documents

Publication Publication Date Title
TWI220962B (en) Firmware updating method and related apparatus for checking content of replacing firmware before firmware updating
US7320126B2 (en) Implementation of in system programming to update firmware on memory cards
CN100543667C (en) Disk drive
US8627020B2 (en) Security erase of a delete file and of sectors not currently assigned to a file
CN1318979C (en) How to Update the Firmware of the Optical Disk System
US20110004871A1 (en) Embedded electronic device and firmware updating method thereof
US8601464B2 (en) Memory online update system and method
US20050251799A1 (en) Method of updating firmware
US9836417B2 (en) Bridge configuration in computing devices
CN1469257A (en) Flash memory rewriting control system and rewriting control method
US20060282653A1 (en) Method for updating frimware of memory card
US20060026415A1 (en) Method of updating a portion BIOS
CN118656101A (en) Baseboard management controller firmware upgrade method, device, equipment and medium
CN1317641C (en) Firmware update method and device for checking program content to ensure compatibility of firmware update
CN112115097B (en) Access method and storage device for operation log information
CN114296764A (en) System upgrading method and device, storage medium and electronic equipment
US7788454B2 (en) Controller including electrically rewritable nonvolatile memory
CN1248094C (en) Mouse device capable of storing data
CN101000554B (en) System and method thereof
CN1282922C (en) Method and device for updating firmware using memory card
CN111522568A (en) Method for verifying upgrade file under boot
CN1942865A (en) Restoring the firmware and all programmable content
TWI417888B (en) An embedded chip system, a method for burning a wafer, and a computer program product
CN1272709C (en) Method for updating opcodes stored in portable device memory
JP2002007152A (en) Download method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20070523

Termination date: 20190218

CF01 Termination of patent right due to non-payment of annual fee