[go: up one dir, main page]

CN100378660C - Method for repairing program by detour and electronic device using the same - Google Patents

Method for repairing program by detour and electronic device using the same Download PDF

Info

Publication number
CN100378660C
CN100378660C CNB2004100067667A CN200410006766A CN100378660C CN 100378660 C CN100378660 C CN 100378660C CN B2004100067667 A CNB2004100067667 A CN B2004100067667A CN 200410006766 A CN200410006766 A CN 200410006766A CN 100378660 C CN100378660 C CN 100378660C
Authority
CN
China
Prior art keywords
mentioned
program
exception
instruction
revision
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
CNB2004100067667A
Other languages
Chinese (zh)
Other versions
CN1661548A (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.)
BenQ Corp
Original Assignee
BenQ Corp
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 BenQ Corp filed Critical BenQ Corp
Priority to CNB2004100067667A priority Critical patent/CN100378660C/en
Publication of CN1661548A publication Critical patent/CN1661548A/en
Application granted granted Critical
Publication of CN100378660C publication Critical patent/CN100378660C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

A bypass patching method implemented in a program-driven electronic device having a rewritable memory for storing a program, the program comprising a replaced portion of the program stored in a first area, comprising: obtaining a correction program for replacing the replaced partial program; storing the correction program in a second area of the rewritable memory; changing a beginning instruction of the replaced partial program into an exception generating instruction, so that the replaced partial program generates a program repair exception when being executed; when the program repair exception is received, the correction program is executed.

Description

绕道修补程序的方法及使用该方法的电子装置 Method for bypassing patch and electronic device using the method

技术领域 technical field

本发明涉及修正加载至一程序驱动电子装置的需要修改程序的方法,特别是涉及经由接收程序修补例外来执行上述需要修改程序的修正程序的方法。The present invention relates to a method for modifying a program that needs to be modified loaded into a program-driven electronic device, in particular to a method for executing the above-mentioned modified program that needs to be modified by receiving a program repair exception.

背景技术 Background technique

在一个以内存记录程序,并由此程序驱动的程序驱动电子装置中,当执行于程序驱动电子装置中的程序有错误部分或其中某些部分需要被更新时,通常会以重写的方式将正确或新版的程序加载以取代原来的程序。但是这样的作法需要比较长的时间,而且当原来程序只有一小部分需要修改时,对于整个程序重新安装的作法而言是非常没有效率的。而整个程序更新的程序也会告知使用者请求同意,这对使用者而言也会造成使用上的不便。In a program-driven electronic device that records a program in memory and is driven by this program, when the program executed in the program-driven electronic device has a wrong part or some parts of it need to be updated, it will usually be rewritten. The correct or new version of the program is loaded to replace the original program. But such an approach requires a relatively long time, and when only a small part of the original program needs to be modified, it is very inefficient for the practice of reinstalling the entire program. And the update procedure of the whole program will also inform the user to request consent, which will also cause inconvenience to the user.

在另一种作法上,只针对原来程序中需要修改的部分用更新程序代码覆盖作修改。这种作法中并不是每种情况皆适用的。因为如果储存更新程序代码所需的位大于需要修改的部分就无法直接覆盖上述被取代部分程序。而且移动通讯装置及数字相机在用来储存操作系统的闪存(flash memory)如果需要更新程序,需要以区块(block)为单位作更新。因此并不能单纯地只更新原来程序中需要修改的部分。In another approach, only the part that needs to be modified in the original program is covered with the updated program code for modification. This practice is not applicable in every situation. Because if the required bit for storing the updated program code is greater than the part to be modified, it is impossible to directly cover the above-mentioned replaced part of the program. Moreover, if the flash memory (flash memory) used for storing the operating system of the mobile communication device and the digital camera needs to update the program, it needs to be updated in units of blocks. Therefore, it is not possible to simply update only the parts that need to be modified in the original program.

因此,需要一种更具弹性的修补程序的方法,用以克服上述需要更新整个程序及不能适用每种情况的部分更新的缺点。Therefore, a more flexible patching method is needed to overcome the above-mentioned shortcomings of needing to update the entire program and partial updates that cannot be applied to every situation.

发明内容 Contents of the invention

有鉴于此,本发明的目的在提供一种更具弹性的修补程序的方法,用以克服上述需要更新整个程序及不能适用每种情况的部分更新的缺点。In view of this, the purpose of the present invention is to provide a more flexible method for patching programs to overcome the above-mentioned shortcomings of needing to update the entire program and partial updates that cannot be applied to every situation.

基于上述目的,本发明提供一种绕道修补程序方法,执行于一程序驱动电子装置中,上述程序驱动电子装置具有一可重写内存,用以储存一程序,上述程序包含储存在一第一区域的一被取代部分程序,包括下列步骤:取得一修正程序,用以取代上述被取代部分程序;储存上述修正程序于上述可重写内存的一第二区域;将上述被取代部分程序的一开头指令改成一例外产生指令,使得上述被取代部分程序被执行时产生程序修补例外;当接收上述程序修补例外时,执行上述修正程序。Based on the above purpose, the present invention provides a method for bypassing a repair program, which is executed in a program-driven electronic device. The above-mentioned program-driven electronic device has a rewritable memory for storing a program, and the above-mentioned program includes storage in a first area A replaced part of the program includes the following steps: obtaining a corrected program to replace the replaced part of the program; storing the corrected program in a second area of the rewritable memory; The instruction is changed to an exception generation instruction, so that a program repair exception is generated when the above-mentioned replaced part of the program is executed; when the above-mentioned program repair exception is received, the above-mentioned correction program is executed.

