Information writing method for mcu firmware and terminal

By acquiring the characteristic data of the MCU interrupt vector table, creating an array, mapping physical addresses in the assembly module, and using linker scripts and parsing tools to write customized information, the problems of easy tampering of MCU firmware information and improper space utilization are solved, thereby improving security and scalability.

CN115186271BActive Publication Date: 2026-05-05X-SPEED INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
X-SPEED INFORMATION TECH CO LTD
Filing Date
2022-07-26
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

Existing methods for modifying MCU firmware information suffer from problems such as easy tampering of information, inconvenience in space allocation due to address changes, waste of space, and poor scalability. Furthermore, software version iterations can easily lead to device bricking.

Method used

By obtaining the interrupt vector table characteristic data of the MCU, determining the end address, creating an array in the C language module of the original firmware and mapping it to the physical address of the assembly module, defining the physical address using the linker script, and using a parsing tool to write customized information into the information space to generate new firmware.

Benefits of technology

It enables customized modification of MCU firmware information without altering the original firmware code, improving information security, preventing third-party tampering, and optimizing space utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115186271B_ABST
    Figure CN115186271B_ABST
Patent Text Reader

Abstract

This invention provides a method and terminal for writing information into MCU firmware. The method involves obtaining characteristic data of the MCU's interrupt vector table and determining the end address of the interrupt vector table based on the characteristic data. An array is created in the C language module of the original firmware, and the address of the array is mapped to the physical address of the assembly module in the original firmware. A linker script is obtained, and the address after the end address is defined as the physical address in the linker script. A parsing tool is created, which obtains the information space of the original firmware and writes customized information into the information space to generate new firmware. This application customizes and modifies information within the MCU firmware without changing the original firmware code. By utilizing the changing physical addresses within the firmware, it avoids third-party software arbitrarily tampering with firmware information through field matching and other methods, thus ensuring the security of the firmware information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of embedded systems, and more particularly to a method and terminal for writing MCU firmware information. Background Technology

[0002] The Cortex-M0 core is designed by ARM based on the ARMv6M core architecture. The most significant difference between the Cortex-M0 and other Cortex-M series designs is its low-power design. Currently, there is a severe lack of technical means for MCUs (Microcontroller Units) to provide self-identifying product information in their software. This is because, generally, during the compilation and linking of MCU software, the addresses of predefined data information change after compilation; that is, after any modification to the source code file, the overall address space changes with each compilation. Therefore, the most common technique for modifying firmware information is to introduce identifiable fixed information. When modifying firmware information, this fixed information is first located to pinpoint the "address," and then the information is written to that address. However, this method has problems: the fixed identifiable information is easily identified and tampered with by third parties, and because of the change in "address," it is not easy to re-customize the fixed information using external tools.

[0003] Furthermore, if the MCU has sufficient on-chip flash resources, a separate flash space can be allocated for independent use regardless of cost. However, this presents several problems: 1. The address and size of the information to be written are fixed within the entire firmware file, making it easy for third parties to tamper with them; 2. The allocation of flash space is difficult to control. If the space is too large, there will be wasted space; if the space is too small, subsequent customization and scalability will be poor; 3. Because it involves the allocation of the MCU's on-chip flash space, if the address allocation is improper, software version iterations need to be handled with extreme care. Once an error occurs, the device becomes a "brick". Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a method and terminal for writing information in MCU firmware, so as to realize the customized modification of fixed information and improve the security of information.

[0005] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:

[0006] A method for writing information to MCU firmware, comprising the following steps:

[0007] S1. Obtain the characteristic data of the interrupt vector table of the MCU, and determine the end address of the interrupt vector table based on the characteristic data;

[0008] S2. Create an array in the C language module of the original firmware, and map the address of the array to the physical address of the assembly module in the assembly module of the original firmware;

[0009] S3. Obtain the linker script, and define the address after the end address as the physical address in the linker script;

[0010] S4. Create a parsing tool, obtain the information space of the original firmware in the parsing tool, write the customized information into the information space, and generate new firmware.

[0011] To solve the above-mentioned technical problems, another technical solution adopted by the present invention is as follows:

[0012] An MCU firmware information writing terminal includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it performs the following steps:

[0013] S1. Obtain the characteristic data of the interrupt vector table of the MCU, and determine the end address of the interrupt vector table based on the characteristic data;

