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

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

RE: [avr-gcc-list] define const char


From: Stu Bell
Subject: RE: [avr-gcc-list] define const char
Date: Mon, 15 Dec 2008 14:05:40 -0700

You can use the method I used to place a program length into flash.
 
Step 1: define your program version to reside in a special section, somewhat similar to the way PROGMEM works:
 
    #define PROG_VER_MAJOR 1UL
    #define PROG_VER_MINOR 1UL
    #define PROG_VER_BUILD 100UL
 
    const uint32_t ProgramVersion __attribute__ ((section (".progver")))
                   = (PROG_VER_MAJOR << 24UL) | (PROG_VER_MAJOR << 16UL) | PROG_VER_BUILD;
 
Step 2.: Define the section in a linker script, modified from whatever script your current processor is using.  I happen to use the ATmega2560, so I modified the avr6.x script.:
 
  .rela.plt      : { *(.rela.plt)  }
  /* Internal text space or external memory.  */
  .text :
  {
    *(.vectors)
    KEEP(*(.vectors))
    *(.progver)
    /* KEEP(*(.progver)) - don't need to keep if it isn't defined */
    /* For data that needs to reside in the lower 64k of progmem.  */
    *(.progmem.gcc*)
    *(.progmem*)
Step 3: Reading the version info: Since we've defined the location to be at the bottom of memory, the standard pgm_read_* routines should work fine.
 
I wrote all of this down in a thread somewhere on AvrFreaks.net, but I cannot find it at the moment.
 
Hope this helps!

Best regards,

Stu Bell
DataPlay (DPHI, Inc.)

 


From: address@hidden [mailto:address@hidden On Behalf Of Schwichtenberg, Knut
Sent: Monday, December 15, 2008 7:52 AM
To: Wynand Weyers; address@hidden
Subject: RE: [avr-gcc-list] define const char

Look to the avrlibc documentation and search for progmem. That's for only keeping the data in the flash. To find data always at the same location (address) you need to define a specific segment and update the linker script to address that segment. There have been several articles on this list as well as on the avrfreaks forum
 
Knut


From: address@hidden [mailto:address@hidden On Behalf Of Wynand Weyers
Sent: Monday, December 15, 2008 10:47 AM
To: address@hidden
Subject: [avr-gcc-list] define const char

How can I define a const char, to ensure that the data will always be stored in program memory at the same address?

 

I would like to acquire the application version number from the bootloader software.

 

Regards

 

Wynand Weyers

 

Logox

 

Mobile:  082 387 2496

Tel:       012 667 2028

Fax:      012 667 4655

 



__________ Information from ESET NOD32 Antivirus, version of virus signature database 3691 (20081214) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


This message was checked by MailScan for WorkgroupMail.
www.workgroupmail.com

reply via email to

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