DSPRelated.com
Forums

CodeWarrior linker does not check memory limits

Started by Pete Becher May 13, 2003
Hi All,

I thought I would post this so others might avoid the problems I was
having.

CodeWarrior linker does not do any checking to see if your code is
over-running the available pFlash space.

I was having a lot of problems when my code got to a certain size.
The program would run the first time but not after reset. What
happens is the excess pFlash code will overrun into pRAM. It will
run just fine until you power-down the system at which point the code
in pRAM will be lost.

I was not adding up all the memory segments that go into pFlash to
figure out if I was at the limit. This is described well in the SDK
Programmers Guide, Chapter 6 Target Configuration (if one reads it).

It would be nice if CW would let a user know when the limit is
reached (rather than letting the code act like it is going bonkers).

Pete



Hi Ron,

How does one get the latest linker.cmd? I have version 5.04 and if I
create a new project I still get a linker.cmd file with a 2001 date
on it. Is there some problem with upgrades?

Pete

Below is the direct reply from Ron. >The linker does report if you are out of memory if the LCF is setup
>properly. the stationary we ship since CodeWarrior for DSP56800
>v5.0 has
>done this.

>Ron

--- In , "Pete Becher" <pbecher@d...>
wrote:
> Hi All,
>
> I thought I would post this so others might avoid the problems I
was
> having.
>
> CodeWarrior linker does not do any checking to see if your code is
> over-running the available pFlash space.
>
> I was having a lot of problems when my code got to a certain size.
> The program would run the first time but not after reset. What
> happens is the excess pFlash code will overrun into pRAM. It will
> run just fine until you power-down the system at which point the
code
> in pRAM will be lost.
>
> I was not adding up all the memory segments that go into pFlash to
> figure out if I was at the limit. This is described well in the
SDK
> Programmers Guide, Chapter 6 Target Configuration (if one reads it).
>
> It would be nice if CW would let a user know when the limit is
> reached (rather than letting the code act like it is going bonkers).
>
> Pete


Pete,

The CodeWarrior linker DOES check for memory overruns in segments
already so that must not be what is happening.

If you are using the Embedded SDK (which it sounds like you are), the
PFlash memory segment is defined as follows on the 805 for example:

MEMORY {

.pFlash (RX) : ORIGIN = 0x0086, LENGTH = 0x7D7A

If that MEMORY segment exceeds the pre-defined length of 0x7D7A in
your project the linker will return an error and not finish the build
so that must not be what's happening in your case.

What the linker doesn't do for you is it doesn't check for stack
usage
to make sure that you will not exceed the amount of space that you
have alloted for it which can lead to funny behavior when you run
your
project (maybe that is what is happening). However, the Embedded SDK
includes stack check utilities to help out in that regards.....see
5.2.2 in the SDK Programmer's Guide.

Regards,
John

--- In , "Pete Becher" <pbecher@d...>
wrote:
> Hi All,
>
> I thought I would post this so others might avoid the problems I
was
> having.
>
> CodeWarrior linker does not do any checking to see if your code is
> over-running the available pFlash space.
>
> I was having a lot of problems when my code got to a certain
size.
> The program would run the first time but not after reset. What
> happens is the excess pFlash code will overrun into pRAM. It will
> run just fine until you power-down the system at which point the
code
> in pRAM will be lost.
>
> I was not adding up all the memory segments that go into pFlash to
> figure out if I was at the limit. This is described well in the
SDK
> Programmers Guide, Chapter 6 Target Configuration (if one reads
it).
>
> It would be nice if CW would let a user know when the limit is
> reached (rather than letting the code act like it is going
bonkers).
>
> Pete



John,

If it is checking, it must not be doing a very good job of it.

I am only using about 1/10 of my stack space so I'm quite sure that
is not the problem.

My .xMAP file was showing that the sum of the segments that go into
pFLASH (.pFlash, .pIntRAM_Mirror, .xExtRAM_Mirror) is larger than
the .pFlash segment.

However, I should say I was getting the following error message
randomly.

Can't write application "M2CanCntlV0.00.15.S".
An unknown error occurred when linking target "Flash" for
project "M2CanContl.mcp".

If I reboot or remove object code, recurse and reboot it will compile
and link "just fine".

When is the last time the linker was checked for this condition?
Maybe there is an error in my linker.cmd file that could cause this
or maybe it is just a CWerk.

Pete --- In , "jdw_atx" <jdw_atx@y...> wrote:
> Pete,
>
> The CodeWarrior linker DOES check for memory overruns in segments
> already so that must not be what is happening.
>
> If you are using the Embedded SDK (which it sounds like you are),
the
> PFlash memory segment is defined as follows on the 805 for example:
>
> MEMORY {
>
> .pFlash (RX) : ORIGIN = 0x0086, LENGTH = 0x7D7A
>
> If that MEMORY segment exceeds the pre-defined length of 0x7D7A in
> your project the linker will return an error and not finish the
build
> so that must not be what's happening in your case.
>
> What the linker doesn't do for you is it doesn't check for stack
> usage
> to make sure that you will not exceed the amount of space that you
> have alloted for it which can lead to funny behavior when you run
> your
> project (maybe that is what is happening). However, the Embedded
SDK
> includes stack check utilities to help out in that regards.....see
> 5.2.2 in the SDK Programmer's Guide.
>
> Regards,
> John
>
> --- In , "Pete Becher" <pbecher@d...>
> wrote:
> > Hi All,
> >
> > I thought I would post this so others might avoid the problems I
> was
> > having.
> >
> > CodeWarrior linker does not do any checking to see if your code
is
> > over-running the available pFlash space.
> >
> > I was having a lot of problems when my code got to a certain
> size.
> > The program would run the first time but not after reset. What
> > happens is the excess pFlash code will overrun into pRAM. It
will
> > run just fine until you power-down the system at which point the
> code
> > in pRAM will be lost.
> >
> > I was not adding up all the memory segments that go into pFlash
to
> > figure out if I was at the limit. This is described well in the
> SDK
> > Programmers Guide, Chapter 6 Target Configuration (if one reads
> it).
> >
> > It would be nice if CW would let a user know when the limit is
> > reached (rather than letting the code act like it is going
> bonkers).
> >
> > Pete