In-depth understanding of the structure of the. binfile and. nb0 File

Source: Internet
Author: User

. A binfile is an image file that describes the nature of the file. It consists of the file header (head), the starting address of the image data (imagestart), the image data length (imagelength), and multiple relatively independent records (record).

The header consists of seven bytes. The content is: 42 30 30 30 46 46 0a, that is, "b000ff/x0a". This is the basis for determining whether the image file is of the. Bin type.

The starting address (imagestart) of the image data is composed of four bytes. It defines the starting address of the image file to be parsed and loaded in the memory.

The Image Data Length (imagelength) is also composed of four bytes, which indicates the total storage space occupied by the. Bin image file after parsing in the memory.

Each record consists of a 4-byte start storage address (recordstart), a 4-byte data length (recordlength), and a 4-byte checksum) and recordlength record data (recorddata.

According to the preceding. BIN file format, the. binfile is not a simple copy of the memory program space. Therefore, it cannot be directly written into the memory or flash space by serial port. It must be downloaded through Pb and parsed by eboot according to the. binfile format and loaded again before running.

The. nb0 file is different. It is a hard copy of the memory running program image, and its data content is the same as the data in the memory when the program is running. In view of this,. nb0 can be downloaded to the specified position through the serial port for direct operation. Obviously,. nb0 is a non-existing image file.

Next, I will use a specific. binfile and corresponding nb0 file to help you better understand the above concepts:

Use ultraedit to open the NK. binfile to be analyzed and NK. nb0 file. For convenience of analysis, I have intercepted a small part of the NK. Bin and NK. nb0 files:

Part of the NK. binfile:

00000000 H: 42 30 30 46 46 0a 00 00 80 64 67 fa 00 00

00000010 H: 00 00 80 04 00 00 EB 01 00 00 Fe 03 00 EA 40

00000020 H: 00 00 80 08 00 00 00 EE 02 00 45 43 45 43 1c

00000030 H: 48 fa 80 48 00 00 00 80 00 00 00 5E 01 00 1c

00000040 H: 48 fa 00 00 10 00 80 A0 3D 05 00 14 E3 F3 01 00

00000050 H: 00 0f E1 13 00 A0 E3 80 00 80 E3 40 00 80 E3 00

.................. :....................................... .........

00053dd0h: F7 03 80 BC F7 03 80 A0 F7 03 80 01 00 00 00 84

00053de0h: F2 04 80 A8 F2 04 80 EC F2 04 80 AC F2 04 80 A0

.................. :....................................... .........

00f40960h: 12 00 00 00 12 00 00 64 AE 80 80 1C 36 fa 80 00

00f40970h: 00 00 00 00 10 00 80 00 00 00 00

Part of the corresponding NK. nb0 file:

00000000 H: Fe 03 00 EA 00 00 00 00 00 00 00 00 00 00 00 00 00

00000010 H: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00000020 H: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00000030 H: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00000040 H: 45 43 45 43 1C 48 fa 80 1C 48 fa 00 00 00 00

00000050 H: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

.................. :....................................... .........

000000ff0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00001000 H: 00 00 0f E1 13 00 A0 E3 80 00 80 E3 40 00 80 E3

00001010 H: 00 F0 23 E1 10 0f 11 EE 01 0a C0 E3 04 00 C0 E3

.................. :....................................... .........

00054d90h: 84 F2 04 80 A8 F2 04 80 EC F2 04 80 AC F2 04 80

.................. :....................................... .........

00fa6760h: 1C 36 fa 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00fa6770h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

.................. :......... Fill 0 until the end of the file .....................
Next we will analyze the above image:
First, check the. Bin image:
1. Start with a 7-Byte File Header 42 30 30 46 46 0a;
2. next, the starting address of the 4-byte image data is 00 00 80, indicating that the starting address of the target is 0x80000000. the nb0 file will be loaded to 0x80000000 for running.
3. next, the 4-byte length of the image data is 64 67 fa 00, indicating that the storage space occupied after the image data is parsed is 0x00fa6764 bytes. Let's look at it again. the 16-byte data of the nb0 file address 0x00fa6760 is 1C 36 fa 80 00 00 00 00 00 00 00 00 00 00 00 00, and all the data from now on is 00, from this we can see that 0x00fa6764 is the last valid data address. I think my friends here already know the connection between the. binfile AND THE. nb0 file.
4. the next 4 bytes are the starting address of 1st records 00 00 80, indicating that the starting address of 1st records is 0x80000000;
5. the next 4 bytes are the length of 1st records: 00 00, indicating that the data domain length of 1st records is 4 bytes.
6. the next 4 bytes are the verification code of 1st records EB 01 00;
7. the next 4 bytes are the data content of the 1st records Fe 03 00 ea. At this point, I believe that my friends have already thought about the starting point. View the starting 4 bytes of the. nb0 file, which is the data content of the 1st records we just analyzed.
8. The next 4 bytes are the starting address of 2nd records: 40 00 00 80, indicating that the starting address of 2nd records is 0x80000040;
9. the next 4 bytes are the length of 2nd records at, indicating that the data domain length of 2nd records is 8 bytes.
10. the next 4 bytes are the verification code EE 02 00 for 2nd records;
11. The next 8 bytes are the data content of 2nd records 45 43 45 43 1C 48 fa 80. Check the 8-byte content of the 0x00000040 address in the. nb0 file: 45 43 45 43 1C 48 fa 80, which is the data domain content of the 2nd records in the. binfile.
Similarly, we can use the same method to parse all records in the. binfile. The. nb0 file can be constructed based on the. Bin record.
At this point, I believe that my friends have a deep understanding of the format of the. binfile and the differences and connections between the. binfile AND THE. nb0 file.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.