EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Root code size

Started by seecwriter August 16, 2011
On an RCM3000, I'm getting an Out of Root Code error. Its using 24765
bytes of root code. How much do I have to reduce that?

Steve

I haven't worked with any of the R3000 or R2000 based processors only the R4000 upwards so I can't answer this directly but...

I would assume that DC 9.x provides some mechanisms for adjusting the amount of root code versus root data available and so the exact answer would depend on the settings of the macros controlling the sizes.

Does DC 9.x produce a .org file which shows the amount of memory allocated for each type of memory and the amount actually used ?

Regards,
Peter

--- In r..., "seecwriter" wrote:
>
> On an RCM3000, I'm getting an Out of Root Code error. Its using 24765
> bytes of root code. How much do I have to reduce that?
>
> Steve
>

<*>[Attachment(s) from Moore, Robert included below]

One place to start is TN238 (Rabbit Memory Usage Tips) . . .
Unfortunately I cannot find it on the Digi site since they mashed
Rabbit into it willy nilly. So I have attached it. You also need the
DC9.62 documentation.

It may be that this forum does not permit attachments. If it does not
come through, write me directly and I will forward the doc to you.

If ANYONE knows anbody in digi please tell them what a mess they have
made of the Rabbit product line in almost every possible way. I even
received a phone call from Digi in response to one of my letters
concerning the mess. And the digi person could not find what I was
looking for either.

bob

Robert K Moore, PhD
Designer, Macular Metrics
R...@brown.edu
401-226-6888

>> --- In r..., "seecwriter" wrote:
>>
>> On an RCM3000, I'm getting an Out of Root Code error. Its using 24765
>> bytes of root code. How much do I have to reduce that?
>>
>> Steve
--
<*>Attachment(s) from Moore, Robert:
<*> 1 of 1 File(s) http://groups.yahoo.com/group/rabbit-semi/attachments/folder/432011698/item/list
<*> TN238.pdf

I've moved most string literals to xmem. The only string literals
left in root are some sprintf formatting strings ("%2d"), and some
other 2 and 3-char string literals. For strings that short, you don't
really save any memory by putting them in xmem. In any case, I'm
still running out of root code space.

Then I backed out all #ximport defines for my webpage. There are 28
png and jpg files that get imported. They vary in size from 1k to 3k.
Removing these imports allowed me to get a clean compile. Adding them
back in, one at a time, I was able to get all but the last two back
in before I ran out of root code space. I take it that #ximport files
are stored in root code space. Is there a way to put them in xmem
space?

Steve
--- In r..., "Moore, Robert" wrote:
>
> One place to start is TN238 (Rabbit Memory Usage Tips) . . .
> Unfortunately I cannot find it on the Digi site since they mashed
> Rabbit into it willy nilly. So I have attached it. You also need the
> DC9.62 documentation.
>
> It may be that this forum does not permit attachments. If it does not
> come through, write me directly and I will forward the doc to you.
>
> If ANYONE knows anbody in digi please tell them what a mess they have
> made of the Rabbit product line in almost every possible way. I even
> received a phone call from Digi in response to one of my letters
> concerning the mess. And the digi person could not find what I was
> looking for either.
>
> bob
>
> Robert K Moore, PhD
> Designer, Macular Metrics
> Robert_Moore@...
> 401-226-6888
>
> >> --- In r..., "seecwriter" wrote:
> >>
> >> On an RCM3000, I'm getting an Out of Root Code error. Its using 24765
> >> bytes of root code. How much do I have to reduce that?
> >>
> >> Steve
> --
>

On 8/17/2011 7:20 PM, seecwriter wrote:
> Then I backed out all #ximport defines for my webpage. There are 28
> png and jpg files that get imported. They vary in size from 1k to 3k.
> Removing these imports allowed me to get a clean compile. Adding them
> back in, one at a time, I was able to get all but the last two back
> in before I ran out of root code space. I take it that #ximport files
> are stored in root code space. Is there a way to put them in xmem
> space?

ximport puts dat in xmem, that is what the 'x' is for. You probably ran
out of mem on the matching http spec entries that are stored in root.

Separate Instruction & Data can help. Reducing string literals will
help. The DATAORG sets the root code/data split.

The problem with DC is it puts a lot of code in root space (like case
statement jump tables) and their libs use root code where it is not
necessary.

--
------
Scott G. Henion, Consultant
Web site: http://SHDesigns.org
Rabbit libs: http://shdesigns.org/rabbit/
------

