EmbeddedRelated.com
Forums

Serial Flash to eliminate Out of xmem code space, use a larger ROM/RAM

Started by aintnoprobs July 14, 2004
Hi experts,

The problem of running out of xmem is still haunting me.
However I have learnt heaps on DC's memory management based on the
previous thread 21888, subject "Out of variable data space & Out of
xmem code space, use a larger ROM/RAM"

I have used enabled I&D, use DC 8.3 on a RCM3700

I use the line #memmap xmem on my code

My compiled version of *.bin file produces the following *.map info.

//Segment Origin Size
Root Code 00:0000 005257
Root Data 00:cfff 007c22
Xmem Code 05:e000 061478

If I decrease some root code and force them to xmem, i run out of
xmem space. I have a few questions.

1. How much Xmemcode do I have available on such a board. ( I have
217,575 bytes of ximports)
2. Is it right that if I say I have about 52K of Root and data space
left on the 64K addressable memory when I&D is ON?
3. Why do I run out of XMEMCode when it says that I have about 1M of
physical memory space on R3000's? The RCM3700 has a 1Meg serial flash. I am thinking if I could write
these ximport files ( which are static ) to the serial flash I could
save heaps of XMEM. But I have no clue how to send these to the
serial flash.
My idea is.
a. Write a program - > This program gets the ximports, and writes
the contents of xmem to serial flash
b. Then write the main program that will reside permanently on the
module with no ximports (html and static files). The web server
should be able to read the flash and associate the web files to the
web server when requested. Wouldn't this enable to save the XMEM
space taken by the chunk of static files ( ximports )? 4. Has anyone successfully written files to the RCM3700 serial
flash? ( if so any direction would be appreciated; the sample given
on DC is not so useful at the moment :( )

Thank you.
Nil-


At 10:37 PM 7/14/2004, you wrote:
>Hi experts,
>
>The problem of running out of xmem is still haunting me.
>However I have learnt heaps on DC's memory management based on the
>previous thread 21888, subject "Out of variable data space & Out of
>xmem code space, use a larger ROM/RAM"
>
>I have used enabled I&D, use DC 8.3 on a RCM3700
>
>I use the line #memmap xmem on my code
>
>My compiled version of *.bin file produces the following *.map info.
>
>//Segment Origin Size
>Root Code 00:0000 005257
>Root Data 00:cfff 007c22
>Xmem Code 05:e000 061478
>

0x05000+0xe000 +0x61478 = 0x74478 or 476280 bytes

>I have a few questions.
>
>1. How much Xmemcode do I have available on such a board. ( I have
>217,575 bytes of ximports)

With 512k flash you get 512k-(root code)-(ID block)- (User Block size).

so 478280 bytes + 32k user block + 0x5257 root code = 530127 bytes total.
You have exceeded the 512k flash.

The above does nit take in to account that some data needed to be aligned
at 4k boundaries. Also, separate I&D fragments the memory. so some is wasted.

>2. Is it right that if I say I have about 52K of Root and data space
>left on the 64K addressable memory when I&D is ON?

In theory, but string literals get put in root data. For root data you
gain, 20k. You gain more root code, but that takes the same out of xmem flash.

>3. Why do I run out of XMEMCode when it says that I have about 1M of
>physical memory space on R3000's?

You only have 512k of flash. Yes, the R3k can address 1meg, but you can
only store a bin file less than 512k.

>The RCM3700 has a 1Meg serial flash. I am thinking if I could write
>these ximport files ( which are static ) to the serial flash I could
>save heaps of XMEM. But I have no clue how to send these to the
>serial flash.
>< clip >
>4. Has anyone successfully written files to the RCM3700 serial
>flash? ( if so any direction would be appreciated; the sample given
>on DC is not so useful at the moment :( )

The sample works fine. It reads and writes to the flash. Just take the code
and use it.

I'ld write a program that takes a bunch of files, builds a list like:

struct {
char name[NAME_MAX];
unsigned long size;
unsigned long offset; // offset to the data fron start
} file_list;

Create a file with the above list followed by the files. Then add code to
download an write that to the serial flash.

If you have enough xmem RAM when running you could xalloc enough memory and
copy the serial flash to RAM. Then just build the http table to point to
the data.

<Scott


--- In rabbit-semi@rabb..., Scott Henion <shenion@s...> wrote:
> At 10:37 PM 7/14/2004, you wrote:
> >Hi experts,
> >
> >The problem of running out of xmem is still haunting me.
> >However I have learnt heaps on DC's memory management based on the
> >previous thread 21888, subject "Out of variable data space & Out of
> >xmem code space, use a larger ROM/RAM"
> >
> >I have used enabled I&D, use DC 8.3 on a RCM3700
> >
> >I use the line #memmap xmem on my code
> >
> >My compiled version of *.bin file produces the following *.map info.
> >
> >//Segment Origin Size
> >Root Code 00:0000 005257
> >Root Data 00:cfff 007c22
> >Xmem Code 05:e000 061478
> >
>
> 0x05000+0xe000 +0x61478 = 0x74478 or 476280 bytes

Why do you add the Xmem Code segment starting address to the xmem code
size to get the xmem code size? Why isn't the xmem code size 398456 bytes.

Steve


At 11:23 AM 7/15/2004, you wrote:
>--- In rabbit-semi@rabb..., Scott Henion <shenion@s...> wrote:
> > At 10:37 PM 7/14/2004, you wrote:
> > >Hi experts,
> > >
> > >The problem of running out of xmem is still haunting me.
> > >However I have learnt heaps on DC's memory management based on the
> > >previous thread 21888, subject "Out of variable data space & Out of
> > >xmem code space, use a larger ROM/RAM"
> > >
> > >I have used enabled I&D, use DC 8.3 on a RCM3700
> > >
> > >I use the line #memmap xmem on my code
> > >
> > >My compiled version of *.bin file produces the following *.map info.
> > >
> > >//Segment Origin Size
> > >Root Code 00:0000 005257
> > >Root Data 00:cfff 007c22
> > >Xmem Code 05:e000 061478
> > >
> >
> > 0x05000+0xe000 +0x61478 = 0x74478 or 476280 bytes
>
>Why do you add the Xmem Code segment starting address to the xmem code
>size to get the xmem code size? Why isn't the xmem code size 398456 bytes.
>
>Steve

I am calculating the size of the code stored in flash, not xmem code size.

That is where it starts in flash. Yes the size is 398456, but it starts
at 0x13000 in the Flash Rom. Note: this due to separate I&D, normally it is:

Xmem Code f8:e000 0143e6

Here: xmem code starts at 0x06000. Separate I&D gains some root data space
at the expense of xmem code space.



> I'ld write a program that takes a bunch of files, builds a list
like:
>
> struct {
> char name[NAME_MAX];
> unsigned long size;
> unsigned long offset; // offset to the data fron start
> } file_list;
>
> Create a file with the above list followed by the files. Then add
code to
> download an write that to the serial flash.
>
> If you have enough xmem RAM when running you could xalloc enough
memory and
> copy the serial flash to RAM. Then just build the http table to
point to
> the data.
>
> <Scott>

Hi Scott,
How do I find out how much xmem RAM is available within a program?
Is there a function that prints it out?. Is there a way to
calculate it via the *.map file?.
Well I intend to place this whole 220K of static files on xmem RAM.

Another question raised is, If I am to provide a solution for
firmware upgrades, I would have to provide them with two binary
files.
1. First file that writes to serial flash.
2. Actual Program.
Does the above statement sound right to you? PS: I am using your
Ethernet DLM for software upgrades. :)
Regards
Nil-


At 07:30 PM 7/15/2004, you wrote:

>
>
> > If you have enough xmem RAM when running you could xalloc enough
>memory and
> > copy the serial flash to RAM. Then just build the http table to
>point to
> > the data.
> >
> > <Scott>
>
>Hi Scott,
>How do I find out how much xmem RAM is available within a program?

unsigned long xavail(NULL);

The above returns the free xmem RAM.

>Is there a function that prints it out?. Is there a way to
>calculate it via the *.map file?.

printf("Free xmem RAM %ld\n",xavail(NULL));

You can't easily tell be the map file as some RAM is hidden in the bios.

>Well I intend to place this whole 220K of static files on xmem RAM.
>
>Another question raised is, If I am to provide a solution for
>firmware upgrades, I would have to provide them with two binary
>files.
>1. First file that writes to serial flash.
>2. Actual Program.
>Does the above statement sound right to you? PS: I am using your
>Ethernet DLM for software upgrades. :)

You will need to find a way to get the files to the serial flash. Setting
up an FTP is an option. Look at the getfile.c sample in the http samples.

There might be a way to do it via the web interface. There is an upload
sample in the samples directory, but it uses the sflash fat system. You
might be able to figure out the POST syntax and write a cgi handler.

Maybe someone else here has a good example of uploading files via a browser.

<scott