EmbeddedRelated.com
Forums

Getting Root code space

Started by Steve Trigero February 9, 2007
I'm trying to add RabbitWeb to my RCM3000 application and I'm getting
the "Out of Root Code Space" error.

Here is the memory map of my application before adding RabbitWeb:

//Segment Origin Size
Root Code 00:0000 0057f7
Root Data b1:cbff 0028e7
Xmem Code 32:e000 006c9e

I suspect that my application is too large to add RabbitWeb to, but I don't
know how much root code space I need for RabbitWeb, nor how much root
code space I have left?

I've already done the "#memmap xmem" thing, all string literals are in xmem,
I don't use printf, and debug is turned off. I tried changing DATAORG some
time ago, but it caused all kinds of problems so I put it back. I'm not using
separate I&D. My application already uses ethernet in DHCP mode, and I
have 2 sockets declared.

Here is memory map after I add RabbitWeb:

//Segment Origin Size
Root Code 00:0000 0060f7
Root Data b1:9549 ffffd203
Xmem Code f9:e226 04abd1
Would moving to one of the R4000 modules get me more memory?

Steve
Steve
First thing to do is use Split I&D , that get's all your root code
out of root memory... Second thing to do is fiddle with Data Org,
and yes it's tricky but you can usually move it 0x1000 and get 4K
more dta space... third thing to do is move anything you can to
XMEM and yes I know that's a PITA..

I worked on a pretty large app that was full boat TCP/IP (SNMP and
all) and had RabbibWeb in it so I know it can be done...

And No a R4000 aint gonna do squat for getting you more code space...

--.- Dave
--- In r..., Steve Trigero
wrote:
>
> I'm trying to add RabbitWeb to my RCM3000 application and I'm
getting
> the "Out of Root Code Space" error.
>
> Here is the memory map of my application before adding RabbitWeb:
>
> //Segment Origin Size
> Root Code 00:0000 0057f7
> Root Data b1:cbff 0028e7
> Xmem Code 32:e000 006c9e
>
> I suspect that my application is too large to add RabbitWeb to,
but I don't
> know how much root code space I need for RabbitWeb, nor how much
root
> code space I have left?
>
> I've already done the "#memmap xmem" thing, all string literals
are in xmem,
> I don't use printf, and debug is turned off. I tried changing
DATAORG some
> time ago, but it caused all kinds of problems so I put it back.
I'm not using
> separate I&D. My application already uses ethernet in DHCP mode,
and I
> have 2 sockets declared.
>
> Here is memory map after I add RabbitWeb:
>
> //Segment Origin Size
> Root Code 00:0000 0060f7
> Root Data b1:9549 ffffd203
> Xmem Code f9:e226 04abd1
> Would moving to one of the R4000 modules get me more memory?
>
> Steve
>
I'll give the separate I&D a try next week. Last time I tried it my
application would run right so I quit. Does it matter that I have no
code in root memory. At least code that I've specifically put there.
Isn't "#memmap xmem" supposed to put all code into xmem space
unless the code has been specifically declared to be in root?
I've seen posts that state that switch statements use root code space
even if the procedure they are in are in xmem. But when I convert
a switch statement to an if...else if... statement my root code usage
goes up, not down, and my total code amount tends to increase. I
don't see any benefit from not using switch. Have I misunderstood
something?
Do you know how much root code I have to reclaim in order to
get RabbitWeb to fit?

Its good to know it can be done, cause I'm supposed to add SNMP
too. Sheesh!

Steve

----- Original Message ----
From: Dave August
To: r...
Sent: Saturday, February 10, 2007 9:08:18 AM
Subject: [rabbit-semi] Re: Getting Root code space

Steve

First thing to do is use Split I&D , that get's all your root code

out of root memory... Second thing to do is fiddle with Data Org,

and yes it's tricky but you can usually move it 0x1000 and get 4K

more dta space... third thing to do is move anything you can to

XMEM and yes I know that's a PITA..

I worked on a pretty large app that was full boat TCP/IP (SNMP and

all) and had RabbibWeb in it so I know it can be done...

And No a R4000 aint gonna do squat for getting you more code space...

--.- Dave

--- In rabbit-semi@ yahoogroups. com, Steve Trigero

wrote:

>

> I'm trying to add RabbitWeb to my RCM3000 application and I'm

getting

> the "Out of Root Code Space" error.

>

> Here is the memory map of my application before adding RabbitWeb:

>

> //Segment Origin Size

> Root Code 00:0000 0057f7

> Root Data b1:cbff 0028e7

> Xmem Code 32:e000 006c9e

>

> I suspect that my application is too large to add RabbitWeb to,

but I don't

> know how much root code space I need for RabbitWeb, nor how much

root

> code space I have left?

>

> I've already done the "#memmap xmem" thing, all string literals

are in xmem,

> I don't use printf, and debug is turned off. I tried changing

DATAORG some

> time ago, but it caused all kinds of problems so I put it back.

I'm not using

> separate I&D. My application already uses ethernet in DHCP mode,

and I

> have 2 sockets declared.

>

> Here is memory map after I add RabbitWeb:

>

> //Segment Origin Size

> Root Code 00:0000 0060f7

> Root Data b1:9549 ffffd203

> Xmem Code f9:e226 04abd1

>

>

> Would moving to one of the R4000 modules get me more memory?

>

> Steve

>

--- In r..., Steve Trigero
wrote:
>
> I'll give the separate I&D a try next week. Last time I tried it
my
> application would run right so I quit. Does it matter that I have
no
> code in root memory. At least code that I've specifically put
there.
> Isn't "#memmap xmem" supposed to put all code into xmem space
> unless the code has been specifically declared to be in root?
> I've seen posts that state that switch statements use root code
space
> even if the procedure they are in are in xmem.

In 8.61, switch statements stay entirely within XMEM and use a jump
table. This table ljmps directly to each case without using a root
redirector. I think earlier versions may have put a table in root
or else redirectors in root; it seems like I remember reading about
this change in upgrade notes, but my memory has been inaccurate
before. As far as root memory on an if statement, whenever a 4K
boundary is crossed in XMEM, all jump instructions across that 4K
boundary are replaced with a jump into root code, and the root code
redirects the jump with a ljmp. A switch table in a large function
goes directly to each case without any redirectors in root code. In
separate I&D, these jump redirectors don't hurt you. It isn't just
the "if" statement; root redirectors are necessary to support the
xmem code.

In separate I&D, I wouldn't use #memmap xmem, because the root code
is 52K whether you use it or not. Use #memmap anymem xxxxx. Look
at the information window and change the number down if there is too
much wasted root code; move it up if you get a compiler error about
no root code left.
But when I convert
> a switch statement to an if...else if... statement my root code
usage
> goes up, not down, and my total code amount tends to increase. I
> don't see any benefit from not using switch. Have I misunderstood
> something?
> Do you know how much root code I have to reclaim in order to
> get RabbitWeb to fit?

One beef I have with DC is their libraries use too much root code,
and this forces separate I&D. I don't know if the RabbitWeb fits
into this category. I bought a display for a BL2100 and the
libraries for it forced me into separate I&D kicking and screaming.
I am just getting back into the Rabbit, but have not bought a
RabbitWeb interface, so I can't be of help there.

Don't forget that with separate I&D, you still have a DATAORG to
worry about. It has a different meaning now. Root constants
(string literals and constant "initialized" structures) are stored
below DATAORG. Above DATAORG, you have root variables. IRQ's are a
little trickier with separate I&D; it's been so long since I have
used DC, I forgot the IRQ issues.
>
> Its good to know it can be done, cause I'm supposed to add SNMP
> too. Sheesh!
>
> Steve
>
> ----- Original Message ----
> From: Dave August
> To: r...
> Sent: Saturday, February 10, 2007 9:08:18 AM
> Subject: [rabbit-semi] Re: Getting Root code space
>
>
>
> Steve
>
> First thing to do is use Split I&D , that get's all your root code
>
> out of root memory... Second thing to do is fiddle with Data Org,
>
> and yes it's tricky but you can usually move it 0x1000 and get 4K
>
> more dta space... third thing to do is move anything you can to
>
> XMEM and yes I know that's a PITA..
>
> I worked on a pretty large app that was full boat TCP/IP (SNMP and
>
> all) and had RabbibWeb in it so I know it can be done...
>
> And No a R4000 aint gonna do squat for getting you more code
space...
>
> --.- Dave
>
> --- In rabbit-semi@ yahoogroups. com, Steve Trigero
wrote:
>
> > > I'm trying to add RabbitWeb to my RCM3000 application and I'm
>
> getting
>
> > the "Out of Root Code Space" error.
>
> > > Here is the memory map of my application before adding RabbitWeb:
>
> > > //Segment Origin Size
>
> > Root Code 00:0000 0057f7
>
> > Root Data b1:cbff 0028e7
>
> > Xmem Code 32:e000 006c9e
>
> > > I suspect that my application is too large to add RabbitWeb to,
>
> but I don't
>
> > know how much root code space I need for RabbitWeb, nor how much
>
> root
>
> > code space I have left?
>
> > > I've already done the "#memmap xmem" thing, all string literals
>
> are in xmem,
>
> > I don't use printf, and debug is turned off. I tried changing
>
> DATAORG some
>
> > time ago, but it caused all kinds of problems so I put it back.
>
> I'm not using
>
> > separate I&D. My application already uses ethernet in DHCP mode,
>
> and I
>
> > have 2 sockets declared.
>
> > > Here is memory map after I add RabbitWeb:
>
> > > //Segment Origin Size
>
> > Root Code 00:0000 0060f7
>
> > Root Data b1:9549 ffffd203
>
> > Xmem Code f9:e226 04abd1
>
> > > > Would moving to one of the R4000 modules get me more memory?
>
> > > Steve
>
> >
>
>
>
>
>
Hi Steve,

It looks like you are getting plenty of help regarding the use of
#memmap xmem and freeing up code space on the Rabbit 3000, but I
wanted to point out that moving to a 4000-based core module will
likely free up some code space for you. Currently, the RCM4xxx core
modules have the same basic memory sizes as their 3000-based
counterparts, but the new instructions in the 4000 (which are
utilized by Dynamic C) can result in some code size savings.

Specifically, code for long data types has been improved
significantly. For example, loading a long into BC:DE on the Rabbit
3000 indirectly through HL requires the following sequence:

ld e, (hl)
inc hl
ld d, (hl)
inc hl
ld c, (hl)
inc hl
ld b, (hl)
inc hl
(7 bytes total)

On the 4000, the sequence is reduced to a single instruction:

ld bcde, (hl)
(2 bytes total)

Even if you optimize for size on the 3000, you still end up with a
function call to load the long into BC:DE, which is 3 bytes.

Even if you do not use a lot of long data types in your application
directly, anything having to do with xmem uses longs for address
calculations, so you will notice the benefit.

In addition to the improved handling of longs, there are also a
number of other improved instruction sequences that all contribute to
better code size. Adding 2 longs is now accomplished with a single
instruction, there are improved instructions for handling conditional
jumps, and some register exchanges that used to use the stack now are
done with a single instruction.

Another thing you can use is the "far" storage type in Dynamic C 10
(Rabbit 4000 only). Far data allows you to access xmem data directly,
allowing you to remove all xmem2root and root2xmem calls. This can be
used to free up root data space (i.e. put buffers directly in xmem).
The code generated for far data is also smaller and more efficient
than using the xmem2root-type functions.

Anyway, I hope this helps.

Regards,
Tim

--- In r..., Steve Trigero
wrote:
>
> I'm trying to add RabbitWeb to my RCM3000 application and I'm
getting
> the "Out of Root Code Space" error.
>
> Here is the memory map of my application before adding RabbitWeb:
>
> //Segment Origin Size
> Root Code 00:0000 0057f7
> Root Data b1:cbff 0028e7
> Xmem Code 32:e000 006c9e
>
> I suspect that my application is too large to add RabbitWeb to, but
I don't
> know how much root code space I need for RabbitWeb, nor how much
root
> code space I have left?
>
> I've already done the "#memmap xmem" thing, all string literals are
in xmem,
> I don't use printf, and debug is turned off. I tried changing
DATAORG some
> time ago, but it caused all kinds of problems so I put it back. I'm
not using
> separate I&D. My application already uses ethernet in DHCP mode,
and I
> have 2 sockets declared.
>
> Here is memory map after I add RabbitWeb:
>
> //Segment Origin Size
> Root Code 00:0000 0060f7
> Root Data b1:9549 ffffd203
> Xmem Code f9:e226 04abd1
> Would moving to one of the R4000 modules get me more memory?
>
> Steve
>
Steve, I've been there myself. Besides all the other stuff for
memeory usage, the separate I&D seems to be a pretty good idea for
the RCM3000. It does change how the DATAORG works, so you'll likely
need to fiddle with it too. I wish there was a little more
discipline, but was able to fiddle around and take a pretty hefty
application and add tcp/ip and rabbitweb. DC can give you a nice
memory usage report when it builds, but is pretty unhelpful when it
can't.

I was a little disappointed with DC9.50 - programs got bigger and
necessary .lib's seem to be getting out of hand. I was also
disappointed with Rabbitweb once I got beyond the basic canned
demos. I did give it the old college try, but did not feel it the
best toold for the job at hand. I've since rebuilt the project in
9.10 (far easier) and have started to write my my job using
conventional C rather than the odd new language that rabbit web would
have me use. It is a little more work, but the results seem to be
better.

Jon
--- In r..., Steve Trigero
wrote:
>
> I'll give the separate I&D a try next week. Last time I tried it my
> application would run right so I quit. Does it matter that I have
no
> code in root memory. At least code that I've specifically put
there.
> Isn't "#memmap xmem" supposed to put all code into xmem space
> unless the code has been specifically declared to be in root?
> I've seen posts that state that switch statements use root code
space
> even if the procedure they are in are in xmem. But when I convert
> a switch statement to an if...else if... statement my root code
usage
> goes up, not down, and my total code amount tends to increase. I
> don't see any benefit from not using switch. Have I misunderstood
> something?
> Do you know how much root code I have to reclaim in order to
> get RabbitWeb to fit?
>
> Its good to know it can be done, cause I'm supposed to add SNMP
> too. Sheesh!
>
> Steve
>
> ----- Original Message ----
> From: Dave August
> To: r...
> Sent: Saturday, February 10, 2007 9:08:18 AM
> Subject: [rabbit-semi] Re: Getting Root code space
>
>
>
> Steve
>
> First thing to do is use Split I&D , that get's all your root code
>
> out of root memory... Second thing to do is fiddle with Data Org,
>
> and yes it's tricky but you can usually move it 0x1000 and get 4K
>
> more dta space... third thing to do is move anything you can to
>
> XMEM and yes I know that's a PITA..
>
> I worked on a pretty large app that was full boat TCP/IP (SNMP and
>
> all) and had RabbibWeb in it so I know it can be done...
>
> And No a R4000 aint gonna do squat for getting you more code
space...
>
> --.- Dave
>
> --- In rabbit-semi@ yahoogroups. com, Steve Trigero
wrote:
>
> > > I'm trying to add RabbitWeb to my RCM3000 application and I'm
>
> getting
>
> > the "Out of Root Code Space" error.
>
> > > Here is the memory map of my application before adding RabbitWeb:
>
> > > //Segment Origin Size
>
> > Root Code 00:0000 0057f7
>
> > Root Data b1:cbff 0028e7
>
> > Xmem Code 32:e000 006c9e
>
> > > I suspect that my application is too large to add RabbitWeb to,
>
> but I don't
>
> > know how much root code space I need for RabbitWeb, nor how much
>
> root
>
> > code space I have left?
>
> > > I've already done the "#memmap xmem" thing, all string literals
>
> are in xmem,
>
> > I don't use printf, and debug is turned off. I tried changing
>
> DATAORG some
>
> > time ago, but it caused all kinds of problems so I put it back.
>
> I'm not using
>
> > separate I&D. My application already uses ethernet in DHCP mode,
>
> and I
>
> > have 2 sockets declared.
>
> > > Here is memory map after I add RabbitWeb:
>
> > > //Segment Origin Size
>
> > Root Code 00:0000 0060f7
>
> > Root Data b1:9549 ffffd203
>
> > Xmem Code f9:e226 04abd1
>
> > > > Would moving to one of the R4000 modules get me more memory?
>
> > > Steve
>
> >
>
>
>
>
>