Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » AVR-GCC
  • » [avr-gcc-list] progmem and section attributes [RSS Feed]

#1 June 10, 2010 11:26:09

Lars N.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr-gcc-list] progmem and section attributes


Hi!

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?

-- Lars.

_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Offline

#2 June 10, 2010 16:29:48

Stu B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr-gcc-list] progmem and section attributes


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.)

_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Offline

#3 June 17, 2010 11:55:21

Lars N.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr-gcc-list] progmem and section attributes


* Stu Bell <sb***@*ataplay.com> :
> 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?

ATmega 16 and 162, so no problems w.r.t flash size.

> #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

Ok, that's the way I did it, too.


-- Lars.

_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Offline

  • Root
  • » AVR-GCC
  • » [avr-gcc-list] progmem and section attributes [RSS Feed]

Board footer

Moderator control

Enjoy the 20th of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support