[0014] S2. Create an array in the C language module of the original firmware, and map the address of the array to the physical address of the assembly module in the assembly module of the original firmware;

[0015] S3. Obtain the linker script, and define the address after the end address as the physical address in the linker script;

[0016] S4. Create a parsing tool, obtain the information space of the original firmware in the parsing tool, write the customized information into the information space, and generate new firmware.

[0017] The beneficial effects of this invention are as follows: An array space is created in the original firmware to store customized information of the MCU firmware, and the array space is constructed at the physical address after the end address of the interrupt vector table. At the same time, a parsing tool is created to parse and obtain the physical address, and customized information is written into the MCU firmware within the physical address. Thus, the array space can be modified externally, and the modified array space information can be read from the physical address. The customization and modification of information within the MCU firmware can be performed without changing the original firmware code. Furthermore, because this method requires the use of the changing physical address within the firmware, it avoids third-party software from arbitrarily tampering with firmware information through field matching or other methods, thus ensuring the security of firmware information. Attached Figure Description

[0018] Figure 1 This is a flowchart of the steps of an MCU firmware information writing method disclosed in this invention;

[0019] Figure 2 A flowchart of a parsing tool for an MCU firmware information writing method provided in an embodiment of the present invention;

[0020] Figure 3 A flowchart illustrating the program construction of an MCU firmware information writing method provided in an embodiment of the present invention;

[0021] Figure 4 An input interface diagram of an MCU firmware information writing method provided in an embodiment of the present invention;

[0022] Figure 5 A binary file comparison diagram of an MCU firmware information writing method provided in an embodiment of the present invention;

[0023] Figure 6 This is a schematic diagram of the structure of an MCU firmware information writing terminal provided in an embodiment of the present invention;

[0024] Label Explanation:

[0025] 1. An MCU firmware information writing terminal; 2. ; memory; 3. processor. Detailed Implementation

[0026] To explain in detail the technical content, objectives, and effects of the present invention, the following description is provided in conjunction with the embodiments and accompanying drawings.

[0027] Please refer to Figure 1 A method for writing information to MCU firmware, comprising the following steps:

[0028] S1. Obtain the characteristic data of the interrupt vector table of the MCU, and determine the end address of the interrupt vector table based on the characteristic data;

[0029] S2. Create an array in the C module of the original firmware, and map the address of the array to the physical address of the assembly module in the assembly module of the original firmware;

[0030] S3. Obtain the linker script, and define the address after the end address as the physical address in the linker script;

[0031] S4. Create a parsing tool, obtain the information space of the original firmware in the parsing tool, write the customized information into the information space, and generate new firmware.

[0032] As can be seen from the above description, the beneficial effects of the present invention are as follows: an array space is created in the original firmware to store customized information of the MCU firmware, and the array space is constructed at the physical address after the end address of the interrupt vector table. At the same time, a parsing tool is created to parse and obtain the physical address, and customized information is written into the MCU firmware within the physical address. Thus, the array space can be modified externally, and the modified array space information can be read from the physical address. The customization and modification of information within the MCU firmware can be performed without changing the original firmware code. Furthermore, because this method requires the use of the changing physical address within the firmware, it avoids third-party software from arbitrarily tampering with firmware information through field matching and other methods, thus ensuring the security of firmware information.

[0033] Furthermore, the characteristic data includes the number of maskable interrupt channels and the number of interrupt threads;

[0034] Specifically, S1 is:

[0035] Obtain the number of maskable interrupt channels and the number of interrupt threads in the interrupt vector table; obtain the total number of interrupts in the interrupt vector table based on the number of maskable interrupt channels and the number of interrupt threads; and determine the end address of the interrupt vector table based on the total number of interrupts.

[0036] As described above, by consulting relevant technical manuals, the number of maskable interrupt channels and the number of interrupt threads in the interrupt vector table can be determined. The total number of interrupts is obtained by adding the two together, and the end address of the interrupt vector table is calculated according to the ARM architecture. The end address of the interrupt vector table is then used as the physical address of the customized information. Setting the physical address of the customized information after the interrupt vector table does not occupy the interrupt vector table address preset by the MCU itself, and will not cause incompatibility issues due to subsequent product updates and iterations.

[0037] Furthermore, S2 specifically includes:

[0038] S21. Create an array in the C language module of the original firmware;

[0039] S22. In the assembly module, the array is called, and the address of the array is mapped to the physical address of the assembly module through real address mode.

[0040] As described above, the starting address of the assembly module is the ending address of the interrupt vector table. Since the address located at the offset position of the end address of the interrupt vector table is a valid physical address and does not conflict with the fixed interrupt vector table address of the MCU, the address located at the offset position of the end address of the interrupt vector table can be used as the physical address for storing customized information.

[0041] Furthermore, S3 specifically refers to:

[0042] S31. Obtain the linker script, and obtain the starting address of the interrupt vector table in the linker script;

[0043] S32. Determine the end address of the interrupt vector table based on the total number of interrupts and the start address of the interrupt vector table;

[0044] S33. Define the end address of the interrupt vector table in the linker script as the start address of the assembly module of the original firmware.

[0045] As described above, defining the address of the array through the linker script avoids the generated binary file from being abnormal due to the compiler optimizing the area of ​​the array address and causing it to not correspond to the content of the assembly module, thus ensuring the normal operation of the assembly module.

[0046] Furthermore, S4 specifically includes:

[0047] S41. Import the original firmware into the parsing tool, obtain the end address of the interrupt vector table of the original firmware, and calculate the offset address based on the end address of the interrupt vector table.

[0048] S42. Determine the information space based on the offset address, write the customized information into the information space, and generate new firmware.

[0049] As described above, the parsing tool is used to verify whether this method can effectively modify and customize the information of the original firmware, to test the feasibility of this method, and to complete the customization and modification of MCU firmware information through the parsing tool.

[0050] Please refer to Figure 6 A terminal for writing MCU firmware information includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it performs the following steps:

[0051] S1. Obtain the characteristic data of the interrupt vector table of the MCU, and determine the end address of the interrupt vector table based on the characteristic data;

[0052] S2. Create an array in the C language module of the original firmware, and map the address of the array to the physical address of the assembly module in the assembly module of the original firmware;

[0053] S3. Obtain the linker script, and define the address after the end address as the physical address in the linker script;

[0054] S4. Create a parsing tool, obtain the information space of the original firmware in the parsing tool, write the customized information into the information space, and generate new firmware.

[0055] As can be seen from the above description, the beneficial effects of the present invention are as follows: an array space is created in the original firmware to store customized information of the MCU firmware, and the array space is constructed at the physical address after the end address of the interrupt vector table. At the same time, a parsing tool is created to parse and obtain the physical address, and customized information is written into the MCU firmware within the physical address. Thus, the array space can be modified externally, and the modified array space information can be read from the physical address. The customization and modification of information within the MCU firmware can be performed without changing the original firmware code. Furthermore, because this method requires the use of the changing physical address within the firmware, it avoids third-party software from arbitrarily tampering with firmware information through field matching and other methods, thus ensuring the security of firmware information.

[0056] Furthermore, the characteristic data includes the number of maskable interrupt channels and the number of interrupt threads;

[0057] Specifically, S1 is:

[0058] Obtain the number of maskable interrupt channels and the number of interrupt threads in the interrupt vector table; obtain the total number of interrupts in the interrupt vector table based on the number of maskable interrupt channels and the number of interrupt threads; and determine the end address of the interrupt vector table based on the total number of interrupts.

[0059] As described above, by consulting relevant technical manuals, the number of maskable interrupt channels and the number of interrupt threads in the interrupt vector table can be determined. The total number of interrupts is obtained by adding the two together, and the end address of the interrupt vector table is calculated according to the ARM architecture. The end address of the interrupt vector table is then used as the physical address of the customized information. Setting the physical address of the customized information after the interrupt vector table does not occupy the interrupt vector table address preset by the MCU itself, and will not cause incompatibility issues due to subsequent product updates and iterations.

[0060] Furthermore, S2 specifically includes:

[0061] S21. Create an array in the C language module of the original firmware;

[0062] S22. In the assembly module, the array is called, and the address of the array is mapped to the physical address of the assembly module through real address mode.

[0063] As described above, the starting address of the assembly module is the ending address of the interrupt vector table. Since the address located at the offset position of the end address of the interrupt vector table is a valid physical address and does not conflict with the fixed interrupt vector table address of the MCU, the address located at the offset position of the end address of the interrupt vector table can be used as the physical address for storing customized information.

[0064] Furthermore, S3 specifically refers to:

