[En-Nut-Discussion] How to determin size of RAM

uprinz2 at netscape.net uprinz2 at netscape.net
Mon Aug 23 14:59:15 CEST 2010


Thanks!


Was to easy to find out... :)


With that one we could initialize a CPU when neither NUTMEM_START nor NUTMEM_SIZE is set. Great, will add that to the STM32 port tonight.
NUTMEMxxx must still be available if there is external memory connected to the system and the user lieks to put heap there.
It is also usefull if the user needs some RAM for his own purpose.


Best regards
Ulrich




-----Original Message-----
From: Ole Reinhardt <ole.reinhardt at embedded-it.de>
To: Ethernut User Chat (English) <en-nut-discussion at egnite.de>
Sent: Mon, Aug 23, 2010 11:20 am
Subject: Re: [En-Nut-Discussion] How to determin size of RAM


Hi Ulrich,

Sorry for doing a nearly full quote.. but I think this is needed to
understand the calculations.

> /*!
> * \brief Last memory address.
> */
> #define NUTMEM_END (uptr_t)(NUTMEM_START + NUTMEM_SIZE - 1U)
> extern void *__heap_start;
> 
> #define HEAP_START  &__heap_start
> #define HEAP_SIZE  ((uptr_t) (NUTMEM_END - 256 - (uptr_t) (&__heap_start)))
> 
> To do it more automatically I have the following in my linker file:
> 
> MEMORY
> {
>      FLASH0 (rx) : ORIGIN = 0x00000000, LENGTH = 256K
>      SRAM0 (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
> }
> ....
>      .bss :
>      {
>    PROVIDE (_sbss = .);
>    *(.bss)
>    *(COMMON)
>    . = ALIGN(4);
>    PROVIDE (_ebss = .);
>    . += 0x400;
>    PROVIDE (__exp_stack = .);
>    . += 0x400;
>    PROVIDE (_estack = .);
>    PROVIDE (__heap_start = .);
>      } > SRAM0
> 
> So adding "extern void *__heap_start;" to nutinit.c is the first part of 
> the action. But how to figure out the size between this and the end of 
> the RAM? Is there such a thing like a variable filler to declare 
> __heap_end or something to calculate something like 
> origin+size-__heap_start?

What's about:

__ram_start__           = ORIGIN(SRAM0);
__ram_size__            = LENGTH(SRAM0);
__ram_end__             = __ram_start__ + __ram_size__;

__heap_size__           = __ram_end__ - __heap_start;


Regards,

Ole Reinhardt

-- 

Thermotemp GmbH, Embedded-IT

Embedded Hard-/ Software and Open Source Development, 
Integration and Consulting

http://www.embedded-it.de

Geschäftsstelle Siegen - Steinstraße 67 - D-57072 Siegen - 
tel +49 (0)271 5513597, +49 (0)271-73681 - fax +49 (0)271 736 97

Hauptsitz - Hademarscher Weg 7 - 13503 Berlin
Tel +49 (0)30 4315205 - Fax +49 (0)30 43665002
Geschäftsführer: Jörg Friedrichs, Ole Reinhardt
Handelsregister Berlin Charlottenburg HRB 45978 UstID DE 156329280 

_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

 



More information about the En-Nut-Discussion mailing list