# How to setup an Arduino Uno board in Gentoo

## mikegpitt

I recently set up Gentoo to work with my new Arduino Uno board, and since I ran into a few quirks I put together a quick how to on how to get things working.  I also recommend reading this document, which is very helpful: http://www.arduino.cc/playground/linux/gentoo

Step 1:  Install crossdev (which is needed to install gcc-avr)

```
emerge sys-devel/crossdev
```

Step 2 (optional):  Add USE="cxx -nocxx" to your /etc/make.conf and run an `emerge -DuN world`

Details

When attempting to install gcc-avr I ran into an issue with my USE flags, since I had C++ support disabled globally, which caused an emerge error about having both the "cxx nocxx" and "-cxx -nocxx" USE flags enabled.  I believe this is because gcc was built with USE="-cxx", but instead of fiddling around with individual packages I just enabled the USE flags globally.

Add this line to your /etc/make.conf (or just append the USE flags to your USE= line):

```
USE="$USE cxx -nocxx"
```

You will now need to apply the new USE flags to world

```
emerge -DuN world
```

Step 3:  Install gcc-avr

```
crossdev -t avr
```

Step 4:  Install arduino frontend.  There are two options here:

Step 4a:  Install the arduino frontend in the main portage tree:

```
echo "dev-embedded/arduino" >> /etc/portage/package.keywords

echo "dev-embedded/arduino java" >> /etc/portage/package.use

emerge arduino
```

Step 4b (recommended):  Install the latest arduino frontend from the arduino overlay:  http://gitorious.org/gentoo-arduino.  Use layman or your usual method to add the arduino ebuilds to Gentoo.  (I maintain my own personal overlay, so I just downloaded the tarball of the complete overlay and copied the ebuilds to my local overlay.)  Once you have added the ebuilds do the following:

```

echo "dev-embedded/arduino java" >> /etc/portage/package.use

echo "dev-embedded/arduino" >> /etc/portage/package.keywords

echo "dev-java/rxtx" >> /etc/portage/package.keywords

emerge arduino

emerge -1 rxtx
```

Step 5:  Install/Update avrdude to version 5.6 or later.

Details

I ran into an error when working in the arduino IDE that read:

```
avrdude: AVR Part "atmega328p" not found.
```

  The solution is to update to the latest avrdude, which supports the atmega328p chipset.

```
echo "dev-embedded/avrdude" >> /etc/portage/package.keywords

emerge -1 avrdude
```

Step 6:  Edit your arduino boards.txt configuration file to have the correct protocol for accessing the Arduino Uno board.

Details

In the arduino IDE, you will likely want to select the option Tools->Board->Arduino Uno.  Initially I had an incorrect board selected, which caused the following error:

```
avrdude: stk500_getsync(): not in sync: resp=0xfe
```

However, if I chose the correct board (Arduino Uno), I received this error:

```
Double check connections and try again, or use -F to override this check.
```

This error was because boards.txt was pointing to an incorrect protocol to communicate with the board.  To fix, change the following line in:

/usr/share/arduino-0021/hardware/arduino/boards.txt under the section that starts with "uno.name=Arduino Uno"

Original:

```
change uno.upload.protocol=stk500
```

New:

```
uno.upload.protocol=arduino
```

Step 7:  Fix linker errors

Details

I ran into a couple linker errors when attempting to build code with gcc-avr

Error 1:

```
/usr/libexec/gcc/avr/ld: cannot open linker script file ldscripts/avr5.x: No such file or directory
```

Fix 1:

```
ln -s /usr/lib/binutils/avr/2.22/ldscripts /usr/avr/lib/ldscripts
```

Error 2:

```
/usr/libexec/gcc/avr/ld: cannot find crtm328p.o: No such file or directory
```

Fix 2:

```
ln -s /usr/avr/lib/avr5/crtm328p.o /usr/avr/lib/crtm328p.o
```

Step 8:  Make sure your kernel is configured correctly.

Details

You will need ftdi_sio & cdc_acm built into your kernel or compiled as modules.  I personally have them added as modules.  When plugging in the Arduino board, cdc_acm should automatically load, but you will need to have ftdi_sio manually loaded, or the board won't function properly.  The following will add ftdi_sio to be loaded at boot (you won't need to do this if it is built directly into your kernel):

```
echo 'modules_2_6="${modules_2_6} ftdi_sio" ' >> /etc/conf.d/modules

modprobe ftdi_sio
```

The drivers are located here in `make menuconfig`:

```
Device Drivers -> USB support -> USB Serial Converter support -> USB FTDI Single Port Serial Driver

Device Drivers -> USB support -> USB Modem (CDC ACM) support
```

Step 9:  Add your user to the appropriate groups to access the hardware.

To be added later... I wasn't able to get this working for my user, so I have been using the IDE as root for the time being

Step 10:  Plug in the board, configure the arduino IDE and start coding!

```
arduino
```

You will want to make sure you have the following options selected:

```
Tools->Board->Arduino Uno

Tools->Board->Serial Port->/dev/ttyACM0
```

----------

## bartex

Hi mikegpitt,

very useful tutorial. Love it  :Smile: 

BR,

bartex

----------

## Yczo