其中,本发明的具有绕道修补程序方法可以利用一程序实现,记录于例如内存或存储装置的储存介质上,当此程序加载至一程序驱动电子装置中,则可执行如上所述绕道修补程序方法。Wherein, the method with a detour patch program of the present invention can be realized by using a program, which is recorded on a storage medium such as a memory or a storage device. When this program is loaded into a program-driven electronic device, the above-mentioned detour patch method method can be executed. .

另外,本发明提出一种程序驱动电子装置,用以执行绕道修补程序方法,包含可重写内存,用以储存程序,上述程序包含储存在第一区域的被取代部分程序;处理器,耦接于上述内存,其中当上述处理器取得修正程序时,储存上述修正程序于上述可重写内存的第二区域,用以取代上述被取代部分程序。上述处理器将上述被取代部分程序的一开头指令改成例外产生指令,使得上述被取代部分程序被执行时产生程序修补例外。以及当上述处理器接收上述程序修补例外时,执行上述修正程序。In addition, the present invention proposes a program-driven electronic device for executing a bypass repair program method, including a rewritable memory for storing a program, the above-mentioned program includes a replaced part of the program stored in the first area; a processor coupled to In the above-mentioned memory, when the above-mentioned processor obtains the correction program, store the above-mentioned correction program in the second area of the above-mentioned rewritable memory to replace the above-mentioned replaced part of the program. The processor changes a beginning instruction of the replaced part of the program into an exception generating instruction, so that a program repair exception is generated when the replaced part of the program is executed. and when the processor receives the program repair exception, execute the repair program.

附图说明 Description of drawings

图1示出了执行本发明较佳实施例的绕道修补程序方法的移动通讯装置方块图;Fig. 1 shows the block diagram of the mobile communication device that executes the detour patch method of the preferred embodiment of the present invention;

图2示出了本发明较佳实施例中上述内存4的示意图;Fig. 2 shows the schematic diagram of above-mentioned memory 4 in the preferred embodiment of the present invention;

图3A及图3B中示出了本发明较佳实施例的绕道修补程序方法流程图;Figure 3A and Figure 3B show a flow chart of a detour repair program method in a preferred embodiment of the present invention;

图4示出了多个修正程序的数据结构示意图;FIG. 4 shows a schematic diagram of data structures of multiple correction programs;

图5示出了依据本发明实施例的绕道修补程序方法的计算机可读取储存介质示意图。FIG. 5 shows a schematic diagram of a computer-readable storage medium of a method for bypassing a repair program according to an embodiment of the present invention.

附图符号说明Description of reference symbols

1-处理器;2-取得单元;4-内存;10-移动通讯装置;41-固件使用区;42-固件预留区;43-数据区;44-中断向量表;45-例外处理模块;46-被取代部分程序;47-49-修正程序471,481,491-索引字段;472,482,492-版本字段;473,483,493-下个修正程序地址字段;474,487,494-修正程序代码。1-processor; 2-acquisition unit; 4-memory; 10-mobile communication device; 41-firmware use area; 42-firmware reserved area; 43-data area; 44-interrupt vector table; 45-exception processing module; 46-Replaced part of the program; 47-49-Modification program 471, 481, 491-Index field; 472, 482, 492-Version field; 473, 483, 493-Next revision program address field; 474, 487, 494- Correct the program code.

具体实施方式 Detailed ways

本发明提供一种绕道修补程序方法,执行于一程序驱动电子装置中,用以克服上述需要更新整个程序及部分更新方法不能适用每种情况的的缺点。在本实施例中以移动通讯装置为例,然而本发明较佳实施例的绕道修补程序方法可以执行于其它程序驱动电子装置中。The present invention provides a method for bypassing a patch program, which is implemented in a program-driven electronic device, to overcome the above-mentioned shortcoming that the entire program needs to be updated and the partial update method cannot be applied to every situation. In this embodiment, a mobile communication device is taken as an example, however, the detour patching method of the preferred embodiment of the present invention can be implemented in other program-driven electronic devices.

图1示出了一执行本发明的绕道修补程序方法的移动通讯装置10,上述移动通讯装置10包含处理器1、取得单元2、及内存4。上述处理器1耦接于上述取得单元2及内存4。上述取得单元2用以取得修正程序。在本实施例中,虽以移动通讯装置10为例,然其并非用以限定本发明,本发明的程序驱动电子装置可以是其它电子装置。FIG. 1 shows a mobile communication device 10 implementing the detour patching method of the present invention. The mobile communication device 10 includes a processor 1 , an acquisition unit 2 , and a memory 4 . The processor 1 is coupled to the acquisition unit 2 and the memory 4 . The obtaining unit 2 is used to obtain the correction program. In this embodiment, although the mobile communication device 10 is taken as an example, it is not intended to limit the present invention, and the program-driven electronic device of the present invention may be other electronic devices.

在本实施例中,取得单元2经由无线通讯方式,从个人计算机下载或连接因特网取得修正程序。举例来说,取得单元2可以经由内含修正程序的短信服务(Short Messaging Services,简称SMS)讯息来取得修正程序。In this embodiment, the acquisition unit 2 downloads the correction program from a personal computer or connects to the Internet via wireless communication. For example, the obtaining unit 2 may obtain the correction program through a Short Messaging Services (SMS) message containing the correction program.

