Hex file address modification method and system

By automating the processing of Hex files, including address modification, reordering, and intelligent padding, the problems of continuity and checksum updates in Hex file address modification are solved, improving processing efficiency and file adaptability, making it suitable for embedded system development.

CN121365013APending Publication Date: 2026-01-20LISHEN (QINGDAO) NEW ENERGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511576780.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-31
Publication Date
2026-01-20

AI Technical Summary

Technical Problem

Existing technologies for modifying Hex file addresses suffer from problems such as difficulty in maintaining address continuity, complex padding and alignment processing, cumbersome checksum updates, low efficiency, and imperfect base address processing, leading to burning failures and low processing efficiency.

Method used

This paper provides a method and system for modifying Hex file addresses. By importing Hex files, splitting record regions, modifying the starting and base addresses, reordering, and performing intelligent padding, the paper ensures the continuity of data blocks and automatic update of checksums, thus meeting the alignment requirements of hardware platforms.

Benefits of technology

It automates and intelligently processes Hex file address modification, improving processing efficiency, ensuring file integrity and continuity, adapting to the address requirements of different hardware platforms, and avoiding burning errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121365013A_ABST
    Figure CN121365013A_ABST
Patent Text Reader

Abstract

The invention discloses a Hex file address modification method and system. The method comprises the following steps of: importing a Hex file, and segmenting each row of records into six areas including a start symbol ':', a data length, an address, a record type, data and a check code according to the format of the Hex file; modifying an initial address and all base addresses of the Hex file; the modification of the address is generally the overall offset from the initial address, so that the purpose can be achieved by modifying the initial address and all base addresses in the file. For the Hex file with the modified address, reordering records according to a base address; and performing intelligent filling on the sorted Hex file to ensure that the total length of data of each continuous address is aligned. The invention has the following beneficial effects: full-automatic treatment is realized; an intelligent filling mechanism; the file integrity is ensured through automatic check code updating, and burning errors are avoided through address continuous line verification; the compatibility is high; the treatment efficiency is high.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of embedded system development, and particularly relates to a Hex file address modification method and system, which is suitable for Hex file address adjustment before firmware programming of an embedded system. BACKGROUND

[0002] As one of the most commonly used firmware formats in embedded system development, Hex file address modification is an indispensable part of the embedded software development process. Hex file (Intel HEX format) is a text format containing address information, used to store binary data to be programmed into microcontrollers or memories. Each line record of this format contains key information such as data length, address, record type, data content, and check code.

[0003] In embedded system development practice, it is often necessary to modify the starting address or overall offset address of the Hex file. The main reasons include: hardware platform differences, different hardware platforms may have different memory mappings, so the Hex file address needs to be adjusted to adapt to the target hardware; multi-firmware coexistence requirements, multiple firmware may need to be programmed simultaneously on the same hardware platform, so the address space of each firmware needs to be adjusted to avoid conflicts; Bootloader support, when using Bootloader, application firmware needs to avoid the address space occupied by Bootloader; memory type switching: when the target memory capacity or type changes, the address space may need to be reallocated.

[0004] In the prior art, Hex file address modification mainly faces the following technical challenges:

[0005] (1) Difficulty in maintaining address continuity: Data records in Hex files are not strictly arranged in address order, and modifying the address can easily break the address continuity, leading to programming failure;

[0006] (2) Complex padding alignment processing: Some hardware platforms require data blocks to be aligned according to specific boundaries (such as 8 bytes), which requires an intelligent padding mechanism;

[0007] (3) Tedious check code update: After address modification, the check code of each line needs to be recalculated and updated, which is prone to human error;

[0008] (4) Low efficiency: Traditional methods rely heavily on manual line-by-line modification, which is inefficient when dealing with large files;

[0009] (5) Incomplete base address processing: The processing of type 04 (extended linear address) records is not intelligent enough, affecting the usability of the modified file. SUMMARY

[0010] The application aims to provide a Hex file address modification method and system, so as to realize the automation and high reliability of Hex file address modification, realize the intelligent filling of non-continuous addresses, ensure the continuity of each data block after address modification, realize the automatic updating of check codes to ensure the integrity of files and meet the special requirements of hardware platforms on data alignment.

