CN112395065B - Interrupt service method and device for starting loading of embedded system - Google Patents

Interrupt service method and device for starting loading of embedded system Download PDF

Info

Publication number
CN112395065B
CN112395065B CN202011348632.9A CN202011348632A CN112395065B CN 112395065 B CN112395065 B CN 112395065B CN 202011348632 A CN202011348632 A CN 202011348632A CN 112395065 B CN112395065 B CN 112395065B
Authority
CN
China
Prior art keywords
app
interrupt
interrupt service
bootloader
embedded system
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011348632.9A
Other languages
Chinese (zh)
Other versions
CN112395065A (en
Inventor
黎晓英
黎小三
李鄂胜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hubei Kait Automotive Electronic & Electrical Systems Co ltd
Original Assignee
Hubei Kait Automotive Electronic & Electrical Systems Co ltd
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 Hubei Kait Automotive Electronic & Electrical Systems Co ltd filed Critical Hubei Kait Automotive Electronic & Electrical Systems Co ltd
Priority to CN202011348632.9A priority Critical patent/CN112395065B/en
Publication of CN112395065A publication Critical patent/CN112395065A/en
Application granted granted Critical
Publication of CN112395065B publication Critical patent/CN112395065B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4812Task transfer initiation or dispatching by interrupt, e.g. masked
    • 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/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/32Address formation of the next instruction, e.g. by incrementing the instruction counter
    • G06F9/322Address formation of the next instruction, e.g. by incrementing the instruction counter for non-sequential address
    • G06F9/327Address formation of the next instruction, e.g. by incrementing the instruction counter for non-sequential address for interrupts
    • 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/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention relates to an interrupt service method for starting loading of an embedded system, which comprises the following steps: defining a global variable named as a judgment quantity on the same absolute address in program storage spaces of the Bootloader and the App; initializing the judgment amount to a first set value when the Bootloader runs, and setting the judgment amount to a second set value when the Bootloader needs to jump to App; when an App is operated, setting the judgment amount as the first set value when the jump to a Bootloader is needed; and realizing interrupt service of the startup loading of the embedded system based on the judgment. The invention can realize the starting loading of the processor without the interrupt vector shifter, and interrupt resources can be respectively used in the Bootloader section and the App section.

Description

Interrupt service method and device for starting loading of embedded system
Technical Field
The present invention relates to the field of embedded system boot loading technologies, and in particular, to an interrupt service method and apparatus for boot loading of an embedded system, and a computer storage medium.
Background
Based on the processor with IAP function, the Bootloader function can be realized, so that the product can realize the function of updating software in the system through communication methods such as a communication bus and the like. The Flash in the chip of the processor is divided into 2 parts (the size is determined according to the requirement), the first half part is a Bootloader area, and the second half part is an App area. After the processor is powered up, the Bootloader section is firstly removed from running, whether a correct App section program exists is checked, and if yes, the process immediately jumps to the App running; otherwise, stay in Bootloader section waiting to communicate with download device to update App section program. When the App section runs, the processor can jump to the Bootloader section again by means of diagnostic commands and the like, and the App section software starts to be updated.
For a processor without an interrupt vector offset register, the interrupt entry may be relocated to the App segment by setting an offset address; however, for a processor without an interrupt vector offset register, the interrupt entry address cannot be offset, but can still be in the Bootloader segment. While the program in the App section generally inevitably needs to use interrupt resources, this means that Bootloader will not be able to use interrupt resources. After updating the App, the interrupt vector table of the App is copied and replaced with the interrupt vector table of the Bootloader segment, specifically, as shown in fig. 2a, ① is interrupted when the App segment is executed, ② jumps to the interrupt service function of the App, ③ returns the interrupt, the App segment is continuously executed, and ④ copies the interrupt vector table of the App and replaces the interrupt vector table of the Bootloader segment. Meanwhile, the Bootloader section program should be locked after the factory programming to prevent accidental erasing, which is contradictory to the point that the interrupt vector table of the App copies and replaces the interrupt vector table of the Bootloader section. In addition, bootloader cannot use interrupt resources, the communication process can only poll continuously, and the efficiency is greatly reduced.
Disclosure of Invention
In view of the foregoing, it is desirable to provide an interrupt service method and apparatus for boot loading of an embedded system, so as to solve the problem that a processor without an interrupt vector offset register cannot use interrupt resources in Bootloader segment and App segment respectively.
The invention provides an interrupt service method for starting loading of an embedded system, which comprises the following steps:
Defining a global variable named as a judgment quantity on the same absolute address in program storage spaces of the Bootloader and the App;
initializing the judgment amount to a first set value when the Bootloader runs, and setting the judgment amount to a second set value when the Bootloader needs to jump to App;
When an App is operated, setting the judgment amount as the first set value when the jump to a Bootloader is needed;
And realizing interrupt service of the startup loading of the embedded system based on the judgment.
Further, the first set value is "0", and the second set value is "1"; or the first set value is "1", and the second set value is "0".
Further, the interrupt service for implementing the startup loading of the embedded system based on the judgment amount specifically comprises the following steps:
And realizing interrupt service in the Bootloader and interrupt service in the App based on the judgment.
Further, based on the judgment, implementing interrupt service in the Bootloader, specifically:
And if the Bootloade is interrupted during operation, judging whether the judgment quantity is a second set value: if yes, loading a service function address corresponding to an interrupt vector table in the App, and then using a jump instruction to jump to the service function address for operation; if not, the computing resource is manually stacked, then the interrupt service sub-function of the Bootloader is called, and finally the computing resource is manually popped.
Further, using the jump instruction to jump to the service function address for running, further comprising:
and when the service function address is jumped to run, closing the interrupt resource used by the Bootloader.
Further, based on the judgment, implementing interrupt service in the App specifically includes:
the method comprises the steps that computing resources needed to be used by interrupt service in an App are stacked through a compiler;
calling an interrupt service sub-function of the App, and popping a computing resource required to be used by interrupt service in the App through a compiler before returning the interrupt;
and adding the address of the interrupt service sub-function of the App into the address of the corresponding terminal type in the interrupt vector table of the App through the linker.
The invention also provides an interrupt service device for starting and loading the embedded system, which comprises a processor and a memory, wherein the memory is stored with a computer program, and when the computer program is executed by the processor, the interrupt service method for starting and loading the embedded system is realized.
The invention also provides a computer storage medium on which a computer program is stored which, when executed by a processor, implements an interrupt service method for boot loading of the embedded system.
The beneficial effects are that: the invention sets the judgment quantity, and can judge whether the interruption occurs in the running process of the App or the running process of the Bootloader through the value of the judgment quantity, thereby being convenient for accurately judging the interruption position, being convenient for carrying out corresponding stacking/popping processing when the interruption occurs, ensuring the accurate return of the interruption program and ensuring that both Bootloade and the App can use the interruption resource.
Drawings
FIG. 1 is a flowchart of a method for providing an interrupt service method for boot loading of an embedded system according to a first embodiment of the present invention;
FIG. 2a is a diagram showing the change in the program counter orientation of an interrupt service when a processor without an interrupt vector offset register in the prior art performs a boot load;
FIG. 2b is a schematic diagram illustrating a program counter for implementing Bootloader interrupt according to a first embodiment of the interrupt service method for startup loading of a mid-embedded system according to the present invention;
FIG. 2c is a schematic diagram of a program counter for implementing App interrupt according to a first embodiment of an interrupt service method for boot loading of an embedded system according to the present invention;
FIG. 3a is a diagram of a calling program for calling an interrupt service sub-function of a Bootloader when implementing boot loading according to a first embodiment of the interrupt service method for boot loading of an embedded system provided by the present invention;
FIG. 3b is a schematic diagram illustrating an interrupt service sub-function calling Bootloader when implementing boot loading according to a first embodiment of the method for providing interrupt service for boot loading of an embedded system of the present invention.
Detailed Description
The following detailed description of preferred embodiments of the application is made in connection with the accompanying drawings, which form a part hereof, and together with the description of the embodiments of the application, are used to explain the principles of the application and are not intended to limit the scope of the application.
Example 1
As shown in fig. 1, embodiment 1 of the present invention provides an interrupt service method for startup loading of an embedded system, hereinafter referred to as the present method, comprising the following steps:
s1, defining a global variable with the name of judgment on the same absolute address in program storage spaces of Bootloader and App;
S2, initializing the judgment amount to a first set value when the Bootloader runs, and setting the judgment amount to a second set value when the Bootloader needs to jump to an App;
S3, when the App is operated, setting the judgment quantity as the first set value when the jump to the Bootloader is needed;
and S4, realizing interrupt service of starting loading of the embedded system based on the judgment.
In this embodiment, a global variable named IsInApp (i.e., a judgment) is defined in Bootloader and App at the same absolute address, and is used to indicate whether the current program is running in Bootloader or App. In the Bootloader program, it is initialized to the first setting value, so IsInApp is the first setting value, indicating that it is running in the Bootloader. When the jump to App operation is required, it is set to the second setting value, so IsInApp is the second setting value, indicating operation in App. In the App procedure, it is defined as not initializing. Thus, when the jump is made from the Bootloader, the value is the second set value. When the operation needs to jump to the Bootloader, the Bootloader is set as a first set value, and the operation is indicated to return to the Bootloader. For example, example code in Bootloader engineering: unsigned char isivapp@0x10=0; example code in App engineering: __ no-init unsigned char IsInApp@0x10.
Because global variable IsInApp is set, when an interrupt occurs, whether the interrupt occurs during the running of an App or during the running of a Bootloader can be judged, so that the accurate judgment of the interrupt position is realized, the corresponding stack-in/stack-out processing is convenient to carry out when the interrupt occurs, the accurate return of an interrupt program is ensured, and the Bootloader and the App can both use interrupt resources. The method aims at realizing that the interrupt resources can be used by the processors based on the interrupt-free vector offset register in both the Bootloader section and the App section, and the Bootloader section can be locked.
Preferably, the first set value is "0", and the second set value is "1"; or the first set value is "1", and the second set value is "0".
In this embodiment, the first set value is "0", and the second set value is "1".
Preferably, the interrupt service for implementing the startup loading of the embedded system based on the judgment comprises the following steps:
And realizing interrupt service in the Bootloader and interrupt service in the App based on the judgment.
Preferably, the interrupt service in the Bootloader is implemented based on the judgment, specifically:
and if the Bootloader is interrupted in operation, judging whether the judgment quantity is a second set value: if yes, loading a service function address corresponding to an interrupt vector table in the App, and then using a jump instruction to jump to the service function address for operation; if not, the computing resource is manually stacked, then the interrupt service sub-function of the Bootloader is called, and finally the computing resource is manually popped.
The interrupt service function in Bootloader immediately determines IsInApp the variables upon entry. If IsInApp is 1, then the address of the corresponding service function in the App's interrupt vector table is loaded using nested assembly code, and then jumps to that address run using a jump instruction. Thus, the interrupt service function of the App is executed, and the interrupt return can be correctly executed after the completion. Note that: after loading the service function address of App, a jump instruction must be used, a CALL instruction cannot be used, otherwise, the stack will be unbalanced when the function returns, and the processor will run. If IsInApp is 0, the interrupt service sub-function of Bootloader is called, but the direct call will cause stack imbalance when the interrupt service function of App is interrupted and returned, the interrupt service sub-function of Bootloader is directly called, and when the compiler is compiled, the computing resource needed to be used by the sub-function will be first stacked, and then decision IsInApp is made to determine branching. Then for the case of running App interrupt service at IsInApp, the stack imbalance for this path would result, as the last interrupt return from App interrupt service directly would result, the processor would run off. Therefore, the interrupt service sub-function of Bootloader cannot be directly called. Aiming at the problem, the embodiment uses the nested assembly to manually push all the computing resources into stacks, uses the embedded assembly CALL to serve the subfunctions, and finally manually pop the stacks to restore the computing resources, wherein the computing resources are determined according to the characteristics of a processor and a compiler, the specific implementation codes are shown in figure 3a, and the disassembly codes are shown in figure 3 b. When an interrupt occurs in the Bootloader, as shown in fig. 2b, the program counter points to the torsion change, ① generates an interrupt when the Bootloader segment is executed, ② jumps to the interrupt service function of the Bootloader according to the interrupt vector table, ③ jumps to the interrupt service sub-function of the Bootloader according to IsInApp, and ④ the interrupt service sub-function of the Bootloader returns after execution, ⑤ the interrupt returns, and the Bootloader segment is continuously executed.
Preferably, the jump instruction is used to jump to the address of the service function for running, and the method further comprises:
and when the service function address is jumped to run, closing the interrupt resource used by the Bootloader.
Preferably, the interrupt service in the App is implemented based on the judgment, specifically:
the method comprises the steps that computing resources needed to be used by interrupt service in an App are stacked through a compiler;
calling an interrupt service sub-function of the App, and popping a computing resource required to be used by interrupt service in the App through a compiler before returning the interrupt;
and adding the address of the interrupt service sub-function of the App into the address of the corresponding terminal type in the interrupt vector table of the App through the linker.
The interrupt service function is normally written in App. The compiler will put the computing resource needed by the interrupt service function into stack immediately and restore before the interrupt returns; interrupt returns are used without normal returns. The linker will add the address of the service function to the specified address of the corresponding interrupt type in the App's interrupt vector table. When an interrupt occurs in the App, as shown in fig. 2c, the program counter points to the torsion change, ① is interrupted when the App segment is executed, ② jumps to the interrupt service function of the Bootloader according to the interrupt vector table, ③ jumps to the interrupt service function of the App according to IsInApp, and ④ interrupts and returns to continue to execute the App segment.
Example 2
An embodiment 2 of the present invention provides an interrupt service device for startup loading of an embedded system, including a processor and a memory, where the memory stores a computer program, and when the computer program is executed by the processor, the interrupt service method for startup loading of an embedded system provided in embodiment 1 is implemented.
The interrupt service device for starting and loading the embedded system provided by the embodiment of the invention is used for realizing the interrupt service method for starting and loading the embedded system, so that the interrupt service device for starting and loading the embedded system has the technical effects of the interrupt service method for starting and loading the embedded system, and the interrupt service device for starting and loading the embedded system is also provided and is not described in detail herein.
Example 3
Embodiment 3 of the present invention provides a computer storage medium having stored thereon a computer program which, when executed by a processor, implements the interrupt service method for startup loading of an embedded system provided in embodiment 1.
The computer storage medium provided by the embodiment of the invention is used for realizing the interrupt service method of the startup loading of the embedded system, so that the technical effects of the interrupt service method of the startup loading of the embedded system are achieved, and the computer storage medium is also provided and will not be described in detail herein.
The present invention is not limited to the above-mentioned embodiments, and any changes or substitutions that can be easily understood by those skilled in the art within the technical scope of the present invention are intended to be included in the scope of the present invention.

Claims (6)

1. An interrupt service method for starting loading of an embedded system is characterized by comprising the following steps:
Defining a global variable named as a judgment quantity on the same absolute address in program storage spaces of the Bootloader and the App;
initializing the judgment amount to a first set value when the Bootloader runs, and setting the judgment amount to a second set value when the Bootloader needs to jump to App;
When an App is operated, setting the judgment amount as the first set value when the jump to a Bootloader is needed;
based on the judgment, realizing interrupt service of starting loading of the embedded system;
based on the judgment, the interrupt service of the startup loading of the embedded system is realized, which comprises the following steps:
based on the judgment, realizing interrupt service in the Bootloader and interrupt service in the App;
and realizing interrupt service in the Bootloader based on the judgment, wherein the interrupt service comprises the following steps:
And if the Bootloade is interrupted during operation, judging whether the judgment quantity is a second set value: if yes, loading a service function address corresponding to an interrupt vector table in the App, and then using a jump instruction to jump to the service function address for operation; if not, the computing resource is manually stacked, then the interrupt service sub-function of the Bootloader is called, and finally the computing resource is manually popped.
2. The interrupt service method of embedded system boot loading of claim 1, wherein the first setting value is "0" and the second setting value is "1"; or the first set value is "1", and the second set value is "0".
3. The method of interrupt service for startup loading of an embedded system according to claim 1, wherein the jump instruction is used to jump to the service function address for execution, further comprising:
and when the service function address is jumped to run, closing the interrupt resource used by the Bootloader.
4. The interrupt service method for startup loading of an embedded system according to claim 1, wherein the interrupt service in the App is implemented based on the determination, specifically:
the method comprises the steps that computing resources needed to be used by interrupt service in an App are stacked through a compiler;
calling an interrupt service sub-function of the App, and popping a computing resource required to be used by interrupt service in the App through a compiler before returning the interrupt;
And adding the address of the interrupt service sub-function of the App into the address of the corresponding interrupt type in the interrupt vector table of the App through the linker.
5. An interrupt service device for startup loading of an embedded system, comprising a processor and a memory, wherein the memory stores a computer program, and the computer program, when executed by the processor, implements the interrupt service method for startup loading of an embedded system according to any one of claims 1 to 4.
6. A computer storage medium having stored thereon a computer program which, when executed by a processor, implements an interrupt service method of boot loading of an embedded system according to any of claims 1-4.
CN202011348632.9A 2020-11-26 2020-11-26 Interrupt service method and device for starting loading of embedded system Active CN112395065B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011348632.9A CN112395065B (en) 2020-11-26 2020-11-26 Interrupt service method and device for starting loading of embedded system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011348632.9A CN112395065B (en) 2020-11-26 2020-11-26 Interrupt service method and device for starting loading of embedded system

Publications (2)

Publication Number Publication Date
CN112395065A CN112395065A (en) 2021-02-23
CN112395065B true CN112395065B (en) 2024-09-13

Family

ID=74605279

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011348632.9A Active CN112395065B (en) 2020-11-26 2020-11-26 Interrupt service method and device for starting loading of embedded system

Country Status (1)

Country Link
CN (1) CN112395065B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113986481A (en) * 2021-09-30 2022-01-28 深圳曦华科技有限公司 Interrupt service instance calling method and related device
CN113986480A (en) * 2021-09-30 2022-01-28 深圳曦华科技有限公司 Method for calling interrupt service function and related device

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105117269A (en) * 2015-10-09 2015-12-02 天津国芯科技有限公司 Optimization Method of Compiler Based on Vectored Interrupt
CN107153613A (en) * 2017-05-11 2017-09-12 山东鲁能智能技术有限公司 BootLoader program debugging methods and system based on HCS12 single-chip microcomputers

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10104432B2 (en) * 2006-12-01 2018-10-16 Time Warner Cable Enterprises Llc Methods and apparatus for software provisioning of a network device
CN110209531A (en) * 2019-05-23 2019-09-06 湖北三江航天险峰电子信息有限公司 A kind of long-range ARM online upgrade system and method based on RS422 interface
CN111897560B (en) * 2020-08-27 2024-10-15 吉林大学 Program upgrading system, method, device and storage medium based on NB-IoT module

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105117269A (en) * 2015-10-09 2015-12-02 天津国芯科技有限公司 Optimization Method of Compiler Based on Vectored Interrupt
CN107153613A (en) * 2017-05-11 2017-09-12 山东鲁能智能技术有限公司 BootLoader program debugging methods and system based on HCS12 single-chip microcomputers

Also Published As

Publication number Publication date
CN112395065A (en) 2021-02-23

Similar Documents

Publication Publication Date Title
US5615400A (en) System for object oriented dynamic linking based upon a catalog of registered function set or class identifiers
CN112395065B (en) Interrupt service method and device for starting loading of embedded system
EP1872203B1 (en) Selecting subroutine return mechanisms
US12340233B2 (en) Method for operating application program, terminal device and computer-readable storage medium
JPH08234994A (en) Computer system and its operating method
EP2548115A1 (en) Apparatus and method for handling exception events
AU2022202175B2 (en) Firmware publication of multiple binary images
US7360206B1 (en) Method for an interpreter to control a native function call based on a signature of the native function
US20190303171A1 (en) Booting method using system firmware with multiple embedded controller firmwares
US8909835B2 (en) Computer system and method of controlling computer system
US7802080B2 (en) Null exception handling
EP3944174B1 (en) Methods and processors for performing resource deduction for execution of smart contract
US7278139B2 (en) Emulation class revision system and method
JP3322202B2 (en) Method and system for processing instructions
US11775284B2 (en) Electronic device and code patching method
US7562209B2 (en) Supporting different instruction set architectures during run time
CN114217880A (en) Method for breaking through android ghost process limitation
CN112685095B (en) Virtual device loading method, device, equipment and storage medium
CN114385261A (en) Method for loading program in process
US6785806B1 (en) Bios having macro/effector pairs for hardware initialization
CN110990041A (en) Bootloader upgrading method and bootloader upgrading system
US20080127235A1 (en) Methods, systems and computer program products for dynamic linkage
US20050071833A1 (en) Utilization of platform-based optimization routines by a computer system
US20220197673A1 (en) Binary Image Publication by Firmware
CN119376824A (en) A method for providing an initialization environment for an APP program in a bootloader

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant