Go Down

Topic: error compiling on gcc-avr 4.6.1 (Read 15 times) previous topic - next topic

_artem_

Jul 16, 2011, 11:08 pm Last Edit: Jul 16, 2011, 11:11 pm by _artem_ Reason: 1
I upgraded gcc-avr (avr-gcc) from 4.6.0 to 4.6.1 and now I get this error when I click "Compile" button ("play" button) even on empty sketch!

Code: [Select]
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/Tone.cpp:37:0:
/usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h:66:48: error: variable 'port_to_mode_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
/usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h:67:49: error: variable 'port_to_input_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
/usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h:68:50: error: variable 'port_to_output_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
/usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h:70:54: error: variable 'digital_pin_to_port_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
/usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h:72:58: error: variable 'digital_pin_to_bit_mask_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
/usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h:73:55: error: variable 'digital_pin_to_timer_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
/usr/share/arduino/hardware/arduino/cores/arduino/Tone.cpp:108:45: error: variable 'tone_pin_to_timer_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'


on gcc-avr 4.6.0 clicking the same button gives "... done" but 4.6.1 gives the above error.
I posted the bug to gcc-avr but they say the bug is in arduino ide and not in gcc...
could you atleast tell me the command line to compile a arduino uno code from the console (terminal, cmd). So I can post the exact command line that gives that error in gcc bugzilla.
I tried to compile a C code with `avr-gcc 1.c -o 1` and it compiled without any errors. But compiling in IDE gives that error. So I don't know how to identify the bug'er.

p.s. my board is Arduino Uno (ATmega328P-PU), OS is ArchLinux x86_64, gcc & gcc-avr are 4.6.1
Code: [Select]

[_artem_@linux-void ~]$ avr-gcc -v
Using built-in specs.
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/4.6.1/lto-wrapper
Target: avr
Configured with: ../configure --disable-libssp --disable-nls --enable-languages=c,c++ --infodir=/usr/share/info --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --prefix=/usr --target=avr --with-gnu-as --with-gnu-ld --with-as=/usr/bin/avr-as --with-ld=/usr/bin/avr-ld
Thread model: single
gcc version 4.6.1 (GCC)
[_artem_@linux-void ~]$

stimmer

Press Shift while clicking compile to see the command lines generated to compile your sketch.

The error looks like it is to do with const correctness - maybe the new GCC has changed how it deals with progmem data. I'd say the gcc-avr people are probably right, the bug might be with the Arduino headers not being properly const correct.

madworm

What version of the arduino ide do you have? I see it is installed system wide. Maybe you use outdated code.

V 0022 has this:

pins_arduino.c

Code: [Select]
const uint16_t PROGMEM port_to_mode_PGM[]
• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!

_artem_

#3
Jul 17, 2011, 02:33 am Last Edit: Jul 17, 2011, 02:38 am by _artem_ Reason: 1
thanks for "Shift+" :)

Code: [Select]

avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -I/usr/share/arduino/hardware/arduino/cores/arduino /usr/share/arduino/hardware/arduino/cores/arduino/Tone.cpp -o/tmp/build941971144755971461.tmp/Tone.cpp.o


so this code gives such an error...

Error is produced by this lines from the pins_arduino.h

Code: [Select]
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 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[];


I'm using 0022, installed in archlinux from aur. Just downloaded the latest package from arduino.cc, extracted, changed path in the command line to not to use my system-wide headers. It gives the same error.

Fabio Varesano

#4
Jul 18, 2011, 03:31 pm Last Edit: Jul 18, 2011, 03:36 pm by Fabio Varesano Reason: 1
@_artem_ I'm on your same boat.. same problem here.

Fabio Varesano

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.


_artem_

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

stimmer

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)

tanders12

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.

ygrek

#9
Jul 19, 2011, 09:23 am Last Edit: Jul 19, 2011, 01:37 pm by ygrek Reason: 1
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:
Code: [Select]

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
Code: [Select]
cd / && sudo patch -p0 < /tmp/arduino.patch

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

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



lesto


A simple pacman -U /var/cache/pacman/pkg/gcc-avr-4.6.1-1-x86_64.pkg.tar.xz fixed the issue.

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
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Fabio Varesano

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 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49764

edge

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?

lesto

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)
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

edge

#14
Aug 04, 2011, 07:06 pm Last Edit: Aug 04, 2011, 07:08 pm by edge Reason: 1
This is only version :
Code: [Select]
$ 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

Go Up