=================================================
Building the Arduino / Sanguino on Gentoo amd64
=================================================
:CreationDate: 2009-09-01 17:27:01
:Id: HW/makerbot/arduino-on-gentoo
:tags: - hardware
- software
- 3dPrint
Ok, so I had this nice CupCake_ kit. It comes with pre-built
electronics, and pre-installed firmware. But I like being able to do
upgrades, especially since the whole thing is still maturing.
So, the `MakerBot instructions`_ say "get the Arduino_ env, apply the
Sanguino_ patch, and you're done". Easy, right?
I start by downloading the sources for the Arduino_ software. You see,
I run a 64-bit machine, and the pre-built Linux binaries are 32
bits. Not good enough.
Of course, I have to build the cross-compiling tool-chain… easy
enough: crossdev_ has a special target for it::
# crossdev -t avr
Only it does not work: ``avr-libc-headers`` requires the compiler to
be already build. I don't go fixing it the proper way, I just follow
the `hint found in a mailing list post`_, and do (after the failed
``crossdev`` run)::
# USE='-nls -fortran -gtk -openmp -mudflap' emerge -v cross-avr/gcc
# crossdev -t avr
and I have a (hopefully) working cross-compiler.
Then, following the `Arduino instructions`_, I say::
~/arduino-src/build/linux$ ./make.sh
and it goes::
The Java bundle that is included with Processing supports only i686 by default.
To build the code, you will need to install the Java 1.5.0_15 JDK (not a JRE,
and not any other version), and create a symlink to the directory where it is
installed. Create the symlink in the "work" directory, and named it "java":
ln -s /path/to/jdk1.5.0_15 /home/dakkar/arduino-src/build/linux/work/java"
Ok, I'll do it. By having mis-read the notice, I actually symlink the
``icedtea6`` JDK. It didn't seem to mind.
Now it builds, but it won't run: there are 32-bit libraries! Who built
them??
Looking at Portage (yes, I run Gentoo) I see that there is an ebuild
for an (older) Arduino version, and it declares dependency on exactly
the library that is giving me problems. So::
emerge -av dev-java/rxtx uisp
and I have the right library. Of course the Arduino program won't use
it (it's not in the default ``CLASSPATH``), so I symlink it over the
bundled version::
rm work/lib/RXTXcomm.jar work/lib/librxtxSerial.so
ln -s /usr/share/rxtx-2/lib/RXTXcomm.jar work/lib/
ln -s /usr/lib/rxtx-2/librxtxSerial.so work/lib/
It runs!
.. warning:: In the official Portage tree, RXTX is at version 2.1.7.2,
which does not seem to work. We need version 2.2; you can get it
from `my overlay </cgit/gentoo-overlay/>`_.
Of course, no Sanguino_ support, and the CupCake_ main board is a
Sanguino_.
The `Sanguino instructions`_ say to add a couple of directories,
overwrite a few files, add some lines to a file, and it should be
enough. Well, not so fast. It didn't work for me.
After a bit of ``find``, I see that the ``boards.txt`` file (the one
that needs to have data added to) has been copied from it "source"
location (``/home/dakkar/arduino-src/hardware/boards.txt``) to the
"work" location
(``/home/dakkar/arduino-src/build/linux/work/hardware/boards.txt``). Ok,
I should have read *all* the instructions: it said to rebuild the
Arduino environment every time a change is made.
By this point I'm sick and tired of re-doing all the work-arounds, so
I just change the ``make.sh`` script::
===================================================================
--- make.sh (revision 756)
+++ make.sh (working copy)
@@ -34,25 +34,7 @@
install -m 755 dist/arduino work/arduino
- ARCH=`uname -m`
- if [ $ARCH = "i686" ]
- then
- echo Extracting JRE...
- tar --extract --file=jre.tgz --ungzip --directory=work
- else
-# echo This is not my beautiful house.
-# if [ $ARCH = "x86_64" ]
-# then
-# echo You gots the 64.
-# fi
- echo "
-The Java bundle that is included with Processing supports only i686 by default.
-To build the code, you will need to install the Java 1.5.0_15 JDK (not a JRE,
-and not any other version), and create a symlink to the directory where it is
-installed. Create the symlink in the \"work\" directory, and named it \"java\":
-ln -s /path/to/jdk1.5.0_15 `pwd`/work/java"
- exit
- fi
+ ln -s "$(java-config -O)" work/java
fi
cd ../..
@@ -91,6 +73,11 @@
rm -rf ../build/linux/work/classes
mkdir ../build/linux/work/classes
+rm ../build/linux/work/lib/RXTXcomm.jar
+rm ../build/linux/work/lib/librxtxSerial.so
+ln -s /usr/share/rxtx-2/lib/RXTXcomm.jar ../build/linux/work/lib/
+ln -s /usr/lib/rxtx-2/librxtxSerial.so ../build/linux/work/lib/
+
../build/linux/work/java/bin/java \
-cp ../build/linux/work/java/lib/tools.jar \
com.sun.tools.javac.Main \
Now::
rm -rf work/
./make.sh
./run.sh
and I have the environment working! Actually working: I used the
results of these instructions to upgrade the firmware of both boards
on the CupCake_, and it worked perfectly.
.. _CupCake: http://wiki.makerbot.com/cupcake
.. _`MakerBot instructions`: http://wiki.makerbot.com/cupcake-motherboard-firmware-update
.. _crossdev: https://wiki.gentoo.com/wiki/Crossdev
.. _`hint found in a mailing list post`: https://www.mail-archive.com/avr-libc-dev@nongnu.org/msg03019.html
.. _Arduino: https://arduino.cc/
.. _`Arduino instructions`: https://code.google.com/p/arduino/wiki/BuildingArduino
.. _Sanguino: http://sanguino.cc/
.. _`Sanguino instructions`: http://sanguino.cc/softwareforlinux