[0011] To achieve the object of the application, the technical solution provided by the application is as follows.

[0012] The first aspect

[0013] The application provides a Hex file address modification method, which comprises the following steps:

[0014] Step S1: importing a Hex file, and dividing each line record into six areas of a start symbol ":", data length, address, record type, data and check code according to the Hex file format;

[0015] Step S2: modifying the start address and all base addresses of the Hex file; the modification of the address is generally a whole offset from the start address, so that the modification of the start address and all base addresses in the file can achieve the purpose.

[0016] Step S3: reordering the records according to the base address for the Hex file after the address modification;

[0017] Step S4: intelligently filling the reordered Hex file to ensure that the total length (unit byte) of each block of continuous addresses is aligned.

[0018] The second aspect

[0019] Corresponding to the above method, the application provides a Hex file address modification system, which comprises the following units: a file importing and dividing unit, an address modification unit, a reordering unit and an intelligent filling unit.

[0020] The file importing and dividing unit is used for importing a Hex file, and dividing each line record into six areas of a start symbol, data length, address, record type, data and check code according to the Hex file format;

[0021] The address modification unit is used for modifying the start address and all base addresses of the Hex file.

[0022] The reordering unit is used for reordering the records according to the base address for the Hex file after the address modification.

[0023] The intelligent filling unit is used for intelligently filling the reordered Hex file to ensure that the total length of each block of continuous addresses is aligned.

[0024] Compared with the prior art, the application has the following beneficial effects:

[0025] (1) Full automation: full-process automation from address modification to file reorganization, reducing manual intervention and improving processing efficiency;

[0026] (2) Intelligent filling mechanism: unique non-continuous address filling algorithm, configurable data alignment requirements (such as 8-byte alignment); intelligent judgment of filling position and filling amount;

[0027] (3) High reliability: automatic code verification update ensures file integrity, and address continuous line verification avoids programming errors;

[0028] (4) Strong compatibility: supports all record types of standard IntelHex format, and adapts to different hardware platform address requirements;

[0029] (5) High processing efficiency: optimized algorithm design ensures high speed of large file processing; low memory occupation, suitable for embedded development environment. BRIEF DESCRIPTION OF DRAWINGS

[0030] Figure 1 The Hex file address modification method flowchart provided by the embodiment of the application;

[0031] Figure 2 The Hex file standard format diagram in the embodiment of the application;

[0032] Figure 3 The Hex file address modification logic flowchart in the embodiment of the application;

[0033] Figure 4 The recalculated checksum flowchart in the embodiment of the application;

[0034] Figure 5 The data record line start address calculation flowchart in the embodiment of the application;

[0035] Figure 6 The address continuous line judgment flowchart in the embodiment of the application;

[0036] Figure 7 The non-continuous address filling byte calculation flowchart in the embodiment of the application;

[0037] Figure 8 The address filling flowchart in the embodiment of the application;

[0038] Figure 9 The Hex file text to be modified in the application example of the application;

[0039] Figure 10This is a schematic diagram illustrating the address modification for record types "04" and "05" in the application example of this application;

[0040] Figure 11 This is a schematic diagram of the Hex file before modification in the application example of this application;

[0041] Figure 12 To and Figure 11 The corresponding modified Hex file is shown in the diagram. Detailed Implementation

[0042] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0043] It should be noted that, as Figure 2 As shown, Hex files have a fixed standard format, and each line conforms to the layout shown in the image below, from left to right:

[0044] (1) Start with “:” to indicate the start of a record;

[0045] (2) Two hexadecimal numbers, representing the length of this line of data in bytes, with a maximum of 20H;

[0046] (3) Four hexadecimal numbers represent the address of the data record, which may be the base address or the offset address depending on the record type;

[0047] (4) Two hexadecimal numbers represent the record type ("00" indicates that the current line is a data record; "01" indicates the end of the Hex file; "02" indicates an extended segment address record, the data field of this line is shifted left by 4 bits to get the segment address, and the segment address needs to be added to the address of all subsequent data record lines; "04" indicates an extended linear address record, the data field of this line is shifted left by 16 bits to get the base address, and the address is used as the base address of all subsequent data record lines before the next 04 type line appears; "05" indicates the program entry address).

