Hello Everyone,
I want to place a string constant in code flash at a specific address. So, I read that this can be done by using the #pragma address
Here is the code:
#pragma address fixed_addr=0x27000
const uint8_t fixed_addr[] = {"Renesas"};
But when I build my project I get the message that the #pragma address is being ignored. Here is the warning in my build output.
../src/hal_entry.c: At top level:
../src/hal_entry.c:256: warning: ignoring '#pragma address fixed_addr' [-Wunknown-pragmas]
256 | #pragma address fixed_addr=0x27000
I see the unknown-pragmas. How do I enable the pragma?
My project is for the RA4M3.
I am using FSP version 5.2.0
e2 studio is version 2024-01.1
Thanks,
Ed
Do you use GCC? There are no pragma address in GCC.cf. https://gcc.gnu.org/onlinedocs/gcc-13.3.0/gcc/Pragmas.htmlNote that #pragma is there to realize "compiler specific" features and definitely not compatible with other compilers.You can use attribute, instead.cf. https://gcc.gnu.org/onlinedocs/gcc-13.3.0/gcc/Variable-Attributes.htmlThis FAQ may help you.FAQ - Allocating a variable/function to a specified section in a GCC projecthttps://en-support.renesas.com/knowledgeBase/19554085
Okay, so I want to use the __attribute__ keyword. the example shown in the knowledge base is
char myVar[32] __attribute__ ((section (".mydata"))) = { ...I'm halfway there. My question now is how do I setup .mydata so that it points to a specific address in code memory?
You will need to add a section to your linker script with the address specified. Note that you'll have to adjust the size of the flash region that's already defined to accommodate that or the linker will have errors about overlapping sections.
Thanks, I have never added a section to my linker script. You are talking about file fsp.ld correct? Can you give me an example for setting up a section that is 32 bytes long?