This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Greetings,
I am porting code from our TMS320F28379D projects to the TMS320F28386S. Some of the code defines sections which contain some type of data. All of them, except for one, are failing to show up in the map file and the output of the linker. The one exception is a section from an assembly file which contains code. The missing sections are from cpp files. I am generating list files, so I can see that the missing data is there. So I’m assuming that the files have compiled correctly, and the data is in the object files.
In the map file, the sections’ space can be seen in the MEMORY_CONFIGURATION area. But the section names and their associated object files don’t show up in the SECTION_ALLOCATION_MAP. To determine that they are really not in the output, I am having the C2000 Hex Utility generate a TI-TXT file. The resulting file does not contain the data.
I am using CCS 10.4.0.0006 with compiler version TI v20.2.5.LTS.
The cpp files look like this, with some being arrays:
#pragma DATA_SECTION("<MySection>")
const struct <STRUCT_TYPE> StructName =
{
<ELEMENT_VALUE_1>,
<ELEMENT_VALUE_2>,
<ELEMENT_VALUE_3>
};
The cmd file looks like this:
MEMORY
{
PAGE 0:
<MY_MEM_DEF> : origin=0x12345, length=6
}
SECTION
{
<MySection> : > <MY_MEM_DEF>, PAGE = 0
}
Is there something else I need to be doing to have the show up in the output?
Thank you,
Ed
const struct <STRUCT_TYPE> StructName =
Is there a C function which reads a field in StructName?
I am porting code from our TMS320F28379D projects to the TMS320F28386S
I need to see details of the build for both projects. For one of the TMS320F28379D projects, please rebuild the entire project. One way to do that is to right-click on the name of the project and select Rebuild Project. Then save the contents of the Console (not Problems) view to a text file. Use the icon named Copy Build Log (older versions of CCS) or Save build log to file (newer versions of CCS). When you name the log file, be sure to use the file extension .txt. Please repeat those steps with the TMS320F28386S project. Please attach both text files to your next post. If you are not comfortable attaching the build logs, you can send them to me privately. Hover your mouse over my screen name or avatar. A box will pop up. Click on Send a private message. Attach the text files to that message.
Thanks and regards,
-George
Thank you for sending in the build logs by private message. They show that the older project uses COFF ABI, and the newer project uses EABI. You also said that the answer to this question ...
Is there a C function which reads a field in StructName?
... is no. That being the case, the solution is to apply either #pragma RETAIN(symbol) or __attribute__((retain)) to StructName. For further detail, please see the Conditional Linking: Section Removal or Retention part of the larger article C2000 Migration from COFF to EABI.
Thanks and regards,
-George
Hi George,
Thank you for the link to the migration page. It also explains the issue I am having with the leading underscores.
But I’m not understanding the syntax for #pragma RETAIN correctly. When I use it, I get a compile error which says, error #18: expected a ")". The construct is created as below. In this case, I used one of the tables. I’ve tried a few variations on the theme including using single quotes, but always get a compile failure. Is there something more which is needed?
#pragma DATA_SECTION("MyDataSection")
#pragma RETAIN("MyDataSection")
const uint16 MyTable[<TABLE_SIZE>] = ...
Thank you,
Ed
There is an error in the C2000 migration article. The #pragma RETAIN is not applied to a section, but a C symbol (function or data). Thus, write ...
#pragma RETAIN(MyTable)
Thanks and regards,
-George
I tried that with the same result. I also placed it before and after the table declaration.
Thank you,
Ed
Please search the C28x compiler manual for the sub-chapter titled The RETAIN Pragma. Maybe some detail there will be helpful.
Or, use __attribute__((retain)) instead.
Is this C code, or C++ code?
Thanks and regards,
-George
__attribute__((retain)) worked! Any idea why it is needed for the 388, but not the 379?
Thank you,
Ed
I don't know. To work that out, put the file back in the state where it fails to build, then follow the directions in the article How to Submit a Compiler Test Case.
Thanks and regards,
-George
Oh wait ...
Any idea why it is needed for the 388, but not the 379?
Do you mean to ask why the retain is needed at all? Because, under EABI, any part of the code not referenced is automatically removed.
Also, I'm just about to leave for the Thanksgiving break. Any further reply will be delayed.
Thanks and regards,
-George
BTW. I read the document you suggested above, and the syntax for C++ is simply #pragma RETAIN - no argument. So now that is working too!
Thank you for all the help George.
Ed