通常硬件制造厂会预先将该产品内部的内存逻辑划分为:(a)用以存放数据的数据区,及(b)用以存放固件程序的程序区。因为逻辑划分时硬件制造厂并不晓得实际固件程序需要多大储存空间,所以均会预留远超过固件程序大小的较大空间。故实际加载固件程序至内存时,在程序区的末端往往会有一部分固件预留区。图2示出了本发明较佳实施例中上述内存4的示意图,上述数据区为数据区43,而上述程序区包含固件预留区(empty area)42及固件使用区(code area)41。Usually, the hardware manufacturer will logically divide the internal memory of the product into: (a) a data area for storing data, and (b) a program area for storing firmware programs. Because the hardware manufacturer does not know how much storage space the actual firmware program needs when logically partitioning, it will reserve a large space far exceeding the size of the firmware program. Therefore, when the firmware program is actually loaded into the memory, there is often a part of the firmware reserved area at the end of the program area. Fig. 2 has shown the schematic diagram of above-mentioned memory 4 in the preferred embodiment of the present invention, and above-mentioned data area is data area 43, and above-mentioned program area comprises firmware reserved area (empty area) 42 and firmware use area (code area) 41.

固件使用区41储存着用以驱动上述移动通讯装置10的程序。当上述程序中有一部分程序码需要修改时,可以利用本发明的绕道修补程序方法修正。在固件使用区41中有一被取代部分程序46、例外处理模块45、及中断向量表44。The firmware usage area 41 stores programs for driving the above-mentioned mobile communication device 10 . When a part of the program code needs to be modified in the above program, it can be corrected by using the detour patch method of the present invention. In the firmware usage area 41 there is a replaced part program 46 , an exception handling module 45 , and an interrupt vector table 44 .

本发明较佳实施例中,上述中断向量表44所记录的各种例外对应的例外处理程序码所在地址皆为指向上述例外处理模块45的地址。因此任何例外产生时,处理器1皆根据上述例外处理模块45所记录的例外处理程序来处理例外。In a preferred embodiment of the present invention, the addresses of the exception handling program codes corresponding to various exceptions recorded in the interrupt vector table 44 all point to the address of the exception handling module 45 . Therefore, when any exception occurs, the processor 1 handles the exception according to the exception handling program recorded by the exception handling module 45 .

不同于传统的例外处理程序,本发明较佳实施例中,例外处理模块45所记录的例外处理程序首先判别处理器1接收的例外是否为程序修补例外。Different from the traditional exception handling program, in the preferred embodiment of the present invention, the exception handling program recorded by the exception handling module 45 first determines whether the exception received by the processor 1 is a program repair exception.

图3A示出了本发明较佳实施例的电子装置修补程序过程的流程图。首先处理器1经由取得单元2取得一修正程序47,上述修正程序47稍后会被用以取代被取代部分程序46(步骤S2)。举例来说,由移动通讯装置10的制造者发送一内含修正程序47的短信至移动通讯装置10。取得单元2取得上述短信并撷取出上述修正程序47。FIG. 3A shows a flow chart of the electronic device repair program process of the preferred embodiment of the present invention. First, the processor 1 acquires a revised program 47 via the acquiring unit 2, and the revised program 47 will be used to replace the replaced part of the program 46 later (step S2). For example, the manufacturer of the mobile communication device 10 sends a short message containing the correction program 47 to the mobile communication device 10 . The obtaining unit 2 obtains the above-mentioned short message and retrieves the above-mentioned correction program 47 .

接着,处理器1将上述修正程序47储存在内存4的固件预留区42中相邻于数据区43的区域(步骤S4),处理器1并记录储存修正程序47的地址。Next, the processor 1 stores the correction program 47 in an area adjacent to the data area 43 in the reserved firmware area 42 of the memory 4 (step S4), and the processor 1 records the address of the correction program 47.

等到修正程序47确实储存在内存4中后,处理器1接着修改被取代部分程序46(步骤S6),使处理器1稍后欲再执行被取代部分程序46时都会产生程序修补例外;如此处理器1稍后将无法执行被取代部分程序46,而是会跳到修正程序47所在地址以执行修正程序47。After the revised program 47 is indeed stored in the internal memory 4, the processor 1 then revises the replaced part of the program 46 (step S6), so that the processor 1 will generate a program repair exception when it intends to execute the replaced part of the program 46 later; The device 1 will not be able to execute the replaced part of the program 46 later, but will jump to the address where the modified program 47 is located to execute the modified program 47 .

在本实施例中,我们将被取代部分程序46的开端指令修改为“例外产生指令”(exception-causing code)即处理器1执行该指令时,会导致处理器1产生例外(exception)情形的指令。上述例外产生指令包含具有未定义指令码(op code)的指令,或存取非法内存地址的指令。In this embodiment, we modify the beginning instruction of the replaced part of the program 46 to "exception-causing code", that is, when the processor 1 executes the instruction, it will cause the processor 1 to generate an exception (exception) situation. instruction. The above-mentioned exception-generating instructions include instructions with undefined op codes, or instructions that access illegal memory addresses.

