[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] FAQ addition / Proof-read

From: daniel_laptop
Subject: Re: [avr-libc-dev] FAQ addition / Proof-read
Date: Tue, 26 Nov 2002 19:52:13 +1300

"E. Weddington" wrote:
On 25 Nov 2002 at 20:44, Joerg Wunsch wrote:

> As E. Weddington wrote:
> > How do you setup a project to use external RAM?
> Well, basically it's already in the FAQ. ;-)
> http://savannah.nongnu.org/download/avr-libc/doc/avr-libc-user-manual/
> FAQ.html#faq_startup

Duh. So it is.

So I see in the FAQ about having to write an assembly file, but
didn't I read somewhere on this list that you don't have to do that
method necessarily; you could write C code and put it into the init1
section? If so, could that alternative be written up as the standard
way of doing it and deprecate the assembly?

There is a reference there for that
"For more information on using sections, including how to use them from C code, see Memory_Sections. "

Form an earlier email

> Time to do some serious proof-reading...

> Ted Roth

In the .noinit description at

It is possible to tell the linker explicitly where to place the .noinit section by adding
-Wl,--section-start=.noinit=0x802000 to the avr-gcc command line at the linking stage.

It would be good idea to add a NOTE that doing this will also move __heap_start (heap)
to '.noinit start + size of noinit.'

quote from a linker script
  /* Global data not cleared after reset.  */
  .noinit  SIZEOF(.bss) + ADDR(.bss) :
     PROVIDE (__noinit_start = .) ;
     PROVIDE (__noinit_end = .) ;
     _end = . ;
     PROVIDE (__heap_start = .) ;
  }  > data

Att. is the .h file I use that enables external RAM and at runtime checks if _STDLIB_H_
defined (malloc) and if noinit section has been moved and sets __heap_start to __bss_end .
NOT THE BEST IDEA to check _STDLIB_H_ (library functions use malloc as well)
(If anyone is interested ;-)


/* Daniel Mooney
For .noinit section moved into external SRAM.
enable xram in init1
and if stdlib (malloc) included already,
in init5 check if .noinit moved and fix
mallox_heap_start back into internal SRAM.

#include <avr/io.h>
void init_xram (void) __attribute__ ((naked)) __attribute__ ((section 

init_xram (void)
  /* enable xram */

/* next section only done if "#include <stdlib.h>" already done (malloc) */
#ifdef _STDLIB_H_
/* stdlib.h has char *__malloc_heap_start */

/* ##### is __heap_start used for other things ??? ##### */
/* not at present but keep an eye on future changes */

/* this needs to be done after .init4 to stick */
void init_noinit_moved (void) __attribute__ ((naked)) __attribute__ ((section 

init_noinit_moved (void)
  extern char __bss_end;
  extern char __noinit_start;

/* if below is only when .noinit section position set (moved) e.g. in makefile
   LDFLAGS += -Wl,--section-start=.noinit=0x800260
   below moves __malloc_heap_start back to __bss_end
   (same as it would be with zero .noinit size and .noinit not moved)
  if(&__bss_end != &__noinit_start) /* noinit has been moved */ 
      __malloc_heap_start = &__bss_end; /* set malloc_heap_start to bss_end */


reply via email to

[Prev in Thread] Current Thread [Next in Thread]