This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to fix AVR progmem type attribute?


Hello,

could you tell me if there is any way (and, if yes, how?) to
make the "progmem" type attribute in the AVR port work again?
It works in 3.0, and is broken in 3.1 and mainline, most likely
after the 2001-09-21 table-driven attributes changes.  I'd like
to have a fix ready for inclusion in 3.1.1 if possible.

The attribute tells GCC to put constants (initialized variables)
in a special section that is allocated in the progam memory space
(the largest AVR chip so far has 128K of flash program memory,
and only 4K of data RAM, so it is a good idea to put large
constant tables in the flash memory, even if they must then be
accessed by using special macros or library functions).

Now, it works fine when used with variables.  The problem is,
it used to work with types too, now it doesn't.  The following:

  typedef int prog_int __attribute__((__progmem__));
  prog_int table[5] = { 1, 2, 3, 4, 5 };

(which now doesn't work) used to be equivalent to

  int table[5] __attribute__((__progmem__)) = { 1, 2, 3, 4, 5 };

(which still works fine).

Now, the "typedef" causes a warning: `progmem' attribute ignored
to be printed in config/avr/avr.c (avr_handle_progmem_attribute),
and table is placed in the data section (prog_int works like int).
But, disabling the "*no_add_attrs = true;" where the warning is
printed is not sufficient.  Something else is still wrong - the
attribute is still not inherited from the type to the variable.

Please help - I don't yet fully understand how these new
attributes work, and I'd like to get it right the first time :)

Thanks,
Marek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]