the __attribute__ with 'at' is ignored

Asked by Douglas

eclipse: Kepler 20140224-0627
java: 1.6.0_54
OS: OSX 10.9.4
toolchain: 1.10.2.201407190854

I am trying to force a variable to be at a fixed RAM location on a Cortex M3 (in this case, a Silcon Labs EFM32LG330F256).

In my code I have declared my variable as:
uint32_t fingerprint __attribute__((at(0x20008c48)));

but the compiler gives:

../include/fingerprint.h:22:1: warning: 'at' attribute directive ignored [-Wattributes]
uint32_t fingerprint __attribute__ ((at(0x20008c48)));
^

is this supported with this toolchain??

Is there also a way to force gcc to not initialise a variable too?

Cheers
Douglas

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Terry Guo
Solved:
Last query:
Last reply:
Revision history for this message
Best Terry Guo (terry.guo) said :
#1

I believe the gcc 'section' attribute is the one you are looking for. Its usage looks like:

struct duart a __attribute__ ((section ("DUART_A"))) = { 0 };

You also need to specify the address for section "DUART_A" in linker script. Also quoted from gcc manual:

You may use the section attribute with initialized or uninitialized global variables
but the linker requires each object be defined once, with the exception
that uninitialized variables tentatively go in the common (or bss) section and
can be multiply “defined”.

Revision history for this message
Uwe Bonnes (bon) said :
#2

What about
uint32_t *fingerprint = (uint32_t*)0x20008c48;

Revision history for this message
TM (tm1234) said :
#3

> You may use the section attribute with initialized or uninitialized global variables
> but the linker requires each object be defined once, with the exception
> that uninitialized variables tentatively go in the common (or bss) section and
> can be multiply “defined”

This article might also be of relevance in this context?

http://mcuoneclipse.com/2014/04/19/gnu-linker-can-you-not-initialize-my-variable/

To quote...

"So this means that if I use the __attribute__ with section, the variable is treated like an initialized variable."

... unless additional steps are taken in the linker script.

Revision history for this message
Douglas (douglas-pearless) said :
#4

Thanks Terry Guo, that solved my question.