The file with the suffix X0 is a type of hexadecimal file format, and the Intel Hex file format is also a commonly used hexadecimal file format. X0 is a commonly used file format for TI programming software and tools, while Hex file is a commonly used file format for third-party programmers. A compiler (such as TI’s integrated development environment CCS) compiles C language or assembly language programs to generate binary machine code, and then the machine code generates two hexadecimal file formats, X0 and Hex. This article first introduces these two file formats, then introduces how to generate these two file formats in the CCS compilation environment, and finally uses the UCD3xxx series digital power Controller to further understand these two file formats through examples.
1X0 andHex file format
X0 and Hex files are ASCII (American Standard Code for Information Interchange, American Standard Code for Information Interchange) text files composed of lines of text that conform to the corresponding file format. In the computer, all data must be represented by binary numbers when stored and operated, such as 52 letters (including uppercase) such as a, b, c, d, numbers such as 0, 1, and some commonly used symbols ( Such as *, #, @, etc.) are also represented by binary numbers when stored in the computer. ASCII code is used to represent these letters, numbers and symbols, it uses a specified combination of 7-bit or 8-bit binary numbers to represent 128 or 256 possible characters. The X0 and Hex file formats use ASCII codes to represent binary information.
The name of the X0 format is “Tektronix Extended hexadecimal file format” (Tektronix Extended hexadecimal file format), see Figure 1 for the specific format.
picture1:X0 file format
The X0 file uses the percent sign “%” as the record mark, indicating the beginning of a line; the record length refers to the number of characters (not the number of bytes) in each line except the percent sign, accounting for one byte; the record type occupies one character, There are two types: 6-represents data, 8-represents the end; checksum is the checksum of the entire line of characters (not bytes) except the checksum itself and the percent sign, occupying one byte; the address has a total of 9 characters , the first character is 8, which means that the address occupies a total of 8 characters, and the next 8 characters (4 bytes) are the address to be loaded with data; the data is the program code or other information.
Take “Hello, Word! (add newline)” commonly used in computers as an example, if it is loaded into address 0x006B, then the X0 file is as follows
There are many Hex file formats. This article mainly introduces the “Intel Hexadecimal object file format” (Intel Hexadecimal object file format). The specific format is shown in Figure 2.
picture2:Hex file format
The Intel Hex file uses a colon “:” as the record mark, indicating the beginning of a new line; the record length occupies one byte, which refers to the number of bytes of actual data or information contained in each line; the loading offset occupies two bytes , is the relative address (the loading offset plus the extended linear address is the absolute address); there are 6 record types, which are: 0 – data record, 1 – end of file record, 2 – extended segment address record, 3 – start segment Address Records, 4 – Extended Linear Address Record, 5 – Start Linear Address Record; the data portion of each row record is variable and may or may not be up to 255 bytes, depending on the type of record being recorded. The last one is the checksum, which is the checksum except the colon and the checksum itself. The specific method is to accumulate each byte, and then take the complement of the last byte of the calculation result (invert and add 1) as the check byte.
Or take “Hello, Word! (with newline)” as an example, load it to address 0x0000, the Hex file is as follows:
2 UCD3xxx storage structure
picture3:UCD3xxx storage structure
Before introducing how to generate X0 and Hex files, it is necessary to understand the storage structure of UCD3xxx series digital controllers, as shown in Figure 3. UCD3xxx has three modes: reset mode, ROM mode and flash mode. The storage maps corresponding to these three states are different. In reset mode, all memory is mapped as ROM; in ROM mode, program flash (Program Flash) is mapped at 0x10000 to 0x17FFF, data flash (Data Flash) is from 0x18800 to 0x18FFF, random access storage (RAM) is placed at 0x19000 to 0x19FFF; in Flash mode, data and random access locations are unchanged, program flash locations are remapped to 0 to 0x7FFF. The last 4 bytes of program flash hold the checksum of the entire program flash.
The start-up process of UCD3xxx is: start to enter reset mode after power-on; enter ROM mode after power-on, the chip will automatically jump to 0xA000 for execution. In the address from 0xA000 to 0xAFFF, a ROM program is solidified. In addition to doing some initialization of the chip itself, this program also calculates the checksum of the program flash memory, and then compares it with the checksum stored in the last 4 bytes of the program flash memory. If it is inconsistent, the program will stop and wait for the host command. If the comparison results are consistent, the chip will enter the Flash mode, and the ROM program will execute the jump instruction to enter the program flash memory to run.
3 how toCCS Generated in an integrated development environmentX0 andHex document
picture4:CCS Compiler compilation option settings
The generation of X0 and Hex files is inseparable from the format conversion programs: Hex470.exe and FusionX0ToHex.exe. Hex470.exe is a program that comes with the assembly language toolkit. FusionX0ToHex.exe is the conversion program that comes with the TI Fusion Digital Power Designer Graphical User Interface (GUI). Hex470.exe and FusionX0ToHex.exe can be called from the command line. The respective command formats are described below.
The command line format of Hex470.exe is: Hex470 [选项] File name, hex470 is the command to invoke the conversion program, options are additional information to control the conversion process (refer to Reference 2 for details), and file name refers to the name of the input file. Hex470 can convert the files with the suffix of Out generated by CCS compilation into Hex files of various formats, such as:
Hex470 –i sample.out
This command converts the generated sample.out file into an Intel Hex format file, the file name is sample.hex;
Hex470 –x sample.out
This command converts the generated sample.out file into X0 format file, the file name is sample.x0.
Since Hex470 can directly convert Out files to Hex files, why convert them to X0 first and then convert them to Hex files? There are two reasons: Hex470 will not calculate the checksum of the program flash; the Hex file address generated by Hex470 is based on the program flash mode, and the address required by the programmer is ROM mode, that is, from 0x10000 to 0x17FFF, so UCD3xxx does not support The Hex file directly generated by Hex470 needs to be converted into Hex format file through the FusionX0ToHex.exe conversion program. The specific command format is:
FusionX0ToHex –infile x0-file
–infile mainly specifies the input X0 file.
–format mainly specifies which Hex format is generated, namely intel, srec (Motorola S-Record) and hexdump.
–pflash-checksum mainly specifies the check mode of the program flash memory, calc mode – calculate the check digit based on the X0 file and write it into the corresponding position; none mode – the check digit defaults to 0xFFFFFFFF; source mode uses X0’s own check digit.
–export specifies which part of the storage to output, pflash means to output only the program flash part. dflash refers to the output data flash section. both are output program and data flash. Whichever part is filled with 0xFF if it is not present in the X0 file. source is to output X0 directly.
–outfile is to specify the output Hex file name.
The following will introduce how to embed the hex470 and FusionX0ToHex command lines in the CCS compilation environment.
In the CCS (version 3.x) compilation environment, enter the Project menu, then select Build Options, and then click the General tab, and the interface shown in Figure 4 will appear. In the Final build steps, we can enter the following two command lines:
hex470 -x -memwidth 8 .debugFB_48V_HS.out
FusionX0ToHex –infile FB_48V_HS.x0 –pflash-checksum calc –export both –format intel –outfile FB_48V_HS.hex
In the first command: -x option means to convert .debugFB_48V_HS.out into X0 file, -memwidth 8 means to define the system storage word width as 8 bits.
In the second command: the input file to be transferred is FB_48V_HS.x0, the output file is FB_48V_HS.hex, the check digit of the program flash memory is calculated, and the content of the program and data flash memory is output at the same time, the format is intel hexadecimal.
4 based onUCD3xxx Learn more aboutX0 andHex file format
In order to further understand the X0 and Hex formats, let’s take a look at the generated X0 and Hex files through the UCD3xxx hard-switch full-bridge evaluation board software, as shown in Figure 5 and Figure 6.
The first column of Figure 5 starts with the percent sign; the next two columns (one byte) represent the character length of each line except the percent sign, and the maximum number of characters in each line is 0x4E (78); then one column represents the following data Type, except the last line is 8 (end), the others are 6 (data); there are two more columns for the check of the entire line; the address occupies 9 columns, starting with 8, and the next 4 bytes represent the actual address; address It’s all data after that. As can be seen from the figure, the address of the program flash memory of the X0 file starts from 0, and there is no check of the entire program flash memory. TI programming software and tools mainly use files in X0 format. The programming software will calculate the checksum of the program flash memory, and then write to the last 4 bytes, so X0 does not need to calculate the checksum of the entire program flash memory.
The first column in Figure 6 is all colons; followed by a byte refers to the number of bytes of data contained in the entire row; two bytes are the offset address; one byte refers to the record type; followed by a byte Countless data. The last byte is the checksum of each line. The first line of Figure 6 specifies the extended address, which is 0x0001; the last line marks the end of the file. Also, in the last 4 bytes of the program flash (pink area) is the checksum of the entire program flash. If this checksum is incorrect, the program will not jump to program flash for execution.
If you use the programming software (GUI) and tools (USB adapter) provided by TI to program, you only need files in X0 format; if you use a third-party programmer to program in the production line, you will need Hex format files. The required X0 or Hex files can be generated according to the introduction of this article.
1. SLUS868D – Digital Power Controllers, Texas Instruments Inc., 2012
2. SPNU118J – ARM Assembly Language Tools v4.9 User’s Guide, Texas Instruments Inc., 2011
3. SRecord V1.59- Manipulate EPROM load files, 2012
4. Fusion Digital Power Designer, Texas Instruments Inc., 2012
The Links: NL10276BC24-19D PM200CVA060 NEC-LCD