Pages: [1] 2   Go Down
Author Topic: error compiling on gcc-avr 4.6.1  (Read 14547 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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:
[_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 ~]$
« Last Edit: July 16, 2011, 04:11:05 pm by _artem_ » Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


"The old Europe"
Offline Offline
Edison Member
*
Karma: 1
Posts: 2005
Bootloaders suck!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
const uint16_t PROGMEM port_to_mode_PGM[]
Logged

• 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!

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for "Shift+" smiley

Code:
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:
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.
« Last Edit: July 16, 2011, 07:38:34 pm by _artem_ » Logged

Torino, Italy
Offline Offline
Sr. Member
****
Karma: 2
Posts: 309
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@_artem_ I'm on your same boat.. same problem here.
« Last Edit: July 18, 2011, 08:36:17 am by Fabio Varesano » Logged

Torino, Italy
Offline Offline
Sr. Member
****
Karma: 2
Posts: 309
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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:
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:
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


« Last Edit: July 19, 2011, 06:37:50 am by ygrek » Logged

0
Offline Offline
Shannon Member
****
Karma: 132
Posts: 10502
:(){:|:&};:
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Torino, Italy
Offline Offline
Sr. Member
****
Karma: 2
Posts: 309
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pisa - Italy
Offline Offline
Jr. Member
**
Karma: 0
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Offline Offline
Shannon Member
****
Karma: 132
Posts: 10502
:(){:|:&};:
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-grin)
Logged

sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Pisa - Italy
Offline Offline
Jr. Member
**
Karma: 0
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is only version :
Code:
$ 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
« Last Edit: August 04, 2011, 12:08:22 pm by edge » Logged

Pages: [1] 2   Go Up
Jump to: