[Top][All Lists]

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

Re: [avr-gcc-list] Constant in external flash

From: daniel_laptop
Subject: Re: [avr-gcc-list] Constant in external flash
Date: Thu, 26 Sep 2002 14:34:09 +1200

Kang Tin LAI wrote:

> Hi,
> For saving program memory for more codes, I intend to put all constants,
> mainly the LCD character and graphic patterns, in a external flash rom.
> Instead of using pointer, I hope a direct access, example:
> const (may be some attribute here) float pi = 3.1416;
> p = pi * d;
> pi will not be linked into .data, pi will be accessed as external SRAM
> (of cause readonly). My prediction that is an extra segment, linker will
> put all these constants to this segment, then use objcopy to create a
> file for flash rom writer or download.
> Possible to do it? Or anyone implemented similar things before?
> Regards.
> --
> ---
> Kang Tin LAI <address@hidden>
> -----
> avr-gcc-list at http://avr1.org

Hello Kang

Have you looked at ".noinit section"
info in doc's memory sections

the only problem that i can see when moved into ext. sram is that it also
moves malloc position
att. is a file that i use to set the malloc back to internal sram.

also flash file has to be created manually.
(if you find a way of auto creating flash file, let me know)

Daniel Mooney.

/* 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]