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.
Tool/software:
Hi all,
I have a software which has multiple work modes.
The code uses either CPU and CLA. As the CLA part is splitted in many functions which I use according the current working mode.
But memory available for CLA is constrained (only LS space), I would like to know if it is possible to define an overlay?
As I only use a couple of CLA function in each configuration, the idea is to load the corresponding functions for the actual working mode.
My CLA function are named as follow:y
My CLA sections are defined as follow in the linker file:
Cla1Prog : LOAD = FLASHG, RUN = RAMLS1_5, LOAD_START(_Cla1funcsLoadStart), LOAD_END(_Cla1funcsLoadEnd), RUN_START(_Cla1funcsRunStart), LOAD_SIZE(_Cla1funcsLoadSize), PAGE = 0, ALIGN(4) CLAscratch : { *.obj(CLAscratch) . += CLA_SCRATCHPAD_SIZE; *.obj(CLAscratch_end) } > RAMLS0, PAGE = 1 .scratchpad : > RAMLS0, PAGE = 1 .bss_cla : > RAMLS0, PAGE = 1 .const_cla : LOAD = FLASHG, RUN = RAMLS0, RUN_START(_Cla1ConstRunStart), LOAD_START(_Cla1ConstLoadStart), LOAD_SIZE(_Cla1ConstLoadSize), PAGE = 1
How do I have to change this to use overlay with UNION and GROUP?
UNION { GROUP { ??? } load = FLASHG, LOAD_START(_taskA_load_start), SIZE(_taskA_size) GROUP { ??? } load = FLASHG, LOAD_START(_taskB_load_start), SIZE(_taskB_size) } run = RAMLS1_5, RUN_START(_task_run_start)
Thanks for any help.
Best regards
Fabrice
Hi Fabrice,
I would suggest keeping the CLA memory allocations the same in the linker cmd file and adding #if statements around each function to check which working mode is chosen. You can add a #define to refer to which working mode is being run and #if statements could check for this.
For example, you could have:
#define WORKING_MODE 1
#if WORKING_MODE == 1
//include function definitions for CLA1ModeA_xxxx functions
#endif
#if WORKING_MODE == 2
//include function definitions for CLA1ModeB_xxxx functions
#endif
You could also alternatively include predefined symbols for each working mode and wrap the functions in #ifdef
statements.
This way, the compiler won't actually allocate CLA memory for functions that aren't needed in the current working mode. Let me know if this would be a viable solution for you.
Best Regards,
Delaney
Hi Delaney,
Thanks for your input, but this is not really what I want to do.
Using defines means having multiple compiled version. The CLA routines are "static" and I can not change the configuration "on the fly".
Want I want to do, is to have all the CLA routines compiled and stored in FLASH but only load the functions group I need in RAM according to boot configuration.
Best regards,
Fabrice
I found myself a solution which seems to work.
It is quiet simple: use #pragma CODE_SECTION
to move wanted functions into a specific code section!
For example:
#pragma CODE_SECTION(Cla1ModeATask1, "Cla1ModeA");
__interrupt void Cla1ModeATask1() {... }
#pragma CODE_SECTION(Cla1ModeATask2, "Cla1ModeA");
__interrupt void Cla1ModeATask2() {... }
...
#pragma CODE_SECTION(Cla1ModeBTask1, "Cla1ModeB");
__interrupt void Cla1ModeBTask1() {... }
#pragma CODE_SECTION(Cla1ModeBTask2, "Cla1ModeB");
__interrupt void Cla1ModeBTask2() {... }
And then in the linker file
// mode specific functions UNION { GROUP { Cla1ModeA : {} } LOAD = FLASHG, LOAD_START(_Cla1ModeALoadStart), SIZE(_Cla1ModeALoadSize) GROUP { Cla1ModeB : {} } LOAD = FLASHG, LOAD_START(_Cla1ModeBLoadStart), SIZE(_Cla1ModeBLoadSize) } RUN = RAMLS1_5, RUN_START(_Cla1OptionsRunStart), PAGE = 0 //Cla1Prog contains the common code Cla1Prog : LOAD = FLASHG, RUN = RAMLS1_5, LOAD_START(_Cla1funcsLoadStart), LOAD_END(_Cla1funcsLoadEnd), RUN_START(_Cla1funcsRunStart), LOAD_SIZE(_Cla1funcsLoadSize), PAGE = 0, ALIGN(4)