Using the COFF compiler for this C2000:
At the end of the task, my objective at a high level is to:
1) Know the flash address of a variable which has been declared and initialized in my C code as global
2) Know the RAM/run address of that variable which has been declared and initialized in my C code as global
3) Using the knowledge provided in objective 1 - use an external tool to manipulate the .out/hex file at that known flash address.
To convey the idea more simply: I'd like to be able to modify some global values in the output binary - without recompiling. To calibrate values, which might be unique to systems - which will run identical code otherwise.
I've been assigning global variables into a custom data section:
float sc_PVDD __attribute__((section(".mySectionName"))) = 12.0F ;
This declaration is at the head of a source file.
The information regarding the 'load' and 'run' address is then conveyed to our external tool, along with a copy function within the same source file (in a startup routine) through linker directives which extract LOAD and RUN addresses to the global variables _runmySectionName and _initmySectionName:
SECTIONS
{
.vectors: load = 0x000000000
.text : > FLASH1 | FLASH2, PAGE = 0
appheader : > APPHDR, PAGE = 0
codestart : > CODESTART PAGE = 0
.switch : > FLASH1 | FLASH2, PAGE = 0
.cinit : > FLASH1 | FLASH2, PAGE = 0
.pinit : > FLASH1 | FLASH2, PAGE = 0
.const : > FLASH1 | FLASH2, PAGE = 0
.econst : > FLASH1 | FLASH2, PAGE = 0
.rtdx_text : > FLASH1 | FLASH2, PAGE = 0
IQmath : > FLASH1 | FLASH2, PAGE = 0
ramfuncs : LOAD = FLASH1 | FLASH2,
RUN = PRAM,
LOAD_START(_RamfuncsLoadStart),
LOAD_END(_RamfuncsLoadEnd),
RUN_START(_RamfuncsRunStart),
PAGE = 0
.bss : > RAML4, PAGE = 0
.ebss : > RAML4, PAGE = 0
.far : > RAML4, PAGE = 0
.reset : > RESET, PAGE = 0, TYPE = DSECT
.data : > RAML4, PAGE = 0
.cio : > RAML4, PAGE = 0
.sysmem : > RAML4, PAGE = 0
.esysmem : > RAML4, PAGE = 0
.stack : > RAMM0M1, PAGE = 0
.rtdx_data : > RAML4, PAGE = 0
.mySectionName: LOAD = FLASH1, RUN = RAML4, PAGE = 0, LOAD_START(__initmySectionName), RUN_START(__runmySectionName)
}
To gather the Run address of the variable has been, so far, trivial. It is neatly populated in the _runmySectionName in every compile; however the location, in flash/init, of any variables placed in .mySectionName remains unknown, as at the linker stage the following is returned:
LOAD placement ignored for ".mySectionName": object is uninitialized
The variables are indeed being initialized by the .cinit table at startup by the startup assembly code provided by TI; but my objective is to prevent the variables from being placed in that region of memory.
A solution I have seen is to declare the variables in this section as 'const'; which does indeed provide a load and a run address - however that doesn't satisfy my needs - as the variables can be altered by the running program during runtime. These values are initial-values which can be updated as runtime moves forward.