Hello mikegpitt. On first place, thank for your guide, i will be really lost without it, but i'm really new on gentoo. I was following the guide but i found two issues that did not left run arduino.

for not corrupt your post i decided create a new for me [note: second issue solved]

https://forums.gentoo.org/viewtopic-p-6924386.html#6924386

The first is that i only could (after use overlay) use arduino v 0.017 and not the last v 1.0 contained on their web. On the same way installs rxtx v2.1.7.2-r3 being required rxtx-2.2_pre2 (contained in the overlay) or upload code on AMD64 systems. The overlay don't works

and the second is that finalized the steps of your guide, when i run #arduino from console, nothing happen.

Is detailed on my post.

Please, if you could help me a bit, i will be greatful and arduino will be posible for me on linux

SalutesLast edited by Yczo on Mon Jan 09, 2012 7:48 pm; edited 1 time in total

----------

## mikegpitt

 *Yczo wrote:*   

> The first is that i only could (after use overlay) use arduino v 0.017 and not the last v 1.0 contained on their web (not very important to me)

 

Yes, this is the version that is in portage right now, I think... if you use the overlay you can install version 0.0021, but really I don't think there will be much of a difference.

 *Yczo wrote:*   

> and the second is that finalized the steps of your guide, when i run #arduino from console, nothing happen

 Have you emerged arduino with java support?  I believe you need to do that to have the GUI available.  I should modify my guide...

```
echo "dev-embedded/arduino java" >> /etc/portage/package.use 

emerge arduino
```

EDIT:  No need to modify the guide, I apparently already added that line in  :Laughing:   It still would explain why you aren't seeing the GUI though.

----------

## Yczo

Oh it was an incompatibility with the latest java virtual machine oracle-jre-bin-1.7 . The solution is install sun-jre-bin-1.6

Now i need to install rxtx-2.2_pre2 or higher to upload code to board with AMD64, but i'm not sure how to do. I'm trying. Salutes

----------

## mikegpitt

 *Yczo wrote:*   

> Now i need to install rxtx-2.2_pre2 or higher to upload code to board with AMD64, but i'm not sure how to do.

 dev-java/rxtx-2.2_pre2 is packaged with the arduino overlay...  It looks like the ebuild has the ~amd64, so I would imagine it should work fine for you.  Grab the overlay, add the ebuild to your package.keywords, emerge it, and you should be all set.

----------

## Yczo

at last i could use overlay. After upgrade rxtx and arduino, i had the problem of avrdude: AVR Part "atmega328p" not found.  but update arvdude did not bring the solution for me.

I decided repeat the steps od the guide. From the steep 1, and now i have a new and serious problem when i try to compile code with arduino, that did not have before

In file included from /usr/lib/gcc/avr/4.5.3/../../../../avr/include/util/delay.h:44:0,

                 from /usr/lib/gcc/avr/4.5.3/../../../../avr/include/avr/delay.h:37,

                 from /usr/share/arduino-0021/hardware/arduino/cores/arduino/wiring_private.h:30,

                 from /usr/share/arduino-0021/hardware/arduino/cores/arduino/WInterrupts.c:33:

/usr/lib/gcc/avr/4.5.3/../../../../avr/include/math.h:426:15: error: expected identifier or ‘(’ before ‘double’

/usr/lib/gcc/avr/4.5.3/../../../../avr/include/math.h:426:15: error: expected ‘)’ before ‘>=’ token

uf, my head explodes, and think that probably i have to format and reinstall all the system makes me tremble.

----------

## mikegpitt

Hmm... Well it doesn't seem that you are alone, I see a lot of Google results with a similar error.  Here's one page that explains some of what might be happening:  http://arduino.cc/forum/index.php?topic=79371.0

Although, I noticed today in my `emerge --sync` that there appears that cross-avr/avr-libc-1.8.0 is now in portage.  I'm currently running 1.7.1 on my system.  Perhaps when you started again from scratch you went to version 1.8.0, which is causing the error?

----------

## riding_qwerty

Nice little tutorial.  I am about halfway through...having an issue with the Arduino IDE itself.  In this case, when I click on a menu, it stays open so long as the mouse button is depressed, and disappears upon release; also, I cannot select anything.

Is this a Java issue?  I am using the sun-jre-bin-1.6, and emerged the stable arduino package (arduino-0017) as I am not very familiar with using overlays.

Any advice or known issues similar to this?  Thanks in advance.

----------

## mikegpitt

 *riding_qwerty wrote:*   

> Nice little tutorial.  I am about halfway through...having an issue with the Arduino IDE itself.  In this case, when I click on a menu, it stays open so long as the mouse button is depressed, and disappears upon release; also, I cannot select anything.
> 
> Is this a Java issue?  I am using the sun-jre-bin-1.6, and emerged the stable arduino package (arduino-0017) as I am not very familiar with using overlays.
> 
> Any advice or known issues similar to this?  Thanks in advance.

 I'm also using sun-jre-bin:1.6, and I did have arduino-0017 installed for a bit without this issue.  Do you see any debugging output on the command line?  If yes, post that here... also it may help to run the command with strace, to get some lower level debugging information.

