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.
Hi,
I'd like to understand the Flash>RAM linking process more thoroughly and there is something which is not clear in the linker command file. I can't find the initialization and the definition of the following variables:
extern Uint16 RamfuncsLoadStart, RamfuncsLoadEnd, RamfuncsRunStart;
In the linker command file I only found the following:
// Used for running BackGround in flash and the ISR in RAMLOAD_START(_RamfuncsLoadStart),
LOAD_END(_RamfuncsLoadEnd),
RUN_START(_RamfuncsRunStart),
Any help would be welcome. Thank you.
You will find the definition of these variables in a file called GlobalPrototypes.h
Vivek
I checked the Fxxxxxx_GlobalPrototypes.h files but those definitions are all external. My main question is that where and with which value were these variables initialized.
They will be initialized by the linker. All you have to do is call the memcopy function with these variables as the argument. This will copy the variables from flash to ram. We don't have to modify the variables anywhere in the code.
Vivek
All right, but from where will the linker know the exact values to initialize these RamFuncs variables?If I'm correct RamFuncsLoadStart and RamFuncsLoadEnd should contain the start/end adresses of the particular Flash memory part which contains the code to be copied into RAM. Where can I set these addresses?
If you take a look at your linker file you will see in the sections specification, that ramfuncs are linked to RAML0. (Assuming you are running from flash.) Now if you look at the start address of RAML0 in Memory specification, you will see the start address. The load address will be Flash address from which these functions are copied. (FlashD in mine)
Therefore RamFuncsRunAdress: Start address of the ramfuncs destination address (in Ram)
RamFuncsStartAddress: Start address of the ramfuncs source address (in Flash)
RamFuncsEndAddress: End Address of the ramfuncs source address (in Flash)
Now all these values are automatically given by the linker. All you have to do is to call the Memcopy function. Unless you want to modift the address, you dont have to worry about these variables.
Vivek
Vivek, thanks so much for your help, I really appreciate it. Could you please tell me which linker command file do you refer? Mine is F2806x_FLASH_BlinkingLED.CMD and it is probably differs from yours. However, the LOAD_START, LOAD_END etc. directives are defining _RamFuncsStartAddress, _RamFuncsEndAddress symbols, please note the underline in front of the variable names.
[code]
SECTIONS
{
/* Allocate program areas: */
.cinit : > FLASHA, PAGE = 0
.pinit : > FLASHA, PAGE = 0
.text : > FLASHA, PAGE = 0
codestart : > BEGIN PAGE = 0
ramfuncs : LOAD = FLASHA,
RUN = progRAM,
LOAD_START(_RamfuncsLoadStart),
LOAD_END(_RamfuncsLoadEnd),
RUN_START(_RamfuncsRunStart),
PAGE = 0
csmpasswds : > CSM_PWL PAGE = 0
csm_rsvd : > CSM_RSVD PAGE = 0
/* Allocate uninitalized data sections: */
.stack : > RAMM0, PAGE = 1
.ebss : > dataRAM, PAGE = 1
.esysmem : > dataRAM, PAGE = 1
/* Initalized sections go in Flash */
/* For SDFlash to program these, they must be allocated to page 0 */
.econst : > FLASHA PAGE = 0
.switch : > FLASHA PAGE = 0
/* Allocate IQ math areas: */
IQmath : > FLASHA PAGE = 0 /* Math Code */
IQmathTables : > IQTABLES PAGE = 0, TYPE = NOLOAD /* Math Tables In ROM */
/* Uncomment the section below if calling the IQNexp() or IQexp()
functions from the IQMath.lib library in order to utilize the
relevant IQ Math table in Boot ROM (This saves space and Boot ROM
is 1 wait-state). If this section is not uncommented, IQmathTables2
will be loaded into other memory (SARAM, Flash, etc.) and will take
up space, but 0 wait-state is possible.
*/
/*
IQmathTables2 : > IQTABLES2, PAGE = 0, TYPE = NOLOAD
{
IQmath.lib<IQNexpTable.obj> (IQmathTablesRam)
}
*/
/* Uncomment the section below if calling the IQNasin() or IQasin()
functions from the IQMath.lib library in order to utilize the
relevant IQ Math table in Boot ROM (This saves space and Boot ROM
is 1 wait-state). If this section is not uncommented, IQmathTables2
will be loaded into other memory (SARAM, Flash, etc.) and will take
up space, but 0 wait-state is possible.
*/
/*
IQmathTables3 : > IQTABLES3, PAGE = 0, TYPE = NOLOAD
{
IQmath.lib<IQNasinTable.obj> (IQmathTablesRam)
}
*/
.reset : > RESET, PAGE = 0, TYPE = DSECT
vectors : > VECTORS PAGE = 0, TYPE = DSECT
}
[/code]
Even though they start with the leading _, they refer to the same variables. While writing code in asm (.cmd files ar in asm), we refer to extern variables with a leading _ to avoid namespace collisions.
vivek
All the symbols defined in C will endup with a _ in front of them in assembly. This is specific to C28x - I've seen other compilers that do not do this. The linker understands the assembly symbols - so Vivek is correct, they are the same symbols.
Note these are symbols that don't take up any space. You can read about the symbols that the linker creates in this manner in the assembly reference guide:
Hi Lori,
thank you for your reply. In the mean time I studied the assembly language tool users guide and found on page 210 the following:
"Six new operators have been added to the link command file syntax:
LOAD_START( sym ) Defines sym with the load-time start address of related allocation unit
START( sym )
LOAD_END( sym ) Defines sym with the load-time end address of related allocation unit
END( sym )
etc..."
Now I understand the point but have a last question: in which file are the RamFuncsXYZ variables are defined? All the C files are referring them as externs. Or are they defined with the LOAD_START etc directives? It's a bit confusing.
JustGreg said:Now I understand the point but have a last question: in which file are the RamFuncsXYZ variables are defined? All the C files are referring them as externs. Or are they defined with the LOAD_START etc directives? It's a bit confusing.
They are defined by the linker itself.
Lori Heustess said:Or are they defined with the LOAD_START etc directives?
Yes - by the linker when it sees one of the directives LOAD_START(symbol) etc...