error compiling on gcc-avr 4.6.1

@artem I'm on your same boat.. same problem here.

I've temporarily fixed the problem by downgrading to gcc-avr 4.6.0-3. I found that I had the older version 4.6.0-3 in /var/cache/pacman/pkg ..
A simple pacman -U /var/cache/pacman/pkg/gcc-avr-4.6.1-1-x86_64.pkg.tar.xz fixed the issue.

yes on 4.6.0-3 code compiles just fine, but delay() doesn't work. So I'm still hoping that delay() function was fixed in 4.6.1 but I can't try it because either avr-g++ or ide is buggy

The delay() bug has been solved before, search for it. It was a problem with avr-binutils, not avr-gcc, so even if gcc 4.6.1 worked you would still get the bug. It is solved by patching the binutils sources with a Debian patchset before compiling (this is something the arch avr-binutils package maintainers should do)

I can confirm the same problem. Also running arch.

pacman -U /var/cache/pacman/pkg/gcc-avr-4.6.1-1-x86_64.pkg.tar.xz

works great thanks Fabio.

here ya go artem:

http://arduino.cc/forum/index.php/topic,49900.15.html

The reason I posted it for you rather than having you find it yourself is because when I had that problem I remember having a hard time wording the search correctly.

Hi, guys

I've managed to compile and run blink example for Arduino Uno on archlinux x86_64, gcc-avr 4.6.1

Here is patch:

diff -u /usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h ./pins_arduino.h
--- /usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h	2011-07-19 14:29:17.000000000 +0300
+++ ./pins_arduino.h	2011-07-19 09:47:42.732685122 +0300
@@ -63,14 +63,14 @@

 // On the ATmega1280, the addresses of some of the port registers are
 // greater than 255, so we can't store them in uint8_t's.
-extern const uint16_t PROGMEM port_to_mode_PGM[];
-extern const uint16_t PROGMEM port_to_input_PGM[];
-extern const uint16_t PROGMEM port_to_output_PGM[];
+extern const prog_uint16_t port_to_mode_PGM[];
+extern const prog_uint16_t port_to_input_PGM[];
+extern const prog_uint16_t port_to_output_PGM[];

-extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
-// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
-extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
-extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
+extern const prog_uint8_t digital_pin_to_port_PGM[];
+// extern const prog_uint8_t digital_pin_to_bit_PGM[];
+extern const prog_uint8_t digital_pin_to_bit_mask_PGM[];
+extern const prog_uint8_t digital_pin_to_timer_PGM[];

 // Get the bit location within the hardware port of the given virtual pin.
 // This comes from the pins_*.c file for the active board configuration.
diff -u /usr/share/arduino/hardware/arduino/cores/arduino/Tone.cpp ./Tone.cpp
--- /usr/share/arduino/hardware/arduino/cores/arduino/Tone.cpp	2011-07-19 14:29:17.000000000 +0300
+++ ./Tone.cpp	2011-07-19 14:28:34.798922373 +0300
@@ -90,7 +90,7 @@
 
 #define AVAILABLE_TONE_PINS 1
 
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
+const prog_uint8_t tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
 static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
 
 #elif defined(__AVR_ATmega8__)
@@ -105,7 +105,7 @@
 #define AVAILABLE_TONE_PINS 1

 // Leave timer 0 to last.
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
+const prog_uint16_t tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
 static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255 */ };

 #endif

Apply it with

cd / && sudo patch -p0 < /tmp/arduino.patch

As you see, I changed only types for constants. Got working ones from "avr/pgmspace.h", like:

typedef uint16_t PROGMEM prog_uint16_t;

So, it seems to me, that the problem lies in gcc-avr.

P.S.: delay() issue still exists with gcc-avr 4.6.1

This solution works only on arch linux and derivate. Corrected commands are:
32bit pacman -U /var/cache/pacman/pkg/gcc-avr-4.6.0-3-i686.pkg.tar.xz
64bit pacman -U /var/cache/pacman/pkg/gcc-avr-4.6.0-3-x86_64.pkg.tar.xz

you can also blacklist gcc-avr in /etc/pacman.conf

Thanks @ygrek .. your patch seems to be working without any side effects also on more complex Arduino sketches. I can now use the newer gcc-avr without problems.

A bug report against gcc-avr has been opened by artem at 49764 – [avr-g++] Rejects attribute progmem

Sorry i receive an error:
pacman -U /var/cache/pacman/pkg/gcc-avr-4.6.0-3-i686.pkg.tar.xz

error: '/var/cache/pacman/pkg/gcc-avr-4.6.0-3-i686.pkg.tar.xz': cannot open package file

Can you help me?

