AnsweredAssumed Answered

Codewarrior Code and variable relocation

Question asked by Matt Lang on Feb 19, 2018
Latest reply on Feb 24, 2018 by ZhangJennie

I'm using Codewarrior 10.6.4 for a target of the Coldfire V1 MCF51JE256RM. I am trying to force some RAM variables to specific addresses but I can't seem to find the correct syntax.

 

I have tried the @0x00000 way like below

uint_8 g_recv_size@0x805A05;

 

-----------------------------------------------------------------------------------------------------

I have tried the __attribute((section (".myBufSection"))); Like below

 

uint_8 g_recv_size __attribute__((section (".myBufSection"))); 

and edited the linker file 

 

/* placing my named section at given address: */
.myBufBlock 0x805A05 :
{
KEEP(*(.myBufSection)) /* keep my variable even if not referenced */
} >> userram

 

-----------------------------------------------------------------------------------------------------

I have tried the #pragma approach. This gives me "end of line expected" errors

 

#pragma define_section mySectionInRAM “.myCodeInRAM” far_absolute RX
#pragma section mySectionInRAM begin

 

uint_8 g_send_size;

#pragma section mySectionInRAM end

 

-----------------------------------------------------------------------------------------------------

I have tried the __delspec((section (".myBufSection"))); Like below

 

__delspec((section (".myBufSection"))) uint_8 g_recv_size; 

and edited the linker file 

 

/* placing my named section at given address: */
.myBufBlock 0x805A05 :
{
KEEP(*(.myBufSection)) /* keep my variable even if not referenced */
} >> userram

 

 

 

 

What is the proper way to do this seemingly simple task? I want to force a variable to a specific RAM address.

Outcomes