[0048] (5) Several hexadecimal numbers, the data area of ​​each row, the data length is consistent with the data in part (2);

[0049] (6) Two hexadecimal numbers, the check code of this line, and the complement of the remainder of the sum of the other bytes except the colon and itself when modulo 256.

[0050] like Figure 1 As shown, this invention provides a method for modifying the address of a Hex file, comprising the following steps:

[0051] Step S1: Import the Hex file. Based on the Hex file format, divide each record into six areas: start symbol ":", data length, address, record type, data, and checksum. Figure 2 As shown;

[0052] Additionally, in step S1, the imported code project generates a Hex file. When splitting each line of records according to the Hex format, the current line of records is treated as a string. First, the string length L is calculated. The first character is :, the second and third characters are the data length, the fourth and seventh characters are the address, the eighth and ninth characters are the record type, the tenth to L-2 characters are the data, and the last two characters are the checksum.

[0053] Step S2: Modify the starting address and all base addresses of the Hex file; modifying the address generally involves offsetting the entire file from the starting address, so modifying the starting address and all base addresses in the file will achieve the desired result.

[0054] like Figure 3 As shown, step S2 specifically includes the following: performing the following operations on each line of record in the Hex file:

[0055] Step S2.1: Identify rows with record types 04 and 05, and extract the corresponding data areas, where 04 represents the base address and 05 represents the entry address;

[0056] Step S2.2: If the current line is the base address line, then the hexadecimal number of the data area is added to the offset address and shifted right by 16 bits; if the current line is the entry address line, then the hexadecimal number of the data area is directly added to the offset address.

[0057] Step S2.3: The row that modifies the address needs to recalculate the checksum and replace the original checksum with the recalculated checksum.

[0058] In step S2.3, the method for recalculating the checksum is as follows: Figure 4 As shown, it specifically includes the following:

[0059] Step S2.3.1: Treat the data length, address, record type, and characters of the data area of ​​the current row as hexadecimal numbers, and convert every two hexadecimal numbers into decimal numbers (1 byte) and sum them.

[0060] Step S2.3.2: Divide the sum by 256 and take the remainder;

[0061] Step S2.3.3: Take the complement of the remainder modulo 256 and convert it to hexadecimal to obtain the recalculated check code.

[0062] Step S3: reordering the records according to the base address for the Hex file after the address is modified;

[0063] The step S3 specifically comprises the following:

[0064] Step S3.1: identifying the line of record type 04 and the lines after it to the line before the next line of record type 04 as a block, and dividing the Hex file into several blocks;

[0065] Step S3.2: sorting the blocks according to the data area (base address) of the first line (record type "04") of each block from small to large.

[0066] Step S4: intelligently filling the sorted Hex file to ensure that the total length (unit byte) of the data of each block with continuous address is aligned.

[0067] The step S4 specifically comprises the following:

[0068] Step S4.1: calculating the starting address of each data record line; the step S4.1 specifically comprises the following:

[0069] identifying the line of record type 04, recording the data in the data area of the line as A, judging whether the record type of each line after it is 02, if yes, recording the data in the data area of the line as B, at this time the base address is ADDR_BASE=A*2^16+B*2^4; if not, taking A left shift 16 bits as the base address, ADDR_BASE=A*2^16; wherein, record type 00 indicates that the line is a data record, and 02 indicates that the line is a segment address;

[0070] for the line of data record type 00, the address area value is recorded as C, and the data length area value is recorded as DataLength; the address area value of the adjacent next data record line is recorded as ADDR_NEXT;

[0071] for any data record line after the line of any base address, the starting address is recorded as ADDR_THIS=ADDR_BASE+C. The flow of calculating each data record line is shown in Figure 5 .

[0072] Step S4.2: for the line of the first base address, starting from the first data record line after it, judging the address continuity line by line, and the specific judging method flow is shown in Figure 6 ; the step S4.2 specifically comprises the following: for the line of the first base address, starting from the first data record line after it, judging the address continuity line by line, and the specific judging method flow is shown in

[0073] Calculate the start address ADDR_NEXT of the next data record row (record type is "00"), and the difference between the two is: addr_err = ADDR_NEXT - ADDR THIS; if addr_err = DataLength, the two data record addresses are continuous; if addr_err > DataLength, the two data record addresses are discontinuous.

[0074] Step S4.3: Non-continuous address padding byte calculation

[0075] As shown in the step S4.3, specifically includes the following: before analyzing the first data record, define the total data length TotalByte = 0; if the current data record row and the next row address are continuous, then Figure 7

[0076] TotalByte = TotalByte + DataLength; otherwise, judge the continuous address block alignment (TotalByte can be divided by the alignment parameter, and the alignment parameter is determined by the hardware); if aligned, the current address block is completed; if not aligned, calculate how many bytes need to be filled to align, recorded as Supplnum; compare Supplnum and addr_err-DataLength, if Supplnum < addr_err-DataLength, then supplement Supplnum bytes, end the current continuous address block operation; if Supplnum >= addr_err-DataLength, then supplement addr_err-DataLength bytes, and fill the discontinuous bytes continuously.

[0077] Step S4.4: Fill the non-continuous address padding byte.

[0078] As shown in the step S4.4, specifically includes the following: Figure 8

[0079] Judge the data record row that needs to be filled with bytes and calculate the number of padding bytes (hexadecimal), recorded as FillByte; the specific filling method is as follows:

[0080] ​​If the current record row data length DataLength+FillByte≤20H, then fill FillByte*2 "F" in the row data area, modify the data length area to DataLength+FillByte, and then update the check code, that is, take the data length, address, record type and data area character of the row as hexadecimal numbers, convert the sum of every two hexadecimal numbers (1 byte) to decimal, then take the remainder by dividing by 256, and finally take the complement of the remainder with 256 as the module and convert it to hexadecimal number to replace the original check code.

[0081] If the current record row data length DataLength+FillByte>20H, then the current row data area needs to be supplemented to 20H bytes, the data length is modified to 20H, and the check code is modified; then a row is inserted below the row, and the format is: | data length | the starting address of the current row | 00 | data | check code; wherein the data length = FillByte-(20H-DataLength), the starting address of the current row = the address of the above row + 20H, and the data is data length*2 "F"; finally, the check code of the current row is obtained according to the method of calculating the check code and filled into the check code position.

[0082] Corresponding to the above method, the application provides a Hex file address modification system, comprising the following units: a file import and division unit, an address modification unit, a reordering unit and an intelligent filling unit.

[0083] The file import and division unit is used to import a Hex file, and according to the Hex file format, each row record is divided into six areas of a starting symbol, a data length, an address, a record type, data and a check code.

[0084] The address modification unit is used to modify the starting address and all base addresses of the Hex file.

[0085] The reordering unit is used to reorder the records according to the base address for the Hex file after the address is modified.

[0086] The intelligent filling unit is used to intelligently fill the reordered Hex file, so as to ensure that the total length of data of each block of continuous addresses is aligned.

[0087] Application example

[0088] First step: import file and divide area

[0089] Import the Hex file to be processed, open the example file using a text tool, for example, Figure 9 As shown in the first row, according to the fixed format of the Hex record, it can be divided into the following parts:

[0090] " " indicates the start tag, indicating the start of the line record;

[0091] "02": the data length (byte) of the data area of the current line record, indicating that there are 2 bytes in the data area of the current line record;

[0092] "0000": the starting address of the current line record, since the current line is a non-data record line, the address does not participate in the calculation;

[0093] "04": the record type of the current line record, indicating that the current line record is an extended linear address;

[0094] "0040": the data area (2 bytes corresponding to the data length), combined with the record type, indicating that the extended linear address base address is "0040", and the starting address of the data record line immediately following it is taken as the base address by left shifting 16 bits of the value;

[0095] "BA": the data check code of the current line.

[0096] Step 2: Modify the address

