WO2020107469A1 - Application processing method and apparatus and storage medium - Google Patents

Application processing method and apparatus and storage medium Download PDF

Info

Publication number
WO2020107469A1
WO2020107469A1 PCT/CN2018/118733 CN2018118733W WO2020107469A1 WO 2020107469 A1 WO2020107469 A1 WO 2020107469A1 CN 2018118733 W CN2018118733 W CN 2018118733W WO 2020107469 A1 WO2020107469 A1 WO 2020107469A1
Authority
WO
WIPO (PCT)
Prior art keywords
boot program
program
area
application
address
Prior art date
Application number
PCT/CN2018/118733
Other languages
French (fr)
Chinese (zh)
Inventor
杨小渊
薛冰
邹旭
Original Assignee
深圳市大疆创新科技有限公司
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 深圳市大疆创新科技有限公司 filed Critical 深圳市大疆创新科技有限公司
Priority to CN201880073390.1A priority Critical patent/CN111356982A/en
Priority to PCT/CN2018/118733 priority patent/WO2020107469A1/en
Publication of WO2020107469A1 publication Critical patent/WO2020107469A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Definitions

  • the embodiments of the present invention relate to the field of computers, and in particular, to a program processing method, device, and storage medium.
  • the boot programs and application programs in embedded systems are usually stored in a readable and writable storage device.
  • the size of the current boot program for embedded systems is fixed.
  • the original The boot program of the software can no longer meet the demand, and the original boot program needs to be expanded.
  • the application program is usually stored after the boot program.
  • the size of the new boot program exceeds the size of the original boot program, it will cause the new boot program to overwrite part of the storage area or all the storage occupied by the application program. Area, which causes the application to fail to run properly, and ultimately the embedded device to fail to run normally.
  • Embodiments of the present invention provide a program processing method, device, and storage medium to implement normal upgrade of an application program and a boot program in an embedded device, so as to prevent the boot program from covering the effective execution code of the application program, so that the upgraded application program can be normal Run, so that the upgraded embedded device can run normally.
  • a first aspect of an embodiment of the present invention is to provide a program processing method, which is applied to an embedded device, and a memory of the embedded device stores a first boot program and a first application program; the method includes:
  • firmware to be upgraded where the firmware to be upgraded includes a second application program and a second boot program;
  • the first boot program is replaced with the second boot program, and the sizes of the first boot program and the head region are greater than or equal to the size of the second boot program.
  • a second aspect of an embodiment of the present invention is to provide a program processing method, which is applied to an embedded device, and a memory of the embedded device stores a first boot program and a first application program; the method includes:
  • firmware to be upgraded where the firmware to be upgraded includes a second application program and a second boot program;
  • a third aspect of the embodiments of the present invention is to provide an embedded device, including: a memory and a processor;
  • the memory stores a first boot program and a first application program
  • the processor is used to perform the following operations:
  • firmware to be upgraded where the firmware to be upgraded includes a second application program and a second boot program;
  • the first boot program is replaced with the second boot program, and the sizes of the first boot program and the head region are greater than or equal to the size of the second boot program.
  • a fourth aspect of the embodiments of the present invention is to provide an embedded device, including: a memory and a processor;
  • the memory stores a first boot program and a first application program
  • the processor is used to perform the following operations:
  • firmware to be upgraded where the firmware to be upgraded includes a second application program and a second boot program;
  • a fifth aspect of the embodiments of the present invention is to provide a computer-readable storage medium on which a computer program is stored, which is executed by a processor to implement the method according to the first aspect.
  • the second application program stores There is a start address of the second boot program, according to the start address of the second boot program, the second boot program is obtained, and the first boot program in the memory is replaced with the second boot program to implement the application program And bootloader upgrade.
  • the second application program includes a head area. When the size of the second boot program is larger than the size of the first boot program, the second boot program may occupy the head area of the second application program to prevent the second boot program from being overwritten.
  • the effective execution code of the second application program makes the upgraded second application program run normally, so that the upgraded embedded device can run normally.
  • FIG. 1 is a schematic diagram of an embedded device and a controller provided by an embodiment of the present invention
  • FIG. 2 is a flowchart of a program processing method provided by an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of a memory of an embedded device provided by an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a memory of an embedded device provided by an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of a memory of an embedded device provided by an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of a memory of an embedded device provided by an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of a memory of an embedded device provided by an embodiment of the present invention.
  • FIG. 8 is a flowchart of a program processing method according to another embodiment of the present invention.
  • FIG. 9 is a flowchart of a program processing method according to another embodiment of the present invention.
  • FIG. 10 is a schematic diagram of a memory of an embedded device provided by an embodiment of the present invention.
  • FIG. 11 is a schematic diagram of a memory of an embedded device provided by an embodiment of the present invention.
  • FIG. 12 is a structural diagram of an embedded device provided by an embodiment of the present invention.
  • 21 Embedded device; 22: Controller; 31: Firmware to be upgraded;
  • a component when a component is said to be “fixed” to another component, it can be directly on another component or it can also exist in a centered component. When a component is considered to be “connected” to another component, it can be directly connected to another component or there can be centered components at the same time.
  • An embodiment of the present invention provides a program processing method.
  • the program processing method is applied to embedded devices.
  • the embedded device 21 includes a processor, a memory, and a transceiver.
  • the controller 22 includes a processor, a transceiver, and a network adapter.
  • the controller 22 may specifically be a computer, a tablet computer, or the like.
  • FIG. 2 is a flowchart of a program processing method provided by an embodiment of the present invention. As shown in FIG. 2, the method in this embodiment may include:
  • Step S201 Obtain firmware to be upgraded, where the firmware to be upgraded includes a second application program and a second boot program.
  • the memory of the embedded device stores a first boot program and a first application program.
  • the first boot program is recorded as the old boot program of the embedded device
  • the first application program is recorded as the old application program of the embedded device.
  • the embedded device obtains firmware to be upgraded, and the firmware to be upgraded may include a new application program and a new boot program, or, The firmware to be upgraded may include only a new application program.
  • the new application program is recorded as the second application program, and the new boot program is recorded as the second boot program.
  • the acquiring firmware to be upgraded includes receiving the firmware to be upgraded sent by a controller.
  • the controller 22 can communicate with a server through a network adapter, and the server sends the firmware to be upgraded to the controller 22, and the processor of the controller 22 sends the firmware to be upgraded to the embedded through the transceiver of the controller 22 Device 21, the processor of the embedded device 21 receives the firmware to be upgraded through the transceiver of the embedded device 21, and the firmware to be upgraded may specifically be a composite file of a new application program and a new boot program, or, the to-be-upgraded The firmware may specifically be a new application program.
  • the controller 22 may not include a network adapter, that is, the controller 22 may generate the firmware to be upgraded, and send the generated firmware to be upgraded to the embedded device 21 through the transceiver.
  • the embedded device 21 may include a network adapter through which the embedded device 21 obtains the firmware to be upgraded from the server without receiving the firmware to be upgraded sent by the controller 22.
  • Step S202 Replace the first application program in the memory with the second application program and the second boot program, where the second application program stores a start address of the second boot program, The start address of the second boot program is at a first preset position after the second application program, and the second application program includes a header area.
  • FIG. 3 or FIG. 4 shows the memory of the embedded device 21.
  • the memory of the embedded device 21 currently stores the boot program 1 and the application program 1.
  • Boot program 1 is denoted as the first boot program
  • application program 1 is denoted as the first application program
  • the start address of boot program 1 is address A
  • application program 1 is after boot program 1
  • the start address of application program 1 is address B
  • the program tail of the boot program 1 includes a jump execution code area, and the role of the jump execution code area is to directly jump to the fixed running address of the application program 1, that is, the start address of the application program 1.
  • 31 represents the firmware to be upgraded received by the embedded device 21 from the controller 22, and the firmware to be upgraded 31 includes an application program 2 and a boot program 2, where the application program 2 is recorded as the second application Program, boot program 2 is denoted as the second boot program.
  • the firmware to be upgraded is written into the memory of the embedded device 21.
  • the processor of the embedded device 21 transfers the embedded device 21
  • the application program 1 stored in the memory of is replaced with the firmware to be upgraded, that is, the application program 1 stored in the memory of the embedded device 21 is replaced with the application program 2 and the boot program 2.
  • the processor of the embedded device 21 starts to execute from the start address of the boot program 1, that is, address A, and when it reaches the jump execution code area of the boot program 1, jumps to the application program 2
  • the starting address is the address B.
  • the start address of the boot program 2 is the address E
  • the start address of the boot program 2 is a preset position after the tail address of the application 2, and the preset position is recorded as the first preset position.
  • the start address of application 2 and application 1 are the same, both are address B.
  • the start address of the boot program 2, ie, the length of address E relative to address B is y.
  • the difference between application 2 and application 1 is that application 2 includes a header area, and the running address of application 2 is address D, that is, the effective execution code of application 2 starts from address D and starts from application 2
  • the part from the start address B of the application to the running address D of the application 2 is the header area of the application 2.
  • the application program 2 stores the start address of the boot program 2, that is, the address E.
  • Step S203 Acquire the start address of the second boot program from the second application program, and acquire the second boot program from the start address of the second boot program.
  • the start address of the boot program 2 is obtained from the application program 2 as the address E, and from the boot program 2 That is, the address E starts to acquire the boot program 2.
  • obtaining the start address of the second boot program from the second application program includes the following feasible implementation manners:
  • a feasible implementation manner is that: the second application program includes a first area; and the first area stores a start address of the second boot program.
  • the acquiring the start address of the second boot program from the second application includes: acquiring the start address of the second boot program from the first area of the second application.
  • the application program 2 includes a first area, which is referred to as a copy boot program area, and an address E, which is a start address of the boot program 2, is stored in the copy boot program area.
  • an address E which is a start address of the boot program 2
  • the processor of the embedded device 21 executes from the boot program 1 to the application program 2, it reads the address E, which is the start address of the boot program 2, from the copy boot program area of the application program 2.
  • the second application further includes a second area
  • the second area stores the running address of the second application
  • the tail address of the second area is the first The starting address of an area.
  • the acquiring the start address of the second boot program from the second application includes: determining the start address of the first area according to the second area; and according to the start of the first area Start address, the start address of the second boot program is obtained from the first area of the second application program.
  • the application program 2 may further include a second area, which is referred to as a running address storage area, and the starting address of the running address storage area is address C.
  • the distance between address C and address B is x.
  • the running address storage area stores an address D which is the running address of the application 2.
  • the copy boot program area is behind the run address storage area.
  • the tail address of the run address storage area is the start address of the copy boot program area.
  • the second application further includes a third area, the third area stores a start address of the second area, and the third area is in the second application Within the head area.
  • the acquiring the start address of the second boot program from the second application includes: acquiring the start address of the second area from the third area; starting from the second area Start address, determine the start address of the first area; according to the start address of the first area, obtain the start address of the second boot program from the first area of the second application .
  • the application 2 may further include a third area, which is referred to as a jump execution code area, a jump execution code area in the application 2 and a jump execution code in the boot program 1 described above
  • a jump execution code area in the above boot program 1 is for jumping to the start address of the application 2, namely the address B
  • the jump execution code area in the application 2 is for jumping to Application program 2 running address storage area or copy boot program area.
  • the jump execution code area in the application program 2 stores the start address of the running address storage area of the application program 2.
  • the jump execution code area in the application 2 is in the head area of the application 2.
  • the processor of the embedded device 21 executes from the boot program 1 to the application program 2, it jumps from the jump execution code area in the application program 2 to the run address storage area, and determines the run address storage area according to the run address storage area Copy the boot program area, and read the start address of the boot program 2, namely the address E, from the copy boot program area according to the start address of the copy boot program area.
  • the second application program further includes a third area, the third area stores a start address of the first area, and the third area is in the second Within the head area of the application.
  • the acquiring the start address of the second boot program from the second application includes: acquiring the start address of the first area from the third area; according to the start of the first area Start address, the start address of the second boot program is obtained from the first area of the second application program.
  • the jump execution code area in the application 2 stores the start address of the copy boot area of the application 2.
  • the jump execution code area in the application program 2 jumps to the start address of the copy boot program area, and according to the start of the copy boot program area Address, read the address E, which is the start address of the boot program 2, from the copy boot program area.
  • the starting address of the third area is the starting address of the head area of the second application.
  • the start address of the jump execution code area in the application 2 is the address B which is the start address of the head area of the application 2.
  • the boot program 2 is acquired from the start address of the boot program 2 as the address E .
  • the first area further includes the length of the second boot program; the acquiring the second boot program from the start address of the second boot program includes: according to the The length of the second boot program is obtained from the start address of the second boot program.
  • the copy boot program area of the embedded device 21 may store both the start address of the boot program 2 and the length of the boot program 2, when the processor of the embedded device 21 reads the boot program 2 according to any of the above methods
  • the boot program 2 is obtained from the boot address 2 starting address E according to the length of the boot program 2.
  • the starting address is the address E and the length of the boot program 2, and the tail address of the boot program 2 can be determined.
  • the tail address is the position where the processor of the embedded device 21 stops acquiring the boot program 2.
  • Step S204 Replace the first boot program with the second boot program, and the sizes of the first boot program and the head area are greater than or equal to the size of the second boot program.
  • the processor of the embedded device 21 obtains the boot program 2
  • the original boot program 1 in the memory of the embedded device 21 is replaced with the boot program 2, that is, the boot program 1 is overwritten with the boot program 2.
  • the size of the boot program 2 and the boot program 1 may be different, and the size of the boot program 2 may be larger than the boot program 1 or may be smaller than the boot program 1. In this embodiment, the size of the boot program 2 is larger than that of the boot program 1 as an example.
  • the boot program 2 Since the size of the boot program 2 is larger than the size of the boot program 1, when the processor of the embedded device 21 overwrites the boot program 1 with the boot program 2, the boot program 2 will occupy the head area of the application 2, in In this embodiment, the sum of the size of the boot program 1 and the size of the head area of the application 2 is greater than or equal to the size of the boot program 2. As shown in FIG. 5, assuming that the size of the boot program 2 is larger than the size of the boot program 1 by x, after the boot program 2 is overwritten by the boot program 1, the boot program 2 will occupy the size of the head area of the app 2 as x Area.
  • x is less than or equal to the size of the head area of the application 2, so that the boot program 2 will not overwrite the effective execution code of the application 2, thereby affecting the normal operation of the application 2. For example, if x is smaller than the size of the head area of the application 2, after the boot program 2 is overwritten, the head area of the application 2 becomes smaller, for example, the area from address B to address D becomes It is the area from address C to address D. This embodiment does not limit the relationship between the size of the area from address B to address C and the size of the area from address C to address D.
  • the starting address of the first area is the running address of the second application program.
  • the second area is within the head area of the second application.
  • the size of the storage space between the start address of the first boot program and the start address of the second area is greater than or equal to the size of the second boot program.
  • the start address of the copy boot program area of the application 2 is the address D which is the running address of the application 2.
  • the running address storage area of the application 2 is in the header area of the application 2. In this case, if the size of the boot program 2 is larger than the size of the boot program 1, the boot program 2 may occupy part of the head area or the entire head area of the application program 2, specifically, the boot program 2 may not occupy the The running address storage area in the header area can also occupy the running address storage area. As shown in FIG.
  • the size of the storage space must be greater than or equal to the size of the boot program 2. As shown in FIG. 6, when the boot program 2 can occupy the running address storage area in the header area, the storage space from the boot address of the boot program 1 to the address A to the boot address of the boot program 2 is the storage space The size must be greater than or equal to the size of bootloader 2.
  • the starting address of the first area is at a second preset position after the running address of the second application program.
  • the second area is not within the head area of the second application.
  • the size of the storage space between the start address of the first boot program and the running address of the second application program is greater than or equal to the size of the second boot program.
  • the start address of the copy boot program area of the application 2 is a preset position after the address D, which is the running address of the application 2, and the preset position is recorded as the second preset position. Limit the distance from address D to the start address of the copy boot program area.
  • the running address storage area of the application 2 is not in the header area of the application 2. In this case, the size of the storage space from the start address of the boot program 1 (address A) to the running address of the application program 2 (address D) must be greater than or equal to the size of the boot program 2, that is, the boot program 2
  • the head area of the application 2 can be occupied at most.
  • the maximum value of the size of the boot program 2 is the sum of the size of the boot program 1 and the size of the head area of the application 2.
  • the processor replacing the first boot program with the second boot program includes: comparing the first boot program and the second boot program; if the first boot program Unlike the second boot program, the first boot program is replaced with the second boot program. If the first boot program and the second boot program are the same, delete the second boot program after the second application program.
  • the processor of the embedded device 21 obtains the start address of the boot program 2 as the address E
  • the boot program 2 is acquired from the start address of the boot program 2 as the address E
  • the boot program 2 and the embedded program are compared.
  • the method further includes: deleting the second boot program after the second application program.
  • boot program 1 and boot program 2 are different. After the processor of embedded device 21 replaces boot program 1 with boot program 2, boot program 2 after application program 2 may be further deleted.
  • the size of the head area of the application 2 can be determined according to the sizes of the boot program 1 and the boot program 2, for example, when generating firmware to be upgraded, the application can be determined according to the sizes of the boot program 1 and the boot program 2 The size of the header area of program 2.
  • this embodiment is also applicable to the scenario of shrinking the boot program, not just expanding the boot program.
  • the second application program stores the starting address of the second boot program, according to The starting address of the second boot program is obtained, and the first boot program in the memory is replaced with the second boot program, thereby realizing the upgrade of the application program and the boot program.
  • the second application program includes a head area. When the size of the second boot program is larger than the size of the first boot program, the second boot program may occupy the head area of the second application program to prevent the second boot program from being overwritten.
  • the effective execution code of the second application program makes the upgraded second application program run normally, so that the upgraded embedded device can run normally.
  • An embodiment of the present invention provides a program processing method.
  • 8 is a flowchart of a program processing method according to another embodiment of the present invention. As shown in FIG. 8, based on the embodiment shown in FIG. 2, after the first boot program is replaced with the second boot program, the method may further include:
  • Step S701 Starting from the start address of the second boot program, execute the second boot program.
  • the processor of the embedded device 21 replaces the original boot program 1 in the memory of the embedded device 21 with the boot program 2, if the embedded device 21 does not restart, the processor of the embedded device 21 will Start running application 2. If the embedded device 21 restarts, the processor of the embedded device 21 will execute the boot program 2 from the address A, which is the start address of the boot program 2.
  • Step S702 When executing the second boot program, obtain the running address of the second application program.
  • the tail of the boot program 2 includes a get run address area and a jump execution code area, where the get run address area is used to get the run address of the application 2 (address D), and the jump execution code of the boot program 2
  • the area is used to jump directly to address D to start execution.
  • the jump execution code area is mainly assembly code, which directly changes the running address of the program.
  • the second boot program stores the start address of the second area; the acquiring the running address of the second application program when executing the second boot program includes: When the second boot program is executed, the running address of the second application program is obtained from the second area according to the start address of the second area.
  • the acquisition run address area at the end of the boot program 2 stores the start address of the second area described in the above embodiment, that is, the start address of the run address storage area, since the run address storage area stores the run address of the application 2 Address D, when the processor of the embedded device 21 executes the acquisition operation address area at the end of the boot program 2, it reads the start address of the operation address storage area from the acquisition operation address area, and according to the operation address storage area
  • the starting address is the address D which is the running address of the application 2 is read from the running address storage area.
  • Step S703 Jump from the second boot program to the running address of the second application program, and execute the second application program.
  • the processor of the embedded device 21 executes the jump execution code area at the end of the boot program 2, it jumps directly to the address D of the application program 2 to start execution of the application program 2.
  • the acquisition run address area at the end of the boot program 2 only needs to acquire the run address of the application program 2 before the processor of the embedded device 21 executes the jump execution code area at the tail of the boot program 2.
  • the jumping from the second boot program to the running address of the second application program, and executing the second application program includes: jumping from the second boot program to the running of the second application program Address, execute the second application program, and delete the second boot program after the second application program.
  • the application program 2 stores the start address of the boot program 2 as the address E
  • the processor of the embedded device 21 may also delete the address according to the address E Bootloader 2 after application 2.
  • the first boot program is replaced with a second boot program with a larger capacity, so that the boot program is repaired, replaced, and expanded.
  • the second boot program Starting from the start address of the second boot program, execute the second boot program, and when executing the second boot program, directly obtain the running address of the second application program, and jump directly from the second boot program to the
  • the running address of the second application program is the starting address of the effective execution code, and executing the second application program improves the execution efficiency of the upgraded second application program.
  • An embodiment of the present invention provides a program processing method.
  • the method is applied to an embedded device, and a memory of the embedded device stores a first boot program and a first application program.
  • 9 is a flowchart of a program processing method according to another embodiment of the present invention. As shown in FIG. 9, the method may include:
  • Step S801 Obtain firmware to be upgraded, where the firmware to be upgraded includes a second application program and a second boot program.
  • the memory of the embedded device 21 stores a first boot program and a first application program
  • the first boot program is specifically the boot program 2 in the above embodiment
  • the first application program is specifically in the above embodiment ⁇ 2 ⁇ Application 2.
  • the address D represents the running address of the application program 2, that is, the starting address of the effective execution code of the application program 2.
  • the storage space between the address C and the address D may be a partial header area remaining after the boot program 2 occupies a partial header area of the application 2.
  • Step S802 Replace the first application program in the memory with the second application program and the second boot program, where the second application program stores a start address of the second boot program, The start address of the second boot program is at a preset position after the second application program.
  • the firmware to be upgraded received by the embedded device 21 from the controller 22 includes the application program 3 and the boot program 2 shown in FIG. 10.
  • the processor of the embedded device 21 After receiving the firmware to be upgraded sent by the controller 22, the processor of the embedded device 21 writes the firmware to be upgraded into the memory of the embedded device 21. Specifically, the processor of the embedded device 21 The application program 2 stored in the memory is replaced with the application program 3 and the boot program 2. After the embedded device 21 is powered on again, the processor of the embedded device 21 executes from the start address of the boot program 2 that is the address A, and the run address of the boot program 2 is obtained to obtain the run address of the application program 3 and the code is effectively executed The starting address of is the address D, and jump to the address D of the application 3 to start execution.
  • the application program 3 stores the start address of the boot program 2, the start address of the boot program 2 is the address E, the start address of the boot program 2 is a preset position after the tail address of the application program 3, optionally, the boot program
  • the starting address of 2 is the length of address E relative to address C is y.
  • Step S803 Acquire the start address of the second boot program from the second application program, and acquire the second boot program from the start address of the second boot program.
  • the processor of the embedded device 21 acquires the address E, which is the start address of the boot program 2, from the application 3, and acquires the boot program 2 from the address E.
  • Step S804 Compare the first boot program and the second boot program.
  • the processor of the embedded device 21 After acquiring the boot program 2 from the address E, the processor of the embedded device 21 compares the boot program currently stored in the memory of the embedded device 21 with the boot program 2.
  • Step S805 If the first boot program and the second boot program are the same, delete the second boot program after the second application program.
  • the processor of the embedded device 21 deletes the boot program 2 after the application program 3.
  • Step S806 If the first boot program and the second boot program are different, replace the first boot program with the second boot program.
  • the processor of the embedded device 21 may replace the boot program currently stored in the memory of the embedded device 21 For bootloader 2.
  • the memory of the embedded device 21 currently stores the boot program 1 and the application program 1.
  • the processor of the embedded device 21 receives the firmware to be upgraded sent by the controller 22 includes the application program 3 and the boot program 2, and the processor of the embedded device 21 writes the application program 3 and the boot program 2 to the memory of the embedded device 21 Specifically, the processor of the embedded device 21 replaces the application program 1 with the application program 3 and the boot program 2.
  • the processor of the embedded device 21 starts to execute from the start address of the boot program 1, that is, address A, and when it reaches the jump execution code area of the boot program 1, jumps to the application 2 The starting address is the address B.
  • the address B may be the starting address of the jump execution code area in the head area of the application 3, the jump execution code area in the head area of the application 3 stores the address C, and the processor slave address of the embedded device 21 B jumps directly to address C to start running.
  • the address C may be the starting address of the running address storage area in the head area of the application 3, the running address storage area stores the running address of the application 3, that is, the address D, and the processor of the embedded device 21 starts from the running address
  • the storage area obtains the address D of the running address of the application 3.
  • the address D may specifically be the start address of the copy boot program area in the application 3, and the copy boot program area stores the address E, which is the start address of the boot program 2.
  • the processor of the embedded device 21 obtains the boot program 2 from the address E, and replaces the boot program 1 in the memory of the embedded device 21 with the boot program 2.
  • the processor of the embedded device 21 starts to execute from the start address of the boot program 2 which is the address A.
  • the boot program 2 can obtain the running address of the application 3 which is the address D.
  • the embedded device 21 The processor jumps directly from boot program 2 to address D and executes application program 3.
  • the processor of the embedded device 21 may delete the boot program 2 after the application program 3 during the execution of the application program 3, or may delete the boot program 2 after the application program 3 after replacing the boot program 1 with the boot program 2.
  • the first application currently stored in the memory of the embedded device is replaced with the second application and the second boot program in the firmware to be upgraded, and the second The start address of the second boot program is obtained from the application program.
  • the second boot program is obtained from the start address of the second boot program, the first boot program currently stored in the memory of the embedded device and the The second boot program, if the first boot program and the second boot program are the same, delete the second boot program after the second application program, to avoid that the processor of the embedded device runs the second application program every time, The second boot program after the second application program needs to be verified to improve the running speed of the embedded device.
  • FIG. 12 is a structural diagram of an embedded device provided by an embodiment of the present invention.
  • the embedded device 110 includes: a memory 111 and a processor 112.
  • the memory 111 stores a first boot program and a first application program;
  • the processor 112 is used to perform the following operations: obtain firmware to be upgraded, the firmware to be upgraded includes a second application program and a second boot program;
  • the processor 112 stores the memory 111
  • the first application program in is replaced with the second application program and the second boot program, the second application program stores a start address of the second boot program, the second boot program
  • the start address is at a first preset position after the second application program, and the second application program includes a header area;
  • the processor 112 obtains the start of the second boot program from the second application program Address and obtain the second boot program from the start address of the second boot program;
  • the processor 112 replaces the first boot program with the second boot program, the first boot program and all
  • the size of the header area is greater than or equal to the size
  • the second application program includes a first area; the first area stores a start address of the second boot program.
  • processor 112 obtains the start address of the second boot program from the second application program, it is specifically used to: obtain the first address from the first area of the second application program. The starting address of the bootloader.
  • the second application program further includes a second area, the second area stores the running address of the second application program, and the tail address of the second area is the start of the first area address.
  • the processor 112 when the processor 112 obtains the start address of the second boot program from the second application program, it is specifically used to: determine the start address of the first area according to the second area; Acquire the start address of the second boot program from the first area of the second application according to the start address of the first area.
  • the second application further includes a third area, where the third area stores a start address of the second area, and the third area is in the head of the second application within the area.
  • the processor 112 when the processor 112 obtains the start address of the second boot program from the second application program, it is specifically used to: obtain the start address of the second area from the third area; According to the start address of the second area, determine the start address of the first area; according to the start address of the first area, obtain the first address from the first area of the second application The starting address of the second bootloader.
  • the starting address of the third area is the starting address of the head area of the second application.
  • the starting address of the first area is the running address of the second application program.
  • the second area is within the head area of the second application.
  • the size of the storage space between the start address of the first boot program and the start address of the second area is greater than or equal to the size of the second boot program.
  • the starting address of the first area is at a second preset position after the running address of the second application program.
  • the second area is not within the head area of the second application.
  • the size of the storage space between the start address of the first boot program and the running address of the second application program is greater than or equal to the size of the second boot program.
  • the first area further includes the length of the second boot program; when the processor 112 acquires the second boot program from the start address of the second boot program, it is specifically used to: The length of the second boot program is obtained from the start address of the second boot program.
  • the processor 112 replaces the first boot program with the second boot program, it is also used to: execute the second boot program starting from the start address of the second boot program; When executing the second boot program, obtain the running address of the second application program; jump from the second boot program to the running address of the second application program, and execute the second application program.
  • the second boot program stores the start address of the second area; when the processor 112 executes the second boot program, when acquiring the running address of the second application program, it is specifically used : When executing the second boot program, obtain the running address of the second application program from the second area according to the start address of the second area.
  • the processor 112 jumps from the second boot program to the running address of the second application program, and when the second application program is executed, it is specifically used to: jump from the second boot program to Running address of the second application program, executing the second application program, and deleting the second boot program after the second application program.
  • processor 112 replaces the first boot program with the second boot program, it is also used to: delete the second boot program after the second application program.
  • the processor 112 when the processor 112 replaces the first boot program with the second boot program, it is specifically used to: compare the first boot program and the second boot program; if the first boot program Unlike the second boot program, the first boot program is replaced with the second boot program.
  • the processor 112 is further configured to: if the first boot program and the second boot program are the same, delete the second boot program after the second application program.
  • the embedded device 110 further includes: a communication interface 113; when the processor 112 acquires firmware to be upgraded, it is specifically used to: receive the firmware to be upgraded sent by the controller through the communication interface 113.
  • the second application program stores the starting address of the second boot program, according to The starting address of the second boot program is obtained, and the first boot program in the memory is replaced with the second boot program, thereby realizing the upgrade of the application program and the boot program.
  • the second application program includes a head area. When the size of the second boot program is larger than the size of the first boot program, the second boot program may occupy the head area of the second application program to prevent the second boot program from covering The effective execution code of the second application program makes the upgraded second application program run normally, so that the upgraded embedded device can run normally.
  • the embedded device 110 includes: a memory 111 and a processor 112; the memory 111 stores a first boot program and a first application program; the processor 112 is used to perform the following operations: obtain firmware to be upgraded, and the The firmware upgrade includes a second application program and a second boot program; replacing the first application program in the memory 111 with the second application program and the second boot program, the second application program storing the The start address of the second boot program, the start address of the second boot program is at a preset position after the second application program; the start of the second boot program is obtained from the second application program Address, and obtain the second boot program from the start address of the second boot program; compare the first boot program and the second boot program; when the first boot program and the second When the boot programs are the same, delete the second boot program after the second application program.
  • the processor 112 is further configured to: when the first boot program and the second boot program are different, replace the first boot program with the second boot program.
  • the first application currently stored in the memory of the embedded device is replaced with the second application and the second boot program in the firmware to be upgraded, and the second The start address of the second boot program is obtained from the application program.
  • the second boot program is obtained from the start address of the second boot program, the first boot program currently stored in the memory of the embedded device and the The second boot program, if the first boot program and the second boot program are the same, delete the second boot program after the second application program, to avoid that the processor of the embedded device runs the second application program every time, The second boot program after the second application program needs to be verified to improve the running speed of the embedded device.
  • this embodiment also provides a computer-readable storage medium on which a computer program is stored, which is executed by a processor to implement the program processing method described in the above embodiment.
  • the disclosed device and method may be implemented in other ways.
  • the device embodiments described above are only schematic.
  • the division of the units is only a division of logical functions.
  • there may be other divisions for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware, or in the form of hardware plus software functional units.
  • the above integrated unit implemented in the form of a software functional unit may be stored in a computer-readable storage medium.
  • the above software functional units are stored in a storage medium, and include several instructions to enable a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute the method described in each embodiment of the present invention Partial steps.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program code .

