I am working with AVR ATmega328p MCU and I would like to add constant string at address 0x7000 into flash memory. How can I do this with AVR-GCC?
My code contains this declaration:
// Firmware version
static volatile char version[16] __attribute__ ((section (".fwversion"))) = "0.01 DEV";
Now, when I run gcc with this flags:
avr-gcc -Wl,--section-start=.fwversion=0x7000 -mmcu=atmega328p -DF_CPU=8000000UL -Os -Wall -o main.elf main.c
The ELF file contains section .fwversion and after avr-objcopy, there are data at address 0x7000 in iHEX file.
But when I run gcc with -Wl,--gc-sections flag:
avr-g++ -Wl,--gc-sections -Wl,--section-start=.fwversion=0x7000 -mmcu=atmega328p -DF_CPU=8000000UL -Os -Wall -o main.elf main.c
the .fwversion section is removed.
I need to use -Wl,--gc-sections flag but I also need constant string stored in flash memory. What flags should I use to achieve this?
Is it possible to use something like this in GCC?
static volatile char version[16] __attribute__ ((section (0x7000))) = "0.01 DEV";
avr-objdumpdoesn't show the.fwversionsection inmain.elf? - Ignacio Vazquez-Abrams.fwversionis removed in ELF, thus the code is not in HEX file. - vasco