[0097] Identify the lines with record types "04" (base address) and "05" (entry address), and extract the data area. If the current line is a base address line, the hexadecimal number of the data area is added to the offset address by right shifting 16 bits; if the current line is an entry address line, the hexadecimal number of the data area is directly added to the offset address. Take the record type of the first line as an example, the record type is "04" and the data area is "0040". Assuming that the requirement is to offset the file address by 200000H in total, the modified address is "0060" according to the modification logic. Recognize that the record type of the last line of the file is "05", and the data area is "00401414". According to the modification logic, the modified address is "00601414". After modifying the address, the check code of the modified line needs to be recalculated. Take the first line as an example, the value participating in the check code calculation after the address modification is "020000040060". According to the check code calculation logic, the hexadecimal value is grouped two by two and converted to decimal sum, i.e. 02H+00H+00H+04H+00H+60H converted to decimal sum is 2+0+0+4+96=102, and the remainder after division by 256 is 154, and the complement is 154, which is converted to hexadecimal to get the new check code 9AH; Therefore, the first line after modifying the address is " : 0200000400609A", as shown in Figure 10 .

[0098] Step 3: Reorder the records according to the base address

[0099] Identify the line of record type "04" and the lines after it to the next line of record type "04" as a block, divide the file into several blocks; then according to the first line (record type "04") data area (base address) of each block from small to large to sort these blocks.

[0100] Step 4: Intelligent filling, ensure that the total length of each block of continuous address data (unit byte) alignment

[0101] (1) Calculate the starting address of each data record line

[0102] Identify the line of record type "04", record the data in its data area as A; judge whether the record type of each line after it is "02", if so, record the data in its data area as B, at this time the base address ADDR_BASE = A*2^16 + B*2^4; if not, left shift A by 16 bits as the base address, that is, ADDR_BASE = A*2^16. For data record line (record type "00" line), its address area value is recorded as C, and the data length area value is recorded as DataLength; the next adjacent data record line is recorded as ADDR_NEXT. For any data record line after the line where the base address is located, its starting address ADDR_THIS = ADDR_BASE + C. Take the second and third lines of the example file as an example, there are only "04" type record lines before these two lines, so the base address is calculated from the address of the "04" type line before it; that is, ADDR_BASE = A*2^16 = 00600000H. Take the second line as the current line, then its starting address ADDR_THIS = 0000H + ADDR_BASE = 00600000H; the starting address of the next line, that is, the third line, is ADDR_NEXT = 0020H + ADDR_BASE = 00600020H.

[0103] (2) Judge the continuity of address

[0104] For the first base address row, from the first data record row after it, judge the address continuity row by row. The specific judgment method is to calculate the address difference between the next row and the current row, addr_err = ADDR_NEXT - ADDR THIS; if addr_err = DataLength, it means that the addresses of the two data records are continuous; if addr_err > DataLength, it means that the addresses of the two data records are not continuous. Similarly, take the second and third rows of the example file as an example, addr_err = ADDR_NEXT - ADDR THIS = 00600020H - 00600000H = 20H, the data length of the second row record is DataLength = 20H, addr_err = DataLength, so the second and third rows are continuous. Take the third and fourth rows as an example, the third row address is 00600020H, the fourth row address is 00601000H, addr_err = ADDR_NEXT - ADDR THIS = 00601000H - 00600020H = FE0H, the data length of the third row record is DataLength = 08H, addr_err > DataLength, so the third and fourth rows are not continuous.

[0105] (3) Non-continuous address padding byte calculation

[0106] Before analyzing the first data record, first define the total data length TotalByte = 0. If the address of the current data record row is continuous with the next row, then TotalByte = TotalByte + DataLength; otherwise, judge the alignment of the continuous address block (such as whether TotalByte can be divided by 8). If aligned, the current address block operation is completed. If not aligned, calculate how many bytes need to be filled to align, recorded as Supplnum; compare Supplnum with addr_err - DataLength, if Supplnum < addr_err - DataLength, then supplement Supplnum bytes, end the current continuous address block operation; if Supplnum >= addr_err - DataLength, then supplement addr_err - DataLength bytes, fill the non-continuous bytes continuously.

[0107] Take the first four lines of the example file as an example, the second line is the data record line (record type "00"), the second line and the third line are continuous, at this time TotalByte is the sum of the data length of the second line and the data length of the third line, i.e. TotalByte = 20H + 08H = 28H, it is judged whether 28H meets the alignment requirement, the present application requires that the length of a continuous address block is an integer multiple of 8 bytes, 28H / 8H = 5H, which meets the alignment requirement, i.e. the second line and the third line are a continuous address block.