Abstract

Provided in embodiments of the present invention are an application processing method and apparatus and a storage medium. In the embodiment of the present invention, a first application in a storage device of an embedded apparatus is replaced with a second application and a second bootloader in an upgrade firmware. The second application stores a start address of the second bootloader. The second bootloader is acquired according to the start address of the second bootloader, and a first bootloader in the storage device is replaced with the second bootloader, thereby realizing upgrading of an application and a bootloader. The second application comprises a header region. If the size of the second bootloader is greater than the size of the first bootloader, the second bootloader can occupy the header region of the second application, such that the second bootloader does not overwrite an effective executable code of the second application, thereby enabling normal operation of the upgraded second application, and accordingly enabling normal operation of the upgraded embedded apparatus.

Description

程序处理方法、设备及存储介质Program processing method, device and storage medium 技术领域Technical field
本发明实施例涉及计算机领域,尤其涉及一种程序处理方法、设备及存储介质。The embodiments of the present invention relate to the field of computers, and in particular, to a program processing method, device, and storage medium.
背景技术Background technique
随着计算机技术的发展,嵌入式系统已经广泛应用在电子产品、工业设备等领域,为了便于产品维护,延长产品的使用时长以及扩展新的产品功能,需要对嵌入式系统进行升级,具体包括对引导程序和应用程序的升级。With the development of computer technology, embedded systems have been widely used in electronic products, industrial equipment and other fields. In order to facilitate product maintenance, prolong the use of products and expand new product functions, it is necessary to upgrade embedded systems, including specific Bootstrap and application upgrades.
嵌入式系统中的引导程序和应用程序通常存放在可读写的存储器件中,当前嵌入式系统的引导程序的大小固定,但是,随着产品功能的拓展或者引导程序可靠性的提高,原有的引导程序已经不能满足需求,需要对原有的引导程序进行扩容。The boot programs and application programs in embedded systems are usually stored in a readable and writable storage device. The size of the current boot program for embedded systems is fixed. However, with the expansion of product functions or the reliability of boot programs, the original The boot program of the software can no longer meet the demand, and the original boot program needs to be expanded.
现有技术,通常将应用程序存储在引导程序的后面,当新的引导程序的大小超出原有引导程序的大小时,将导致新的引导程序覆盖掉应用程序所占用的部分存储区域或全部存储区域,从而导致应用程序无法正常运行,最终导致嵌入式设备无法正常运行。In the prior art, the application program is usually stored after the boot program. When the size of the new boot program exceeds the size of the original boot program, it will cause the new boot program to overwrite part of the storage area or all the storage occupied by the application program. Area, which causes the application to fail to run properly, and ultimately the embedded device to fail to run normally.
发明内容Summary of the invention
本发明实施例提供一种程序处理方法、设备及存储介质,以实现嵌入式设备中应用程序和引导程序正常升级,避免引导程序覆盖到应用程序的有效执行代码,使得升级后的应用程序可以正常运行,从而使得升级后的嵌入式设备可以正常运行。Embodiments of the present invention provide a program processing method, device, and storage medium to implement normal upgrade of an application program and a boot program in an embedded device, so as to prevent the boot program from covering the effective execution code of the application program, so that the upgraded application program can be normal Run, so that the upgraded embedded device can run normally.
本发明实施例的第一方面是提供一种程序处理方法,应用于嵌入式设备,所述嵌入式设备的存储器存储有第一引导程序和第一应用程序;所述方法包括:A first aspect of an embodiment of the present invention is to provide a program processing method, which is applied to an embedded device, and a memory of the embedded device stores a first boot program and a first application program; the method includes:
获取待升级固件,所述待升级固件包括第二应用程序和第二引导程序;Obtain firmware to be upgraded, where the firmware to be upgraded includes a second application program and a second boot program;
将所述存储器中的所述第一应用程序替换为所述第二应用程序和所述第二引导程序,所述第二应用程序存储有所述第二引导程序的起始地址,所述第二引导程序的起始地址在所述第二应用程序之后的第一预设位置,所述第二应用程序包括头部区域;Replacing the first application program in the memory with the second application program and the second boot program, the second application program storing a start address of the second boot program, the first The start address of the second boot program is at a first preset position after the second application program, and the second application program includes a header area;
从所述第二应用程序中获取所述第二引导程序的起始地址,并从所述第二引导程序的起始地址开始获取所述第二引导程序;Acquiring the start address of the second boot program from the second application program, and acquiring the second boot program from the start address of the second boot program;
将所述第一引导程序替换为所述第二引导程序,所述第一引导程序和所述头部区域的大小大于或等于所述第二引导程序的大小。The first boot program is replaced with the second boot program, and the sizes of the first boot program and the head region are greater than or equal to the size of the second boot program.
本发明实施例的第二方面是提供一种程序处理方法,应用于嵌入式设备,所述嵌入式设备的存储器存储有第一引导程序和第一应用程序;所述方法包括:A second aspect of an embodiment of the present invention is to provide a program processing method, which is applied to an embedded device, and a memory of the embedded device stores a first boot program and a first application program; the method includes:
获取待升级固件,所述待升级固件包括第二应用程序和第二引导程序;Obtain firmware to be upgraded, where the firmware to be upgraded includes a second application program and a second boot program;
将所述存储器中的所述第一应用程序替换为所述第二应用程序和所述第二引导程序,所述第二应用程序存储有所述第二引导程序的起始地址,所述第二引导程序的起始地址在所述第二应用程序之后的预设位置;Replacing the first application program in the memory with the second application program and the second boot program, the second application program storing a start address of the second boot program, the first The start address of the second boot program is at a preset position after the second application program;
从所述第二应用程序中获取所述第二引导程序的起始地址,并从所述第二引导程序的起始地址开始获取所述第二引导程序;Acquiring the start address of the second boot program from the second application program, and acquiring the second boot program from the start address of the second boot program;
比较所述第一引导程序和所述第二引导程序;Comparing the first boot program and the second boot program;
如果所述第一引导程序和所述第二引导程序相同,则删除所述第二应用程序之后的所述第二引导程序。If the first boot program and the second boot program are the same, delete the second boot program after the second application program.
本发明实施例的第三方面是提供一种嵌入式设备,包括:存储器和处理器;A third aspect of the embodiments of the present invention is to provide an embedded device, including: a memory and a processor;
所述存储器存储有第一引导程序和第一应用程序;The memory stores a first boot program and a first application program;
所述处理器用于执行以下操作:The processor is used to perform the following operations:
获取待升级固件,所述待升级固件包括第二应用程序和第二引导程序;Obtain firmware to be upgraded, where the firmware to be upgraded includes a second application program and a second boot program;
将所述存储器中的所述第一应用程序替换为所述第二应用程序和所述第二引导程序,所述第二应用程序存储有所述第二引导程序的起始地址,所述第二引导程序的起始地址在所述第二应用程序之后的第一预设位置,所述第二应用程序包括头部区域;Replacing the first application program in the memory with the second application program and the second boot program, the second application program storing a start address of the second boot program, the first The start address of the second boot program is at a first preset position after the second application program, and the second application program includes a header area;
从所述第二应用程序中获取所述第二引导程序的起始地址,并从所述 第二引导程序的起始地址开始获取所述第二引导程序;Acquiring the start address of the second boot program from the second application program, and acquiring the second boot program from the start address of the second boot program;
将所述第一引导程序替换为所述第二引导程序,所述第一引导程序和所述头部区域的大小大于或等于所述第二引导程序的大小。The first boot program is replaced with the second boot program, and the sizes of the first boot program and the head region are greater than or equal to the size of the second boot program.
本发明实施例的第四方面是提供一种嵌入式设备,包括:存储器和处理器;A fourth aspect of the embodiments of the present invention is to provide an embedded device, including: a memory and a processor;
所述存储器存储有第一引导程序和第一应用程序;The memory stores a first boot program and a first application program;
所述处理器用于执行以下操作:The processor is used to perform the following operations:
获取待升级固件,所述待升级固件包括第二应用程序和第二引导程序;Obtain firmware to be upgraded, where the firmware to be upgraded includes a second application program and a second boot program;
将所述存储器中的所述第一应用程序替换为所述第二应用程序和所述第二引导程序,所述第二应用程序存储有所述第二引导程序的起始地址,所述第二引导程序的起始地址在所述第二应用程序之后的预设位置;Replacing the first application program in the memory with the second application program and the second boot program, the second application program storing a start address of the second boot program, the first The start address of the second boot program is at a preset position after the second application program;
从所述第二应用程序中获取所述第二引导程序的起始地址,并从所述第二引导程序的起始地址开始获取所述第二引导程序;Acquiring the start address of the second boot program from the second application program, and acquiring the second boot program from the start address of the second boot program;
比较所述第一引导程序和所述第二引导程序;Comparing the first boot program and the second boot program;
当所述第一引导程序和所述第二引导程序相同时,删除所述第二应用程序之后的所述第二引导程序。When the first boot program and the second boot program are the same, delete the second boot program after the second application program.
本发明实施例的第五方面是提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行以实现如第一方面所述的方法。A fifth aspect of the embodiments of the present invention is to provide a computer-readable storage medium on which a computer program is stored, which is executed by a processor to implement the method according to the first aspect.
本实施例提供的程序处理方法、设备及存储介质,通过将嵌入式设备的存储器中的第一应用程序替换为待升级固件中的第二应用程序和第二引导程序,该第二应用程序存储有第二引导程序的起始地址,根据该第二引导程序的起始地址,获取该第二引导程序,并将该存储器中的第一引导程序替换为该第二引导程序,实现了应用程序和引导程序的升级。第二应用程序包括头部区域,当第二引导程序的大小大于第一引导程序的大小时,该第二引导程序可占用该第二应用程序的头部区域,避免该第二引导程序覆盖到第二应用程序的有效执行代码,使得升级后的第二应用程序可以正常运行,从而使得升级后的嵌入式设备可以正常运行。In the program processing method, device and storage medium provided in this embodiment, by replacing the first application program in the memory of the embedded device with the second application program and the second boot program in the firmware to be upgraded, the second application program stores There is a start address of the second boot program, according to the start address of the second boot program, the second boot program is obtained, and the first boot program in the memory is replaced with the second boot program to implement the application program And bootloader upgrade. The second application program includes a head area. When the size of the second boot program is larger than the size of the first boot program, the second boot program may occupy the head area of the second application program to prevent the second boot program from being overwritten. The effective execution code of the second application program makes the upgraded second application program run normally, so that the upgraded embedded device can run normally.
附图说明BRIEF DESCRIPTION
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly explain the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required in the description of the embodiments. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without paying any creative labor, other drawings can also be obtained based on these drawings.
图1为本发明实施例提供的嵌入式设备和控制器的示意图;1 is a schematic diagram of an embedded device and a controller provided by an embodiment of the present invention;
图2为本发明实施例提供的程序处理方法的流程图;2 is a flowchart of a program processing method provided by an embodiment of the present invention;
图3为本发明实施例提供的嵌入式设备的存储器的示意图;3 is a schematic diagram of a memory of an embedded device provided by an embodiment of the present invention;
图4为本发明实施例提供的嵌入式设备的存储器的示意图;4 is a schematic diagram of a memory of an embedded device provided by an embodiment of the present invention;
图5为本发明实施例提供的嵌入式设备的存储器的示意图;5 is a schematic diagram of a memory of an embedded device provided by an embodiment of the present invention;
图6为本发明实施例提供的嵌入式设备的存储器的示意图;6 is a schematic diagram of a memory of an embedded device provided by an embodiment of the present invention;
图7为本发明实施例提供的嵌入式设备的存储器的示意图;7 is a schematic diagram of a memory of an embedded device provided by an embodiment of the present invention;
图8为本发明另一实施例提供的程序处理方法的流程图;8 is a flowchart of a program processing method according to another embodiment of the present invention;
图9为本发明另一实施例提供的程序处理方法的流程图;9 is a flowchart of a program processing method according to another embodiment of the present invention;
图10为本发明实施例提供的嵌入式设备的存储器的示意图;10 is a schematic diagram of a memory of an embedded device provided by an embodiment of the present invention;
图11为本发明实施例提供的嵌入式设备的存储器的示意图;11 is a schematic diagram of a memory of an embedded device provided by an embodiment of the present invention;
图12为本发明实施例提供的嵌入式设备的结构图。12 is a structural diagram of an embedded device provided by an embodiment of the present invention.
附图标记:Reference mark:
21:嵌入式设备;22:控制器;31:待升级固件;21: Embedded device; 22: Controller; 31: Firmware to be upgraded;
110:嵌入式设备;111:存储器;112:处理器;110: embedded device; 111: memory; 112: processor;
113:通讯接口。113: Communication interface.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be described clearly below with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by a person of ordinary skill in the art without making creative efforts fall within the protection scope of the present invention.
需要说明的是,当组件被称为“固定于”另一个组件,它可以直接在另一个组件上或者也可以存在居中的组件。当一个组件被认为是“连接”另一个组件,它可以是直接连接到另一个组件或者可能同时存在居中组件。It should be noted that when a component is said to be "fixed" to another component, it can be directly on another component or it can also exist in a centered component. When a component is considered to be "connected" to another component, it can be directly connected to another component or there can be centered components at the same time.
除非另有定义,本文所使用的所有的技术和科学术语与属于本发明的 技术领域的技术人员通常理解的含义相同。本文中在本发明的说明书中所使用的术语只是为了描述具体的实施例的目的,不是旨在于限制本发明。本文所使用的术语“及/或”包括一个或多个相关的所列项目的任意的和所有的组合。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field of the present invention. The terminology used in the description of the present invention herein is for the purpose of describing specific embodiments, and is not intended to limit the present invention. The term "and/or" as used herein includes any and all combinations of one or more related listed items.
下面结合附图,对本发明的一些实施方式作详细说明。在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。The following describes some embodiments of the present invention in detail with reference to the accompanying drawings. In the case of no conflict, the following embodiments and the features in the embodiments can be combined with each other.
本发明实施例提供一种程序处理方法。该程序处理方法应用于嵌入式设备。如图1所示,嵌入式设备21包括处理器、存储器和收发器。控制器22包括处理器、收发器和网络适配器。控制器22具体可以是计算机、平板电脑等。An embodiment of the present invention provides a program processing method. The program processing method is applied to embedded devices. As shown in FIG. 1, the embedded device 21 includes a processor, a memory, and a transceiver. The controller 22 includes a processor, a transceiver, and a network adapter. The controller 22 may specifically be a computer, a tablet computer, or the like.
图2为本发明实施例提供的程序处理方法的流程图。如图2所示,本实施例中的方法,可以包括:2 is a flowchart of a program processing method provided by an embodiment of the present invention. As shown in FIG. 2, the method in this embodiment may include:
步骤S201、获取待升级固件,所述待升级固件包括第二应用程序和第二引导程序。Step S201: Obtain firmware to be upgraded, where the firmware to be upgraded includes a second application program and a second boot program.
在本实施例中,所述嵌入式设备的存储器存储有第一引导程序和第一应用程序。该第一引导程序记为该嵌入式设备的旧引导程序,该第一应用程序记为该嵌入式设备的旧应用程序。所述嵌入式设备需要对该旧引导程序和/或该旧引导程序进行升级时,所述嵌入式设备获取待升级固件,该待升级固件可以包括新的应用程序和新的引导程序,或者,该待升级固件可以只包括新的应用程序,此处,将新的应用程序记为第二应用程序,将新的引导程序记为第二引导程序。In this embodiment, the memory of the embedded device stores a first boot program and a first application program. The first boot program is recorded as the old boot program of the embedded device, and the first application program is recorded as the old application program of the embedded device. When the embedded device needs to upgrade the old boot program and/or the old boot program, the embedded device obtains firmware to be upgraded, and the firmware to be upgraded may include a new application program and a new boot program, or, The firmware to be upgraded may include only a new application program. Here, the new application program is recorded as the second application program, and the new boot program is recorded as the second boot program.
在本实施例中,所述获取待升级固件,包括:接收控制器发送的所述待升级固件。如图1所示,控制器22可通过网络适配器与服务器通信,该服务器将待升级固件发送给控制器22,控制器22的处理器通过控制器22的收发器将该待升级固件发送给嵌入式设备21,嵌入式设备21的处理器通过嵌入式设备21的收发器接收该待升级固件,该待升级固件具体可以是新的应用程序和新的引导程序的合成文件,或者,该待升级固件具体可以是新的应用程序。In this embodiment, the acquiring firmware to be upgraded includes receiving the firmware to be upgraded sent by a controller. As shown in FIG. 1, the controller 22 can communicate with a server through a network adapter, and the server sends the firmware to be upgraded to the controller 22, and the processor of the controller 22 sends the firmware to be upgraded to the embedded through the transceiver of the controller 22 Device 21, the processor of the embedded device 21 receives the firmware to be upgraded through the transceiver of the embedded device 21, and the firmware to be upgraded may specifically be a composite file of a new application program and a new boot program, or, the to-be-upgraded The firmware may specifically be a new application program.
在一些实施例中,控制器22可以不包括网络适配器,也就是说,控 制器22可以生成该待升级固件,并将其生成的该待升级固件通过收发器发送给嵌入式设备21。In some embodiments, the controller 22 may not include a network adapter, that is, the controller 22 may generate the firmware to be upgraded, and send the generated firmware to be upgraded to the embedded device 21 through the transceiver.
在另外一些实施例中,嵌入式设备21可包括网络适配器,嵌入式设备21通过该网络适配器从服务器获取待升级固件,而不需接收控制器22发送的待升级固件。In some other embodiments, the embedded device 21 may include a network adapter through which the embedded device 21 obtains the firmware to be upgraded from the server without receiving the firmware to be upgraded sent by the controller 22.
步骤S202、将所述存储器中的所述第一应用程序替换为所述第二应用程序和所述第二引导程序,所述第二应用程序存储有所述第二引导程序的起始地址,所述第二引导程序的起始地址在所述第二应用程序之后的第一预设位置,所述第二应用程序包括头部区域。Step S202: Replace the first application program in the memory with the second application program and the second boot program, where the second application program stores a start address of the second boot program, The start address of the second boot program is at a first preset position after the second application program, and the second application program includes a header area.
图3或图4所示为嵌入式设备21的存储器,嵌入式设备21的存储器当前存储有引导程序1和应用程序1。引导程序1记为第一引导程序,应用程序1记为第一应用程序,引导程序1的起始地址为地址A,应用程序1在引导程序1之后,应用程序1的起始地址为地址B,引导程序1的程序尾端包括跳转执行代码区,该跳转执行代码区的作用是直接跳转到应用程序1固定的运行地址即应用程序1的起始地址。FIG. 3 or FIG. 4 shows the memory of the embedded device 21. The memory of the embedded device 21 currently stores the boot program 1 and the application program 1. Boot program 1 is denoted as the first boot program, application program 1 is denoted as the first application program, the start address of boot program 1 is address A, application program 1 is after boot program 1, and the start address of application program 1 is address B , The program tail of the boot program 1 includes a jump execution code area, and the role of the jump execution code area is to directly jump to the fixed running address of the application program 1, that is, the start address of the application program 1.
如图3或图4所示,31表示嵌入式设备21从控制器22接收到的待升级固件,该待升级固件31包括应用程序2和引导程序2,其中,应用程序2记为第二应用程序,引导程序2记为第二引导程序。当嵌入式设备21的处理器接收到控制器22发送的待升级固件后,将该待升级固件写入嵌入式设备21的存储器中,具体的,嵌入式设备21的处理器将嵌入式设备21的存储器中存储的应用程序1替换为该待升级固件,也就是,将嵌入式设备21的存储器中存储的应用程序1替换为应用程序2和引导程序2。嵌入式设备21重新上电后,嵌入式设备21的处理器从引导程序1的起始地址即地址A开始执行,执行到该引导程序1的跳转执行代码区时,跳转到应用程序2的起始地址即地址B。As shown in FIG. 3 or FIG. 4, 31 represents the firmware to be upgraded received by the embedded device 21 from the controller 22, and the firmware to be upgraded 31 includes an application program 2 and a boot program 2, where the application program 2 is recorded as the second application Program, boot program 2 is denoted as the second boot program. After the processor of the embedded device 21 receives the firmware to be upgraded sent by the controller 22, the firmware to be upgraded is written into the memory of the embedded device 21. Specifically, the processor of the embedded device 21 transfers the embedded device 21 The application program 1 stored in the memory of is replaced with the firmware to be upgraded, that is, the application program 1 stored in the memory of the embedded device 21 is replaced with the application program 2 and the boot program 2. After the embedded device 21 is powered on again, the processor of the embedded device 21 starts to execute from the start address of the boot program 1, that is, address A, and when it reaches the jump execution code area of the boot program 1, jumps to the application program 2 The starting address is the address B.
如图3或图4所示,引导程序2的起始地址为地址E,引导程序2的起始地址在应用程序2的尾部地址之后的预设位置,该预设位置记为第一预设位置。应用程序2与应用程序1的起始地址相同,都是地址B。引导程序2的起始地址即地址E相对于地址B的长度为y。应用程序2与应用程序1不同之处在于,应用程序2包括头部区域,应用程序2的运行地址 是地址D,也就是说,应用程序2的有效执行代码从地址D开始,从应用程序2的起始地址B开始到应用程序2的运行地址D之间的部分是应用程序2的头部区域。As shown in FIG. 3 or FIG. 4, the start address of the boot program 2 is the address E, and the start address of the boot program 2 is a preset position after the tail address of the application 2, and the preset position is recorded as the first preset position. The start address of application 2 and application 1 are the same, both are address B. The start address of the boot program 2, ie, the length of address E relative to address B is y. The difference between application 2 and application 1 is that application 2 includes a header area, and the running address of application 2 is address D, that is, the effective execution code of application 2 starts from address D and starts from application 2 The part from the start address B of the application to the running address D of the application 2 is the header area of the application 2.
在本实施例中,应用程序2存储有引导程序2的起始地址,也就是地址E。In this embodiment, the application program 2 stores the start address of the boot program 2, that is, the address E.
步骤S203、从所述第二应用程序中获取所述第二引导程序的起始地址,并从所述第二引导程序的起始地址开始获取所述第二引导程序。Step S203: Acquire the start address of the second boot program from the second application program, and acquire the second boot program from the start address of the second boot program.
嵌入式设备21的处理器将应用程序1替换为应用程序2和引导程序2之后,从该应用程序2中获取引导程序2的起始地址即地址E,并从该引导程序2的起始地址即地址E开始获取该引导程序2。After the processor of the embedded device 21 replaces the application program 1 with the application program 2 and the boot program 2, the start address of the boot program 2 is obtained from the application program 2 as the address E, and from the boot program 2 That is, the address E starts to acquire the boot program 2.
在本实施例中,从所述第二应用程序中获取所述第二引导程序的起始地址,包括如下几种可行的实现方式:In this embodiment, obtaining the start address of the second boot program from the second application program includes the following feasible implementation manners:
一种可行的实现方式是:所述第二应用程序包括第一区域;所述第一区域存储有所述第二引导程序的起始地址。所述从所述第二应用程序中获取所述第二引导程序的起始地址,包括:从所述第二应用程序的所述第一区域中获取所述第二引导程序的起始地址。A feasible implementation manner is that: the second application program includes a first area; and the first area stores a start address of the second boot program. The acquiring the start address of the second boot program from the second application includes: acquiring the start address of the second boot program from the first area of the second application.
如图5所示,应用程序2包括第一区域,该第一区域记为拷贝引导程序区,拷贝引导程序区中存储有引导程序2的起始地址即地址E。嵌入式设备21的处理器从引导程序1执行到应用程序2时,从该应用程序2的该拷贝引导程序区中读取引导程序2的起始地址即地址E。As shown in FIG. 5, the application program 2 includes a first area, which is referred to as a copy boot program area, and an address E, which is a start address of the boot program 2, is stored in the copy boot program area. When the processor of the embedded device 21 executes from the boot program 1 to the application program 2, it reads the address E, which is the start address of the boot program 2, from the copy boot program area of the application program 2.
另一种可行的实现方式是:所述第二应用程序还包括第二区域,所述第二区域存储有所述第二应用程序的运行地址,所述第二区域的尾部地址为所述第一区域的起始地址。所述从所述第二应用程序中获取所述第二引导程序的起始地址,包括:根据所述第二区域,确定所述第一区域的起始地址;根据所述第一区域的起始地址,从所述第二应用程序的所述第一区域中获取所述第二引导程序的起始地址。Another feasible implementation manner is that: the second application further includes a second area, the second area stores the running address of the second application, and the tail address of the second area is the first The starting address of an area. The acquiring the start address of the second boot program from the second application includes: determining the start address of the first area according to the second area; and according to the start of the first area Start address, the start address of the second boot program is obtained from the first area of the second application program.
如图5所示,应用程序2还可以包括第二区域,该第二区域记为运行地址存储区,运行地址存储区的起始地址为地址C。可选的,地址C相对于地址B的距离为x。该运行地址存储区存储有应用程序2的运行地址即地址D。拷贝引导程序区在运行地址存储区的后面,可选的,运行地址存 储区的尾部地址为拷贝引导程序区的起始地址。嵌入式设备21的处理器从引导程序1执行到应用程序2时,根据运行地址存储区,确定出运行地址存储区后的拷贝引导程序区,并根据拷贝引导程序区的起始地址,从该拷贝引导程序区中读取引导程序2的起始地址即地址E。As shown in FIG. 5, the application program 2 may further include a second area, which is referred to as a running address storage area, and the starting address of the running address storage area is address C. Optionally, the distance between address C and address B is x. The running address storage area stores an address D which is the running address of the application 2. The copy boot program area is behind the run address storage area. Optionally, the tail address of the run address storage area is the start address of the copy boot program area. When the processor of the embedded device 21 executes from the boot program 1 to the application program 2, the copy boot program area after the run address storage area is determined according to the run address storage area, and from the start address of the copy boot program area, from The start address of the boot program 2 in the copy boot program area is the address E.
再一种可行的实现方式是:所述第二应用程序还包括第三区域,所述第三区域存储有所述第二区域的起始地址,所述第三区域在所述第二应用程序的所述头部区域内。所述从所述第二应用程序中获取所述第二引导程序的起始地址,包括:从所述第三区域中获取所述第二区域的起始地址;根据所述第二区域的起始地址,确定所述第一区域的起始地址;根据所述第一区域的起始地址,从所述第二应用程序的所述第一区域中获取所述第二引导程序的起始地址。Another feasible implementation manner is: the second application further includes a third area, the third area stores a start address of the second area, and the third area is in the second application Within the head area. The acquiring the start address of the second boot program from the second application includes: acquiring the start address of the second area from the third area; starting from the second area Start address, determine the start address of the first area; according to the start address of the first area, obtain the start address of the second boot program from the first area of the second application .
如图5所示,应用程序2还可以进一步包括第三区域,该第三区域记为跳转执行代码区,应用程序2中的跳转执行代码区和上述引导程序1中的跳转执行代码区的不同之处在于,上述引导程序1中的跳转执行代码区是为了跳转到应用程序2的起始地址即地址B,而应用程序2中的跳转执行代码区是为了跳转到应用程序2的运行地址存储区或拷贝引导程序区。可选的,应用程序2中的跳转执行代码区存储有应用程序2的运行地址存储区的起始地址。应用程序2中的跳转执行代码区在该应用程序2的头部区域内。嵌入式设备21的处理器从引导程序1执行到应用程序2时,从应用程序2中的跳转执行代码区跳转到运行地址存储区,根据运行地址存储区,确定出运行地址存储区后的拷贝引导程序区,并根据拷贝引导程序区的起始地址,从该拷贝引导程序区中读取引导程序2的起始地址即地址E。As shown in FIG. 5, the application 2 may further include a third area, which is referred to as a jump execution code area, a jump execution code area in the application 2 and a jump execution code in the boot program 1 described above The difference of the area is that the jump execution code area in the above boot program 1 is for jumping to the start address of the application 2, namely the address B, and the jump execution code area in the application 2 is for jumping to Application program 2 running address storage area or copy boot program area. Optionally, the jump execution code area in the application program 2 stores the start address of the running address storage area of the application program 2. The jump execution code area in the application 2 is in the head area of the application 2. When the processor of the embedded device 21 executes from the boot program 1 to the application program 2, it jumps from the jump execution code area in the application program 2 to the run address storage area, and determines the run address storage area according to the run address storage area Copy the boot program area, and read the start address of the boot program 2, namely the address E, from the copy boot program area according to the start address of the copy boot program area.
又一种可行的实现方式是:所述第二应用程序还包括第三区域,所述第三区域存储有所述第一区域的起始地址,所述第三区域在所述所述第二应用程序的所述头部区域内。所述从所述第二应用程序中获取所述第二引导程序的起始地址,包括:从所述第三区域中获取所述第一区域的起始地址;根据所述第一区域的起始地址,从所述第二应用程序的所述第一区域中获取所述第二引导程序的起始地址。Another feasible implementation manner is: the second application program further includes a third area, the third area stores a start address of the first area, and the third area is in the second Within the head area of the application. The acquiring the start address of the second boot program from the second application includes: acquiring the start address of the first area from the third area; according to the start of the first area Start address, the start address of the second boot program is obtained from the first area of the second application program.
如图5所示,应用程序2中的跳转执行代码区存储有应用程序2的拷 贝引导程序区的起始地址。嵌入式设备21的处理器从引导程序1执行到应用程序2时,从应用程序2中的跳转执行代码区跳转到拷贝引导程序区的起始地址,并根据拷贝引导程序区的起始地址,从该拷贝引导程序区中读取引导程序2的起始地址即地址E。As shown in FIG. 5, the jump execution code area in the application 2 stores the start address of the copy boot area of the application 2. When the processor of the embedded device 21 executes from the boot program 1 to the application program 2, the jump execution code area in the application program 2 jumps to the start address of the copy boot program area, and according to the start of the copy boot program area Address, read the address E, which is the start address of the boot program 2, from the copy boot program area.
在一些实施例中,所述第三区域的起始地址为所述第二应用程序的所述头部区域的起始地址。如图5所示,应用程序2中的跳转执行代码区的起始地址为应用程序2的头部区域的起始地址即地址B。In some embodiments, the starting address of the third area is the starting address of the head area of the second application. As shown in FIG. 5, the start address of the jump execution code area in the application 2 is the address B which is the start address of the head area of the application 2.
可选的,当嵌入式设备21的处理器按照上述任一种方式获取到引导程序2的起始地址即地址E后,从该引导程序2的起始地址即地址E开始获取该引导程序2。Optionally, after the processor of the embedded device 21 obtains the start address of the boot program 2 as the address E according to any of the above methods, the boot program 2 is acquired from the start address of the boot program 2 as the address E .
在其中一些实施例中,所述第一区域还包括所述第二引导程序的长度;所述从所述第二引导程序的起始地址开始获取所述第二引导程序,包括:根据所述第二引导程序的长度,从所述第二引导程序的起始地址开始获取所述第二引导程序。例如,嵌入式设备21的拷贝引导程序区可以同时存储有引导程序2的起始地址和引导程序2的长度,当嵌入式设备21的处理器按照上述任一种方法读取到引导程序2的起始地址即地址E后,根据该引导程序2的长度,从该引导程序2的起始地址即地址E开始获取该引导程序2,可以理解,嵌入式设备21的处理器根据引导程序2的起始地址即地址E和该引导程序2的长度,可确定出引导程序2的尾部地址,该尾部地址即为该嵌入式设备21的处理器停止获取该引导程序2的位置。In some of these embodiments, the first area further includes the length of the second boot program; the acquiring the second boot program from the start address of the second boot program includes: according to the The length of the second boot program is obtained from the start address of the second boot program. For example, the copy boot program area of the embedded device 21 may store both the start address of the boot program 2 and the length of the boot program 2, when the processor of the embedded device 21 reads the boot program 2 according to any of the above methods After the starting address is address E, the boot program 2 is obtained from the boot address 2 starting address E according to the length of the boot program 2. It can be understood that the processor of the embedded device 21 according to the boot program 2 The starting address is the address E and the length of the boot program 2, and the tail address of the boot program 2 can be determined. The tail address is the position where the processor of the embedded device 21 stops acquiring the boot program 2.
步骤S204、将所述第一引导程序替换为所述第二引导程序,所述第一引导程序和所述头部区域的大小大于或等于所述第二引导程序的大小。Step S204: Replace the first boot program with the second boot program, and the sizes of the first boot program and the head area are greater than or equal to the size of the second boot program.
当嵌入式设备21的处理器获取到引导程序2后,将嵌入式设备21的存储器中原有的引导程序1替换为引导程序2,也就是说,用引导程序2来覆盖引导程序1。After the processor of the embedded device 21 obtains the boot program 2, the original boot program 1 in the memory of the embedded device 21 is replaced with the boot program 2, that is, the boot program 1 is overwritten with the boot program 2.
在本实施例中,引导程序2和引导程序1的大小可能不同,引导程序2的大小可能大于引导程序1的大小,也有可能小于引导程序1的大小。本实施例以引导程序2的大小大于引导程序1的大小为例。In this embodiment, the size of the boot program 2 and the boot program 1 may be different, and the size of the boot program 2 may be larger than the boot program 1 or may be smaller than the boot program 1. In this embodiment, the size of the boot program 2 is larger than that of the boot program 1 as an example.
由于引导程序2的大小大于引导程序1的大小,所以,当嵌入式设备21的处理器用引导程序2来覆盖引导程序1时,将导致引导程序2会占用 到应用程序2的头部区域,在本实施例中,引导程序1的大小和应用程序2的头部区域的大小之和大于或等于引导程序2的大小。如图5所示,假设引导程序2的大小比引导程序1的大小大x,则将引导程序2覆盖掉引导程序1后,引导程序2将占用掉应用程序2的头部区域中大小为x的区域。在本实施例中,x小于或等于应用程序2的头部区域的大小,如此可以保证引导程序2不会覆盖掉应用程序2的有效执行代码,从而影响应用程序2的正常运行。例如,x小于应用程序2的头部区域的大小,则将引导程序2覆盖掉引导程序1后,将导致应用程序2的头部区域变小,例如,由从地址B到地址D的区域变为从地址C到地址D的区域。本实施例不限定从地址B到地址C的区域大小和从地址C到地址D的区域大小之间的关系。Since the size of the boot program 2 is larger than the size of the boot program 1, when the processor of the embedded device 21 overwrites the boot program 1 with the boot program 2, the boot program 2 will occupy the head area of the application 2, in In this embodiment, the sum of the size of the boot program 1 and the size of the head area of the application 2 is greater than or equal to the size of the boot program 2. As shown in FIG. 5, assuming that the size of the boot program 2 is larger than the size of the boot program 1 by x, after the boot program 2 is overwritten by the boot program 1, the boot program 2 will occupy the size of the head area of the app 2 as x Area. In this embodiment, x is less than or equal to the size of the head area of the application 2, so that the boot program 2 will not overwrite the effective execution code of the application 2, thereby affecting the normal operation of the application 2. For example, if x is smaller than the size of the head area of the application 2, after the boot program 2 is overwritten, the head area of the application 2 becomes smaller, for example, the area from address B to address D becomes It is the area from address C to address D. This embodiment does not limit the relationship between the size of the area from address B to address C and the size of the area from address C to address D.
在一些实施例中,所述第一区域的起始地址为所述第二应用程序的运行地址。所述第二区域在所述第二应用程序的所述头部区域内。所述第一引导程序的起始地址与所述第二区域的起始地址之间的存储空间大小大于或等于所述第二引导程序的大小。In some embodiments, the starting address of the first area is the running address of the second application program. The second area is within the head area of the second application. The size of the storage space between the start address of the first boot program and the start address of the second area is greater than or equal to the size of the second boot program.
如图5和图6所示,应用程序2的拷贝引导程序区的起始地址为应用程序2的运行地址即地址D。应用程序2的运行地址存储区在该应用程序2的头部区域内。在这种情况下,如果引导程序2的大小大于引导程序1的大小,则该引导程序2可以占用应用程序2的部分头部区域或整个头部区域,具体的,引导程序2可以不占用该头部区域中的运行地址存储区,也可以占用该运行地址存储区。如图5所示,当引导程序2不占用该头部区域中的运行地址存储区时,从引导程序1的起始地址即地址A到运行地址存储区的起始地址即地址C之间的存储空间大小需大于或等于引导程序2的大小。如图6所示,当引导程序2可以占用该头部区域中的运行地址存储区时,从引导程序1的起始地址即地址A到引导程序2的运行地址即地址D之间的存储空间大小需大于或等于引导程序2的大小。As shown in FIGS. 5 and 6, the start address of the copy boot program area of the application 2 is the address D which is the running address of the application 2. The running address storage area of the application 2 is in the header area of the application 2. In this case, if the size of the boot program 2 is larger than the size of the boot program 1, the boot program 2 may occupy part of the head area or the entire head area of the application program 2, specifically, the boot program 2 may not occupy the The running address storage area in the header area can also occupy the running address storage area. As shown in FIG. 5, when the boot program 2 does not occupy the running address storage area in the header area, from the start address of the boot program 1 which is address A to the start address of the running address storage area which is address C The size of the storage space must be greater than or equal to the size of the boot program 2. As shown in FIG. 6, when the boot program 2 can occupy the running address storage area in the header area, the storage space from the boot address of the boot program 1 to the address A to the boot address of the boot program 2 is the storage space The size must be greater than or equal to the size of bootloader 2.
在另外一些实施例中,所述第一区域的起始地址在所述第二应用程序的运行地址之后的第二预设位置。所述第二区域不在所述第二应用程序的所述头部区域内。所述第一引导程序的起始地址与所述第二应用程序的运行地址之间的存储空间大小大于或等于所述第二引导程序的大小。In some other embodiments, the starting address of the first area is at a second preset position after the running address of the second application program. The second area is not within the head area of the second application. The size of the storage space between the start address of the first boot program and the running address of the second application program is greater than or equal to the size of the second boot program.
如图7所示,应用程序2的拷贝引导程序区的起始地址在应用程序2的运行地址即地址D之后的预设位置,该预设位置记为第二预设位置,本实施例不限定从地址D到拷贝引导程序区的起始地址的距离。应用程序2的运行地址存储区不在应用程序2的头部区域内。在这种情况下,从引导程序1的起始地址即地址A到应用程序2的运行地址即地址D之间的存储空间大小需大于或等于引导程序2的大小,也就是说,引导程序2最多可占用掉应用程序2的头部区域,引导程序2大小的最大值是引导程序1的大小和应用程序2的头部区域大小之和。As shown in FIG. 7, the start address of the copy boot program area of the application 2 is a preset position after the address D, which is the running address of the application 2, and the preset position is recorded as the second preset position. Limit the distance from address D to the start address of the copy boot program area. The running address storage area of the application 2 is not in the header area of the application 2. In this case, the size of the storage space from the start address of the boot program 1 (address A) to the running address of the application program 2 (address D) must be greater than or equal to the size of the boot program 2, that is, the boot program 2 The head area of the application 2 can be occupied at most. The maximum value of the size of the boot program 2 is the sum of the size of the boot program 1 and the size of the head area of the application 2.
在一些实施例中,所述处理器将所述第一引导程序替换为所述第二引导程序,包括:比较所述第一引导程序和所述第二引导程序;若所述第一引导程序和所述第二引导程序不同,则将所述第一引导程序替换为所述第二引导程序。若所述第一引导程序和所述第二引导程序相同,则删除所述第二应用程序之后的所述第二引导程序。In some embodiments, the processor replacing the first boot program with the second boot program includes: comparing the first boot program and the second boot program; if the first boot program Unlike the second boot program, the first boot program is replaced with the second boot program. If the first boot program and the second boot program are the same, delete the second boot program after the second application program.
例如,当嵌入式设备21的处理器获取到引导程序2的起始地址即地址E,从该引导程序2的起始地址即地址E开始获取该引导程序2,并比较引导程序2和嵌入式设备21的存储器中原有的引导程序1,如果引导程序1和引导程序2不同,则将引导程序1替换为引导程序2,如果引导程序1和引导程序2相同,则删除应用程序2之后的引导程序2。For example, when the processor of the embedded device 21 obtains the start address of the boot program 2 as the address E, the boot program 2 is acquired from the start address of the boot program 2 as the address E, and the boot program 2 and the embedded program are compared. The original boot program 1 in the memory of the device 21, if boot program 1 and boot program 2 are different, replace boot program 1 with boot program 2, if boot program 1 and boot program 2 are the same, delete boot after application program 2 Procedure 2.
在一些实施例中,所述将所述第一引导程序替换为所述第二引导程序之后,所述方法还包括:删除所述第二应用程序之后的所述第二引导程序。In some embodiments, after the first boot program is replaced with the second boot program, the method further includes: deleting the second boot program after the second application program.
例如,引导程序1和引导程序2不同,嵌入式设备21的处理器将引导程序1替换为引导程序2后,可进一步删除应用程序2之后的引导程序2。For example, boot program 1 and boot program 2 are different. After the processor of embedded device 21 replaces boot program 1 with boot program 2, boot program 2 after application program 2 may be further deleted.
在本实施例中,应用程序2的头部区域的大小可以根据引导程序1和引导程序2的大小确定,例如,当生成待升级固件时,可根据引导程序1和引导程序2的大小确定应用程序2的头部区域的大小。In this embodiment, the size of the head area of the application 2 can be determined according to the sizes of the boot program 1 and the boot program 2, for example, when generating firmware to be upgraded, the application can be determined according to the sizes of the boot program 1 and the boot program 2 The size of the header area of program 2.
另外,本实施例同样适用于缩小引导程序的场景,而不仅仅是扩大引导程序。In addition, this embodiment is also applicable to the scenario of shrinking the boot program, not just expanding the boot program.
本实施例通过将嵌入式设备的存储器中的第一应用程序替换为待升级固件中的第二应用程序和第二引导程序,该第二应用程序存储有第二引 导程序的起始地址,根据该第二引导程序的起始地址,获取该第二引导程序,并将该存储器中的第一引导程序替换为该第二引导程序,实现了应用程序和引导程序的升级。第二应用程序包括头部区域,当第二引导程序的大小大于第一引导程序的大小时,该第二引导程序可占用该第二应用程序的头部区域,避免该第二引导程序覆盖到第二应用程序的有效执行代码,使得升级后的第二应用程序可以正常运行,从而使得升级后的嵌入式设备可以正常运行。In this embodiment, by replacing the first application program in the memory of the embedded device with the second application program and the second boot program in the firmware to be upgraded, the second application program stores the starting address of the second boot program, according to The starting address of the second boot program is obtained, and the first boot program in the memory is replaced with the second boot program, thereby realizing the upgrade of the application program and the boot program. The second application program includes a head area. When the size of the second boot program is larger than the size of the first boot program, the second boot program may occupy the head area of the second application program to prevent the second boot program from being overwritten. The effective execution code of the second application program makes the upgraded second application program run normally, so that the upgraded embedded device can run normally.
本发明实施例提供一种程序处理方法。图8为本发明另一实施例提供的程序处理方法的流程图。如图8所示,在图2所示实施例的基础上,所述将所述第一引导程序替换为所述第二引导程序之后,所述方法还可以包括:An embodiment of the present invention provides a program processing method. 8 is a flowchart of a program processing method according to another embodiment of the present invention. As shown in FIG. 8, based on the embodiment shown in FIG. 2, after the first boot program is replaced with the second boot program, the method may further include:
步骤S701、从所述第二引导程序的起始地址开始,执行所述第二引导程序。Step S701: Starting from the start address of the second boot program, execute the second boot program.
如图3所示,嵌入式设备21的处理器将嵌入式设备21的存储器中原有的引导程序1替换为引导程序2后,如果嵌入式设备21不重新启动,嵌入式设备21的处理器将开始运行应用程序2。如果嵌入式设备21重新启动,则嵌入式设备21的处理器将从引导程序2的起始地址即地址A开始执行引导程序2。As shown in FIG. 3, after the processor of the embedded device 21 replaces the original boot program 1 in the memory of the embedded device 21 with the boot program 2, if the embedded device 21 does not restart, the processor of the embedded device 21 will Start running application 2. If the embedded device 21 restarts, the processor of the embedded device 21 will execute the boot program 2 from the address A, which is the start address of the boot program 2.
步骤S702、在执行所述第二引导程序时,获取所述第二应用程序的运行地址。Step S702: When executing the second boot program, obtain the running address of the second application program.
如图3所示,引导程序2的尾部包括获取运行地址区和跳转执行代码区,其中,获取运行地址区用于获取应用程序2的运行地址即地址D,引导程序2的跳转执行代码区用于直接跳转到地址D开始执行。在本实施例中,跳转执行代码区主要为汇编代码,直接更改程序的运行地址。As shown in FIG. 3, the tail of the boot program 2 includes a get run address area and a jump execution code area, where the get run address area is used to get the run address of the application 2 (address D), and the jump execution code of the boot program 2 The area is used to jump directly to address D to start execution. In this embodiment, the jump execution code area is mainly assembly code, which directly changes the running address of the program.
在一些实施例中,所述第二引导程序存储有所述第二区域的起始地址;所述在执行所述第二引导程序时,获取所述第二应用程序的运行地址,包括:在执行所述第二引导程序时,根据所述第二区域的起始地址,从所述第二区域中获取所述第二应用程序的运行地址。In some embodiments, the second boot program stores the start address of the second area; the acquiring the running address of the second application program when executing the second boot program includes: When the second boot program is executed, the running address of the second application program is obtained from the second area according to the start address of the second area.
例如,引导程序2尾部的获取运行地址区存储有上述实施例所述的第 二区域的起始地址即运行地址存储区的起始地址,由于运行地址存储区存储有应用程序2的运行地址即地址D,则嵌入式设备21的处理器执行到引导程序2尾部的获取运行地址区时,从该获取运行地址区中读取运行地址存储区的起始地址,并根据该运行地址存储区的起始地址,从该运行地址存储区中读取应用程序2的运行地址即地址D。For example, the acquisition run address area at the end of the boot program 2 stores the start address of the second area described in the above embodiment, that is, the start address of the run address storage area, since the run address storage area stores the run address of the application 2 Address D, when the processor of the embedded device 21 executes the acquisition operation address area at the end of the boot program 2, it reads the start address of the operation address storage area from the acquisition operation address area, and according to the operation address storage area The starting address is the address D which is the running address of the application 2 is read from the running address storage area.
步骤S703、从所述第二引导程序跳转到所述第二应用程序的运行地址,执行所述第二应用程序。Step S703: Jump from the second boot program to the running address of the second application program, and execute the second application program.
当嵌入式设备21的处理器执行到引导程序2尾部的跳转执行代码区时,直接跳转到应用程序2的运行地址即地址D开始执行应用程序2。可选的,引导程序2尾部的获取运行地址区只要在嵌入式设备21的处理器执行引导程序2尾部的跳转执行代码区之前,获取到应用程序2的运行地址即可。When the processor of the embedded device 21 executes the jump execution code area at the end of the boot program 2, it jumps directly to the address D of the application program 2 to start execution of the application program 2. Optionally, the acquisition run address area at the end of the boot program 2 only needs to acquire the run address of the application program 2 before the processor of the embedded device 21 executes the jump execution code area at the tail of the boot program 2.
所述从所述第二引导程序跳转到所述第二应用程序的运行地址,执行所述第二应用程序,包括:从所述第二引导程序跳转到所述第二应用程序的运行地址,执行所述第二应用程序,并删除所述第二应用程序之后的所述第二引导程序。The jumping from the second boot program to the running address of the second application program, and executing the second application program includes: jumping from the second boot program to the running of the second application program Address, execute the second application program, and delete the second boot program after the second application program.
例如,由于应用程序2中存储有引导程序2的起始地址即地址E,则嵌入式设备21的处理器在执行应用程序2时,嵌入式设备21的处理器还可以根据该地址E删除该应用程序2之后的引导程序2。For example, since the application program 2 stores the start address of the boot program 2 as the address E, when the processor of the embedded device 21 executes the application program 2, the processor of the embedded device 21 may also delete the address according to the address E Bootloader 2 after application 2.
本实施例通过将第一引导程序替换为更大容量的第二引导程序,实现了对引导程序的修复、替换和扩容。从该第二引导程序的起始地址开始,执行该第二引导程序,并在执行该第二引导程序时,直接获取第二应用程序的运行地址,从该第二引导程序直接跳转到该第二应用程序的运行地址即有效执行代码的起始地址,执行该第二应用程序,提高了升级后的第二应用程序的执行效率。In this embodiment, the first boot program is replaced with a second boot program with a larger capacity, so that the boot program is repaired, replaced, and expanded. Starting from the start address of the second boot program, execute the second boot program, and when executing the second boot program, directly obtain the running address of the second application program, and jump directly from the second boot program to the The running address of the second application program is the starting address of the effective execution code, and executing the second application program improves the execution efficiency of the upgraded second application program.
本发明实施例提供一种程序处理方法。该方法应用于嵌入式设备,所述嵌入式设备的存储器存储有第一引导程序和第一应用程序。图9为本发明另一实施例提供的程序处理方法的流程图。如图9所示,所述方法可以包括:An embodiment of the present invention provides a program processing method. The method is applied to an embedded device, and a memory of the embedded device stores a first boot program and a first application program. 9 is a flowchart of a program processing method according to another embodiment of the present invention. As shown in FIG. 9, the method may include:
步骤S801、获取待升级固件,所述待升级固件包括第二应用程序和第二引导程序。Step S801: Obtain firmware to be upgraded, where the firmware to be upgraded includes a second application program and a second boot program.
如图10所示,嵌入式设备21的存储器存储有第一引导程序和第一应用程序,该第一引导程序具体为上述实施例中的引导程序2,第一应用程序具体为上述实施例中的应用程序2。地址D表示应用程序2的运行地址即应用程序2的有效执行代码的起始地址。地址C到地址D之间的存储空间可以是引导程序2占用掉应用程序2的部分头部区域后剩余的部分头部区域。As shown in FIG. 10, the memory of the embedded device 21 stores a first boot program and a first application program, the first boot program is specifically the boot program 2 in the above embodiment, and the first application program is specifically in the above embodiment的应用2。 Application 2. The address D represents the running address of the application program 2, that is, the starting address of the effective execution code of the application program 2. The storage space between the address C and the address D may be a partial header area remaining after the boot program 2 occupies a partial header area of the application 2.
步骤S802、将所述存储器中的所述第一应用程序替换为所述第二应用程序和所述第二引导程序,所述第二应用程序存储有所述第二引导程序的起始地址,所述第二引导程序的起始地址在所述第二应用程序之后的预设位置。Step S802: Replace the first application program in the memory with the second application program and the second boot program, where the second application program stores a start address of the second boot program, The start address of the second boot program is at a preset position after the second application program.
嵌入式设备21从控制器22接收到的待升级固件包括如图10所示的应用程序3和引导程序2。嵌入式设备21的处理器接收到控制器22发送的待升级固件后,将该待升级固件写入嵌入式设备21的存储器中,具体的,嵌入式设备21的处理器将嵌入式设备21的存储器中存储的应用程序2替换为应用程序3和引导程序2。嵌入式设备21重新上电后,嵌入式设备21的处理器从引导程序2的起始地址即地址A开始执行,引导程序2的获取运行地址区获取到应用程序3的运行地址即有效执行代码的起始地址为地址D,并跳转到应用程序3的地址D开始执行。应用程序3存储有引导程序2的起始地址,引导程序2的起始地址为地址E,引导程序2的起始地址在应用程序3的尾部地址之后的预设位置,可选的,引导程序2的起始地址即地址E相对于地址C的长度为y。The firmware to be upgraded received by the embedded device 21 from the controller 22 includes the application program 3 and the boot program 2 shown in FIG. 10. After receiving the firmware to be upgraded sent by the controller 22, the processor of the embedded device 21 writes the firmware to be upgraded into the memory of the embedded device 21. Specifically, the processor of the embedded device 21 The application program 2 stored in the memory is replaced with the application program 3 and the boot program 2. After the embedded device 21 is powered on again, the processor of the embedded device 21 executes from the start address of the boot program 2 that is the address A, and the run address of the boot program 2 is obtained to obtain the run address of the application program 3 and the code is effectively executed The starting address of is the address D, and jump to the address D of the application 3 to start execution. The application program 3 stores the start address of the boot program 2, the start address of the boot program 2 is the address E, the start address of the boot program 2 is a preset position after the tail address of the application program 3, optionally, the boot program The starting address of 2 is the length of address E relative to address C is y.
步骤S803、从所述第二应用程序中获取所述第二引导程序的起始地址,并从所述第二引导程序的起始地址开始获取所述第二引导程序。Step S803: Acquire the start address of the second boot program from the second application program, and acquire the second boot program from the start address of the second boot program.
嵌入式设备21的处理器从应用程序3的地址D开始执行的过程中,从应用程序3中获取引导程序2的起始地址即地址E,并从地址E开始获取引导程序2。During execution of the address of the application 3 from the address D of the application 3, the processor of the embedded device 21 acquires the address E, which is the start address of the boot program 2, from the application 3, and acquires the boot program 2 from the address E.
步骤S804、比较所述第一引导程序和所述第二引导程序。Step S804: Compare the first boot program and the second boot program.
嵌入式设备21的处理器在从地址E获取到引导程序2后,比较嵌入 式设备21的存储器中当前已存储的引导程序和引导程序2。After acquiring the boot program 2 from the address E, the processor of the embedded device 21 compares the boot program currently stored in the memory of the embedded device 21 with the boot program 2.
步骤S805、如果所述第一引导程序和所述第二引导程序相同,则删除所述第二应用程序之后的所述第二引导程序。Step S805: If the first boot program and the second boot program are the same, delete the second boot program after the second application program.
如图10所示,由于嵌入式设备21的存储器中当前已存储的引导程序和引导程序2相同,则嵌入式设备21的处理器删除应用程序3之后的引导程序2。As shown in FIG. 10, since the boot program currently stored in the memory of the embedded device 21 and the boot program 2 are the same, the processor of the embedded device 21 deletes the boot program 2 after the application program 3.
步骤S806、如果所述第一引导程序和所述第二引导程序不同,则将所述第一引导程序替换为所述第二引导程序。Step S806: If the first boot program and the second boot program are different, replace the first boot program with the second boot program.
在其他实施例中,如果嵌入式设备21的存储器中当前已存储的引导程序和引导程序2不同,则嵌入式设备21的处理器可以将嵌入式设备21的存储器中当前已存储的引导程序替换为引导程序2。In other embodiments, if the boot program currently stored in the memory of the embedded device 21 is different from the boot program 2, the processor of the embedded device 21 may replace the boot program currently stored in the memory of the embedded device 21 For bootloader 2.
在一些实施例中,如图11所示,嵌入式设备21的存储器当前已存储有引导程序1和应用程序1。嵌入式设备21的处理器接收到控制器22发送的待升级固件包括应用程序3和引导程序2,嵌入式设备21的处理器将应用程序3和引导程序2写入到嵌入式设备21的存储器中,具体的,嵌入式设备21的处理器将应用程序1替换为应用程序3和引导程序2。嵌入式设备21重新上电后,嵌入式设备21的处理器从引导程序1的起始地址即地址A开始执行,执行到该引导程序1的跳转执行代码区时,跳转到应用程序2的起始地址即地址B。该地址B可以是应用程序3头部区域中的跳转执行代码区的起始地址,应用程序3头部区域中的跳转执行代码区存储有地址C,嵌入式设备21的处理器从地址B直接跳转到地址C开始运行。该地址C可以是应用程序3头部区域中的运行地址存储区的起始地址,该运行地址存储区存储有应用程序3的运行地址即地址D,嵌入式设备21的处理器从该运行地址存储区获取应用程序3的运行地址即地址D。该地址D具体可以是应用程序3中的拷贝引导程序区的起始地址,该拷贝引导程序区存储有引导程序2的起始地址即地址E。进一步,嵌入式设备21的处理器从地址E获取引导程序2,并将嵌入式设备21的存储器中的引导程序1替换为引导程序2。当嵌入式设备21重新启动后,嵌入式设备21的处理器从引导程序2的起始地址即地址A开始执行,引导程序2可获取到应用程序3的运行地址即地址D,嵌入式设备21的处理器从引导程序2 直接跳转到地址D开始执行应用程序3。嵌入式设备21的处理器可以在执行应用程序3的过程中删除应用程序3之后的引导程序2,或者,可以在将引导程序1替换为引导程序2后删除应用程序3之后的引导程序2。In some embodiments, as shown in FIG. 11, the memory of the embedded device 21 currently stores the boot program 1 and the application program 1. The processor of the embedded device 21 receives the firmware to be upgraded sent by the controller 22 includes the application program 3 and the boot program 2, and the processor of the embedded device 21 writes the application program 3 and the boot program 2 to the memory of the embedded device 21 Specifically, the processor of the embedded device 21 replaces the application program 1 with the application program 3 and the boot program 2. After the embedded device 21 is powered on again, the processor of the embedded device 21 starts to execute from the start address of the boot program 1, that is, address A, and when it reaches the jump execution code area of the boot program 1, jumps to the application 2 The starting address is the address B. The address B may be the starting address of the jump execution code area in the head area of the application 3, the jump execution code area in the head area of the application 3 stores the address C, and the processor slave address of the embedded device 21 B jumps directly to address C to start running. The address C may be the starting address of the running address storage area in the head area of the application 3, the running address storage area stores the running address of the application 3, that is, the address D, and the processor of the embedded device 21 starts from the running address The storage area obtains the address D of the running address of the application 3. The address D may specifically be the start address of the copy boot program area in the application 3, and the copy boot program area stores the address E, which is the start address of the boot program 2. Further, the processor of the embedded device 21 obtains the boot program 2 from the address E, and replaces the boot program 1 in the memory of the embedded device 21 with the boot program 2. When the embedded device 21 restarts, the processor of the embedded device 21 starts to execute from the start address of the boot program 2 which is the address A. The boot program 2 can obtain the running address of the application 3 which is the address D. The embedded device 21 The processor jumps directly from boot program 2 to address D and executes application program 3. The processor of the embedded device 21 may delete the boot program 2 after the application program 3 during the execution of the application program 3, or may delete the boot program 2 after the application program 3 after replacing the boot program 1 with the boot program 2.
本实施例通过嵌入式设备获取到待升级固件后,将嵌入式设备的存储器中当前存储的第一应用程序替换为该待升级固件中的第二应用程序和第二引导程序,并从第二应用程序中获取第二引导程序的起始地址,在从第二引导程序的起始地址开始获取到该第二引导程序后,比较该嵌入式设备的存储器中当前存储的第一引导程序和该第二引导程序,如果第一引导程序和该第二引导程序相同,则删除第二应用程序之后的该第二引导程序,避免了嵌入式设备的处理器每次运行第二应用程序时,还需要对第二应用程序之后的该第二引导程序进行校验,提高了嵌入式设备的运行速度。In this embodiment, after acquiring the firmware to be upgraded through the embedded device, the first application currently stored in the memory of the embedded device is replaced with the second application and the second boot program in the firmware to be upgraded, and the second The start address of the second boot program is obtained from the application program. After the second boot program is obtained from the start address of the second boot program, the first boot program currently stored in the memory of the embedded device and the The second boot program, if the first boot program and the second boot program are the same, delete the second boot program after the second application program, to avoid that the processor of the embedded device runs the second application program every time, The second boot program after the second application program needs to be verified to improve the running speed of the embedded device.
本发明实施例提供一种嵌入式设备。图12为本发明实施例提供的嵌入式设备的结构图,如图12所示,嵌入式设备110包括:存储器111和处理器112。存储器111存储有第一引导程序和第一应用程序;处理器112用于执行以下操作:获取待升级固件,所述待升级固件包括第二应用程序和第二引导程序;处理器112将存储器111中的所述第一应用程序替换为所述第二应用程序和所述第二引导程序,所述第二应用程序存储有所述第二引导程序的起始地址,所述第二引导程序的起始地址在所述第二应用程序之后的第一预设位置,所述第二应用程序包括头部区域;处理器112从所述第二应用程序中获取所述第二引导程序的起始地址,并从所述第二引导程序的起始地址开始获取所述第二引导程序;处理器112将所述第一引导程序替换为所述第二引导程序,所述第一引导程序和所述头部区域的大小大于或等于所述第二引导程序的大小。An embodiment of the present invention provides an embedded device. FIG. 12 is a structural diagram of an embedded device provided by an embodiment of the present invention. As shown in FIG. 12, the embedded device 110 includes: a memory 111 and a processor 112. The memory 111 stores a first boot program and a first application program; the processor 112 is used to perform the following operations: obtain firmware to be upgraded, the firmware to be upgraded includes a second application program and a second boot program; the processor 112 stores the memory 111 The first application program in is replaced with the second application program and the second boot program, the second application program stores a start address of the second boot program, the second boot program The start address is at a first preset position after the second application program, and the second application program includes a header area; the processor 112 obtains the start of the second boot program from the second application program Address and obtain the second boot program from the start address of the second boot program; the processor 112 replaces the first boot program with the second boot program, the first boot program and all The size of the header area is greater than or equal to the size of the second boot program.
可选的,所述第二应用程序包括第一区域;所述第一区域存储有所述第二引导程序的起始地址。Optionally, the second application program includes a first area; the first area stores a start address of the second boot program.
可选的,处理器112从所述第二应用程序中获取所述第二引导程序的起始地址时,具体用于:从所述第二应用程序的所述第一区域中获取所述第二引导程序的起始地址。Optionally, when the processor 112 obtains the start address of the second boot program from the second application program, it is specifically used to: obtain the first address from the first area of the second application program. The starting address of the bootloader.
可选的,所述第二应用程序还包括第二区域,所述第二区域存储有所 述第二应用程序的运行地址,所述第二区域的尾部地址为所述第一区域的起始地址。Optionally, the second application program further includes a second area, the second area stores the running address of the second application program, and the tail address of the second area is the start of the first area address.
可选的,处理器112从所述第二应用程序中获取所述第二引导程序的起始地址时,具体用于:根据所述第二区域,确定所述第一区域的起始地址;根据所述第一区域的起始地址,从所述第二应用程序的所述第一区域中获取所述第二引导程序的起始地址。Optionally, when the processor 112 obtains the start address of the second boot program from the second application program, it is specifically used to: determine the start address of the first area according to the second area; Acquire the start address of the second boot program from the first area of the second application according to the start address of the first area.
可选的,所述第二应用程序还包括第三区域,所述第三区域存储有所述第二区域的起始地址,所述第三区域在所述第二应用程序的所述头部区域内。Optionally, the second application further includes a third area, where the third area stores a start address of the second area, and the third area is in the head of the second application within the area.
可选的,处理器112从所述第二应用程序中获取所述第二引导程序的起始地址时,具体用于:从所述第三区域中获取所述第二区域的起始地址;根据所述第二区域的起始地址,确定所述第一区域的起始地址;根据所述第一区域的起始地址,从所述第二应用程序的所述第一区域中获取所述第二引导程序的起始地址。Optionally, when the processor 112 obtains the start address of the second boot program from the second application program, it is specifically used to: obtain the start address of the second area from the third area; According to the start address of the second area, determine the start address of the first area; according to the start address of the first area, obtain the first address from the first area of the second application The starting address of the second bootloader.
可选的,所述第三区域的起始地址为所述第二应用程序的所述头部区域的起始地址。Optionally, the starting address of the third area is the starting address of the head area of the second application.
可选的,所述第一区域的起始地址为所述第二应用程序的运行地址。Optionally, the starting address of the first area is the running address of the second application program.
可选的,所述第二区域在所述第二应用程序的所述头部区域内。Optionally, the second area is within the head area of the second application.
可选的,所述第一引导程序的起始地址与所述第二区域的起始地址之间的存储空间大小大于或等于所述第二引导程序的大小。Optionally, the size of the storage space between the start address of the first boot program and the start address of the second area is greater than or equal to the size of the second boot program.
可选的,所述第一区域的起始地址在所述第二应用程序的运行地址之后的第二预设位置。Optionally, the starting address of the first area is at a second preset position after the running address of the second application program.
可选的,所述第二区域不在所述第二应用程序的所述头部区域内。Optionally, the second area is not within the head area of the second application.
可选的,所述第一引导程序的起始地址与所述第二应用程序的运行地址之间的存储空间大小大于或等于所述第二引导程序的大小。Optionally, the size of the storage space between the start address of the first boot program and the running address of the second application program is greater than or equal to the size of the second boot program.
可选的,所述第一区域还包括所述第二引导程序的长度;处理器112从所述第二引导程序的起始地址开始获取所述第二引导程序时,具体用于:根据所述第二引导程序的长度,从所述第二引导程序的起始地址开始获取所述第二引导程序。Optionally, the first area further includes the length of the second boot program; when the processor 112 acquires the second boot program from the start address of the second boot program, it is specifically used to: The length of the second boot program is obtained from the start address of the second boot program.
可选的,处理器112将所述第一引导程序替换为所述第二引导程序之 后,还用于:从所述第二引导程序的起始地址开始,执行所述第二引导程序;在执行所述第二引导程序时,获取所述第二应用程序的运行地址;从所述第二引导程序跳转到所述第二应用程序的运行地址,执行所述第二应用程序。Optionally, after the processor 112 replaces the first boot program with the second boot program, it is also used to: execute the second boot program starting from the start address of the second boot program; When executing the second boot program, obtain the running address of the second application program; jump from the second boot program to the running address of the second application program, and execute the second application program.
可选的,所述第二引导程序存储有所述第二区域的起始地址;处理器112在执行所述第二引导程序时,获取所述第二应用程序的运行地址时,具体用于:在执行所述第二引导程序时,根据所述第二区域的起始地址,从所述第二区域中获取所述第二应用程序的运行地址。Optionally, the second boot program stores the start address of the second area; when the processor 112 executes the second boot program, when acquiring the running address of the second application program, it is specifically used : When executing the second boot program, obtain the running address of the second application program from the second area according to the start address of the second area.
可选的,处理器112从所述第二引导程序跳转到所述第二应用程序的运行地址,执行所述第二应用程序时,具体用于:从所述第二引导程序跳转到所述第二应用程序的运行地址,执行所述第二应用程序,并删除所述第二应用程序之后的所述第二引导程序。Optionally, the processor 112 jumps from the second boot program to the running address of the second application program, and when the second application program is executed, it is specifically used to: jump from the second boot program to Running address of the second application program, executing the second application program, and deleting the second boot program after the second application program.
可选的,处理器112将所述第一引导程序替换为所述第二引导程序之后,还用于:删除所述第二应用程序之后的所述第二引导程序。Optionally, after the processor 112 replaces the first boot program with the second boot program, it is also used to: delete the second boot program after the second application program.
可选的,处理器112将所述第一引导程序替换为所述第二引导程序时,具体用于:比较所述第一引导程序和所述第二引导程序;若所述第一引导程序和所述第二引导程序不同,则将所述第一引导程序替换为所述第二引导程序。Optionally, when the processor 112 replaces the first boot program with the second boot program, it is specifically used to: compare the first boot program and the second boot program; if the first boot program Unlike the second boot program, the first boot program is replaced with the second boot program.
可选的,处理器112还用于:若所述第一引导程序和所述第二引导程序相同,则删除所述第二应用程序之后的所述第二引导程序。Optionally, the processor 112 is further configured to: if the first boot program and the second boot program are the same, delete the second boot program after the second application program.
可选的,嵌入式设备110还包括:通讯接口113;处理器112获取待升级固件时,具体用于:通过通讯接口113接收控制器发送的所述待升级固件。Optionally, the embedded device 110 further includes: a communication interface 113; when the processor 112 acquires firmware to be upgraded, it is specifically used to: receive the firmware to be upgraded sent by the controller through the communication interface 113.
本发明实施例提供的嵌入式设备的具体原理和实现方式均与上述实施例类似,此处不再赘述。The specific principles and implementation manners of the embedded device provided by the embodiments of the present invention are similar to the foregoing embodiments, and details are not described herein again.
本实施例通过将嵌入式设备的存储器中的第一应用程序替换为待升级固件中的第二应用程序和第二引导程序,该第二应用程序存储有第二引导程序的起始地址,根据该第二引导程序的起始地址,获取该第二引导程序,并将该存储器中的第一引导程序替换为该第二引导程序,实现了应用程序和引导程序的升级。第二应用程序包括头部区域,当第二引导程序的 大小大于第一引导程序的大小时,该第二引导程序可占用该第二应用程序的头部区域,避免该第二引导程序覆盖到第二应用程序的有效执行代码,使得升级后的第二应用程序可以正常运行,从而使得升级后的嵌入式设备可以正常运行。In this embodiment, by replacing the first application program in the memory of the embedded device with the second application program and the second boot program in the firmware to be upgraded, the second application program stores the starting address of the second boot program, according to The starting address of the second boot program is obtained, and the first boot program in the memory is replaced with the second boot program, thereby realizing the upgrade of the application program and the boot program. The second application program includes a head area. When the size of the second boot program is larger than the size of the first boot program, the second boot program may occupy the head area of the second application program to prevent the second boot program from covering The effective execution code of the second application program makes the upgraded second application program run normally, so that the upgraded embedded device can run normally.
本发明实施例提供一种嵌入式设备。如图12所示,嵌入式设备110包括:存储器111和处理器112;存储器111存储有第一引导程序和第一应用程序;处理器112用于执行以下操作:获取待升级固件,所述待升级固件包括第二应用程序和第二引导程序;将存储器111中的所述第一应用程序替换为所述第二应用程序和所述第二引导程序,所述第二应用程序存储有所述第二引导程序的起始地址,所述第二引导程序的起始地址在所述第二应用程序之后的预设位置;从所述第二应用程序中获取所述第二引导程序的起始地址,并从所述第二引导程序的起始地址开始获取所述第二引导程序;比较所述第一引导程序和所述第二引导程序;当所述第一引导程序和所述第二引导程序相同时,删除所述第二应用程序之后的所述第二引导程序。An embodiment of the present invention provides an embedded device. As shown in FIG. 12, the embedded device 110 includes: a memory 111 and a processor 112; the memory 111 stores a first boot program and a first application program; the processor 112 is used to perform the following operations: obtain firmware to be upgraded, and the The firmware upgrade includes a second application program and a second boot program; replacing the first application program in the memory 111 with the second application program and the second boot program, the second application program storing the The start address of the second boot program, the start address of the second boot program is at a preset position after the second application program; the start of the second boot program is obtained from the second application program Address, and obtain the second boot program from the start address of the second boot program; compare the first boot program and the second boot program; when the first boot program and the second When the boot programs are the same, delete the second boot program after the second application program.
可选的,处理器112还用于:当所述第一引导程序和所述第二引导程序不同时,将所述第一引导程序替换为所述第二引导程序。Optionally, the processor 112 is further configured to: when the first boot program and the second boot program are different, replace the first boot program with the second boot program.
本发明实施例提供的嵌入式设备的具体原理和实现方式均与图9所示实施例类似,此处不再赘述。The specific principles and implementation manners of the embedded device provided by the embodiments of the present invention are similar to the embodiment shown in FIG. 9 and will not be repeated here.
本实施例通过嵌入式设备获取到待升级固件后,将嵌入式设备的存储器中当前存储的第一应用程序替换为该待升级固件中的第二应用程序和第二引导程序,并从第二应用程序中获取第二引导程序的起始地址,在从第二引导程序的起始地址开始获取到该第二引导程序后,比较该嵌入式设备的存储器中当前存储的第一引导程序和该第二引导程序,如果第一引导程序和该第二引导程序相同,则删除第二应用程序之后的该第二引导程序,避免了嵌入式设备的处理器每次运行第二应用程序时,还需要对第二应用程序之后的该第二引导程序进行校验,提高了嵌入式设备的运行速度。In this embodiment, after acquiring the firmware to be upgraded through the embedded device, the first application currently stored in the memory of the embedded device is replaced with the second application and the second boot program in the firmware to be upgraded, and the second The start address of the second boot program is obtained from the application program. After the second boot program is obtained from the start address of the second boot program, the first boot program currently stored in the memory of the embedded device and the The second boot program, if the first boot program and the second boot program are the same, delete the second boot program after the second application program, to avoid that the processor of the embedded device runs the second application program every time, The second boot program after the second application program needs to be verified to improve the running speed of the embedded device.
另外,本实施例还提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行以实现上述实施例所述的程序处理方 法。In addition, this embodiment also provides a computer-readable storage medium on which a computer program is stored, which is executed by a processor to implement the program processing method described in the above embodiment.
在本发明所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided by the present invention, it should be understood that the disclosed device and method may be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a division of logical functions. In actual implementation, there may be other divisions, for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of hardware, or in the form of hardware plus software functional units.
上述以软件功能单元的形式实现的集成的单元,可以存储在一个计算机可读取存储介质中。上述软件功能单元存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本发明各个实施例所述方法的部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The above integrated unit implemented in the form of a software functional unit may be stored in a computer-readable storage medium. The above software functional units are stored in a storage medium, and include several instructions to enable a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute the method described in each embodiment of the present invention Partial steps. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program code .
本领域技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。上述描述的装置的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for convenience and conciseness of description, only the above-mentioned division of each functional module is used as an example for illustration. In practical applications, the above-mentioned functions can be allocated by different functional modules according to needs, that is, the device The internal structure of is divided into different functional modules to complete all or part of the functions described above. For the specific working process of the device described above, reference may be made to the corresponding process in the foregoing method embodiments, and details are not described herein again.
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的 普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention, rather than limiting it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: The technical solutions described in the foregoing embodiments can still be modified, or some or all of the technical features can be equivalently replaced; and these modifications or replacements do not deviate from the essence of the corresponding technical solutions of the technical solutions of the embodiments of the present invention range.

