Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] How to specify the location of an object in memory(GNU)

2005-11-02 by Tom Walsh

David Hawkins wrote:

>Hey Michel,
>
>Michel wrote:
>  
>
>>I am using the KEIL IDE for ARM7 processors with the GNU Cygnus 
>>compiler on a LPC2106 target. My problem is that I cannot find
>>in the documentation how to tell the compiler to locate an object
>>at a specified place (somwhere in flash memory, for instance).
>>at 0x00016000 int base;
>>    
>>
>
>TomW replied with:
>  
>
>>That would be the linker that would do the physical location of things.
>>
>>Compilers build relocatable objects, linkers place those into regions 
>>that you specify in the linker file (script).
>>    
>>
>
>Could you please tell us WHY you want to do this?
>
>The only time I can ever think of needed to force a particular
>code at a specific address is;
>
>  
>
Just because you know a couple of things doesn't mean that you know it all.

If you recognized the "AT" directive then you would have understood that 
the question was regard to locating a section to a hard address.  
Typically this is done to describe where something such as a binary 
image produced by something other than the compiler.  Or, it is done to 
physically locate entire Sections of code into external memory devices.

Ok?


>  a) an exception vector(s)
>  b) an overlay for a set of device control registers
>
>For (a) you can define a section, and use the linker script to
>perform the locating in Flash. For (b), I've always found it
>nicer to just use a pointer to the peripherals region instead,
>eg.
>
>  typedef struct serial {
>	int control;
>	int status;
>	int data;
>  } serial_t;
>
>  serial_t *com1 = (serial_t *)(SERIAL_BASE_ADDR);
>
>  registers are accessed as com1->control = ...
>
>If you use the linker to link this structure over a specific range
>of addresses, then the syntax changes to com1.control = ...
>But you have to do more work with the linker script.
>
>So, perhaps you are trying to implement something the
>difficult way, tell us what you are trying to do.
>
>Cheers,
>Dave
>
>
>
>
>
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>  
>


-- 
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------------------------------------------

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.