[0108] Take the fourth to thirty-sixth lines of the example file as an example, the fourth line is polled with TotalByte being 0, when the index reaches the thirty-sixth line, the thirty-sixth line and the thirty-seventh line are not continuous, addr_err = 00601414H - 00601400H = 14H, the DataLength of the thirty-sixth line is 12H, addr_err - DataLength = 2H. At this time, TotalByte is the sum of the data lengths of the fourth to thirty-sixth lines, i.e. TotalByte = 414H, which does not meet the requirement, 414H / 8H = 82H...4H; 8H-4H = 4H bytes need to be filled to meet the requirement, i.e. Supplnum = 4H. Supplnum > addr_err - DataLength, so the addr_err - DataLength, i.e. 2H bytes, are filled to make the non-continuous bytes continuous and continue the polling processing.

[0109] (4) Non-continuous address filling

[0110] The data record line that needs to be filled with bytes is judged by (3) and the number of bytes to be filled is calculated, which is recorded as FillByte (hexadecimal). If the data length of the current record line DataLength + FillByte ≤ 20H, then FillByte*2 "F" are filled in the data area of the line, the data length area is modified to DataLength + FillByte, and then the check code is updated, i.e. the data length, address, record type and data area characters of the line are converted into hexadecimal numbers, every 2 hexadecimal numbers are a group (1 byte), the sum is calculated, then divided by 256 to get the remainder, finally the remainder is supplemented with 256 as the module and converted into a hexadecimal number to replace the original check code.

[0111] If the data length of the current record line DataLength + FillByte > 20H, then the data area of the current line needs to be supplemented to 20H bytes, the data length is modified to 20H, and the check code is modified; then a line is inserted below the line, with the format: data length | start address of the current line | 00 | data | check code.

[0112] Wherein, the data length = FillByte - (20H - DataLength), the beginning address of this line = the address of the above line + 20H, the data is data length * 2 "F"; finally, the check code of this line is obtained according to the method of calculating the check code and filled into the check code position.

[0113] The application example to be modified Hex file is compared before and after modification as shown in the following table: Figure 11 、 12 As shown in the table, after modification, address offset is made according to requirements, intelligent filling is made for discontinuous addresses, and the check code is automatically updated, and the file size does not change. The modified Hex file can be normally programmed.

[0114] Finally, it should be noted that: the above embodiments are only used to illustrate and describe the present application, and are not intended to limit the present application to the scope of the described embodiments. In addition, those skilled in the art can understand that the present application is not limited to the above embodiments, and more variants and modifications can be made according to the teaching of the present application, and these variants and modifications all fall within the scope of the present application.

Claims

1. A method of modifying addresses in a Hex file, the method comprising: It comprises the following steps: Step S1: importing a Hex file, and dividing each line record into six areas of start symbol, data length, address, record type, data and check code according to the Hex file format; Step S2: modifying the start address of the Hex file and all base addresses; Step S3: reordering the records according to the base addresses for the Hex file after the address is modified; Step S4: intelligently filling the reordered Hex file to ensure that the total length of data of each block is aligned.

2. The method of claim 1, wherein, In the step S1, when dividing each line record, the current line record is regarded as a string, the length L of the string is calculated first, the first character is:, the second and third characters are the data length, the fourth to seventh characters are the address, the eighth and ninth characters are the record type, the tenth to L-2 characters are the data, and the last two characters are the check code.

3. The method of claim 2, wherein, The step S2 specifically comprises the following: the following operations are performed on each line record in the Hex file: Step S2.1: identifying the line whose record type is 04 and 05, and extracting the corresponding data area, wherein 04 represents the base address and 05 represents the entry address; Step S2.2: if the current line is the base address line, the hexadecimal number of the data area is added with the offset address right shifted by 16 bits; if the current line is the entry address line, the hexadecimal number of the data area is directly added with the offset address; Step S2.3: the line whose address is modified needs to recalculate the check code, and the recalculated check code is replaced with the original check code.

4. The method of claim 3, wherein, In the step S2.3, the method for recalculating the check code specifically comprises the following: Step S2.3.1: the characters of the data length, address, record type and data area of the current line are regarded as hexadecimal numbers, and each two hexadecimal numbers are converted into decimal numbers to be summed up; Step S2.3.2: the sum is divided by 256 to obtain a remainder; Step S2.3.3: the remainder is complemented with 256 as a module, and then converted into a hexadecimal number to obtain the recalculated check code.