Claims (49)

  1. 一种程序处理方法,应用于嵌入式设备,所述嵌入式设备的存储器存储有第一引导程序和第一应用程序;其特征在于,所述方法包括:A program processing method is applied to an embedded device, and a memory of the embedded device stores a first boot program and a first application program; characterized in that the method includes:
    获取待升级固件,所述待升级固件包括第二应用程序和第二引导程序;Obtain firmware to be upgraded, where the firmware to be upgraded includes a second application program and a second boot program;
    将所述存储器中的所述第一应用程序替换为所述第二应用程序和所述第二引导程序,所述第二应用程序存储有所述第二引导程序的起始地址,所述第二引导程序的起始地址在所述第二应用程序之后的第一预设位置,所述第二应用程序包括头部区域;Replacing the first application program in the memory with the second application program and the second boot program, the second application program storing a start address of the second boot program, the first The start address of the second boot program is at a first preset position after the second application program, and the second application program includes a header area;
    从所述第二应用程序中获取所述第二引导程序的起始地址,并从所述第二引导程序的起始地址开始获取所述第二引导程序;Acquiring the start address of the second boot program from the second application program, and acquiring the second boot program from the start address of the second boot program;
    将所述第一引导程序替换为所述第二引导程序,所述第一引导程序和所述头部区域的大小大于或等于所述第二引导程序的大小。The first boot program is replaced with the second boot program, and the sizes of the first boot program and the head region are greater than or equal to the size of the second boot program.
  2. 根据权利要求1所述的方法,其特征在于,所述第二应用程序包括第一区域;所述第一区域存储有所述第二引导程序的起始地址。The method according to claim 1, wherein the second application program includes a first area; the first area stores a start address of the second boot program.
  3. 根据权利要求2所述的方法,其特征在于,所述从所述第二应用程序中获取所述第二引导程序的起始地址,包括:The method according to claim 2, wherein the acquiring the start address of the second boot program from the second application program comprises:
    从所述第二应用程序的所述第一区域中获取所述第二引导程序的起始地址。The start address of the second boot program is obtained from the first area of the second application program.
  4. 根据权利要求2所述的方法,其特征在于,所述第二应用程序还包括第二区域,所述第二区域存储有所述第二应用程序的运行地址,所述第二区域的尾部地址为所述第一区域的起始地址。The method according to claim 2, wherein the second application program further includes a second area, the second area stores a running address of the second application program, and a tail address of the second area Is the starting address of the first area.
  5. 根据权利要求4所述的方法,其特征在于,所述从所述第二应用程序中获取所述第二引导程序的起始地址,包括:The method according to claim 4, wherein the acquiring the start address of the second boot program from the second application program comprises:
    根据所述第二区域,确定所述第一区域的起始地址;Determine the starting address of the first area according to the second area;
    根据所述第一区域的起始地址,从所述第二应用程序的所述第一区域中获取所述第二引导程序的起始地址。Acquire the start address of the second boot program from the first area of the second application according to the start address of the first area.
  6. 根据权利要求4所述的方法,其特征在于,所述第二应用程序还包括第三区域,所述第三区域存储有所述第二区域的起始地址,所述第三区域在所述第二应用程序的所述头部区域内。The method according to claim 4, wherein the second application further includes a third area, the third area stores a start address of the second area, and the third area is located in the Within the head area of the second application.
  7. 根据权利要求6所述的方法,其特征在于,所述从所述第二应用 程序中获取所述第二引导程序的起始地址,包括:The method according to claim 6, wherein the acquiring the start address of the second boot program from the second application program comprises:
    从所述第三区域中获取所述第二区域的起始地址;Acquiring the start address of the second area from the third area;
    根据所述第二区域的起始地址,确定所述第一区域的起始地址;Determine the start address of the first area according to the start address of the second area;
    根据所述第一区域的起始地址,从所述第二应用程序的所述第一区域中获取所述第二引导程序的起始地址。Acquire the start address of the second boot program from the first area of the second application according to the start address of the first area.
  8. 根据权利要求6或7所述的方法,其特征在于,所述第三区域的起始地址为所述第二应用程序的所述头部区域的起始地址。The method according to claim 6 or 7, wherein the starting address of the third area is the starting address of the head area of the second application.
  9. 根据权利要求4-8任一项所述的方法,其特征在于,所述第一区域的起始地址为所述第二应用程序的运行地址。The method according to any one of claims 4-8, wherein the starting address of the first area is the running address of the second application program.
  10. 根据权利要求9所述的方法,其特征在于,所述第二区域在所述第二应用程序的所述头部区域内。The method according to claim 9, wherein the second area is within the head area of the second application.
  11. 根据权利要求10所述的方法,其特征在于,所述第一引导程序的起始地址与所述第二区域的起始地址之间的存储空间大小大于或等于所述第二引导程序的大小。The method according to claim 10, wherein the size of the storage space between the start address of the first boot program and the start address of the second area is greater than or equal to the size of the second boot program .
  12. 根据权利要求4-8任一项所述的方法,其特征在于,所述第一区域的起始地址在所述第二应用程序的运行地址之后的第二预设位置。The method according to any one of claims 4-8, wherein the starting address of the first area is at a second preset position after the running address of the second application program.
  13. 根据权利要求12所述的方法,其特征在于,所述第二区域不在所述第二应用程序的所述头部区域内。The method according to claim 12, wherein the second area is not within the head area of the second application.
  14. 根据权利要求13所述的方法,其特征在于,所述第一引导程序的起始地址与所述第二应用程序的运行地址之间的存储空间大小大于或等于所述第二引导程序的大小。The method according to claim 13, wherein the size of the storage space between the start address of the first boot program and the running address of the second application program is greater than or equal to the size of the second boot program .
  15. 根据权利要求2-14任一项所述的方法,其特征在于,所述第一区域还包括所述第二引导程序的长度;The method according to any one of claims 2-14, wherein the first area further includes a length of the second boot program;
    所述从所述第二引导程序的起始地址开始获取所述第二引导程序,包括:The acquiring the second boot program starting from the starting address of the second boot program includes:
    根据所述第二引导程序的长度,从所述第二引导程序的起始地址开始获取所述第二引导程序。According to the length of the second boot program, the second boot program is acquired starting from the start address of the second boot program.
  16. 根据权利要求4-7、10-13任一项所述的方法,其特征在于,所述将所述第一引导程序替换为所述第二引导程序之后,所述方法还包括:The method according to any one of claims 4-7 and 10-13, wherein after the first boot program is replaced with the second boot program, the method further comprises:
    从所述第二引导程序的起始地址开始,执行所述第二引导程序;Starting from the start address of the second boot program, executing the second boot program;
    在执行所述第二引导程序时,获取所述第二应用程序的运行地址;Acquiring the running address of the second application program when executing the second boot program;
    从所述第二引导程序跳转到所述第二应用程序的运行地址,执行所述第二应用程序。Jump from the second boot program to the running address of the second application program, and execute the second application program.
  17. 根据权利要求16所述的方法,其特征在于,所述第二引导程序存储有所述第二区域的起始地址;The method according to claim 16, wherein the second boot program stores a start address of the second area;
    所述在执行所述第二引导程序时,获取所述第二应用程序的运行地址,包括:The acquiring the running address of the second application program when executing the second boot program includes:
    在执行所述第二引导程序时,根据所述第二区域的起始地址,从所述第二区域中获取所述第二应用程序的运行地址。When the second boot program is executed, the running address of the second application program is obtained from the second area according to the start address of the second area.
  18. 根据权利要求16或17所述的方法,其特征在于,所述从所述第二引导程序跳转到所述第二应用程序的运行地址,执行所述第二应用程序,包括:The method according to claim 16 or 17, wherein the jump from the second boot program to the running address of the second application program to execute the second application program includes:
    从所述第二引导程序跳转到所述第二应用程序的运行地址,执行所述第二应用程序,并删除所述第二应用程序之后的所述第二引导程序。Jump from the second boot program to the running address of the second application program, execute the second application program, and delete the second boot program after the second application program.
  19. 根据权利要求1-15任一项所述的方法,其特征在于,所述将所述第一引导程序替换为所述第二引导程序之后,所述方法还包括:The method according to any one of claims 1-15, wherein after replacing the first boot program with the second boot program, the method further comprises:
    删除所述第二应用程序之后的所述第二引导程序。The second boot program after deleting the second application program.
  20. 根据权利要求1-19任一项所述的方法,其特征在于,所述处理器将所述第一引导程序替换为所述第二引导程序,包括:The method according to any one of claims 1-19, wherein the processor replacing the first boot program with the second boot program includes:
    比较所述第一引导程序和所述第二引导程序;Comparing the first boot program and the second boot program;
    若所述第一引导程序和所述第二引导程序不同,则将所述第一引导程序替换为所述第二引导程序。If the first boot program and the second boot program are different, the first boot program is replaced with the second boot program.
  21. 根据权利要求20所述的方法,其特征在于,所述方法还包括:The method of claim 20, further comprising:
    若所述第一引导程序和所述第二引导程序相同,则删除所述第二应用程序之后的所述第二引导程序。If the first boot program and the second boot program are the same, delete the second boot program after the second application program.
  22. 根据权利要求1-21任一项所述的方法,其特征在于,所述获取待升级固件,包括:The method according to any one of claims 1-21, wherein the acquiring firmware to be upgraded comprises:
    接收控制器发送的所述待升级固件。Receiving the firmware to be upgraded sent by the controller.
  23. 一种程序处理方法,应用于嵌入式设备,所述嵌入式设备的存储器存储有第一引导程序和第一应用程序;其特征在于,所述方法包括:A program processing method is applied to an embedded device, and a memory of the embedded device stores a first boot program and a first application program; characterized in that the method includes:
    获取待升级固件,所述待升级固件包括第二应用程序和第二引导程序;Obtain firmware to be upgraded, where the firmware to be upgraded includes a second application program and a second boot program;
    将所述存储器中的所述第一应用程序替换为所述第二应用程序和所述第二引导程序,所述第二应用程序存储有所述第二引导程序的起始地址,所述第二引导程序的起始地址在所述第二应用程序之后的预设位置;Replacing the first application program in the memory with the second application program and the second boot program, the second application program storing a start address of the second boot program, the first The start address of the second boot program is at a preset position after the second application program;
    从所述第二应用程序中获取所述第二引导程序的起始地址,并从所述第二引导程序的起始地址开始获取所述第二引导程序;Acquiring the start address of the second boot program from the second application program, and acquiring the second boot program from the start address of the second boot program;
    比较所述第一引导程序和所述第二引导程序;Comparing the first boot program and the second boot program;
    如果所述第一引导程序和所述第二引导程序相同,则删除所述第二应用程序之后的所述第二引导程序。If the first boot program and the second boot program are the same, delete the second boot program after the second application program.
  24. 根据权利要求23所述的方法,其特征在于,所述方法还包括:The method of claim 23, further comprising:
    如果所述第一引导程序和所述第二引导程序不同,则将所述第一引导程序替换为所述第二引导程序。If the first boot program and the second boot program are different, the first boot program is replaced with the second boot program.
  25. 一种嵌入式设备,其特征在于,包括:存储器和处理器;An embedded device, which is characterized by comprising: a memory and a processor;
    所述存储器存储有第一引导程序和第一应用程序;The memory stores a first boot program and a first application program;
    所述处理器用于执行以下操作:The processor is used to perform the following operations:
    获取待升级固件,所述待升级固件包括第二应用程序和第二引导程序;Obtain firmware to be upgraded, where the firmware to be upgraded includes a second application program and a second boot program;
    将所述存储器中的所述第一应用程序替换为所述第二应用程序和所述第二引导程序,所述第二应用程序存储有所述第二引导程序的起始地址,所述第二引导程序的起始地址在所述第二应用程序之后的第一预设位置,所述第二应用程序包括头部区域;Replacing the first application program in the memory with the second application program and the second boot program, the second application program storing a start address of the second boot program, the first The start address of the second boot program is at a first preset position after the second application program, and the second application program includes a header area;
    从所述第二应用程序中获取所述第二引导程序的起始地址,并从所述第二引导程序的起始地址开始获取所述第二引导程序;Acquiring the start address of the second boot program from the second application program, and acquiring the second boot program from the start address of the second boot program;
    将所述第一引导程序替换为所述第二引导程序,所述第一引导程序和所述头部区域的大小大于或等于所述第二引导程序的大小。The first boot program is replaced with the second boot program, and the sizes of the first boot program and the head region are greater than or equal to the size of the second boot program.
  26. 根据权利要求25所述的嵌入式设备,其特征在于,所述第二应用程序包括第一区域;所述第一区域存储有所述第二引导程序的起始地址。The embedded device according to claim 25, wherein the second application program includes a first area; the first area stores a start address of the second boot program.
  27. 根据权利要求26所述的嵌入式设备,其特征在于,所述处理器从所述第二应用程序中获取所述第二引导程序的起始地址时,具体用于:The embedded device according to claim 26, wherein when the processor obtains the start address of the second boot program from the second application program, it is specifically used to:
    从所述第二应用程序的所述第一区域中获取所述第二引导程序的起始地址。The start address of the second boot program is obtained from the first area of the second application program.
  28. 根据权利要求26所述的嵌入式设备,其特征在于,所述第二应用程序还包括第二区域,所述第二区域存储有所述第二应用程序的运行地址,所述第二区域的尾部地址为所述第一区域的起始地址。The embedded device according to claim 26, wherein the second application further comprises a second area, the second area stores an execution address of the second application, and the second area The tail address is the start address of the first area.
  29. 根据权利要求28所述的嵌入式设备,其特征在于,所述处理器从所述第二应用程序中获取所述第二引导程序的起始地址时,具体用于:The embedded device according to claim 28, wherein when the processor obtains the start address of the second boot program from the second application program, it is specifically used to:
    根据所述第二区域,确定所述第一区域的起始地址;Determine the starting address of the first area according to the second area;
    根据所述第一区域的起始地址,从所述第二应用程序的所述第一区域中获取所述第二引导程序的起始地址。Acquire the start address of the second boot program from the first area of the second application according to the start address of the first area.
  30. 根据权利要求28所述的嵌入式设备,其特征在于,所述第二应用程序还包括第三区域,所述第三区域存储有所述第二区域的起始地址,所述第三区域在所述第二应用程序的所述头部区域内。The embedded device according to claim 28, wherein the second application further comprises a third area, the third area stores a start address of the second area, and the third area is in Within the head area of the second application.
  31. 根据权利要求30所述的嵌入式设备,其特征在于,所述处理器从所述第二应用程序中获取所述第二引导程序的起始地址时,具体用于:The embedded device according to claim 30, wherein when the processor obtains the start address of the second boot program from the second application program, it is specifically used to:
    从所述第三区域中获取所述第二区域的起始地址;Acquiring the start address of the second area from the third area;
    根据所述第二区域的起始地址,确定所述第一区域的起始地址;Determine the start address of the first area according to the start address of the second area;
    根据所述第一区域的起始地址,从所述第二应用程序的所述第一区域中获取所述第二引导程序的起始地址。Acquire the start address of the second boot program from the first area of the second application according to the start address of the first area.
  32. 根据权利要求30或31所述的嵌入式设备,其特征在于,所述第三区域的起始地址为所述第二应用程序的所述头部区域的起始地址。The embedded device according to claim 30 or 31, wherein the starting address of the third area is the starting address of the head area of the second application.
  33. 根据权利要求28-32任一项所述的嵌入式设备,其特征在于,所述第一区域的起始地址为所述第二应用程序的运行地址。The embedded device according to any one of claims 28-32, wherein the starting address of the first area is the running address of the second application program.
  34. 根据权利要求33所述的嵌入式设备,其特征在于,所述第二区域在所述第二应用程序的所述头部区域内。The embedded device according to claim 33, wherein the second area is within the head area of the second application.
  35. 根据权利要求34所述的嵌入式设备,其特征在于,所述第一引导程序的起始地址与所述第二区域的起始地址之间的存储空间大小大于或等于所述第二引导程序的大小。The embedded device according to claim 34, wherein the size of the storage space between the start address of the first boot program and the start address of the second area is greater than or equal to the second boot program the size of.
  36. 根据权利要求28-32任一项所述的嵌入式设备,其特征在于,所述第一区域的起始地址在所述第二应用程序的运行地址之后的第二预设位置。The embedded device according to any one of claims 28 to 32, wherein the starting address of the first area is at a second preset position after the running address of the second application program.
  37. 根据权利要求36所述的嵌入式设备,其特征在于,所述第二区 域不在所述第二应用程序的所述头部区域内。The embedded device according to claim 36, wherein the second area is not within the head area of the second application.
  38. 根据权利要求37所述的嵌入式设备,其特征在于,所述第一引导程序的起始地址与所述第二应用程序的运行地址之间的存储空间大小大于或等于所述第二引导程序的大小。The embedded device according to claim 37, wherein the size of the storage space between the start address of the first boot program and the running address of the second application program is greater than or equal to the second boot program the size of.
  39. 根据权利要求26-38任一项所述的嵌入式设备,其特征在于,所述第一区域还包括所述第二引导程序的长度;The embedded device according to any one of claims 26 to 38, wherein the first area further includes the length of the second boot program;
    所述处理器从所述第二引导程序的起始地址开始获取所述第二引导程序时,具体用于:When the processor acquires the second boot program from the start address of the second boot program, it is specifically used to:
    根据所述第二引导程序的长度,从所述第二引导程序的起始地址开始获取所述第二引导程序。According to the length of the second boot program, the second boot program is acquired starting from the start address of the second boot program.
  40. 根据权利要求28-31、34、35、37任一项所述的嵌入式设备,其特征在于,所述处理器将所述第一引导程序替换为所述第二引导程序之后,还用于:The embedded device according to any one of claims 28-31, 34, 35, 37, wherein after the processor replaces the first boot program with the second boot program, :
    从所述第二引导程序的起始地址开始,执行所述第二引导程序;Starting from the start address of the second boot program, executing the second boot program;
    在执行所述第二引导程序时,获取所述第二应用程序的运行地址;Acquiring the running address of the second application program when executing the second boot program;
    从所述第二引导程序跳转到所述第二应用程序的运行地址,执行所述第二应用程序。Jump from the second boot program to the running address of the second application program, and execute the second application program.
  41. 根据权利要求40所述的嵌入式设备,其特征在于,所述第二引导程序存储有所述第二区域的起始地址;The embedded device according to claim 40, wherein the second boot program stores a start address of the second area;
    所述处理器在执行所述第二引导程序时,获取所述第二应用程序的运行地址时,具体用于:When the processor executes the second boot program and obtains the running address of the second application program, it is specifically used to:
    在执行所述第二引导程序时,根据所述第二区域的起始地址,从所述第二区域中获取所述第二应用程序的运行地址。When the second boot program is executed, the running address of the second application program is obtained from the second area according to the start address of the second area.
  42. 根据权利要求40或41所述的嵌入式设备,其特征在于,所述处理器从所述第二引导程序跳转到所述第二应用程序的运行地址,执行所述第二应用程序时,具体用于:The embedded device according to claim 40 or 41, wherein the processor jumps from the second boot program to the running address of the second application program, and when executing the second application program, Specifically used for:
    从所述第二引导程序跳转到所述第二应用程序的运行地址,执行所述第二应用程序,并删除所述第二应用程序之后的所述第二引导程序。Jump from the second boot program to the running address of the second application program, execute the second application program, and delete the second boot program after the second application program.
  43. 根据权利要求25-39任一项所述的嵌入式设备,其特征在于,所述处理器将所述第一引导程序替换为所述第二引导程序之后,还用于:The embedded device according to any one of claims 25 to 39, wherein after the processor replaces the first boot program with the second boot program, the processor is further used to:
    删除所述第二应用程序之后的所述第二引导程序。The second boot program after deleting the second application program.
  44. 根据权利要求25-43任一项所述的嵌入式设备,其特征在于,所述处理器将所述第一引导程序替换为所述第二引导程序时,具体用于:The embedded device according to any one of claims 25 to 43, wherein when the processor replaces the first boot program with the second boot program, it is specifically used to:
    比较所述第一引导程序和所述第二引导程序;Comparing the first boot program and the second boot program;
    若所述第一引导程序和所述第二引导程序不同,则将所述第一引导程序替换为所述第二引导程序。If the first boot program and the second boot program are different, the first boot program is replaced with the second boot program.
  45. 根据权利要求44所述的嵌入式设备,其特征在于,所述处理器还用于:The embedded device according to claim 44, wherein the processor is further configured to:
    若所述第一引导程序和所述第二引导程序相同,则删除所述第二应用程序之后的所述第二引导程序。If the first boot program and the second boot program are the same, delete the second boot program after the second application program.
  46. 根据权利要求25-45任一项所述的嵌入式设备,其特征在于,所述嵌入式设备还包括:通讯接口;The embedded device according to any one of claims 25 to 45, wherein the embedded device further comprises: a communication interface;
    所述处理器获取待升级固件时,具体用于:When the processor obtains the firmware to be upgraded, it is specifically used to:
    通过所述通讯接口接收控制器发送的所述待升级固件。Receiving the firmware to be upgraded sent by the controller through the communication interface.
  47. 一种嵌入式设备,其特征在于,包括:存储器和处理器;An embedded device, which is characterized by comprising: a memory and a processor;
    所述存储器存储有第一引导程序和第一应用程序;The memory stores a first boot program and a first application program;
    所述处理器用于执行以下操作:The processor is used to perform the following operations:
    获取待升级固件,所述待升级固件包括第二应用程序和第二引导程序;Obtain firmware to be upgraded, where the firmware to be upgraded includes a second application program and a second boot program;
    将所述存储器中的所述第一应用程序替换为所述第二应用程序和所述第二引导程序,所述第二应用程序存储有所述第二引导程序的起始地址,所述第二引导程序的起始地址在所述第二应用程序之后的预设位置;Replacing the first application program in the memory with the second application program and the second boot program, the second application program storing a start address of the second boot program, the first The start address of the second boot program is at a preset position after the second application program;
    从所述第二应用程序中获取所述第二引导程序的起始地址,并从所述第二引导程序的起始地址开始获取所述第二引导程序;Acquiring the start address of the second boot program from the second application program, and acquiring the second boot program from the start address of the second boot program;
    比较所述第一引导程序和所述第二引导程序;Comparing the first boot program and the second boot program;
    当所述第一引导程序和所述第二引导程序相同时,删除所述第二应用程序之后的所述第二引导程序。When the first boot program and the second boot program are the same, delete the second boot program after the second application program.
  48. 根据权利要求47所述的嵌入式设备,其特征在于,所述处理器还用于:The embedded device according to claim 47, wherein the processor is further configured to:
    当所述第一引导程序和所述第二引导程序不同时,将所述第一引导程序替换为所述第二引导程序。When the first boot program and the second boot program are different, the first boot program is replaced with the second boot program.
  49. 一种计算机可读存储介质,其特征在于,其上存储有计算机程序,所述计算机程序被处理器执行以实现如权利要求1-24任一项所述的方法。A computer-readable storage medium characterized in that a computer program is stored thereon, the computer program is executed by a processor to implement the method according to any one of claims 1-24.
