Be aware that some of this guide requires the execution of commands with root privileges. If you do not know the risks involved please do not continue.
librxtx is reported to cause some problems on gentoo linux because of an overflow, causing the IDE to fail. This problem is noted at rxtx here. Please go here for fixed binaries.
First you need to log in as the superuser and install some necessary packages:
emerge -avq sun-jre-bin crossdev
As the Arduino IDE is written in Java sun-jre-bin is needed. crossdev allows the building of the AVR toolchain.
Ensure that the file /etc/make.conf has the following line:
source /var/lib/layman/make.conf
If it hasn't you probably need to install layman and follow the post-install instructions.
mkdir -pv /usr/local/portage
To build the toolchain:
USE="-openmp" crossdev -t avr -s4 -S --without-headers
"-S" ensures the use of stable package versions.
If creating your own toolchain is not working, you can download a pre-built one from Atmel: http://www.atmel.com/tools/ATMELAVRTOOLCHAIN3_3_2FORLINUX.aspx
This section is quite advanced and therefore a complete guide to kernel configuration is out of scope for this guide. The Gentoo documentation has a good guide on this topic.
The next step is to get the USB to serial adapter working. To save some time later I suggest that you first add your user to the tty and uucp groups. This is done by:
gpasswd -a YOUR_USERNAME tty uucp
(at some point you'll need to logout and login again to apply this change). Then you need to enable support for the FTDI and/or for Uno and Mega the 8U2 (CDC ACM) in the kernel by setting:
Device Drivers -> USB support -> USB Serial Converter support -> USB FTDI Single Port Serial Driver
Device Drivers -> USB support -> USB Modem (CDC ACM) support
It should work either as a module or built into the kernel. Just for convenience its easiest to compile it as a module.
Once selected as [M] run the following command to compile, install and initialise the driver:
make && make modules_install && modprobe ftdi_sio
Next connect the Arduino board to the computer using a USB cable and then run dmesg. You should see something like:
usb 2-1: FTDI USB Serial Device converter now attached to ttyUSB0
The main Portage tree tends to be slow about adding new ebuilds for packages related to Arduino development. An unofficial overlay that contains more up-to-date packages can be found here:
http://gitorious.org/gentoo-arduino/arduino
To use this overlay with layman (it's not in the official list of overlays) you have to create the file /etc/layman/arduino.xml with this content:
<!DOCTYPE repositories SYSTEM "/dtd/repositories.dtd">
<repositories xmlns="" version="1.0">
<repo quality="experimental" status="unofficial">
<name><![CDATA[arduino]]></name>
<description><![CDATA[arduino overlay]]></description>
<homepage>http://gitorious.org/gentoo-arduino/arduino</homepage>
<owner>
<email>stharwardATgmail.com</email>
<name><![CDATA[Soren Harward]]></name>
</owner>
<source type="git">git://gitorious.org/gentoo-arduino/arduino.git</source>
<feed>http://gitorious.org/gentoo-arduino/arduino.atom</feed>
</repo>
<repo quality="experimental" status="unofficial">
<name><![CDATA[luksans-arduino]]></name>
<description><![CDATA[another arduino overlay]]></description>
<homepage>http://gitorious.org/~luksan/gentoo-arduino/luksans-arduino</homepage>
<owner>
<email>luksanATgmail.com</email>
<name><![CDATA[Lukas Sandström]]></name>
</owner>
<source type="git">git://gitorious.org/~luksan/gentoo-arduino/luksans-arduino.git</source>
<feed>http://gitorious.org/~luksan/gentoo-arduino/luksans-arduino.atom</feed>
</repo>
</repositories>
Then modify the file /etc/layman/layman.cfg and add the new xml file to the overlays: section like this:
overlays : http://www.gentoo.org/proj/en/overlays/repositories.xml
file:///etc/layman/arduino.xml
Check if it works by typing
layman -L | grep -i arduino
And add the overlay you want like this:
layman -a arduino
After adding the overlay, simply run:
emerge arduino
If you have a newer system and portage prints a message about keyword changes, you can use this commands:
emerge --autounmask-write arduino && etc-update
and then final run
emerge arduino
Now portage should compile and install all arduino packages of the overlay.
Hopefully at this stage you should be set to go; simply start "/opt/arduino/arduino" (or "/usr/bin/arduino" on newer systems) from your user shell or your desktop "run" command. (With older versions, you would need to be in the directory where it's installed, before you can start it. There is still a problem with symlinking it somewhere else... ideally you could make a symlink from /usr/local/bin/arduino to /opt/arduino/arduino, so that it's in your path, but as of version 0.21, you will then get an error about failing to find "processing/app/Base".)
With any luck the editor comes up without any error messages. Go to the tools menu and select /dev/ttyUSB0 as your serial port then try to upload one of the example sketches. If you get an error about the bootloader not responding then quit the editor and check in ~/.arduino/preferences.txt to make sure that serial.download_rate is set to the correct value for your board.
If uploading sketch fails with: avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.
don't look for other version of avrdude, but edit file: /usr/share/arduino-0021/hardware/arduino/boards.txt
and change uploading protocol for your board e.g. change uno.upload.protocol=stk500 to uno.upload.protocol=arduino
NOTE: for AMD64 Gentoo users see this helpful link
If you want to use the Software Serial feature, you need to install version rxtx-2.2_pre2 or newer. This version is masked in the main portage tree, so you will need to unmask it by adding
=dev-java/rxtx-2.2_pre2 ~x86 ~amd64
to /etc/portage/package.keywords, then emerge it
emerge dev-java/rxtx
See also bug 340042 about some crossdev problems you might run into.
If you still have problems with uploading sketches (Arduino ide says: "Done Uploading" but nothing happen on the board) probably the problem is cross-avr/binutils that at version 2.21 seems to have problems uploading sketches, you can mask that package with
echo "cross-avr/binutils-4.21" >> /etc/portage.mask
and emerge the package:
emerge cross-avr/binutils
Now it emerge the 4.20 version of binutils. After that update probably you should have should face another problem, when arduino ide try to compile your sketch , it print the following error message:
/usr/libexec/gcc/avr/ld: cannot open linker script file ldscripts/avr5.x: No such file or directory
that will be solved with:
ln -s /usr/lib/binutils/avr/2.20.1/ldscripts /usr/avr/lib/ldscripts
Originally by Jonny Stutters, Modified by Nick Stallman, Jon Noble, Shawn Rutledge, Soren Harward, Alexander Brüning and Heiko Steindl, Ivan Gualandri.