The Arduino wiki has a page on getting an Arduino to work with Gentoo. It didn't work for me, so I'm posting what did work here. I'm hesitant to put this on the wiki page directly, because it would require removing a lot of information that was put there for a reason. But, here's what seems to have worked for me. Caveats: I've only tested with an Uno and a Leonardo; and in the process of getting them to work, I did a lot of other things that I don't think made a difference, but I don't remember what half of them were, so who knows?
- Configure your kernel to enable
Device Drivers -> USB support -> USB Modem (CDC ACM) support
. If you're not sure whether you have it, runzgrep USB_ACM
. If you do, there'll be a lineCONFIG_USB_ACM=y
or=m
. It's okay to have as a module, and building a module is faster than recompiling your entire kernel and doesn't require a reboot. I'm not going to go into the process here, though. - Emerge
avrdude
andarduino
.avrdude
uploads programs to the Arduino;arduino
is the IDE, but also contains build programs. As of writing, the newest version ofarduino
in Portage is1.0
. If you're using an Uno or older, I think you can get away with that. If you're using a Mega2560 or newer, you need1.0.1
; see below for installing it. Definitely don't get0015-r1
or0017
. These are higher numbers, so portage thinks they're newer; but there's been a change in versioning schemes, and they're actually older. They've been masked to stop you from installing them accidentally. - That's it.
Now you can use the IDE (it's installed as the binary arduino
), or if you dislike that there's a Makefile you can use for compiling and uploading.
To use the Makefile, you need to export ARDUINODIR=/usr/share/arduino-$VERSION
, or create a symlink from /usr/share/arduino
to that directory. (If you create a symlink, you'll need to remember to update it when you upgrade.) I want to write more about the Makefile, and about avoiding the Arduino IDE in general, but this is not the place.
One thing you can't do is use the build tools (avr-gcc
, avr-g++
and avr-objcopy
) directly. They aren't installed to your path. The Makefile can find them, and you can create symlinks if you want.
One thing I love about Portage is that if a package hasn't been updated to the latest version, you can do it yourself. Because you build from source, you don't need to wait for upstream to compile it. It's not super-easy, but it's not especially hard, either. (For completeness, I should note that I don't know you can't do that with other distros. In particular, I've heard you can do it with Arch. I'm not sure how that would work, and it's possible I misunderstood the person I was talking to.)
In /etc/make.conf
, there might be a setting for PORTDIR_OVERLAY
. If not, set it to something; I use /usr/local/portage
. This is a directory where you can keep a seperate Portage tree which takes priority over the real one. Make this directory, if it doesn't exist. Then further create $PORTDIR_OVERLAY/dev-embedded/arduino
, and cd
into it.
Copy files over:
sudo cp -R /usr/portage/dev-embedded/arduino/* .
sudo cp arduino-1.0.ebuild arduino-1.0.1.ebuild
sudo cp files/arduino-1.0-script.patch files/arduino-1.0.1-script.patch
Now you need to edit arduino-1.0.1.ebuild
and remove the line epatch "${FILESDIR}"/${P}-prog_char-fix.patch
. This line would attempt to apply a patch which no longer matches the source tree.
Call sudo ebuild arduino-1.0.1.ebuild digest
to update the Manifest
file that Portage requires. This will download, but not install, the arduino
package. Finally you can emerge arduino
and you should get version 1.0.1
.
The Arduino wiki tells you to install crossdev
and run crossdev -t avr
. This builds cross-compilation tools. I mentioned above that installing arduino
doesn't put them in your path; crossdev
will. In fact, arduino
seems to list crossdev
among its dependencies, and give you a post-install warning if you haven't built those tools.
However, I spent several hours trying to work out why I could build some programs using the IDE but not the Makefile; the Makefile would pretend to compile them but they would do nothing when uploaded. It could successfully upload programs compiled by the IDE, and it had no problems with other programs. The problem turned out to be that the Makefile was using the tools installed by crossdev
, and the IDE wasn't. I ran crossdev -C -t avr
to uninstall the crossdev
tools, and all my problems were solved. If I was starting again from scratch, I'd try without ever running crossdev
.
That said, I had previously run crossdev -t avr
when I installed arduino
, so it's possible you'll need to have done so to. I think arduino
doesn't build its tools from scratch, so if you want versions of them other than the included ones, or built for a different architechure, you might need to figure out crossdev
.
The Arduino wiki also tells you to add an overlay to layman
(which is an overlay management tool) to get up-to-date versions. When I tried to follow the instructions given, layman
complained about something or other being malformed. Further investigation reveals that that overlay hasn't been updated since 2010, so definitely don't bother with it. (I think I actually am going to remove that section of the page.)