PCT/CN2018/118733 2018-11-30 2018-11-30 Application processing method and apparatus and storage medium WO2020107469A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201880073390.1A CN111356982A (en) 2018-11-30 2018-11-30 Program processing method, program processing apparatus, and storage medium
PCT/CN2018/118733 WO2020107469A1 (en) 2018-11-30 2018-11-30 Application processing method and apparatus and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/118733 WO2020107469A1 (en) 2018-11-30 2018-11-30 Application processing method and apparatus and storage medium

Publications (1)

Publication Number Publication Date
WO2020107469A1 true WO2020107469A1 (en) 2020-06-04

Family

ID=70852505

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/118733 WO2020107469A1 (en) 2018-11-30 2018-11-30 Application processing method and apparatus and storage medium

Country Status (2)

Country Link
CN (1) CN111356982A (en)
WO (1) WO2020107469A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113094067A (en) * 2021-03-30 2021-07-09 国核自仪系统工程有限公司 Firmware updating method of IO module and IO module
CN113238789B (en) * 2021-05-27 2023-06-27 闻泰通讯股份有限公司 Electronic device, firmware upgrading method and device thereof and computer readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030229752A1 (en) * 2002-04-01 2003-12-11 Sreekrishnan Venkiteswaran Updating flash memory
CN104077167A (en) * 2014-07-11 2014-10-01 杭州华三通信技术有限公司 Boot loading method and device based on NAND FLASH
CN104360877A (en) * 2014-10-24 2015-02-18 同济大学 ECU (electronic control unit) firmware updating method based on Bootloader self update
CN105893090A (en) * 2016-03-31 2016-08-24 武汉光迅科技股份有限公司 Method for upgrading BOOTROM and application of embedded system

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103365676B (en) * 2012-04-01 2016-08-03 中兴通讯股份有限公司 The method for upgrading software of communication equipment and device
CN107861745A (en) * 2017-11-30 2018-03-30 厦门科华恒盛股份有限公司 A kind of application program online upgrading method, apparatus, equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030229752A1 (en) * 2002-04-01 2003-12-11 Sreekrishnan Venkiteswaran Updating flash memory
CN104077167A (en) * 2014-07-11 2014-10-01 杭州华三通信技术有限公司 Boot loading method and device based on NAND FLASH
CN104360877A (en) * 2014-10-24 2015-02-18 同济大学 ECU (electronic control unit) firmware updating method based on Bootloader self update
CN105893090A (en) * 2016-03-31 2016-08-24 武汉光迅科技股份有限公司 Method for upgrading BOOTROM and application of embedded system

