Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reserving memory in linker script file

3,276 views
Skip to first unread message

Jeroen Boonen

unread,
Aug 5, 2004, 10:16:03 AM8/5/04
to
Hi,

Is it possible to reserve some memory in the linker script file

ex:
MEMORY
{
sram (WXAI) : org = 0x00000100, len = 256K - 0x100
flash (RX) : org = 0x01000000, len = 2M
}

In the flash I need some reserved spaces were no code my be placed by the
linker...(space is used to add some headers after compilation and linking)

Any help

Jeroen


42Bastian Schick

unread,
Aug 6, 2004, 4:25:10 AM8/6/04
to
On Thu, 05 Aug 2004 14:16:03 GMT, "Jeroen Boonen" <j...@pandora.be>
wrote:

SECTIONS
{
.reserved :
{
. += <enter amount here>;
} > flash;

/* more sections */
}

--
42Bastian
Do not email to bast...@yahoo.com, it's a spam-only account :-)
Use <same-name>@epost.de instead !

Jeroen Boonen

unread,
Aug 6, 2004, 11:23:43 AM8/6/04
to
Hi Bastian,

OK, your solution is a way of doing that, but what I want is that the
compiler automatically places code "around" the reserved space. I need this
for by boot code.
The boot code needs to start at address 0, then at 8K, there is a reserved
place, then further again boot code.
In advance I don't know the size of the first and second boot code...So what
I want is that the linker places code beginning at 0 until needed, but not
the second sector of 8K

Is there a way to do this?

Jeroen

42Bastian Schick

unread,
Aug 12, 2004, 12:41:49 AM8/12/04
to
Hi Jeroen

>OK, your solution is a way of doing that, but what I want is that the
>compiler automatically places code "around" the reserved space. I need this
>for by boot code.
>The boot code needs to start at address 0, then at 8K, there is a reserved
>place, then further again boot code.
>In advance I don't know the size of the first and second boot code...So what
>I want is that the linker places code beginning at 0 until needed, but not
>the second sector of 8K
>
>Is there a way to do this?

Now I understand, I had the same problem with the MCF5282, the Flash
needs some 24bytes for protection and these were not the start or end
:(

But I found no solution other than splitting my code:

MEMORY {
rom1 (rx) : org=0, len = 0x400;
cfg (r) : org=0x400, len = 24;
rom (rx) : org=0x400+24, len 0x80000-0x400-24
}

And then filling rom1 as much as possible.

Ralf Ebeling

unread,
Aug 12, 2004, 4:23:59 AM8/12/04
to
42Bastian Schick wrote:

>>OK, your solution is a way of doing that, but what I want is that the
>>compiler automatically places code "around" the reserved space. I need this
>>for by boot code.
>>The boot code needs to start at address 0, then at 8K, there is a reserved
>>place, then further again boot code.
>>In advance I don't know the size of the first and second boot code...So what
>>I want is that the linker places code beginning at 0 until needed, but not
>>the second sector of 8K
>>
>>Is there a way to do this?
>
> Now I understand, I had the same problem with the MCF5282, the Flash
> needs some 24bytes for protection and these were not the start or end
> :(
>
> But I found no solution other than splitting my code:
>
> MEMORY {
> rom1 (rx) : org=0, len = 0x400;
> cfg (r) : org=0x400, len = 24;
> rom (rx) : org=0x400+24, len 0x80000-0x400-24
> }
>
> And then filling rom1 as much as possible.

What's about using a dummy data section (reserving the space needed
only) placed at a fixed location that won't be initialized on startup?

Ralf

42Bastian Schick

unread,
Aug 13, 2004, 11:31:58 AM8/13/04
to
>>
>> But I found no solution other than splitting my code:
>>
>> MEMORY {
>> rom1 (rx) : org=0, len = 0x400;
>> cfg (r) : org=0x400, len = 24;
>> rom (rx) : org=0x400+24, len 0x80000-0x400-24
>> }
>>
>> And then filling rom1 as much as possible.
>
>What's about using a dummy data section (reserving the space needed
>only) placed at a fixed location that won't be initialized on startup?

I don't see how. The problem is, the GNU linker does not fill up the
section automatically (the HCS12-GNU people discussed this a lot).

Something like:

.rom1 : { *(.text) } >rom1
.rom2 : { *(.text) } >rom2
would be nice, where ld puts as much as possible into rom1 and then
steps over to rom2.

Richard McCord

unread,
Aug 16, 2004, 1:07:20 PM8/16/04
to
This is how I do it
MEMORY {
    ram          ORG = 0x0                     , LEN = 0x80000
    boot         ORG = 0x80000             , LEN = 0x800
    extram      ORG = 0x80000+0x800 , LEN = 0x100000
}

SECTION {
    .test                                        :> ram
    .bootsection    PAD(0x800)    :> boot
    .data                                       :>extram
}

NOTE: sections can not over lap.

Rick

42Bastian Schick

unread,
Aug 18, 2004, 9:43:20 AM8/18/04
to
On Mon, 16 Aug 2004 10:07:20 -0700, Richard McCord
<rmc...@raytheon.com> wrote:

><!doctype html public "-//w3c//dtd html 4.0 transitional//en">
><html>
><more html kicked ...>
What the heck ...

0 new messages