上述开端指令是被取代部分程序46的第一个指令。上述被取代部分程序的范围可以由修正程序设计者决定。举例来说,如果固件使用区41中的固件程序的第三到第六个指令是错误的或需要更新的,则上述被取代部分程序46可以定义为第三到第六个指令或者第二到第六个指令,或者为包含上述第三到第六个指令的任何范围。上述开端指令是被取代部分程序46的第一个指令,所以开端指令可以是上述第三个指令或上述第三个指令以前的任何一指令。同理,如果上述固件程序的第i个指令是错误的或需要更新的,则上述开端指令可以是固件程序第i个指令以前的任何一个指令。The above start instruction is the first instruction of the replaced partial program 46 . The scope of the above-mentioned replaced part of the program can be determined by the revised program designer. For example, if the third to sixth instructions of the firmware program in the firmware use area 41 are wrong or need to be updated, the above-mentioned replaced part program 46 can be defined as the third to sixth instructions or the second to sixth instructions. The sixth directive, or any range encompassing the third through sixth directives above. The above-mentioned beginning instruction is the first instruction of the replaced part program 46, so the beginning instruction can be the above-mentioned third instruction or any instruction before the above-mentioned third instruction. Similarly, if the i-th instruction of the above-mentioned firmware program is wrong or needs to be updated, the above-mentioned beginning instruction can be any instruction before the i-th instruction of the firmware program.

由于闪存的特性中,如果闪存储存的数据需要修改时,其中只要有一个位需要从“0”改变成“1”时,就需要以一个内存区块为单位作修改。亦即上述位所在内存区块的所有数据需要全部被更新,才能重写一个位“1”。因此在本发明较佳实施例的步骤“修改被取代部分程序46”中,我们是将上述开端指令的某些位从“1”修改成“0”。藉此,开端指令被修改成例外产生指令,同时不必将被取代部分程序46所在的整个内存区块数据抹除更新。Due to the characteristics of the flash memory, if the data stored in the flash memory needs to be modified, as long as one bit needs to be changed from "0" to "1", it needs to be modified in units of a memory block. That is to say, all data in the memory block where the above-mentioned bit is located needs to be updated before a bit "1" can be rewritten. Therefore, in the step "modifying the replaced part of the program 46" in the preferred embodiment of the present invention, we modify some bits of the above-mentioned beginning instruction from "1" to "0". In this way, the beginning instruction is modified into an exception generating instruction, and at the same time, it is not necessary to erase and update the data of the entire memory block where the replaced part of the program 46 is located.

处理器1以上述方式并根据一指令修改信息将上述开端指令修改成例外产生指令。上述指令修改信息提供修改上述被取代部分程序46及开端指令所需信息,例如定义被取代部分程序46的起迄地址以及将开端指令的哪几个位修改为逻辑0。此指令修改信息可以记录在上述短信中或修正程序的标头中。The processor 1 modifies the above-mentioned beginning instruction into an exception generating instruction in the above-mentioned manner and according to an instruction modification information. The above-mentioned instruction modification information provides the information needed to modify the above-mentioned replaced partial program 46 and the beginning instruction, such as defining the starting and ending addresses of the replaced partial program 46 and which bits of the beginning instruction are modified to logic 0. This command modification information can be recorded in the above-mentioned short message or in the header of the correction program.

如图4所示,修正程序47具有一标头(header),其中记录着索引(index)、下一个修正程序地址及修正程序版本。上述索引为修正程序47对应之将取代部分开端指令的地址,亦即被取代部分程序46的实际指令码开头地址。如果有第二个修正程序时,第二个修正程序标头还记录着第二个被取代部分程序开端指令的地址。同理,如果有第三个修正程序时,第三个修正程序的标头还记录着第三个被取代部分程序开端指令的地址。As shown in FIG. 4 , the correction program 47 has a header, which records an index, a next correction program address and a correction program version. The above-mentioned index is the address corresponding to the beginning instruction to be replaced by the modification program 47 , that is, the beginning address of the actual instruction code of the replaced part program 46 . If there is a second correction program, the second correction program header also records the address of the second replaced partial program start instruction. Similarly, if there is a third correction program, the header of the third correction program also records the address of the beginning instruction of the third replaced part of the program.

举例来说,图4示出了修正程序47、修正程序48及修正程序49的数据结构示意图。字段471-474组成修正程序47。字段481-484组成修正程序48。字段491-494组成修正程序49。修正程序47的标头地址为以字节为单位的“4096”。修正程序48的标头地址为“4002”。修正程序49的标头地址为“3924”。修正程序47的标头中的下个修正程序地址字段473记录地址“4002”。修正程序48的标头中的下个修正程序地址字段483记录地址“3924”。修正程序49的标头中的下个修正程序地址字段493无地址记录。图中虚线表示根据下个修正程序地址字段可以找到下个修正程序实际地址。For example, FIG. 4 shows a schematic diagram of the data structure of the modification program 47 , the modification program 48 and the modification program 49 . Fields 471-474 make up the revision program 47. Fields 481-484 make up the revision program 48. Fields 491-494 make up the revision procedure 49. The header address of the correction program 47 is "4096" in bytes. The header address of the revised program 48 is "4002". The header address of the revised program 49 is "3924". The next revision program address field 473 in the header of the revision program 47 records an address "4002". The address "3924" is recorded in the next revision program address field 483 in the header of the revision program 48 . The next fixer address field 493 in the header of the fixer 49 has no address record. The dotted line in the figure indicates that the actual address of the next revision program can be found according to the next revision program address field.