For overlays, take a look at this guide:  http://www.gentoo.org/proj/en/overlays/userguide.xml

The arduino overlays is easy to add, even without layman.  Just download the full tarball of the overlay (it's linked to the link I posted in the tutorial), unpack them somewhere on your filesystem, and point to it using the PORTDIR_OVERLAY variable in your make.conf.  I have a line like this in my make.conf.  I unpacked the arduino overlay files in /usr/local/gentoo-arduino-arduino.

```
PORTDIR_OVERLAY="$PORTDIR_OVERLAY /usr/local/gentoo-arduino-arduino"
```

----------

## Yczo

That is! Your last link, soved me all the problems. 

Thank you very much for your attention!!

----------

## riding_qwerty

 *mikegpitt wrote:*   

>  *riding_qwerty wrote:*   Nice little tutorial.  I am about halfway through...having an issue with the Arduino IDE itself.  In this case, when I click on a menu, it stays open so long as the mouse button is depressed, and disappears upon release; also, I cannot select anything.
> 
> Is this a Java issue?  I am using the sun-jre-bin-1.6, and emerged the stable arduino package (arduino-0017) as I am not very familiar with using overlays.
> 
> Any advice or known issues similar to this?  Thanks in advance. I'm also using sun-jre-bin:1.6, and I did have arduino-0017 installed for a bit without this issue.  Do you see any debugging output on the command line?  If yes, post that here... also it may help to run the command with strace, to get some lower level debugging information.
> ...

 

It might be worth mentioning that I have "dev-embedded/arduino ~amd64" in /etc/portage/package.keywords, and that without the ~amd64 flag the package is masked and cannot be emerged.

Here is the output of "strace arduino &> arduino.log"; the java.io.IOException line towards the bottom and the indented portion that follows popped up after trying to run a program that didn't exist, and everything after that popped up upon quitting the IDE.  Also, even though the file menus are unusable, I can use keyboard shortcuts like CTRL+Q to quit or CTRL+O to open a file.

```

execve("/usr/bin/arduino", ["arduino"], [/* 45 vars */]) = 0

brk(0)                                  = 0x20a0000

mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f45ac3ce000

access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)

open("/etc/ld.so.cache", O_RDONLY)      = 3

fstat(3, {st_mode=S_IFREG|0644, st_size=138640, ...}) = 0

mmap(NULL, 138640, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f45ac3ac000

close(3)                                = 0

open("/lib64/libncurses.so.5", O_RDONLY) = 3

read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200S\1\0\0\0\0\0"..., 832) = 832

fstat(3, {st_mode=S_IFREG|0755, st_size=341840, ...}) = 0

mmap(NULL, 2439168, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f45abf5c000

mprotect(0x7f45abfab000, 2093056, PROT_NONE) = 0

mmap(0x7f45ac1aa000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4e000) = 0x7f45ac1aa000

mmap(0x7f45ac1af000, 2048, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f45ac1af000

close(3)                                = 0

open("/lib64/libdl.so.2", O_RDONLY)     = 3

read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\17\0\0\0\0\0\0"..., 832) = 832

fstat(3, {st_mode=S_IFREG|0755, st_size=14512, ...}) = 0

mmap(NULL, 2109704, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f45abd58000

mprotect(0x7f45abd5a000, 2097152, PROT_NONE) = 0

mmap(0x7f45abf5a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f45abf5a000

close(3)                                = 0

open("/lib64/libc.so.6", O_RDONLY)      = 3

read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260!\2\0\0\0\0\0"..., 832) = 832

fstat(3, {st_mode=S_IFREG|0755, st_size=1592528, ...}) = 0

mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f45ac3ab000

mmap(NULL, 3701768, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f45ab9d0000

mprotect(0x7f45abb4f000, 2093056, PROT_NONE) = 0

mmap(0x7f45abd4e000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17e000) = 0x7f45abd4e000

mmap(0x7f45abd53000, 19464, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f45abd53000

close(3)                                = 0

mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f45ac3aa000

mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f45ac3a9000

arch_prctl(ARCH_SET_FS, 0x7f45ac3aa700) = 0

mprotect(0x7f45abd4e000, 16384, PROT_READ) = 0

mprotect(0x7f45abf5a000, 4096, PROT_READ) = 0

mprotect(0x7f45ac1aa000, 16384, PROT_READ) = 0

mprotect(0x6d1000, 4096, PROT_READ)     = 0

mprotect(0x7f45ac3cf000, 4096, PROT_READ) = 0

munmap(0x7f45ac3ac000, 138640)          = 0

rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0

open("/dev/tty", O_RDWR|O_NONBLOCK)     = 3

close(3)                                = 0

brk(0)                                  = 0x20a0000

brk(0x20c1000)                          = 0x20c1000

open("/usr/lib64/locale/locale-archive", O_RDONLY) = 3

fstat(3, {st_mode=S_IFREG|0644, st_size=1534640, ...}) = 0

mmap(NULL, 1534640, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f45ac232000

close(3)                                = 0

getuid()                                = 1000

getgid()                                = 1000

geteuid()                               = 1000

getegid()                               = 1000

rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0

open("/proc/meminfo", O_RDONLY)         = 3

fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0

mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f45ac3cd000

read(3, "MemTotal:        3797416 kB\nMemF"..., 1024) = 1024

close(3)                                = 0

munmap(0x7f45ac3cd000, 4096)            = 0

rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTORER|SA_RESTART, 0x7f45aba05690}, {SIG_DFL, [], 0}, 8) = 0

rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTORER|SA_RESTART, 0x7f45aba05690}, {SIG_DFL, [], SA_RESTORER|SA_RESTART, 0x7f45aba05690}, 8) = 0

rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f45aba05690}, {SIG_DFL, [], 0}, 8) = 0

rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f45aba05690}, {SIG_DFL, [], SA_RESTORER, 0x7f45aba05690}, 8) = 0

rt_sigaction(SIGQUIT, {SIG_DFL, [], SA_RESTORER, 0x7f45aba05690}, {SIG_DFL, [], 0}, 8) = 0

rt_sigaction(SIGQUIT, {SIG_DFL, [], SA_RESTORER, 0x7f45aba05690}, {SIG_DFL, [], SA_RESTORER, 0x7f45aba05690}, 8) = 0

rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0

rt_sigaction(SIGQUIT, {SIG_IGN, [], SA_RESTORER, 0x7f45aba05690}, {SIG_DFL, [], SA_RESTORER, 0x7f45aba05690}, 8) = 0

uname({sys="Linux", node="node", ...})  = 0

stat("/home/george", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0

stat(".", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0

getpid()                                = 32455

open("/usr/lib64/gconv/gconv-modules.cache", O_RDONLY) = 3

fstat(3, {st_mode=S_IFREG|0644, st_size=26050, ...}) = 0

mmap(NULL, 26050, PROT_READ, MAP_SHARED, 3, 0) = 0x7f45ac3c7000

close(3)                                = 0

getppid()                               = 32454

getpgrp()                               = 32454

rt_sigaction(SIGCHLD, {0x441c00, [], SA_RESTORER|SA_RESTART, 0x7f45aba05690}, {SIG_DFL, [], SA_RESTORER|SA_RESTART, 0x7f45aba05690}, 8) = 0

getrlimit(RLIMIT_NPROC, {rlim_cur=29130, rlim_max=29130}) = 0

rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0

open("/usr/bin/arduino", O_RDONLY)      = 3

ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7fff984f00f0) = -1 ENOTTY (Inappropriate ioctl for device)

lseek(3, 0, SEEK_CUR)                   = 0

read(3, "#!/bin/bash\ncd /usr/share/arduin"..., 80) = 55

lseek(3, 0, SEEK_SET)                   = 0

getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=4*1024}) = 0

fcntl(255, F_GETFD)                     = -1 EBADF (Bad file descriptor)

dup2(3, 255)                            = 255

close(3)                                = 0

fcntl(255, F_SETFD, FD_CLOEXEC)         = 0

fcntl(255, F_GETFL)                     = 0x8000 (flags O_RDONLY|O_LARGEFILE)

fstat(255, {st_mode=S_IFREG|0755, st_size=55, ...}) = 0

lseek(255, 0, SEEK_CUR)                 = 0

rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0

read(255, "#!/bin/bash\ncd /usr/share/arduin"..., 55) = 55

rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0

stat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0

stat("/usr/share", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0

stat("/usr/share/arduino-0017", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0

chdir("/usr/share/arduino-0017")        = 0

rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0

rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0

clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f45ac3aa9d0) = 32456

rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0

rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0

rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0

rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0

rt_sigaction(SIGINT, {0x43fa30, [], SA_RESTORER, 0x7f45aba05690}, {SIG_DFL, [], SA_RESTORER, 0x7f45aba05690}, 8) = 0

wait4(-1, Stable Library

=========================================

Native lib Version = RXTX-2.1-7

Java lib Version   = RXTX-2.1-7

0x7fff984f002c, 0, NULL)      = ? ERESTARTSYS (To be restarted)

--- {si_signo=SIGWINCH, si_code=SI_KERNEL, si_value={int=1662233169, ptr=0x7f446313aa51}} (Window changed) ---

wait4(-1, 

java.io.IOException: Target platform: "null" not found.

Make sure that "build.target" in the 

preferences file points to a subdirectory of 

/usr/share/arduino-0017/hardware/cores

   at processing.app.debug.Target.<init>(Target.java:49)

   at processing.app.Editor$43.run(Editor.java:1751)

   at java.awt.event.InvocationEvent.dispatch(Unknown Source)

   at java.awt.EventQueue.dispatchEventImpl(Unknown Source)

   at java.awt.EventQueue.access$000(Unknown Source)

   at java.awt.EventQueue$1.run(Unknown Source)

   at java.awt.EventQueue$1.run(Unknown Source)

   at java.security.AccessController.doPrivileged(Native Method)

   at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)

   at java.awt.EventQueue.dispatchEvent(Unknown Source)

   at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

   at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

   at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

   at java.awt.EventDispatchThread.run(Unknown Source)

Experimental:  JNI_OnLoad called.

[{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 32456

rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0

--- {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=32456, si_status=0, si_utime=0, si_stime=0} (Child exited) ---

wait4(-1, 0x7fff984efb9c, WNOHANG, NULL) = -1 ECHILD (No child processes)

rt_sigreturn(0xffffffffffffffff)        = 0

rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f45aba05690}, {0x43fa30, [], SA_RESTORER, 0x7f45aba05690}, 8) = 0

rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0

read(255, "", 55)                       = 0

exit_group(0)                           = ?

```

I may look into using the overlay tonight to see if that alleviates the issue.

----------

## mikegpitt

```
java.io.IOException: Target platform: "null" not found.
```

Yes, I would look to use the version in the overlay.  It seems like this is a pretty common error with 0017, but I'm not sure why it's happening.  Some googling suggests that it could have something to do with your preferences.txt... but I think the best option is to use the latest version of the IDE.

----------

## paulj

For information, I have created an ebuild and patch files for arduino-1.0 source build. I posted it on the arduino-1.0 enhancement request (https://bugs.gentoo.org/show_bug.cgi?id=303043), and it is also part of my personal overlay at http://gitorious.org/homeoverlay/homeoverlay. I have tested it with a duemilenove arduino, without any issues. in terms of my current versions of other key programs:

sys-devel/crossdev-20111221

cross-avr/gcc-4.5.3-r2

cross-avr/binutils-2.21.1-r2

dev-embedded/avrdude-5.5

cross-avr/avr-libc-1.8.0

I would appreciate any constructive feedback (eg, does it work with other boards)!

----------

## mistik1

Thanks for  sharing your experience setting up your Uno.

Step 2 is not caused by your /etc/make.conf but by crossdev itself https://bugs.gentoo.org/394665

You need to upgrade crossdev to at least crossdev-20111118

```

echo "=sys-devel/crossdev-20111118" >>/etc/portage/package.keywords

emerge -av crossdev

```

Then proceed to step 3.

----------

## superwutze

wow! this thread is simply great!!

thanks a lot for sharing your experiences, finally no use for windows on my notebook anymore  :Wink: 

i use the xml file with layman, the overlay then is called luksans-arduino. it covers quite everything (except the two ln -s ... commands and the unmasking).

----------

## florintanasa

Hello,

I use funtoo linux and thanks for this. 

In funtoo or gentoo is very dificult to install avr toolset and arduino, but I did with layman/luksans-arduino

With this I have errors compilation in arduino (sanguino).

```
/home/florin/arduino-0023/hardware/arduino/cores/arduino/HardwareSerial.cpp:145:15: error: attempt to use poisoned "SIG_USART1_RECV"

make: *** [.build/arduino/HardwareSerial.d] Error 1
```

Then I downloaded the arduino-0023 from arduino.cc site and I got (copy) the toolset from wiring (tools directory) http://wiring.org.co/ and I put the toolset in arduino-0023 in hardware folder.

The I modified Sconstruct from http://code.google.com/p/arscons/ with new toolset path and I make compilation without errors.

Now I using arduino (sanguino) with qt-creator

----------

## superwutze

finally! arduino 1.0 made it into the main portage tree, and with all those fixes mentioned here ist seems to work.

----------

## Robelix

Got the Arduino Uno working with:

```

cd /usr/avr/lib

ln -s avr5/crtm328p.o .

ln -s avr5/libc.a .

ln -s avr5/libm.a .

```

So to the Arduino Mege2560

First I got these "error: attempt to use poisoned "SIG_USART1_RECV" errors - after downgrading to cross-avr/avr-libc-1.7.1 these are gone.

and I did:

```

cd /usr/avr/lib

ln -s avr6/crtm2561.o .

ln -sf avr6/libc.a .

ln -sf avr6/libm.a .

```

Now I get 

```

/usr/libexec/gcc/avr/ld: skipping incompatible /usr/lib/gcc/avr/4.5.3/libgcc.a when searching for -lgcc

/usr/libexec/gcc/avr/ld: cannot find -lgcc

collect2: ld returned 1 exit status

```

But /usr/lib/gcc/avr/4.5.3/libgcc.a seems to be the only avr-libgcc I've got - how does this get incompatible?

----------

## Robelix

Got it.

The second patch from https://bugs.gentoo.org/show_bug.cgi?id=378387 did it for me. 

Now both Arduinos work without any symlinks in /usr/avr/lib/

----------

## andrewwalker27

I've got the Duemilanove 328 board running ok but not my Uno. The Uno device driver exists in /dev as ttyACM0 but not in the menu in the arduino-1.0 software. I'm running ~x86_64 and I've checked I'm in the correct groups. I've also checked with another Uno to prove it wasn't the board at fault. 

The strange thing is that dmesg shows the board

[24006.462034] usb 6-2: udev 13, busnum 6, minor = 652

[24006.462037] usb 6-2: New USB device found, idVendor=2341, idProduct=0001

[24006.462040] usb 6-2: New USB device strings: Mfr=1, Product=2, SerialNumber=220

[24006.462043] usb 6-2: Product: Arduino Uno

[24006.462045] usb 6-2: Manufacturer: Arduino (www.arduino.cc)

[24006.462047] usb 6-2: SerialNumber: 64932343738351402142

[24006.462127] usb 6-2: usb_probe_device

[24006.462130] usb 6-2: configuration #1 chosen from 1 choice

[24006.465037] usb 6-2: adding 6-2:1.0 (config #1, interface 0)

[24006.465074] cdc_acm 6-2:1.0: usb_probe_interface

[24006.465078] cdc_acm 6-2:1.0: usb_probe_interface - got id

[24006.465100] cdc_acm 6-2:1.0: ttyACM0: USB ACM device

[24006.468081] usb 6-2: adding 6-2:1.1 (config #1, interface 1)

[24006.468138] drivers/usb/core/inode.c: creating file '013'

but lsusb just shows a blank line

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 002 Device 003: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB

Bus 003 Device 002: ID 413c:2003 Dell Computer Corp. Keyboard

Bus 006 Device 013: ID 2341:0001  

Bus 002 Device 004: ID 413c:3012 Dell Computer Corp. Optical Wheel Mouse

Can anyone tell me if it is the Arduino software at fault or the USB system? I've checked the USB FTDI Single Port Serial Driver and the USB Modem (CDC ACM) support are enabled in the kernel so I don't think the kernel is at fault. I'm using kernel-3.2.9

----------

## MuMulambda

Sorry to bump a relatively old post, just wanted to help out here

 *Quote:*   

> Nice little tutorial. I am about halfway through...having an issue with the Arduino IDE itself. In this case, when I click on a menu, it stays open so long as the mouse button is depressed, and disappears upon release; also, I cannot select anything.
> 
> Is this a Java issue? I am using the sun-jre-bin-1.6, and emerged the stable arduino package (arduino-0017) as I am not very familiar with using overlays.
> 
> Any advice or known issues similar to this? Thanks in advance.

 

This was happening for me under xmonad, I fixed it by following the steps here in the XMonad Wiki. Hope it helps some people. Basically you get the WM to tell Java that it's one of the non reparenting WM's they have their small list.

----------

## Robelix

0017 is really old - I'm using ardunio-0021 from the overlay http://gitorious.org/gentoo-arduino/arduino with sun-jdk-1.6

(Tried the 1.0 from portage some time ago, but this did not upload to my Uno)

----------

## linoseros

I was looking for this thank you so much

----------

## mikankun

Not sure if you ever figured it out but for anyone wondering about the groups bit. You need to to be part of uucp and tty. You'll also need to make sure /var/lock is writable for the group.

----------

## andrewwalker27

Still can't get it working! I've started from scratch and done the following

Installed crossdev-20120531

emerge sys-devel/crossdev

and

crossdev -t avr

------------------------------------------------------------------------------------------------------------------------------------------------------

 * crossdev version:      20120531

 * Host Portage ARCH:     amd64

 * Target Portage ARCH:   *

 * Target System:         avr

 * Stage:                 4 (C/C++ compiler)

 * ABIs:                  default

 * binutils:              binutils-[latest]

 * gcc:                   gcc-[latest]

 * libc:                  avr-libc-[latest]

 * CROSSDEV_OVERLAY:      /var/lib/layman/rion

 * PORT_LOGDIR:           /var/log/portage

 * PORTAGE_CONFIGROOT:    

 * Portage flags:         

  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -

 * leaving metadata/layout.conf alone in /var/lib/layman/rion

  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -

 * Log: /var/log/portage/cross-avr-binutils.log

 * Emerging cross-binutils ...                                                                                                                  [ ok ]

 * Log: /var/log/portage/cross-avr-gcc-stage1.log

 * Emerging cross-gcc-stage1 ...                                                                                                                [ ok ]

 * Log: /var/log/portage/cross-avr-avr-libc.log

 * Emerging cross-avr-libc ...                                                                                                                  [ ok ]

 * Log: /var/log/portage/cross-avr-gcc-stage2.log

 * Emerging cross-gcc-stage2 ...                                                                                                                [ ok ]

Installed dev-embedded/arduino-1.0  USE="java"

emerge  arduino

Installed rxtx-2.2_pre2

emerge -1 rxtx

Installed avrdude

emerge -1 avrdude-5.11.1

and checked I'm in the right groups. I can now select Uno and /dev/ttyACM0 and when I select upload I get no errors and all the correct lights light up on the Arduino only the code doesn't work. I also get the same result with a Duemilanove.

I'm only using the blink example sketch but I just get the onboard pin 13 led permanently lit, it should blink but doesn't! I've tried other Arduino boards and they work ok when I use my laptop with Ubuntu but Gentoo seems to not work correctly.

Any ideas anyone?

----------

## yngwin

It would be nice if you guys add the information from this thread to the Gentoo Wiki!

----------

## shimbob

I just discovered after much head-wall contact that having the sabayon-distro overlay enabled will cause the 'crossdev avr' step to fail. It was complaining about masked packages and "missing IUSE: libffi". Disabled the sabayon-distro overlay and now it's happy.

[edit]

Sigh.. for several hours now I have been trying to install arduino:

```
>>> Emerging (1 of 1) dev-embedded/arduino-0021 from ardunio

 * Missing avr-g++; you need to crossdev -s4 avr

 * Note that you need >=cross-avr/gcc-4.4.1, if you intend to use the new

 * Arduino Mega 2560.

>>> Unpacking source...

 * git.eclass is deprecated.

 * Please update your ebuilds to use git-2 instead. For details, see

 * http://archives.gentoo.org/gentoo-dev/msg_b7ba363cae580845819ae3501fb157e9.xml

 * GIT update -->

 *    repository:       git://github.com/arduino/Arduino.git

fatal: ambiguous argument 'master': unknown revision or path not in the working tree.

Use '--' to separate paths from revisions

remote: Counting objects: 19115, done.

remote: Compressing objects: 100% (6359/6359), done.

Receiving objects:  38% (7310/19115), 51.48 MiB | 699 KiB/s   
```

and it just hangs there receiving objects...

If I try again, it might hang at 40%, 64%, 65%, it's always different.

----------

## cwc

Thank you for the thread!  I just purchased an Arduino Uno and I'm trying to set up my Gentoo (Funtoo) box to run the IDE.

azzerare ~ # uname -a

Linux azzerare 3.2.12-gentoo #3 SMP Fri Apr 13 05:16:30 PDT 2012 x86_64 AMD Athlon(tm) 64 Processor 3400+ AuthenticAMD GNU/Linux

I'm stuck here.

!!! All ebuilds that could satisfy "dev-embedded/uisp" have been masked.

!!! One of the following masked packages is required to complete your request:

- dev-embedded/uisp-20050207-r1::gentoo (masked by: ~amd64 keyword)

This is my /etc/portage/package.unmask 

>=dev-java/rxtx-9999

>=dev-embedded/uisp-9999

package.unmask is the only /etc/portage/ file I have not put in a directory.  

Here is the error:

emerge arduino

Calculating dependencies... done!

!!! All ebuilds that could satisfy "dev-embedded/uisp" have been masked.

!!! One of the following masked packages is required to complete your request:

- dev-embedded/uisp-20050207-r1::gentoo (masked by: ~amd64 keyword)

(dependency required by "dev-embedded/arduino-1.0[java]" [ebuild])

(dependency required by "arduino" [argument])

For more information, see the MASKED PACKAGES section in the emerge

man page or refer to the Gentoo Handbook.

Any ideas?

----------

## rockdw

My system is a 32bit setup, but I just bypassed all the compiling and grabbed the tarball from arduino.cc:

http://arduino.cc/en/Main/Software

Set up the user to be in the uucp,tty and usb groups and just ran the arduino binary in the arduino-1.0.1 directory.  That has worked just fine for me with my Duemilanove and took about two minutes to set up.  No fuss, no muss.

Just because gentoo is a "from source" distro, that doesn't mean you always have to do that for everything on it.  Sometimes using a binary is ok.  :Wink: 

----------

## cwc

 *rockdw wrote:*   

> My system is a 32bit setup, but I just bypassed all the compiling and grabbed the tarball from arduino.cc:
> 
> http://arduino.cc/en/Main/Software
> 
> Set up the user to be in the uucp,tty and usb groups and just ran the arduino binary in the arduino-1.0.1 directory.  That has worked just fine for me with my Duemilanove and took about two minutes to set up.  No fuss, no muss.
> ...

 

Thanks!  This is the way I run Blender.  Before I tried to emerge ardhino I did the crossdev stuff.  Hopefully this will not interfere with anything.  Once I get things running I'll edit this post or post again.

I got the arduino running from root now I just need to build a circuit and test.  /opt/arduino-1.0.1/arduino 

Thanks again.

----------

## rockdw

Cool.  I'll be interested to hear how it works out.

Good luck.  :Smile: 

----------

## cwc

 *rockdw wrote:*   

> Cool.  I'll be interested to hear how it works out.
> 
> Good luck. 

 

I finally got time to work with my Arduino.

Here are my groups:

azzerare ~ # groups cwc

root tty wheel uucp audio cdrom video cdrw users polkituser plugdev apache ftp cwc

I got the code to compile but when I went to upload I got this error:

Binary sketch size: 3,464 bytes (of a 32,256 byte maximum)

processing.app.SerialNotFoundException: Serial port 'COM1' not found. Did you select the right one from the Tools > Serial Port menu?

I open the application with tty and I get these errors:

^Ccwc@azzerare ~ $ /opt/arduino-1.0.1/arduino 

Experimental:  JNI_OnLoad called.

Stable Library

=========================================

Native lib Version = RXTX-2.1-7

Java lib Version   = RXTX-2.1-7

check_group_uucp(): error testing lock file creation Error details:Permission deniedcheck_lock_status: No permission to create lock file.

please see: How can I use Lock Files with rxtx? in INSTALL

Any ideas??

----------

## cwc

 *rockdw wrote:*   

> Cool.  I'll be interested to hear how it works out.
> 
> Good luck. 

 

I finally got arduino to work.  I downloaded the binary and just run it.

I had to recompile my kernel before I could connect to com1 though.

Now I want to set up a shield https://www.adafruit.com/products/815

Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface - PCA9685

This requires some special cpp code. 

Thanks for the help.

----------

## oliv3r

I've found a few posts dating back to 2009/2010 running into the same bug:

 *Quote:*   

> Step 7: Fix linker errors
> 
> Details
> 
> I ran into a couple linker errors when attempting to build code with gcc-avr
> ...

 

It is now 2013 and I did a fresh crosscompile of avr and avr-libc. I did try arduino IDE, but prefer working with pure avr and thus using avr-gcc. Yet I also find this linker error (different .x file though for my target).

Is this a bug that needs to be fixed? Is a bug report needed? Fix 1 is a nice workaround, but is really a dirty hack. If this really is what is is needed, then why doesn't the e-build sort this? Otherwise, what is the proper way to deal with this.

----------

## _______0

Does gentoo have an overlay for gnoduion?

http://gnome.eu.org/index.php/Gnoduino

The only things to take care are these:

```

 Dependencies

avr-gcc

avr-gcc-g++

avr-libc

avr-binutils

avrdude

pygtk2

gnome-python2-gconf

gnome-python2-gnomevfs

pyserial

pygtksourceview

pyxdg (python-xdg for debian)

dbus-x11

librsvg2 (librsvg2-bin for debian)

```

I am wary of installing trillion java deps for something as simple as arduino.

thnks

----------

## oliv3r

I would suppose there is an overlay.

In any case, this thread was about one of the dependencies and whether is bugged on Gentoo or flawed by design  :Wink: 

I guess if nobody can respond on this thread whether it is; i'll just open a bug report about it.

----------

## qwerty013

For Arduino UNO 2017 update

First, prepare local overlay:

```
sudo mkdir /usr/local/portage

sudo mkdir /usr/local/portage/profiles

sudo touch /usr/local/portage/profiles/repo_name

echo "my_arduino" > /usr/local/portage/profiles/repo_name

sudo vim /etc/portage/make.conf

  add 'PORTDIR_OVERLAY="/usr/local/portage"'
```

Second, do kernel, group and crossdev stuff like here: https://wiki.gentoo.org/wiki/Arduino

But don't forget to compile crossdev (gcc) with c++ USE flag:

```
USE="-openmp -hardened -sanitize -vtv cxx" crossdev -s4 -S --target avr
```

Kernel modules that worked for me: ch341,ftdi_sio (details at wiki page)

Third, workaround for gentoo bug 147155 ('ld' for avr cannot find linker script 'avr5.x'):

```
ln -s /usr/lib/binutils/avr/2.20.1/ldscripts /usr/avr/lib/ldscripts
```

Fourth, workaround for "cannot find crtatmega328p.o":

You need to accept_keyword and install cross-avr/avr-libc-2.0.0.

In my case, there was auto-created file, where I placed ~x86 before the avr-libc 

```
vim /etc/portage/package.keywords/cross-avr

sudo emerge -pv cross-avr/avr-libc
```

Fifth, udev and groups tweaks:

http://www.arduino.org/learning/getting-started/arduino-ide-on-linux-based-os

STEPS 1,2,6

UPD: due to arduino site fcukup and according to my bad memory:

1, 2 - download and extract arduino IDE

6 - ??? run install script, probably (according to current arduino guideline you need to add yourself to 'dialout' group)

7 - PROFITLast edited by qwerty013 on Tue Sep 12, 2017 2:09 pm; edited 2 times in total

----------

## qwerty013

And two more tweaks.

To fix IDE menu font problem:

run before IDE launching

```
export _JAVA_OPTIONS="-Dawt.useSystemAAFontSettings=on"
```

To fix editor font problem:

Change string in ~/.arduino/preferences.txt

```
editor.font=Consolas,bold,14
```

PS: I didn't succeed in 'external editor thing'

UPD: you can write code in your beloved editor, compile it with avr-gcc and upload with avrdude, without IDE at all.

Good example: https://balau82.wordpress.com/2011/03/29/programming-arduino-uno-in-pure-c/

"/usr/share/arduino/hardware/tools/avrdude.conf" - official IDE's avrdude options

avr-gcc flags could be found in terminal stdout, from where you started arduino IDE and tried to compile something.Last edited by qwerty013 on Tue Sep 12, 2017 2:09 pm; edited 1 time in total

----------

## andrewwalker27

When you state 

 *Quote:*   

> compile gcc with c++

 

do you mean cross-avr/gcc or sys-devel/gcc?

It now looks like cross-avr/gcc cross-avr/binutils cross-avr/avr-libc are all obsolete, masked or removed from portage though crossdev still exists, do I only need crossdev now?

The wiki page seems a bit out of date.

----------

## qwerty013

 *andrewwalker27 wrote:*   

> When you state 
> 
>  *Quote:*   compile gcc with c++ 
> 
> do you mean cross-avr/gcc or sys-devel/gcc?
> ...

 

I meant "run this string of code":

```
USE="-openmp -hardened -sanitize -vtv cxx" crossdev -s4 -S --target avr
```

It will compile cross-avr/gcc and other things for arm crossdev toolchain. I just emphasized 'cxx' use flag.

 *Quote:*   

> It now looks like cross-avr/gcc cross-avr/binutils cross-avr/avr-libc are all obsolete, masked or removed from portage though crossdev still exists, do I only need crossdev now?
> 
> The wiki page seems a bit out of date.

 

Yes, you need to emerge only crossdev. I am using 'sys-devel/crossdev-20160602-r1'

----------

