I have a file like this:
#include <avr/io.h>
#include <avr/pgmspace.h>
const PROGMEM char* str = "Hello UART!\r\n";
I'm trying to compile it with a Makefile, this is the final command:
avr-gcc -std=gnu99 -mmcu=atmega328p -DF_CPU=16000000UL -I. -Ilib/
-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
-Wall -Wno-main -Wno-strict-prototypes -Wno-comment -g2 -Wextra
-Wfatal-errors -Wno-unused-but-set-variable -ffunction-sections
-fdata-sections -Wl,--gc-sections -Wl,--relax -Os main.c lib/uart.c
--output main.elf
I am getting the following error:
main.c:9:21: error: variable 'str' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
const PROGMEM char* str = "Hello UART!\r\n";
^
compilation terminated due to -Wfatal-errors.
Makefile:71: recipe for target 'main.elf' failed
make: *** [main.elf] Error 1
What's wrong with my code?
I tried moving the PROGMEM keyword in various places of the declaration, without any change.