在本实施例中,被取代部分程序46的开端指令地址为第“2002”字节,因此修正程序47的标头中的索引字段471记录“2002”代表修正程序47要取代的部分的开端指令地址。修正程序48的标头中的索引字段481记录“108”代表修正程序48要取代的部分的开端指令地址。修正程序49的标头中的索引字段491记录“254”代表修正程序47要取代的部分的开端指令地址。修正程序47-49的标头中的版本字段记录版本信息提供往后修正程序更新时比较新旧版本。In this embodiment, the beginning instruction address of the replaced part program 46 is the "2002" byte, so the index field 471 record "2002" in the header of the revised program 47 represents the beginning instruction of the part to be replaced by the revised program 47 address. The index field 481 record "108" in the header of the modified program 48 represents the beginning instruction address of the part to be replaced by the modified program 48 . The index field 491 record "254" in the header of the modified program 49 represents the beginning instruction address of the part to be replaced by the modified program 47 . The version fields in the headers of fixes 47-49 record version information for later comparison of the old and new versions when the fixes are updated.

图3B是该电子装置程序修补完成后,执行该程序时的流程图,首先处理器1会持续检测是否有例外发生(步骤S8)。当处理器1检测到例外产生时,处理器1可以经由参照中断向量表44以取得例外处理模块45的程序代码读取地址(步骤S10)。接着处理器1可以通过例外处理模块45取得当时产生例外的程序代码地址。同时处理器1亦接收修正程序47-49标头中的索引值,即第一-第三被取代部分程序的开端指令的地址。在本实施例中,处理器1是根据各标头中“下一个修正程序地址”字段依序接收修正程序47-49标头中的索引值。接着处理器1比较上述索引及例外产生地址是否相同(步骤S12)。FIG. 3B is a flow chart of executing the program after the electronic device program is patched. First, the processor 1 will continue to detect whether there is an exception (step S8). When the processor 1 detects that an exception occurs, the processor 1 may obtain the program code read address of the exception processing module 45 by referring to the interrupt vector table 44 (step S10 ). Then the processor 1 can obtain the address of the program code that generated the exception at that time through the exception handling module 45 . At the same time, the processor 1 also receives the index values in the headers of the revised programs 47-49, that is, the addresses of the beginning instructions of the first-third replaced partial programs. In this embodiment, the processor 1 sequentially receives the index values in the headers of the correction programs 47-49 according to the "address of next correction program" field in each header. Next, the processor 1 compares whether the above-mentioned index and the exception generating address are the same (step S12).

如果修正程序47的上述索引和例外产生地址相同则代表处理器1所接收的例外为程序修补例外,亦即该例外为处理器1执行被取代部分程序46的开端指令而产生的程序修补例外。例如:若处理器1所接收到例外产生的地址是“2002”且和修正程序47索引值“2002”相同时,则处理器1会判定所接收到的例外是“被取代部分程序46”开端指令执行时所产生的程序修补例外。同时,处理器1目前接收的索引所属的修正程序47是用以取代产生例外的被取代部分程序46的修正程序。因此处理器1将不执行被取代部分程序46,而会执行修正程序47(步骤S14)。If the index of the modified program 47 is the same as the exception generation address, it means that the exception received by the processor 1 is a program repair exception, that is, the exception is a program repair exception generated by the processor 1 executing the beginning instruction of the replaced part of the program 46 . For example: if the address generated by the exception received by the processor 1 is "2002" and is the same as the index value "2002" of the revised program 47, then the processor 1 will determine that the received exception is the beginning of the "replaced part of the program 46" A program patch exception is generated when the instruction is executed. Meanwhile, the correction program 47 to which the index currently received by the processor 1 belongs is a correction program for replacing the replaced part of the program 46 that generated the exception. Therefore, the processor 1 will not execute the replaced part of the program 46, but will execute the revised program 47 (step S14).

上述修正程序记录回到位于上述被取代部分程序后的指令地址所需的相关信息。藉此,如果处理器1需要回到被取代部分程序原本被执行完毕后所应接续执行的程序所在地址,处理器1在执行目前修正程序完毕后可以根据此相关信息实现此操作。The above-mentioned revised program records relevant information required to return to the address of the instruction located after the above-mentioned replaced part of the program. In this way, if the processor 1 needs to return to the address of the program that should be executed next after the replaced part of the program is originally executed, the processor 1 can realize this operation according to the relevant information after executing the current correction program.

如果修正程序47的上述索引和例外产生地址不相同,则代表处理器1所接收的例外不是目前修正程序的程序修补例外。处理器1判定目前修正程序标头中是否记录着下一个修正程序的地址(步骤S16)。如果目前修正程序标头中记录着下一个修正程序的地址,处理器1根据被记录的下一个修正程序的地址取得下一个修正程序作为目前修正程序(步骤S18)。接着重复步骤S12的操作。例如:若处理器1所接收到例外产生的地址是“254”,则处理器1会依序比对修正程序48-49标头中的索引值是否为“254”,而后执行修正程序49。If the index of the correction program 47 is not the same as the exception generation address, it means that the exception received by the processor 1 is not a program repair exception of the current correction program. The processor 1 determines whether the address of the next revision program is recorded in the header of the current revision program (step S16). If the address of the next correction program is recorded in the header of the current correction program, the processor 1 acquires the next correction program as the current correction program according to the recorded address of the next correction program (step S18). Then repeat the operation of step S12. For example: if the address generated by the exception received by the processor 1 is "254", the processor 1 will sequentially compare whether the index value in the header of the correction program 48-49 is "254", and then execute the correction program 49.