simply write "/var/cache/pacman/pkg/gcc-avr-4"
the hit 1 or 2 times TAB, it will show you all disponible file in the directory that begin with this name. pick up the most recent. If nothing apper, i think is because you have deleted them. If this is the case, look if someone is kind wnought to post you the package (I've deleted theb because of some problem with HD space :D)

This is only version :

$ cd /var/cache/pacman/pkg/gcc-avr-4.6.1-1-i686.pkg.tar.xz

My problem in not compile ,but use DELAY();
Can you help with this please?
Thanks a lot

For those of you who don't have the gcc-avr-4.6.0-3 package anymore, you still can download it here :

http://schlunix.org/archlinux/pool/community/gcc-avr-4.6.0-3-i686.pkg.tar.xz
or
http://schlunix.org/archlinux/pool/community/gcc-avr-4.6.0-3-x86_64.pkg.tar.xz

And thanks for your patch, ygrek. It seems to work fine :wink:

Just want to let you know that using the following command in fedora15 i was able to get the Arduino IDE to compile again.

sudo yum downgrade avr-gcc avr-gcc-c++

Hi,

had the same issue here with gcc-avr-4.6.1 on Arch Linux. But today I could update to gcc-avr-4.6.2-1; and that solved it.

I have same problem!

const char	num1[] PROGMEM = "09194986646", num2[] PROGMEM = "66737819";
char* num[]  PROGMEM = {(void *)num1, (void *)num2};

It works fine when compiling with WINAVR2010 but compiling

const char	num1[] PROGMEM = "09194986646", num2[] PROGMEM = "66737819";
PGM_P num[]  PROGMEM = {(void *)num1, (void *)num2};

with gcc version 4.6.2 (AVR_8_bit_GNU_Toolchain_3.4.1_798) the compiler returns this error:

monitoring.c:10:7: error: variable 'num' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

Have anybody solved this ptoblem?

Two years ago, and I have same problem:
Using older versions of Arduino IDE is OK, but latest betas 1.5.6 , 1.5.7 and 1.5.8 produces same error:

error: variable Text'Info' must be const in order to be put into read-only section by means of 'attribute((progmem))'

My program contains:
char TextInfo [] PROGMEM = "some text";

Changing to
const TextInfo [] PROGMEM = "some text";

causes another error:
error: 'TextInfo' does not name a type

Please, I am beginner and I do not uderstand all of C++ nuances, can you help me to solve this problem?

I'm also having the same problem. Could anyone please lend a hand?

I'm using Ubuntu 14.04 LTS and Arduino IDE 1.0.5

By using the Time library I get

/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:11:0:
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:41:22: error: variable ‘monthNames_P’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
PGM_P monthNames_P[] PROGMEM =

Do just what the error message says and declare 'monthNames_P' a constant.

PGM_P const monthNames_P[] PROGMEM =

I already did, but now I get different error messages:

/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp: In function ‘const char* monthStr(uint8_t)’:
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:63:35: error: new declaration ‘const char* monthStr(uint8_t)’
const char* monthStr(uint8_t month)
^
In file included from /home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:21:0:
/home/adapttech/sketchbook/libraries/Time/Time.h:127:7: error: ambiguates old declaration ‘char* monthStr(uint8_t)’
char* monthStr(uint8_t month);
^
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp: In function ‘const char* monthShortStr(uint8_t)’:
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:69:40: error: new declaration ‘const char* monthShortStr(uint8_t)’
const char* monthShortStr(uint8_t month)
^
In file included from /home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:21:0:
/home/adapttech/sketchbook/libraries/Time/Time.h:129:7: error: ambiguates old declaration ‘char* monthShortStr(uint8_t)’
char* monthShortStr(uint8_t month);
^
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp: In function ‘const char* dayStr(uint8_t)’:
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:77:31: error: new declaration ‘const char* dayStr(uint8_t)’
const char* dayStr(uint8_t day)
^
In file included from /home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:21:0:
/home/adapttech/sketchbook/libraries/Time/Time.h:128:7: error: ambiguates old declaration ‘char* dayStr(uint8_t)’
char* dayStr(uint8_t day);
^
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp: In function ‘const char* dayShortStr(uint8_t)’:
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:83:36: error: new declaration ‘const char* dayShortStr(uint8_t)’
const char* dayShortStr(uint8_t day)
^
In file included from /home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:21:0:
/home/adapttech/sketchbook/libraries/Time/Time.h:130:7: error: ambiguates old declaration ‘char* dayShortStr(uint8_t)’
char* dayShortStr(uint8_t day);

yout "Time" library is broken.

it is non official, so just delete it, it is here:

/home/adapttech/sketchbook/libraries/Time/

and look if you have a new version. You may fix it, the problem SEEMS that function declaration is const char* but function implementation use char*.