5. The method of claim 4, wherein, The step S3 specifically comprises the following: Step S3.1: identifying the line whose record type is 04 and the lines after it to the line before the next line whose record type is 04 as a block, and dividing the Hex file into several blocks; Step S3.2: sorting the blocks according to the data area of the first line of each block from small to large.

6. The method of claim 5, wherein, The step S4 specifically comprises the following: Step S4.1: calculating the start address of each data record line; Step S4.2: for the line where the first base address is located, starting from the first data record line after it, the address continuity is judged line by line; Step S4.3: filling byte calculation for non-continuous addresses; Step S4.4: filling byte for non-continuous addresses.

7. The method of claim 6, wherein, The step S4.1 specifically comprises the following: identifying the line whose record type is 04, recording the data in the data area of the line as A, judging whether the record type of each line after A is 02, if yes, recording the data in the data area of the line as B, and the base address is: ADDR_BASE=A*2^16+B*2^4; if no, A is left shifted by 16 bits as the base address: ADDR_BASE = A * 2^16; wherein, 00 indicates that the current line is a data record; 02 indicates a segment address; For a line of data record type 00, the address area value is recorded as C, and the data length area value is recorded as DataLength; the address area value of the adjacent next data record line is recorded as ADDR_NEXT; For any data record line after the line where the base address is located, the starting address is recorded as: ADDR_THIS = ADDR_BASE + C.

8. The method of claim 7, wherein, The step S4.2 specifically comprises the following: for the first line where the base address is located, starting from the first data record line after it, the address continuity is judged line by line, specifically as follows: The starting address ADDR_NEXT of the next data record line is calculated, and the difference between the address of the current line and the starting address of the next data record line is addr_err = ADDR_NEXT - ADDR_THIS; if addr_err = DataLength, then the addresses of the two data records are continuous; if addr_err > DataLength, then the addresses of the two data records are not continuous.

9. The method of claim 8, wherein, The step S4.3 specifically comprises the following: Before analyzing the first data record, the total data length TotalByte is defined as 0; if the address of the current data record line is continuous with the next line, then TotalByte = TotalByte + DataLength; otherwise, the alignment of the continuous address block is judged; If aligned, the current address block operation is completed; if not aligned, the number of bytes that need to be filled to be aligned is calculated and recorded as Supplnum; the size of Supplnum and addr_err - DataLength is compared; if Supplnum < addr_err - DataLength, then Supplnum bytes are supplemented, and the current continuous address block operation is ended; if Supplnum >= addr_err - DataLength, then addr_err - DataLength bytes are supplemented, and the non-continuous bytes are supplemented to be continuous; The step S4.4 specifically comprises the following: The data record line that needs to be filled with bytes is judged, and the number of bytes to be filled is calculated and recorded as FillByte; the specific filling method is as follows: If the data length of the current record line DataLength + FillByte <= 20H, then FillByte * 2 "F" are filled in the data area of the line, the data length area is modified to DataLength + FillByte, and then the check code is updated; If the current record row data length DataLength+FillByte>20H, the current row data area needs to be supplemented to 20H bytes, the data length is modified to 20H, and the check code is modified; then a row is inserted below the row, and the format is: : data length | the starting address of the current row | 00 | data | check code; wherein, the data length = FillByte-(20H-DataLength), the starting address of the current row = the address of the above row + 20H, the data is data length * 2 "F"; finally, the check code of the current row is filled into the check code position according to the method of calculating the check code.

10. A Hex file address modification system, characterized by, The file import and division unit, the address modification unit, the reordering unit and the intelligent filling unit are included. The file import and division unit is used for importing a Hex file, and dividing each row record into six areas of a starting symbol, a data length, an address, a record type, data and a check code according to the Hex file format; The address modification unit is used for modifying the starting address and all base addresses of the Hex file; The reordering unit is used for reordering the records according to the base addresses for the Hex file after the address is modified; The intelligent filling unit is used for intelligently filling the reordered Hex file, and ensuring that the total length of the data of each block of continuous addresses is aligned.