如果目前修正程序标头中没有记录着下一个修正程序的地址,处理器1判定上述接收例外不是程序修补例外。接着如同一般例外处理程序,处理器1取得此例外的对应例外处理程序并据以处理上述接收例外。例如:若处理器1所接收到例外产生的地址是“235”,则处理器1会依序比对修正程序47-49标头中的索引栏是否包含为“235”。当处理器1(a)依序比对修正程序49索引完毕,仍未找到储存值为“235”的索引栏,且(b)修正程序49标头又没有记录下一个修正程序地址时,此时处理器1判定目前所接收到的例外不是程序修补例外,而回归一般正常的例外处理程序。If the address of the next correction program is not recorded in the current correction program header, the processor 1 determines that the above reception exception is not a program repair exception. Then, like a general exception handling program, the processor 1 obtains the corresponding exception handling program of the exception and handles the above-mentioned received exception accordingly. For example: if the address generated by the exception received by the processor 1 is "235", the processor 1 will sequentially compare whether the index column in the header of the correction program 47-49 contains "235". When the processor 1 (a) has finished indexing the correction program 49 sequentially, but still does not find the index column with the storage value "235", and (b) the head of the correction program 49 does not record the next correction program address, this When the processor 1 determines that the currently received exception is not a program repair exception, it returns to a normal exception handling procedure.

(变形及进阶实施例)(deformation and advanced embodiment)

固件预留区42为程序区中未使用来记录程序的部分,其大小通常可以高达数百千字节(kilobyte,简称KB)。因此利用固件预留区42来储存修正程序是可以较有效利用内存的方法。另外,紧邻数据区43的地址比较容易获得,因此将修正程序储存在紧邻数据区43的区域。然而将修正程序储存在数据区43或内存的其它区域同样可以实现本发明的目的。The firmware reserved area 42 is an unused part of the program area for recording programs, and its size can usually be as high as hundreds of kilobytes (KB for short). Therefore, using the firmware reserved area 42 to store the revision program is a more efficient way to utilize the memory. In addition, the address adjacent to the data area 43 is relatively easy to obtain, so the correction program is stored in an area adjacent to the data area 43 . However, storing the correction program in the data area 43 or other areas of the internal memory can also achieve the purpose of the present invention.

将被取代部分程序46的开端指令修改成例外产生指令的方法中可以将经由记录开端指令的部分位由逻辑1修改成逻辑0来实现。此方法即使在上述开端指令记录在闪存的情况中也可以只修改开端指令而不必更新整个闪存区块的数据。In the method of modifying the beginning instruction of the replaced partial program 46 into an exception generating instruction, it can be realized by modifying some bits of the beginning instruction by recording from logic 1 to logic 0. This method can modify only the beginning instruction without updating the data of the entire flash memory block even in the case that the above-mentioned beginning instruction is recorded in the flash memory.

在移动通讯装置10是移动电话的例子中,可以经由接收包含修正程序47的短信来取得上述修正程序47。然而并非用以限定本发明,本发明的程序驱动电子装置可以经由其它方式取得修正程序。In an example where the mobile communication device 10 is a mobile phone, the modification program 47 can be obtained by receiving a short message containing the modification program 47 . However, it is not intended to limit the present invention, and the program-driven electronic device of the present invention can obtain the correction program through other methods.

其中,本发明较佳实施例的绕道修补程序方法可以利用一程序实现,记录于内存4的储存介质上,当此程序加载至上述移动通讯装置10中,则可执行如上所述绕道修补程序方法。Wherein, the detour patching method of the preferred embodiment of the present invention can be realized by using a program, which is recorded on the storage medium of the memory 4, and when this program is loaded into the above-mentioned mobile communication device 10, the above-mentioned detour patching method can be executed .

因此,本发明提出一种计算机可读取储存介质,用以储存一计算机程序,上述计算机程序用以实现绕道修补程序方法,此方法会执行如上所述的步骤。Therefore, the present invention proposes a computer-readable storage medium for storing a computer program, and the computer program is used to implement a bypass repair method, and the method will execute the above-mentioned steps.

图5示出了依据本发明实施例的绕道修补程序方法的计算机可读取储存介质示意图。此储存介质60,用以储存一计算机程序620,用以实现绕道修补程序方法。其计算机程序包含五个逻辑,分别为修正程序取得逻辑621、开端指令修改逻辑622与例外判断处理逻辑623。FIG. 5 shows a schematic diagram of a computer-readable storage medium of a method for bypassing a repair program according to an embodiment of the present invention. The storage medium 60 is used for storing a computer program 620 for realizing the bypass patch method. Its computer program includes five logics, which are correction program acquisition logic 621 , initial instruction modification logic 622 and exception judgment processing logic 623 .

修正程序取得逻辑621取得并储存修正程序于内存适当地址。开端指令修改逻辑622修改被取代部分程序的开端指令成为例外产生指令。例外判断处理逻辑623判断接收例外是否为程序修补例外并执行对应的修正程序。The modification program obtaining logic 621 obtains and stores the modification program in the appropriate memory address. The beginning instruction modification logic 622 modifies the beginning instruction of the replaced part of the program to become an exception generating instruction. The exception judgment processing logic 623 judges whether the received exception is a program repair exception and executes the corresponding correction program.

综上所述,本发明的绕道修补程序方法可以应用在程序驱动电子装置中,以克服修改驱动上述程序驱动电子装置的程序时,需要更新整个程序及部分更新方法不能适用每种情况的缺点。To sum up, the detour patching method of the present invention can be applied in program-driven electronic devices to overcome the disadvantages that the entire program needs to be updated when modifying the programs driving the above-mentioned program-driven electronic devices, and the partial update method cannot be applied to every situation.

