Pages: [1]   Go Down
Author Topic: Pitfalls found with IDE-1.0.1 on Linux AMD64  (Read 1491 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just wanted to share my experience with new IDE-1.0.1 running on Gentoo AMD64 Linux.

If I use the built in toolset (avr-* version 4.3.2 I think) my sketch doesn't work anymore. It compiles fine, but there is missing some data (binary is about 400 bytes smaller).
First investigation suggests that the FLASH-Library (http://arduiniana.org/libraries/flash/) and the F()-macros seem not to work.
Warnings regarding the Flash-Library look like this:
Code:
In file included from ~/Programme/arduino-1.0.1/libraries/Flash/Flash.cpp:21:
~/Programme/arduino-1.0.1/libraries/Flash/Flash.h:68: warning: ‘__progmem__’ attribute ignored
~/Programme/arduino-1.0.1/libraries/Flash/Flash.h:91: warning: ‘__progmem__’ attribute ignored
~/Programme/arduino-1.0.1/libraries/Flash/Flash.h: In member function ‘char* _FLASH_STRING::copy(char*, size_t, size_t) const’:
~/Programme/arduino-1.0.1/libraries/Flash/Flash.h:75: warning: comparison between signed and unsigned integer expressions
~/Programme/arduino-1.0.1/libraries/Flash/Flash.h: At global scope:
~/Programme/arduino-1.0.1/libraries/Flash/Flash.h:181: warning: ‘__progmem__’ attribute ignored
~/Programme/arduino-1.0.1/libraries/Flash/Flash.h:201: warning: ‘__progmem__’ attribute ignored
~/Programme/arduino-1.0.1/libraries/Flash/Flash.cpp:23: warning: ‘__progmem__’ attribute ignored

And warnings regarding the F()-macro look like this:
Code:
cd_regal_controller_tcp.cpp:385: warning: only initialized variables can be placed into program memory area

Size: 18.148 Bytes

If I use my own toolchain (http://arduino.cc/forum/index.php/topic,95741.msg734762.html#msg734762) everything works fine.

Size: 18.580 Bytes

Also it was necessary to apply a fix to arduino-1.0.1/hardware/arduino/cores/arduino/WString.h:
Code:
class __FlashStringHelper;
//#define F(string_literal) (reinterpret_cast<__FlashStringHelper *>(PSTR(string_literal)))
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
Otherwise the compiler complains about reinterpret_cast discarding some qualifiers.

Regards
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 149
Posts: 6119
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

avr-gcc v4.3.2? I'm using Ubuntu v11.10, and it is using avr-gcc v4.5.3, and last I checked, avr-libc v1.71. Maybe Gentoo should upgrade their AVR stuff. Have you mentioned that to Gentoo?

I'm running IDE v1.0.1 now, and I did not need to modify WString.h.
Logged

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

Hi,
please read carefully. The built-in or bundled toolset of the IDE-1.0.1 download contains gcc-4.3.2. My own(gentooish) toolset is gcc-4.5.3 based. I could even try to use gcc-4.6.3 but I haven't had the time to test.

The problem with WString.h can be triggered by using:
Code:
Serial.print(F("Hello"));

with the linux version which can be downloaded from here.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 149
Posts: 6119
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It may have that bundled with the download, but I wouldn't use it. After I installed IDE v0022 from the Ubuntu Software Center to get the latest avr-gcc and avr-libc, I downloaded the Linux 32-bit IDE v1.0.1 directly from here, and it runs great. It may have avr-gcc v4.3.2 in the download, but that is not what I show when I ask my Ubuntu box. It rarely lies, and it says it is using avr-gcc v4.5.3. From a command prompt:
Code:
avr-gcc -v
Logged

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

You may be correct if you use your commandline, but what does the IDE tells you if you do compile ?
The unchanged downloaded version tells me the following:
Code:
/home/drizzt/Programme/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/home/drizzt/Programme/arduino-1.0.1/hardware/arduino/cores/arduino -I/home/drizzt/Programme/arduino-1.0.1/hardware/arduino/variants/standard -I/home/drizzt/Programme/arduino-1.0.1/libraries/SPI -I/home/drizzt/Programme/arduino-1.0.1/libraries/Ethernet -I/home/drizzt/Programme/arduino-1.0.1/libraries/Metro -I/home/drizzt/Programme/arduino-1.0.1/libraries/Flash -I/home/drizzt/Programme/arduino-1.0.1/libraries/Wire -I/home/drizzt/Programme/arduino-1.0.1/libraries/Adafruit_PWMServoDriver /tmp/build7825702190261685714.tmp/cd_regal_controller_tcp.cpp -o /tmp/build7825702190261685714.tmp/cd_regal_controller_tcp.cpp.o

and if I run
Code:
/home/drizzt/Programme/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -v
from the commandline I get the following output
Code:
Using built-in specs.
Target: avr
Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --disable-libssp --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=avr
Thread model: single
gcc version 4.3.2 (GCC)

Whereas the following command
Code:
avr-g++ -v
gives the following results
Code:
Es werden eingebaute Spezifikationen verwendet.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/avr/gcc-bin/4.5.3/avr-g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/avr/4.5.3/lto-wrapper
Ziel: avr
Konfiguriert mit: /var/tmp/portage/cross-avr/gcc-4.5.3-r2/work/gcc-4.5.3/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/avr/gcc-bin/4.5.3 --includedir=/usr/lib/gcc/avr/4.5.3/include --datadir=/usr/share/gcc-data/avr/4.5.3 --mandir=/usr/share/gcc-data/avr/4.5.3/man --infodir=/usr/share/gcc-data/avr/4.5.3/info --with-gxx-include-dir=/usr/lib/gcc/avr/4.5.3/include/g++-v4 --host=x86_64-pc-linux-gnu --target=avr --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-ppl --with-cloog --disable-ppl-version-check --with-cloog-include=/usr/include/cloog-ppl --disable-lto --enable-nls --without-included-gettext --with-system-zlib --disable-werror --enable-secureplt --enable-multilib --disable-libmudflap --disable-libssp --disable-libgomp --with-python-dir=/share/gcc-data/avr/4.5.3/python --enable-checking=release --disable-libgcj --enable-languages=c,c++ --enable-shared --disable-threads --disable-bootstrap --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.5.3-r2 p1.1, pie-0.4.7'
Thread-Modell: single
gcc-Version 4.5.3 (Gentoo 4.5.3-r2 p1.1, pie-0.4.7)

As one clearly can see the stock IDE is not using the system wide compiler as long as the bundled one hasn't been disabled. I disable it by renaming
Code:
/home/drizzt/Programme/arduino-1.0.1/hardware/tools/avr
to
Code:
/home/drizzt/Programme/arduino-1.0.1/hardware/tools/avr.orig
It can also be removed.

This is one of the reasons why I choose the title 'pitfalls' since these things are not obvious if you do not inspect the compiler output carefully and start to wonder why your perfect running code starts to fail.

regards
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 149
Posts: 6119
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --disable-libssp --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=avr

You are correct about that output. I get that also. I have to be honest, you present a good case except for the "Configured with:" stuff above. I'm not certain about these parameters and what they do:
--prefix=/usr/lib
--bindir=/usr/bin
--libdir=/usr/lib

Does that means this is supposed to use the executable binaries in /usr/bin and libraries in /usr/lib?
Logged

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

Quote
Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --disable-libssp --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=avr

You are correct about that output. I get that also. I have to be honest, you present a good case except for the "Configured with:" stuff above. I'm not certain about these parameters and what they do:
--prefix=/usr/lib
--bindir=/usr/bin
--libdir=/usr/lib

Does that means this is supposed to use the executable binaries in /usr/bin and libraries in /usr/lib?


No these parameters have only been important during building the toolchain itself on running e.g. make install after successful building it:

--prefix the path all paths are prefixed for generating default values
--libdir the path where the libraries and object files would have been stored
--bindir the path where the executables would be installed

Ironically you can overwrite all of these on the commandline and the linker will anyway search the system paths for executables and libraries so these values can be misleading (which they do in this case).

regards
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 149
Posts: 6119
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, that is a surprise. And nobody from Arduino jumps in here, which leads me to believe you are correct. In that light, I have been wasting my time getting the avr-gcc and avr-libc upgraded.

It was not that way when I got here. I had to do delay() bug patches to the avr-libc 1.7.1 files in the /usr/ directory to get v0022 to work. Corrected a data type deprecation in avr-libc v1.8.0 already.

Now they are probably using avr-libc v1.6.7 or the like. Why do I bother?

Downgrade: Exchange new bugs for old ones.
« Last Edit: June 01, 2012, 05:16:55 pm by SurferTim » Logged

Pages: [1]   Go Up
Jump to: