[arm-gnu] Placing variable at absolute address in RAM

Alexander Zakharov azakharov at uniserve.com
Thu Apr 5 07:24:34 UTC 2012


This is what I used in a past:

In linker  'helper' file hwmap.ld

............
.dmaRegisters			0X70000000		(NOLOAD): {
*(.dmaRegisters)			} > HWMAP
............

In source file hwmap.c

.......
DMA_REGISTERS			dmaRegisters
__attribute__ ((used,section(".dmaRegisters")));
.......

In header file dmaRegisters.h

.......
typedef struct
{
  /* Something */   
 
} DMA_REGISTERS;


extern DMA_REGISTERS	dmaRegisters;
.........

And finally, in a main linker file my_board.ld

......
MEMORY
{
  RAM      (rwx)  : ORIGIN = 0x00000000, LENGTH = 16M
  ROM      (rwx)  : ORIGIN = 0xFFFFFFFF, LENGTH = 0
  ALIASMEM (rwx)  : ORIGIN = 0x10000000, LENGTH = 16M
  HWMAP    (rw )  : ORIGIN = 0x20000000, LENGTH = 3584M
}
......
/* Include hardware registers maps */

	INCLUDE hwmap.ld
.....

Then you just use dmaRegisters in your code like " dmaRegisters.field = X; "

Hope it helps. This way you can 'stick' your variable in any place in a
memory - this is how I implemented my hardware registers access in a past,
but should work like a charm for your cause.

Cheers,
Alex 

-----Original Message-----
From: arm-gnu-bounces at codesourcery.com
[mailto:arm-gnu-bounces at codesourcery.com] On Behalf Of Tom Evans
Sent: Thursday, April 05, 2012 1:24 AM
To: JM
Cc: arm-gnu at codesourcery.com
Subject: Re: [arm-gnu] Placing variable at absolute address in RAM

JM wrote:
> Hello
> 
> I've researched this, asked on other forums, and so far I'm no closer.  
> 
> I'm trying to place a variable at a specific address in RAM on a TI 
> ARM Cortex-M3.  I have good reason for doing so, which I can explain
briefly:

How about just calling malloc() in a loop until you get an allocation that
matches all of your addressing requirements, and then free all the ones that
didn't. Brutal, but it should work if called very early on in your startup
before anything else has got to malloc().

If you don't have "malloc" then you should have something similar managing
your heap that could be abused to do this for you.

Tom

_______________________________________________
arm-gnu mailing list
arm-gnu at codesourcery.com
http://sourcerytools.com/cgi-bin/mailman/listinfo/arm-gnu




More information about the arm-gnu mailing list