虽然本发明已以较佳实施例披露如上,然其并非用以限定本发明,本领域的技术人员在不脱离本发明的精神和范围的前提下,可作各种的更动与润饰,因此本发明的保护范围以本发明的权利要求为准。Although the present invention has been disclosed above with preferred embodiments, it is not intended to limit the present invention. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore The protection scope of the present invention shall be determined by the claims of the present invention.

Claims (29)

1. a Hotfix method is executed in the driven by program electronic installation, and the said procedure drive electronics has one can rewrite internal memory, and in order to storing a program, said procedure comprises and is stored in one of a first area and is substituted subprogram, comprises the following steps:
Obtain a revision program, in order to replace the above-mentioned subprogram that is substituted;
Store above-mentioned revision program in an above-mentioned second area that rewrites internal memory;
Make the above-mentioned beginning instruction that is substituted subprogram into an exception and produce instruction, make above-mentioned when being substituted subprogram and being performed generating routine repair exception; And
When receiving said procedure repairing exception, carry out above-mentioned revision program.
2. Hotfix method as claimed in claim 1, wherein, above-mentioned second area is the firmware trough in the above-mentioned program area that rewrites internal memory.
3. Hotfix method as claimed in claim 1, wherein, above-mentioned second area is the part that the firmware trough is in close proximity to file system in the above-mentioned program area that rewrites internal memory.
4. Hotfix method as claimed in claim 1 wherein, before carrying out above-mentioned revision program step, also comprises the following step:
Reception produces the exception that instruction produces by an exception.
5. Hotfix method as claimed in claim 4 wherein, also comprises the following step:
Via obtain an exception processing module with reference to an interrupt vector table, above-mentioned exception processing module is in order to determine whether above-mentioned receipt exception is that said procedure is repaired exception according to the exception that receives.
6. Hotfix method as claimed in claim 4 wherein after above-mentioned receiving step, also comprises the following step:
Whether the index in the address that more above-mentioned exception produces instruction and the present revision program identical determining whether above-mentioned exception is that said procedure is repaired exception, above-mentioned index by in the above-mentioned present revision program record will replace beginning instruction address partly.
7. Hotfix method as claimed in claim 6, wherein, above-mentioned present revision program is above-mentioned revision program.
8. Hotfix method as claimed in claim 7 wherein, when the address of above-mentioned exception generation instruction is identical with above-mentioned index, also comprises routine step down:
Judge that above-mentioned exception is that said procedure is repaired exception.
9. Hotfix method as claimed in claim 6, wherein, above-mentioned second area writes down a plurality of revision programs, also comprises the following step before the above-mentioned comparison step:
Order obtains a revision program in above-mentioned a plurality of revision program as above-mentioned present revision program.
10. Hotfix method as claimed in claim 6, wherein, said sequence is obtained in the step of a revision program in above-mentioned a plurality of revision program, is to come order to obtain according to next revision program address of writing down in the above-mentioned present revision program.
11. Hotfix method as claimed in claim 1, wherein, modify steps also comprises the following step:
Making logical zero via some position in the position that will represent the instruction of above-mentioned beginning into by logical one revises above-mentioned beginning instruction and produces instruction for above-mentioned exception.
12. Hotfix method as claimed in claim 1, wherein, above-mentioned revision program record is got back to and is positioned at the above-mentioned required relevant information of instruction address that is substituted after the subprogram.
13. Hotfix method as claimed in claim 1, wherein, the said procedure drive electronics is one can download the device for mobile communication of revision program.
14. Hotfix method as claimed in claim 13, wherein, above-mentioned device for mobile communication is obtained above-mentioned revision program via the note that download includes revision program.
15. a driven by program electronic installation in order to carry out the Hotfix method, comprises:
One can rewrite internal memory, and in order to storing a program, said procedure comprises and is stored in one of a first area and is substituted subprogram; And
One processor is coupled to the above-mentioned internal memory that rewrites, and wherein when above-mentioned processor is obtained a revision program, stores above-mentioned revision program in an above-mentioned second area that rewrites internal memory, in order to replace the above-mentioned subprogram that is substituted; Above-mentioned processor makes the above-mentioned beginning instruction that is substituted subprogram into an exception and produces instruction, make above-mentioned when being substituted subprogram and being performed generating routine repair exception; And when above-mentioned processor receives said procedure repairing exception, carry out above-mentioned revision program.
16. driven by program electronic installation as claimed in claim 15, wherein, above-mentioned second area is the firmware trough in the above-mentioned program area that rewrites internal memory.
17. driven by program electronic installation as claimed in claim 15, wherein, above-mentioned second area is the part that the firmware trough is in close proximity to the data field in the above-mentioned program area that rewrites internal memory.
18. driven by program electronic installation as claimed in claim 15, wherein, above-mentioned processor also received by an exception and produces the exception that instruction produces before carrying out above-mentioned revision program.
19. driven by program electronic installation as claimed in claim 18, wherein, above-mentioned processor is also obtained an exception processing module according to the exception that receives via reference one interrupt vector table, and above-mentioned exception processing module is in order to determine whether above-mentioned receipt exception is that said procedure is repaired exception.
20. driven by program electronic installation as claimed in claim 18, wherein above-mentioned processor is after the above-mentioned exception of above-mentioned reception, also whether the index in the address of more above-mentioned instruction and the present revision program is identical to determine whether above-mentioned exception is that said procedure is repaired exception, and above-mentioned index will replace beginning instruction address partly by institute's record in the above-mentioned present revision program.
21. driven by program electronic installation as claimed in claim 18, wherein, above-mentioned present revision program is above-mentioned revision program.
22. driven by program electronic installation as claimed in claim 18, wherein, above-mentioned second area writes down a plurality of revision programs, and above-mentioned processor more order is obtained a revision program in above-mentioned a plurality of revision program as above-mentioned present revision program.
23. as claim 21 or 22 described driven by program electronic installations, wherein, when the address of above-mentioned instruction was identical with above-mentioned index, above-mentioned processor judged that also above-mentioned exception is that said procedure is repaired exception.
24. driven by program electronic installation as claimed in claim 22, wherein, above-mentioned processor comes order to obtain another revision program according to next revision program address of writing down in the above-mentioned present revision program.
25. driven by program electronic installation as claimed in claim 15, wherein, above-mentioned processor makes logical zero via some position in the position that will represent the instruction of above-mentioned beginning into by logical one to be revised above-mentioned beginning instruction and produces instruction for above-mentioned exception.
26. driven by program electronic installation as claimed in claim 15, wherein, above-mentioned revision program record is got back to and is positioned at the above-mentioned required relevant information of the later instruction address of subprogram that is substituted.
27. driven by program electronic installation as claimed in claim 15, wherein, the said procedure drive electronics is for downloading an electronic installation of revision program.
28. driven by program electronic installation as claimed in claim 27, wherein, the above-mentioned electronic installation that can download revision program is a device for mobile communication.
29. driven by program electronic installation as claimed in claim 27, wherein, above-mentioned processor is obtained above-mentioned revision program via receiving a note.
CNB2004100067667A 2004-02-26 2004-02-26 Method for repairing program by detour and electronic device using the same Expired - Fee Related CN100378660C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2004100067667A CN100378660C (en) 2004-02-26 2004-02-26 Method for repairing program by detour and electronic device using the same

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2004100067667A CN100378660C (en) 2004-02-26 2004-02-26 Method for repairing program by detour and electronic device using the same

