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

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

RE: [avr-gcc-list] progmem and section attributes


From: Stu Bell
Subject: RE: [avr-gcc-list] progmem and section attributes
Date: Thu, 10 Jun 2010 09:23:06 -0600

 
Lars Noschinski wrote:
> 
> I've got an array which I want to be stored at a specific 
> place in the flash memory. Currently, this variable is marked 
> with the progmem attribute, but this is not compatible with 
> using the section attribute.
> Does using the section attribute to place the variable 
> outside of the .data section imply the effects of the progmem 
> attribute?
> 

Before I asnwer your question, I have a couple of my own (and I'll
explain below why I need the answers):  What AVR processor is this?
Where do you plan on putting the table with respect to the rest of the
code?

Now to the answer.

The PROGMEM macro and associated routines all assume that the constants
are stored in the first 64 Kbytes of flash.  The section attribute
.progmem refers to a seciton in the linker script, which places the data
low in flash.

If you intend to place your array outside the 64 Kbyte limit, accessing
the array will be a little different.

Setting up a different section for your array is easy.  For example, I
set up strings for my bootloader by doing:

#define BOOTSTRING_SECTION   __attribute__ ((section (".bootstring")))

const char boot_Version   [] BOOTSTRING_SECTION = "1.1";
const char boot_Monitor   [] BOOTSTRING_SECTION = "DPHIMON ";

Then, in the LDFLAGS in my makefile:

LDFLAGS += -Wl,--section-start=.bootstring=0x3FA00

However, I know several things about my layout.  First, as an
ATmega2560, I have placed these strings high in flash, way beyond the
64K byte limit for the progmem routines to work.  That means that I need
to access them with Carlos Lamas' morepgmspace.h routines to access the
strings.  (Do a forum search on avrfreaks.net, or just a Google on the
name, to find the files.)

Also, I have made sure that the .bootstring section does not overlap any
other section.  You will not be able to place your array in the middle
of code.  The linker does not allow overlap of sections like that.

Hopefully this will give you enough clues to finish.  If not, I
recommend posting a request on the AVR Gcc forum of avrfreaks.net to get
more information.

Best regards, 

Stu Bell 
DataPlay (DPHI, Inc.) 



reply via email to

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