[0065] S31. Obtain the linker script, and obtain the starting address of the interrupt vector table in the linker script;

[0066] S32. Determine the end address of the interrupt vector table based on the total number of interrupts and the start address of the interrupt vector table;

[0067] S33. Define the end address of the interrupt vector table in the linker script as the start address of the assembly module of the original firmware.

[0068] As described above, defining the address of the array through the linker script avoids the generated binary file from being abnormal due to the compiler optimizing the area of ​​the array address and causing it to not correspond to the content of the assembly module, thus ensuring the normal operation of the assembly module.

[0069] Furthermore, S4 specifically includes:

[0070] S41. Import the original firmware into the parsing tool, obtain the end address of the interrupt vector table of the original firmware, and calculate the offset address based on the end address of the interrupt vector table.

[0071] S42. Determine the information space based on the offset address, write the customized information into the information space, and generate new firmware.

[0072] As described above, the parsing tool is used to verify whether this method can effectively modify and customize the information of the original firmware, to test the feasibility of this method, and to complete the customization and modification of MCU firmware information through the parsing tool.

[0073] This invention provides a method and terminal for writing MCU firmware information. By leveraging the characteristics of the Cortex-M0 core interrupt vector table, it defines the method for obtaining raw firmware information, thereby enabling customization of the raw firmware information. The following specific embodiments illustrate this:

[0074] Please refer to Figures 1 to 5 Embodiment 1 of the present invention is as follows:

[0075] A method for writing information to MCU firmware, comprising the following steps:

[0076] S1. Obtain the characteristic data of the interrupt vector table of the MCU, and determine the end address of the interrupt vector table based on the characteristic data;

[0077] The characteristic data includes the number of maskable interrupt channels and the number of interrupt threads;

[0078] S1 specifically involves: obtaining the number of maskable interrupt channels and the number of interrupt threads in the interrupt vector table; obtaining the total number of interrupts in the interrupt vector table based on the number of maskable interrupt channels and the number of interrupt threads; and determining the end address of the interrupt vector table based on the total number of interrupts.

[0079] The total number of interrupts in the interrupt vector table equals the number of maskable interrupt channels plus the number of interrupt threads. After obtaining the total number of interrupts in the interrupt vector table, the end address of the interrupt vector table is obtained by aligning it to 4 bytes according to the ARM architecture and converting it to hexadecimal.

[0080] It should be noted that the ARM architecture has an ARM instruction set. ARM instructions are 32-bit instructions, stored in 4-byte alignment. Therefore, an instruction must be fetched from an address that is a multiple of 4.

[0081] S2. Create an array in the C module of the original firmware, and map the address of the array to the physical address of the assembly module in the assembly module of the original firmware;

[0082] Specifically, S2 is:

[0083] S21. Create an array in the C language module of the original firmware;

[0084] S22. In the assembly module, the array is called, and the address of the array is mapped to the physical address of the assembly module through real address mode;

[0085] Real address mode refers to addressing using the same 16-bit segment and offset as the 8086 processor. Its maximum addressable space is 1MB. During addressing, the value of the segment register is shifted left by 4 bits and the offset address is added to obtain the address within the 1MB space.

[0086] S3. Obtain the linker script, and define the address after the end address as the physical address in the linker script;

[0087] Specifically, S3 is:

[0088] S31. Obtain the linker script, and obtain the starting address of the interrupt vector table in the linker script;

[0089] S32. Determine the end address of the interrupt vector table based on the total number of interrupts and the start address of the interrupt vector table;

[0090] S33. Define the end address of the interrupt vector table in the linker script as the start address of the assembly module of the original firmware;

[0091] The linker references the linker script and uses the rules specified therein to process the code segments in the code file, linking them into an executable program.

[0092] S4. Create a parsing tool, obtain the information space of the original firmware in the parsing tool, write the customized information into the information space, and generate new firmware;

[0093] Specifically, S4 is:

[0094] S41. Import the original firmware into the parsing tool, obtain the end address of the interrupt vector table of the original firmware, and calculate the offset address based on the end address of the interrupt vector table.

[0095] S42. Determine the information space based on the offset address, write the customized information into the information space, and generate new firmware.

[0096] It should be noted that in practical applications, the files requiring customized information, parsing tools, and the corresponding MCU projects are bound together by compiling scripts to form a complete implementation program.

[0097] Reference Figure 5 The specific operation flow for forming a complete implementation program is as follows:

