ok i use free ram :D
thz
--- In rabbit-semi@rabb..., "shdesigns2003" <nospam@s...>
wrote: > --- In rabbit-semi@rabb..., "racar73"
<racar@i...> wrote:
> >
>
> > > Why do you need to know the amount of free flash space???
> >
> >
> > I need a function calculate space free in ram and flash( a similar > > malloc/free function) for use in linked list
for dynamic memory.
> >
>
> Still don't understand why you need the amount of free flash space.
> Free RAM is useable, Free flash is of no use.
>
> malloc/free work on a RAM heap. This is a separate memory space than
> code. Most OS's and embedded systems have no way of telling how
much
> code (read only) space is free.
>
> If you were to find the amount of free flash space, what would you
> possibly do with it? Yes, you could write to flash (dangerous), but it > would be much better to use a flash filesystem for
that, especially
> because it is pre-allocated at compile time.
>
> <Scott>
Reply by shdesigns2003●September 9, 20032003-09-09
--- In rabbit-semi@rabb..., "racar73" <racar@i...> wrote: >
> > Why do you need to know the amount of free
flash space???
> I need a function calculate space free in ram and flash( a similar
> malloc/free function) for use in linked list for dynamic memory.
>
Still don't understand why you need the amount of free flash space.
Free RAM is useable, Free flash is of no use.
malloc/free work on a RAM heap. This is a separate memory space than
code. Most OS's and embedded systems have no way of telling how much
code (read only) space is free.
If you were to find the amount of free flash space, what would you
possibly do with it? Yes, you could write to flash (dangerous), but it
would be much better to use a flash filesystem for that, especially
because it is pre-allocated at compile time.
<Scott
Reply by racar73●September 9, 20032003-09-09
--- In rabbit-semi@rabb..., "Rudi" <yahoo@d...> wrote: > Maybe I misunderstand your question but:
>
> The result of the xavail() function is the amount of available RAM
> space (in bytes). Just check the doc:
> xavail(): Returns the maximum length of memory that may be
> successfully obtained by an immediate call to xalloc(), and
> optionally allocates that amount.
> The parameter passed is: Pointer to a long word in root data memory
> to store the address of the block. If this pointer is NULL, then the > block is not allocated. Otherwise, the block is
allocated as if by a > call to xalloc().
>
> Note: this does NOT return the amount of free Flash space. No way to > check that, i think ...
>
> So for your demo program:
> - the first xavail() call will report the amount of free space and
> does not allocate it (address = 0 and interpreted as a pointer).
> - your call to xalloc() will allocate ALL available memory and
> return the address of the allocated data area.
> - your next call to xavail() will again report the amount of free
> space which should be 0 now. You just allocated all available space
> with xalloc().
>
> The results you printf are not reliable. You should use %lx to print > a long not %x. Change that, and you will get
normal results.
>
> Why do you need to know the amount of free flash space???
I need a function calculate space free in ram and flash( a similar
malloc/free function) for use in linked list for dynamic memory.
> Regards,
> Rudi
> www.x-graph.be the next generation Rabbit single board computer with > color lcd and touchscreen
>
> --- In rabbit-semi@rabb..., "racar73" <racar@i...>
wrote:
> >
> > >
> > > PS. Could someone with translating software re-post this?
> > >
> >
> > main ()
> > {
> > int int_dimension;
> > long ind_alloc;
> > long dimension;
> > long address=0x0000;
> > long address_1=0x30000;
> >
> > dimensione = xavail(address);
> > printf("\r\n available space RAM %x",dimension);
> > ind_alloc =xalloc(dimensione);
> > printf("\r\n allocate address %lx",ind_alloc);
> > dimensione = xavail(address_1);
> > int_dimension=(int)dimension;
> > printf("\r\n available space RAM %x",dimension);
> >
> > }
> >
> >
> > if change address and address_1 to NULL the resul is not change!!!! > >
> > I need a function calculate space free in ram and flash, a similar > > malloc/free function.
> > thz
> > Gianluca
Reply by Rudi●September 8, 20032003-09-08
Maybe I misunderstand your question but:
The result of the xavail() function is the amount of available RAM
space (in bytes). Just check the doc:
xavail(): Returns the maximum length of memory that may be
successfully obtained by an immediate call to xalloc(), and
optionally allocates that amount.
The parameter passed is: Pointer to a long word in root data memory
to store the address of the block. If this pointer is NULL, then the
block is not allocated. Otherwise, the block is allocated as if by a
call to xalloc().
Note: this does NOT return the amount of free Flash space. No way to
check that, i think ...
So for your demo program:
- the first xavail() call will report the amount of free space and
does not allocate it (address = 0 and interpreted as a pointer).
- your call to xalloc() will allocate ALL available memory and
return the address of the allocated data area.
- your next call to xavail() will again report the amount of free
space which should be 0 now. You just allocated all available space
with xalloc().
The results you printf are not reliable. You should use %lx to print
a long not %x. Change that, and you will get normal results.
Why do you need to know the amount of free flash space???
Regards,
Rudi
www.x-graph.be the next generation Rabbit single board computer with
color lcd and touchscreen
--- In rabbit-semi@rabb..., "racar73" <racar@i...> wrote: >
> >
> > PS. Could someone with translating software re-post this?
> >
>
> main ()
> {
> int int_dimension;
> long ind_alloc;
> long dimension;
> long address=0x0000;
> long address_1=0x30000;
>
> dimensione = xavail(address);
> printf("\r\n available space RAM %x",dimension);
> ind_alloc =xalloc(dimensione);
> printf("\r\n allocate address %lx",ind_alloc);
> dimensione = xavail(address_1);
> int_dimension=(int)dimension;
> printf("\r\n available space RAM %x",dimension);
>
> }
> if change address and address_1 to NULL the resul is not change!!!!
>
> I need a function calculate space free in ram and flash, a similar
> malloc/free function.
> thz
> Gianluca
Reply by racar73●September 8, 20032003-09-08
>
> PS. Could someone with translating software re-post this?
>
main ()
{
int int_dimension;
long ind_alloc;
long dimension;
long address=0x0000;
long address_1=0x30000;
dimensione = xavail(address);
printf("\r\n available space RAM %x",dimension);
ind_alloc =xalloc(dimensione);
printf("\r\n allocate address %lx",ind_alloc);
dimensione = xavail(address_1);
int_dimension=(int)dimension;
printf("\r\n available space RAM %x",dimension);
}
if change address and address_1 to NULL the resul is not change!!!!
I need a function calculate space free in ram and flash, a similar
malloc/free function.
thz
Gianluca
Reply by Robert Richter●September 8, 20032003-09-08
---------- > From: racar73 <racar@raca...>
> To: rabbit-semi@rabb...
> Subject: [rabbit-semi] xalloc & xavail
> Date: Monday, September 08, 2003 9:13 AM
>
>hi, i compile a sample programm in rabbit3000 128Kram 256flash:
>dimensione = xavail(indirizzo_1); You either need a NULL pointer here or the address of a RAM variable.
Are warnings turned off? You should have got a warning about long and
void * being incompatible. >int_dimensione=(int)dimensione;
>printf("\r\n spazio disponibile nella flash %x",dimensione); Why the reference to flash? Sorry, I don't understand the rest of
the
sentence. xalloc & xavail only operate on RAM.
}
>have a result:
>spazio disponibile nella flash
>2e00 You have a lot more than 0x2e00 bytes of RAM available >indirizzo allocazione
>100
>spazio disponibile nella flash
>0 You got a zero because it was unable to allocate any memory. Your
previous
allocation used every byte of xmem RAM available. I don't understand the
references to flash.