[En-Nut-Discussion] Heap and external RAM

Marc Giger gigerstyle at gmx.ch
Fri Sep 8 23:08:06 CEST 2006


Hi list

Is the following comment still true in 4.0.3 ?

/* Then add the remaining RAM to heap.
 *
 * 20.Aug.2004 haraldkipp: This had been messed up somehow. It'snice to
have
 * one continuous heap area, but we lost the ability to have systems
with
 * a gap between internal and external RAM.
 */


My configuration:

PLATFORM = "ETHERNUT1"
AVR_GCC = ""
MCU_ATMEGA128 = ""
LCD_4x20 = ""
LCD_4x20 = ""
NUTMEM_START = "0x100"
NUTMEM_RESERVED = "64"
NUTXMEM_SIZE = "32767"
NUTXMEM_START = "0x8000"
NUT_CPU_FREQ = "16000000"

As you can see from the configuration the external memory starts at
0x8000.
 If I print out NutHeapAvailable(), I get 61445.
So it seems the comment is true.

I tried to modify (quick & dirty) the heap initialization to the
following:

//add internal memory to heap
if ((u_short)NUTMEM_SIZE - 1 - (u_short) (&__heap_start) > 384) {
 NutHeapAdd(&__heap_start, (u_short) NUTMEM_SIZE - 1-(u_short)(&__heap_start)); 
}
//add external RAM to heap
u_short mst = NUTXMEM_START;
if ((u_short)NUTMEM_END - (u_short) (NUTXMEM_START) > 384) {
 NutHeapAdd(&mst, (u_short) NUTMEM_END - 256 -(u_short)(NUTXMEM_START));
}

I'm not sure what 384 (NUT_THREAD_IDLESTACK ?) and 256 stands for, so I
defined the same conditions. Now, if I print out NutHeapAvailable I get
257 ?!
What am I doing wrong?

Another question:
With this configuration where is the stack located? At the end
of external RAM?

Thanks & Greetings

Marc



More information about the En-Nut-Discussion mailing list