[0098] D1. In the compiler, construct the prebuild action; in the prebuild action, import customized user information through int configuration and obtain the version repository and generate version information through git bash, and generate customized information based on customized user information and version information.

[0099] D2. At the same time, create and execute the prebuild and postbuild action scripts in the MCU project, determine whether the compilation is complete, and if so, execute the postbuild action to generate the original firmware.

[0100] D3. Import customized information and original firmware, and package to generate the final firmware.

[0101] It should be noted that D1 generates a file containing customized information; D2 compiles the MCU project that has completed S1, S2 and S3 as described in this application to generate the original firmware; D3 imports the customized information and the original firmware into the parsing tool to generate new firmware.

[0102] Please refer to Figures 1 to 5Embodiment two of the present invention is as follows:

[0103] A method for writing MCU firmware information is applied to the N32G030 series MCUs.

[0104] S1. Obtain the characteristic data of the interrupt vector table of the MCU, and determine the end address of the interrupt vector table based on the characteristic data;

[0105] Specifically, referring to the N32G030 user manual, the characteristic data of its interrupt vector table is as follows: 32 maskable interrupt channels (excluding the 16 Cortex-M0 interrupt lines); therefore, the total number of interrupts in the interrupt vector table = 32 maskable interrupt channels + 16 Cortex-M0 core interrupt threads = 48. According to the ARM architecture 4-byte alignment, we get 48 × 4 = 192. 192 converted to hexadecimal is 0xc0, so 0xc0 is the offset address.

[0106] S2. Create an array in the C module of the original firmware, and map the address of the array to the physical address of the assembly module in the assembly module of the original firmware;

[0107] S21. Define an array gTestInfo in the C language module; the size of the array space can be allocated according to the product design requirements.

[0108] Program code: const uint8_t gTestInfo

[16] = {0x99};

[0109] S22. In the assembly module, call the above array gTestInfo. In real address mode, allocate a contiguous word storage unit for the above array and initialize it with the specified data.

[0110] Program code: import gTestInfo;

[0111] DCD gTestInfo;

[0112] S3. Obtain the linker script, and define the address after the end address as the physical address in the linker script;

[0113] S31. Obtain the linker script, and obtain the starting address of the interrupt vector table in the linker script;

[0114] Program code: define symbol__ICFEDIT_intvec_start__=0x08000000;

[0115] Among them, 0x08000000 is the starting address of the internal ROM of the N32G030 series MCU;

[0116] S32. Based on the offset address 0xc0 calculated from the total number of interrupts above and the start address __ICFEDIT_intvec_start__ of the interrupt vector table, determine the end address of the interrupt vector table as follows:

[0117] __ICFEDIT_intvec_start__+0x000000c0

[0118] S33. Define the end address of the interrupt vector table in the linker script as the start address of the assembly module of the original firmware;

[0119] Program code: define symbol__ICFEDIT_code_start__=__ICFEDIT_intvec_start__+0x000000c0

[0120] S4. Create a parsing tool, obtain the information space of the original firmware in the parsing tool, write the customized information into the information space, and generate new firmware;

[0121] S41. The parsing tool reads the bin image file data of the original firmware;

[0122] S42. Obtain the address SRCADDR at 0xc0 within the bin image file of the original firmware;

[0123] S43. Based on the obtained address SRCADDR, calculate the corresponding offset address SRCOFFSET in the firmware and obtain its information space, where SRCOFFSET = SRCADDR - BASEADDR, and BASEADDR is the internal ROM address of the MCU.

[0124] S44. Write the customized information into the information space of SRCOFFSET;

[0125] S45. After completing the writing of customized information, generate new firmware.

[0126] Reference Figure 4 and Figure 5 The information stored in the gTestInfo array space in the original firmware differs from that stored in the gTestInfo array space in the new firmware, indicating that the customized information was successfully written.

[0127] Please refer to Figure 6 Embodiment 3 of the present invention is as follows:

[0128] An MCU firmware information writing terminal 1 includes a memory 2, a processor 3, and a computer program stored on the memory 2 and running on the processor 3. When the processor 3 executes the computer program, it implements any of the steps of Embodiment 1 to Embodiment 2.

[0129] In summary, the MCU firmware information writing method and terminal provided by this invention compiles a customized information file, a parsing tool, and the corresponding MCU project into a complete program. This program can automatically fill the required customized information into the corresponding positions via the MCU's scripting tools. Furthermore, when providing MCU firmware externally, it can not only import external version management tools via scripts to dynamically extract and generate the current version information, avoiding the uncertainty caused by manual intervention, but also import customized user information for different users, avoiding reinventing the wheel and reducing the cost and risk of version control.

[0130] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent modifications made based on the content of the present invention specification and drawings, or direct or indirect applications in related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A method for writing information to MCU firmware, characterized in that, Including the following steps: S1. Obtain the characteristic data of the interrupt vector table of the MCU, and determine the end address of the interrupt vector table based on the characteristic data; S2. Create an array in the C language module of the original firmware, and map the address of the array to the physical address of the assembly module in the assembly module of the original firmware; S3. Obtain the linker script, and define the address after the end address as the physical address in the linker script; S4. Create a parsing tool, obtain the information space of the original firmware in the parsing tool, write the customized information into the information space, and generate new firmware; Specifically, S4 is: S41. Import the original firmware into the parsing tool, obtain the end address of the interrupt vector table of the original firmware, and calculate the offset address based on the end address of the interrupt vector table. S42. Determine the information space based on the offset address, write the customized information into the information space, and generate new firmware.

2. The method for writing information to MCU firmware according to claim 1, characterized in that, The characteristic data includes the number of maskable interrupt channels and the number of interrupt threads; Specifically, S1 is: Obtain the number of maskable interrupt channels and the number of interrupt threads in the interrupt vector table; obtain the total number of interrupts in the interrupt vector table based on the number of maskable interrupt channels and the number of interrupt threads; and determine the end address of the interrupt vector table based on the total number of interrupts.

3. The method for writing information to MCU firmware according to claim 1, characterized in that, Specifically, S2 is: S21. Create an array in the C language module of the original firmware; S22. In the assembly module, the array is called, and the address of the array is mapped to the physical address of the assembly module through real address mode.

4. The method for writing information to MCU firmware according to claim 2, characterized in that, Specifically, S3 is: S31. Obtain the linker script, and obtain the starting address of the interrupt vector table in the linker script; S32. Determine the end address of the interrupt vector table based on the total number of interrupts and the start address of the interrupt vector table; S33. Define the end address of the interrupt vector table in the linker script as the start address of the assembly module of the original firmware.

5. An MCU firmware information writing terminal, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it performs the following steps: S1. Obtain the characteristic data of the interrupt vector table of the MCU, and determine the end address of the interrupt vector table based on the characteristic data; S2. Create an array in the C language module of the original firmware, and map the address of the array to the physical address of the assembly module in the assembly module of the original firmware; S3. Obtain the linker script, and define the address after the end address as the physical address in the linker script; S4. Create a parsing tool, obtain the information space of the original firmware in the parsing tool, write the customized information into the information space, and generate new firmware; Specifically, S4 is: S41. Import the original firmware into the parsing tool, obtain the end address of the interrupt vector table of the original firmware, and calculate the offset address based on the end address of the interrupt vector table. S42. Determine the information space based on the offset address, write the customized information into the information space, and generate new firmware.

6. The MCU firmware information writing terminal according to claim 5, characterized in that, The characteristic data includes the number of maskable interrupt channels and the number of interrupt threads; Specifically, S1 is: Obtain the number of maskable interrupt channels and the number of interrupt threads in the interrupt vector table; obtain the total number of interrupts in the interrupt vector table based on the number of maskable interrupt channels and the number of interrupt threads; and determine the end address of the interrupt vector table based on the total number of interrupts.

7. The MCU firmware information writing terminal according to claim 5, characterized in that, Specifically, S2 is: S21. Create an array in the C language module of the original firmware; S22. In the assembly module, the array is called, and the address of the array is mapped to the physical address of the assembly module through real address mode.

8. The MCU firmware information writing terminal according to claim 6, characterized in that, Specifically, S3 is: S31. Obtain the linker script, and obtain the starting address of the interrupt vector table in the linker script; S32. Determine the end address of the interrupt vector table based on the total number of interrupts and the start address of the interrupt vector table; S33. Define the end address of the interrupt vector table in the linker script as the start address of the assembly module of the original firmware.

Citation Information

Patent Citations

  • Firmware security analysis method and device

    CN111881455A

  • Method of interrupt vector redirection

    CN1731367A