Can you show us the .org file for the version that compiles to give us some idea of the overall memory situation? That might show us what could possibly be juggled.

Have you tried toggling the size/speed option in the project options and disabling the runtime checks for array indices and pointers? These all have an effect on memory usage as well.

If juggling these and/or the DATAORG does not help it may be an idea to look at other ways of reducing the code size. I've recently done some work on the BACnet stack to reduce its footprint and there are usually a few things you can do to get some reasonable gains if the code has not been written with the weak points of the Dynamic C compiler in mind :)

One of the worst areas for the compiler is array index calculations so if you have code that uses arrays a lot (particularly arrays of structures) consider converting to using a pointer i.e.

for (x=0; x < 8; x++)
{
a[x].b = 0;
a[x].c = 0;
}

p = &a[0];
for (x=0; x < 8; x++, p++)
{
p->b = 0;
p->c = 0;
}

Generally uses less code;

Also with DC 10.x I've found that using char variables to save a bit of storage causes unnecessary code bloat in some cases as the compiler usually converts it to an int, carries on using it and converts back to a char at the end e.g.
void x(char a)

{
char b;
char c;
char i;

c = a + b;

for (i = 0; i < 8; i++)
{
// do something with a, b, c ...
}
}

Will produce smaller code if the variables are all ints at expense of using a little bit more stack space.

Regards
Peter

--- In r..., Scott Henion wrote:
>
> On 8/17/2011 7:20 PM, seecwriter wrote:
> > Then I backed out all #ximport defines for my webpage. There are 28
> > png and jpg files that get imported. They vary in size from 1k to 3k.
> > Removing these imports allowed me to get a clean compile. Adding them
> > back in, one at a time, I was able to get all but the last two back
> > in before I ran out of root code space. I take it that #ximport files
> > are stored in root code space. Is there a way to put them in xmem
> > space?
>
> ximport puts dat in xmem, that is what the 'x' is for. You probably ran
> out of mem on the matching http spec entries that are stored in root.
>
> Separate Instruction & Data can help. Reducing string literals will
> help. The DATAORG sets the root code/data split.
>
> The problem with DC is it puts a lot of code in root space (like case
> statement jump tables) and their libs use root code where it is not
> necessary.
>
> --
> ------
> Scott G. Henion, Consultant
> Web site: http://SHDesigns.org
> Rabbit libs: http://shdesigns.org/rabbit/
> ------
>

I was at a conference last week with Digi. I wouldn't hold out much hope
for any improvements...

TN219 is available on the Digi website which details root memory usage
reduction techniques.

Steve it sounds like you are on the right track, but remember you can move
DATAORG to increase DATA or CODE space depending on what you are running out
of.

Cheers

Pete

From: r... [mailto:r...] On
Behalf Of seecwriter
Sent: Thursday, 18 August 2011 11:21 a.m.
To: r...
Subject: [rabbit-semi] Re: Root code size

I've moved most string literals to xmem. The only string literals
left in root are some sprintf formatting strings ("%2d"), and some
other 2 and 3-char string literals. For strings that short, you don't
really save any memory by putting them in xmem. In any case, I'm
still running out of root code space.

Then I backed out all #ximport defines for my webpage. There are 28
png and jpg files that get imported. They vary in size from 1k to 3k.
Removing these imports allowed me to get a clean compile. Adding them
back in, one at a time, I was able to get all but the last two back
in before I ran out of root code space. I take it that #ximport files
are stored in root code space. Is there a way to put them in xmem
space?

Steve

--- In r... ,
"Moore, Robert" wrote:
>
> One place to start is TN238 (Rabbit Memory Usage Tips) . . .
> Unfortunately I cannot find it on the Digi site since they mashed
> Rabbit into it willy nilly. So I have attached it. You also need the
> DC9.62 documentation.
>
> It may be that this forum does not permit attachments. If it does not
> come through, write me directly and I will forward the doc to you.
>
> If ANYONE knows anbody in digi please tell them what a mess they have
> made of the Rabbit product line in almost every possible way. I even
> received a phone call from Digi in response to one of my letters
> concerning the mess. And the digi person could not find what I was
> looking for either.
>
> bob
>
> Robert K Moore, PhD
> Designer, Macular Metrics
> Robert_Moore@...
> 401-226-6888
>
> >> --- In r...
, "seecwriter" wrote:
> >>
> >> On an RCM3000, I'm getting an Out of Root Code error. Its using 24765
> >> bytes of root code. How much do I have to reduce that?
> >>
> >> Steve
> --
>

Memfault Beyond the Launch