Also Published As

Publication number Publication date
CN111356982A (en) 2020-06-30

Similar Documents

Publication Publication Date Title
US20170322796A1 (en) Device and method for updating firmware and firmware update system
JP5342302B2 (en) Firmware update system, firmware distribution server, and program
CN107870968B (en) Performing real-time updates to a file system volume
CN112416406B (en) Terminal equipment upgrading method, device, terminal equipment and medium
CN102521289B (en) File synchronization method, device and system
US20120101996A1 (en) Apparatus and method for snapshot image segmentation
CN104081329A (en) Backup storage system that backs up data, and backup storage device and method
US20160162278A1 (en) System and method for applying an update to a device system via a system snapshot
US20170052779A1 (en) Method and Device for Running Version File
EP2329368B1 (en) Updating content without using a mini operating system
WO2020107469A1 (en) Application processing method and apparatus and storage medium
CN111258666A (en) Reading method and device of computer file, computer system and storage medium
CN110209420A (en) A kind of method and device updating bootstrap loader
CN111045712A (en) Single system upgrading method and system with backup function
CN114661322B (en) Upgrade method of operating system, electronic equipment and storage medium
CN107291507B (en) Upgrading method for virtual hard disk of virtual machine and electronic equipment
US20160321057A1 (en) Electronic apparatus
US9459883B2 (en) Modifying disk images
US20150269029A1 (en) Immediate Recovery of an Application from File Based Backups
CN111026417A (en) Embedded equipment upgrading method and embedded equipment
US10001921B2 (en) Data migration method and data migration device
US11176089B2 (en) Systems and methods for implementing dynamic file systems
WO2017173924A1 (en) Method and device for switching between file systems
CN114443081A (en) Terminal upgrading method and terminal
KR101143909B1 (en) Dual backup system based on cloud computing

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18941153

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18941153

Country of ref document: EP

Kind code of ref document: A1