[SOLVED] How to get avr-gcc 4.3 on Linux?

Hi!

I'm running Arch Linux 64-bit and I have avr-gcc 4.6.0 installed, which can be found in the official repository on Arch. However, apparently there is a bug in this version which makes programs on my Arduino Mega 1280 unable to send and receive signals through the USB cable. I can install programs, but they can't communicate with the computer in Serial Monitor in Arduino. (Hope you understand what I mean.)

I have read that installing 4.3.x of avr-gcc should fix this problem. But I can only find version 4.3.4 of gcc in the AUR (Arch User Repository), and not an older version of avr-gcc.

So my question is: where can I find version 4.3 of avr-gcc? And how do I install it?

// Daniel Jonsson

Doesn't 4.3.4 qualify as 4.3.x ?

Yeah. However, I can only find that version of gcc in the AUR, not avr-gcc. But maybe gcc = avr-gcc? I must say that I don't know what the difference is, but I have both gcc and avr-gcc in my /usr/bin/ folder and they are both in version 4.6.0. And when I installed gcc 4.3 from the AUR I got some extra files in this folder called gcc-4.3 and similar, but not an additional avr-gcc file.

I suggest that you read this topic:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=42631&postdays=0&postorder=asc

or at least its last pages.

Thanks! That looks interesting. I will try to run the script that is described in the first post of the thread and see if I can install avr-gcc and those other programs to /usr/local/avr.

EDIT: And please tell if this is a good/bad idea, and/or if there are easier ways. The clock is 2:20 am atm, so I will wait with the installation until tomorrow. :)

MaTachi: Yeah. However, I can only find that version of gcc in the AUR, not avr-gcc. [...]

Sorry, my bad. I thought I had read avr-gcc 4.3.4.

You can use Bingo's build script. I've used it too. It will get you avr-gcc 4.4.3 + avr-libc 1.7.1 + avr-binutils 2.20, which runs well on my system (mostly). I can't speak for the 'Arduino Mega' though. There are some issues with delay.h, which may or may not affect you. It should be mentioned in the thread on avrfreaks.net as well.

Just make sure you have a backup of your important stuff, as Bingo's script is intended to be run as root. So it may wreck havoc on your system. It worked on mine, but better be safe.

In the last pages there is the most actual scripts and also .deb files and patches for the avr-gcc to correct the delay.h problems and other.

madworm:

MaTachi: Yeah. However, I can only find that version of gcc in the AUR, not avr-gcc. [...]

Sorry, my bad. I thought I had read avr-gcc 4.3.4.

You can use Bingo's build script. I've used it too. It will get you avr-gcc 4.4.3 + avr-libc 1.7.1 + avr-binutils 2.20, which runs well on my system (mostly). I can't speak for the 'Arduino Mega' though. There are some issues with delay.h, which may or may not affect you. It should be mentioned in the thread on avrfreaks.net as well.

Just make sure you have a backup of your important stuff, as Bingo's script is intended to be run as root. So it may wreck havoc on your system. It worked on mine, but better be safe.

I followed the steps desribed in Bingo's first post, but I ended up with this error message on step 9:

/usr/lib/libbfd.a(plugin.o): In function `try_load_plugin':
(.text+0x3c8): undefined reference to `dlopen'
/usr/lib/libbfd.a(plugin.o): In function `try_load_plugin':
(.text+0x3eb): undefined reference to `dlsym'
/usr/lib/libbfd.a(plugin.o): In function `try_load_plugin':
(.text+0x47b): undefined reference to `dlerror'
collect2: ld returned 1 exit status
make[2]: *** [avarice] Error 1
make[2]: Leaving directory `/usr/local/avr/build/avarice-2.10/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/local/avr/build/avarice-2.10/src'
make: *** [all-recursive] Error 1
(./buildavr-no-insight.sh) avarice build failed

Do you know what may be causing this?

Senso: In the last pages there is the most actual scripts and also .deb files and patches for the avr-gcc to correct the delay.h problems and other.

Is it really a good idea to install .deb files on Arch?

EDIT: Saw this post where someone had the same problem http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=830390&sid=65bea712f6d83d0bb8c590a657ae6fff#830390 I will see if I can get it to work now.

Finally, I managed to finish the installation with Bingo’s script! XD

Now I have a bunch of files in /user/local/avr/, but I’m not really sure where I can find the avr-gcc file (if there is any) and how I’m supposed to make Arduino using it.
Maybe I can rename the avr-gcc file in /usr/bin/ and make a link of the one I have installed (wherever it is located)?
Please tell how you did it madworm. :slight_smile:

I added these lines to '/etc/profile.local':

PATH=$PATH:/usr/local/avr/bin
export PATH

That's all. Don't forget to restart your session. In case you have another installation of avr-gcc sitting on your machine, you may have to remove it (or at least make that folder unaccessible to the user). Otherwise you'd have to deal with the order of the search path.

With that change you can just start the avr-gcc executables in a console, auto-completion should find it. And of course the Arduino IDE as well.

Thanks for your fast answer!

I added those lines to /etc/profile.local, renamed /usr/bin/avr-gcc to /usr/bin/avr-gcc2 and restarted my computer. I suppose that avr-gcc in the terminal should generate something else than:

[17:47] daniel@arch ~ $ avr-gcc
bash: avr-gcc: command not found

So, what have I done wrong?

EDIT: I checked in the /usr/local/avr/bin/ folder and I suppose that just renaming avr-gcc isn't enough. I will try to uninstall avr-gcc completely and see what happens.

It seems like '/etc/profile.local' is not sourced at all, which is odd. Are the permissions correct ? (rw-r--r-- root root)

What's the output of

echo $PATH

Does '/etc/profile' contain any help-text asking you to use '/etc/profile.local' instead ?

You could add it to '/etc/profile' as well, but I guess it would get overwritten by updates.

BTW, you should get something like this:

...>avr-gcc --version

avr-gcc (GCC) 4.4.3
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Also I'm not sure it is a good idea to just rename your 'other' avr-gcc binary. You'll have to take care of ALL of it, including the library files! I had expected that avr-gcc would be installed in '/opt'. Then you could just have set the folder unreadable and be done with it. You definitely don't want a mix-up of old and new versions. Better get rid of all the unused stuff.

The permissions seem to be correct:

[19:11] daniel@arch /etc $ ls -la | grep profile.local
-rw-r--r--  1 root   root      42 Jun 19 17:39 profile.local

Here is my echo $PATH output:

[19:12] daniel@arch /etc $ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/java/bin:/opt/java/db/bin:/opt/java/jre/bin:/usr/bin/vendor_perl:/usr/bin/core_perl

And here is the content of my /etc/profile file:

# /etc/profile

#Set our umask
umask 022

# Set our default path
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
export PATH

# Load profiles from /etc/profile.d
if test -d /etc/profile.d/; then
    for profile in /etc/profile.d/*.sh; do
        test -r "$profile" && . "$profile"
    done
    unset profile
fi

# Source global bash config
if test "$PS1" && test "$BASH" && test -r /etc/bash.bashrc; then
    . /etc/bash.bashrc
fi

# Termcap is outdated, old, and crusty, kill it.
unset TERMCAP

# Man is much better than us at figuring this out
unset MANPATH

# dircolors /etc/DIR_COLORS

And yeah, I will try to uninstall avr-gcc and some related stuff.

It seems the concept of a profile.local file is not implemented there. It should work if you move your newly created file to '/etc/profile.d/' and rename it to something meaningful to you, but with the .sh ending. Like 'avr-gcc-path.sh' or something.

I have uninstalled the packages gcc-avr, avr-libc and binutils-avr now. The packages avrdude, avarice and insight wasn't installed.

EDIT: Ok, I will try that. Thanks.

The avrdude binary should also be in /usr/local/avr/bin after running Bingo’s script. But the Arduino IDE uses its own version anyway. It will only matter if you run it by hand or with other software.

madworm: The avrdude binary should also be in /usr/local/avr/bin after running Bingo's script. But the Arduino IDE uses its own version anyway. It will only matter if you run it by hand or with other software.

Yeah, I read that Bingo's script would install "avr-gcc-4.3.4/binutils-2.20/avr-libc-1.6.8/avr-insight-6.8-1/avrdude-5.10/avarice-2.10", so I went and uninstalled all of those that already were installed.

Anyway, I did as you suggested with the PATH file (or whatever it's called) and now everything seem to work. :D

[19:44] daniel@arch ~ $ avr-gcc --version
avr-gcc (GCC) 4.3.4
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I have also opened a couple of the Communication examples in Arduino, compiled them and tested them on my Arduino Mega board, and they worked flawless. I don't know if I mentioned it, but earlier wouldn't Serial Monitor in the Arduino software send or receive any signals. But now it works just as expected.

Thank you very much madworm! I would not have solved this without your help. I'm so happy XD