Publications (2)

Publication Number Publication Date
CN1661548A CN1661548A (en) 2005-08-31
CN100378660C true CN100378660C (en) 2008-04-02

Family

ID=35010888

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2004100067667A Expired - Fee Related CN100378660C (en) 2004-02-26 2004-02-26 Method for repairing program by detour and electronic device using the same

Country Status (1)

Country Link
CN (1) CN100378660C (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104281443B (en) * 2013-07-12 2020-06-26 锐迪科(重庆)微电子科技有限公司 Method for realizing code and data replacement by using TCM (trusted cryptography module)
CN111782230B (en) * 2020-07-07 2022-05-31 联想(北京)有限公司 Program installation control method and device and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1208194A (en) * 1997-08-08 1999-02-17 华邦电子股份有限公司 Apparatus for patching programs in embedded microprocessor systems
US6202145B1 (en) * 1998-12-14 2001-03-13 International Business Machines Corporation System and method for eliminating a ring transition while executing in protected mode
US6341373B1 (en) * 1996-12-20 2002-01-22 Liberate Technologies Secure data downloading, recovery and upgrading

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6341373B1 (en) * 1996-12-20 2002-01-22 Liberate Technologies Secure data downloading, recovery and upgrading
CN1208194A (en) * 1997-08-08 1999-02-17 华邦电子股份有限公司 Apparatus for patching programs in embedded microprocessor systems
US6202145B1 (en) * 1998-12-14 2001-03-13 International Business Machines Corporation System and method for eliminating a ring transition while executing in protected mode

Also Published As

Publication number Publication date
CN1661548A (en) 2005-08-31

Similar Documents

Publication Publication Date Title
US8200886B2 (en) Efficient system and method for updating a memory device
CN1235137C (en) System and method for compacting field upgradable wireless communication device software code sections
US7644406B2 (en) Update system capable of updating software across multiple FLASH chips
US7873956B2 (en) Communication terminal and communication network for partially updating software, software update method, and software creation device and method therefor
US7971199B1 (en) Mobile device with a self-updating update agent in a wireless network
US20110004871A1 (en) Embedded electronic device and firmware updating method thereof
CN101208755B (en) Apparatus, system and method for accessing persistent files in non-XIP flash memory
US20090320012A1 (en) Secure booting for updating firmware over the air
US20040225873A1 (en) Method and system for recovering program code in a computer system
CN107506219A (en) A kind of general version upgrade method based on android system
CN1641582A (en) Applying custom software image updates to non-volatile storage in a failsafe manner
JP2007219883A (en) Mobile terminal device and software update method
US20160217068A1 (en) Data storing method and embedded system
US7055083B2 (en) Method and apparatus for allocating CRC codes in a flash ROM
JP4586469B2 (en) MEMORY CONTROL DEVICE, MEMORY CONTROL METHOD, PROGRAM
CN100378660C (en) Method for repairing program by detour and electronic device using the same
US20050149493A1 (en) Data recording apparatus and data recording method
US20040186975A1 (en) Flash memory data structure and methods of accessing thereof
US20080320461A1 (en) Method and Apparatus for Reliable In-Place Update
JP2001249855A (en) Method of rewriting data in nonvolatile memory and subscriber circuit
WO2019085365A1 (en) Increment upgrade method based on eigenvalue table look-up method
CN101339513B (en) Data updating method for basic input/output system
JP2004320591A (en) Portable communication terminal
JP2006190278A (en) Method, computer system and program for allowing or disallowing firmware upgrade
JP2004310268A (en) Semiconductor device with built-in flash memory, control method for flash memory, and program for the method

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
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20080402