Hey guys, as part of a project I'm working on, I need to be able to store some custom data at the start of a Tiva processor's internal Flash memory, isolated from regular variables and program data. After doing a bit of research, it seems like memory sections are the best way to accomplish this. I gave it a crack, but it doesn't seem to be working. Here's what I did:
In the .cmd file that my program is using, I modified the SECTIONS block to the following:
SECTIONS { .intvecs : > 0x00000000 .mySection : > FLASH .text : > FLASH .const : > FLASH .cinit : > FLASH .pinit : > FLASH .init_array : > FLASH .vtable : > 0x20000000 .data : > SRAM .bss : > SRAM .sysmem : > SRAM .stack : > SRAM }
All I really did was add a section labeled .mySection to the flash. From my understanding of sections, this should cause variables mapped to .mySection to be located between the end of the interrupt vectors and the start of the .text section. I'm not confident that this is how sections are defined, and I can't find any documentation for modifying these .cmd files, so any help with this would be appreciated.
To test if my section works, I added a C file to my project's root with the following contents:
typedef struct exampleStruct { int a; int b; } exampleStruct; #pragma DATA_SECTION(myExample, ".mySection") exampleStruct myExample;
From my understanding, this should define a structure, and then place the instance of the structure with the symbol myExample in the .mySection section of memory. Also, I added the following as a simpler test in case I messed up the way that structures should work for this:
#pragma DATA_SECTION(arrayA, ".mySection") int arrayA[20];
After doing this, my project builds without any problems. To see if my test worked, I used some of the cg_xml tools to analyze the .out file generated by my build. Specifically, I ran "ofd6x -x app.out | sectti", which printed out the memory breakdown of the binary. All of the regular sections from the SECTION block are there, but it jumps right from .intvecs to .text without showing anything for .mySection.
I looked at the generated linkInfo.xml file as well, and it contained the following:
<logical_group id="lg-4" display="no" color="cyan"> <name>.mySection</name> <run_address>0x0</run_address> <size>0x0</size> <contents> </contents> </logical_group>
From the looks of it, the linker knows that the section was added, but it thinks that it's empty. I'm guessing that the C file I added with the structure and the array is at fault here, but I'm not really sure why. My test with the array is more or less copied and pasted from Example 5-4 from section 5.9.6 in the "ARM Optimizing C/C++ Compiler v5.1" documentation, so I don't know what I need to change to get this to work.
If anyone has any ideas or input it would be very appreciated. Thanks.