avr-gcc-list
[Top][All Lists]
Advanced

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

[avr-gcc-list] Large array in the FLASH size limitation


From: Alex Chernyshoff
Subject: [avr-gcc-list] Large array in the FLASH size limitation
Date: Tue, 15 Oct 2002 00:37:46 -0700 (PDT)

Hi!

My attempts to declare array of chars in the FLASH
memory
is failure, if size of array more then 0x07fff.
Probably, GCC use INT data type to calculate array
size...
I use "avrfreaks" windows build AVR-GCC 3.2 with the
avr-libc-20020630,
makefile is standart with "MCU = atmega103"

Is it a bug, or exist some way to avoid this size
limitation?

Here is simplest example of this.

#include <io.h>
#include <progmem.h>

prog_uchar dtable[0x00008001] = {1,2,3,4,5,6,7,8,9};
int main(void)
{ for(;;)
  {
  }
}

-------- begin --------

C:\avrgcc\Proj\test>make
avr-gcc -c -g -O2 -Wall -Wstrict-prototypes
-Wa,-ahlmns=test.lst -mmcu=atmega103 -I. test.c -o
test.o
test.c:4: error: size of array `dtable' is too large
test.c:4: warning: excess elements in scalar
initializer
test.c:4: warning: (near initialization for `dtable')
test.c:4: warning: excess elements in scalar
initializer
test.c:4: warning: (near initialization for `dtable')
test.c:4: warning: excess elements in scalar
initializer
test.c:4: warning: (near initialization for `dtable')
test.c:4: warning: excess elements in scalar
initializer
test.c:4: warning: (near initialization for `dtable')
test.c:4: warning: excess elements in scalar
initializer
test.c:4: warning: (near initialization for `dtable')
test.c:4: warning: excess elements in scalar
initializer
test.c:4: warning: (near initialization for `dtable')
test.c:4: warning: excess elements in scalar
initializer
test.c:4: warning: (near initialization for `dtable')
test.c:6: warning: excess elements in scalar
initializer
test.c:6: warning: (near initialization for `dtable')
test.c:4: error: storage size of `dtable' isn't known
C:\AVRGCC\BIN\MAKE.EXE: *** [test.o] Error 1
--------  end  --------


But next example is alright.

#include <io.h>
#include <progmem.h>

prog_uchar dtable[0x07fff] = {1,2,3,4,5,6,7,8,9};
int main(void)
{ for(;;)
  {
  }
}

-------- begin --------

C:\avrgcc\Proj\test>make
avr-objcopy -j .eeprom
--set-section-flags=.eeprom="alloc,load"
--change-section-lma .eeprom=0 -O ihex test.elf
test.eep
avr-size test.elf
   text    data     bss     dec     hex filename
  32942       0       0   32942    80ae test.elf
Errors: none
--------  end  --------

Moreover, if array is declared with empty braces with
the text file included with
equivalent binary length more then 32K, and within the
processor FLASH range,
the compiler is dropout with GPF.
Sorry for strange symbols grabbed(international
windows), but i hope, everything is clear without
comments.

Ïðîãðàììà CC1 âûçâàëà îøèáêó îáðàùåíèÿ ê ñòåêó 
â ìîäóëå CC1.EXE ïî àäðåñó 016f:0042614e.
Ðåãèñòðû:
EAX=0133e720 CS=016f EIP=0042614e EFLGS=00010216
EBX=0133e690 SS=0177 ESP=00781ffc EBP=00782028
ECX=00ab450c DS=0177 ESI=00000001 FS=3ee7
EDX=00000002 ES=0177 EDI=0196edc0 GS=0000
Áàéòû ïî àäðåñó CS:EIP:
57 56 53 8b 5d 08 83 fb 01 0f 86 e7 07 00 00 83 
Ñîäåðæèìîå ñòåêà:
00000000 00000000 00000000 00000000
00000000 0133e690 00000001 0196edc0
00000000 00000000 00000000 00782078
004266a9 0133e720 00000000 00000000 

Below is example of such program

#include <io.h>
#include <progmem.h>

prog_uchar dtable[] = {
#include "test.txt"
};

int main(void)
{       for(;;)
        {
        }
}

Thanks...


__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
avr-gcc-list at http://avr1.org



reply via email to

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