Understanding the configuration of C2000 series CMD files[Copy link]
The professional name of CMD is linker configuration file, which stores the configuration information of linker. We call it command file for short. The key is the use of two pseudo instructions, MEMORY and SECTIONS, which are often confusing. System problems are often related to their improper use. I will focus on this. CCS is a development environment inherited from DSP software under DOS system. The command file of CCS is the extension and development of DOS command file after a long period of time, and it has become very concise (I don't know if TI document has detailed CMD configuration instructions). I started learning CMD from DOS, so I will also start with CMD in DOS environment: The composition of command files The beginning part of the command file is the name of each sub-target file to be linked, so that the linker can link the corresponding target files into one file according to the sub-target file name; the next is the linker's operating instructions, which are used to configure the linker, and then the related statements of the two pseudo-instructions MEMORY and SECTIONS, which must be capitalized. MEMORY is used to configure the target memory, and SECTIONS is used to specify the storage location of the segment. The SECTIONS pseudo-instruction The syntax of the SECTIONS directive is as follows: SECTIONS { .text: {all .text input section names} load=load addressrun =run address .data: {all .data input section names} load=load addressrun =run address .bss: {all .bss input segment names} load = load address run = run address .other: {all .other input segment names} load = load address run = run address } SECTIONS must be written in uppercase letters. The braces that follow are the descriptive statements of the output segment. The description of each output segment starts with the segment name. After the segment name is the parameter description of how to organize the input segment and allocate memory to the segment: Take the attribute statement of the .text segment as an example. The content "{all .text input segment names}" is used to explain which sub-target files' segments make up the .text segment of the connector output segment. The following are examples SECTIONS { .text:{ file1.obj(.text) file2(.text) file3(.text,cinit)}omitted } Indicates that the output segment .text is to link file1.obj's .text and file2's .text There are also file3's .text and .cinit. In CCS's SECTIONS, usually only a "{ }" with no content in the middle is written to represent the corresponding sections of all target files. Next, it is explained that "load = load address run = run address". The linker allocates two addresses in the target memory for each output segment: one is the load address, and the other is the run address. Normally, the two addresses are the same, so we can assume that the output segment has only one address. In this case, we don't need to add the "run = run address" statement. But sometimes we need to separate the two addresses. For example, when loading a program into FLASH and then putting it into RAM for high-speed operation, we need to configure the run address and the load address separately, as shown in the following example: load = PROG run = 0x0800."]Constants are loaded into the program storage area and configured to be called from RAM. There are several ways to write "load = load address" that need to be explained. First, the "load" keyword can be omitted. " = " can be written as ">", "load address" can be: address value, storage interval name, PAGE keyword, etc. So don't be surprised when you see a statement like ".text:{ } > 0x0080". The " = " in "run = run address" can be written as ">". There are no other simplified writing methods.