Sunday, July 25, 2010

R runs on the Beagleboad & BeagleTouch!

On Wednesday, in the library, Chris and I talked about how impossible it would be to port R to the Beagleboard platform, given all the insane dependencies on obscure libraries, some java based, some fortran based, you name it.

On Thursday, I read Karim's most recent article with Ned Gulley called, "The Determinants of Individual Performance and Collective Value in Private-Collective Software Innovation". Naturally, this wasn't a wiki-like contest, but there sure was plenty of reuse (R is an established platform), code recombination (Chris + Will + Koen + Mine). In this case, however, I suppose you could say the goal was to increase the "free-rider" problem. That, or I just think it's cool to have a portable R-based gadget. :-)

Ps, totally random aside, this graph is awesome, it proves that multiple people working together for a common good get a lot farther than any one person by themselves (obviously this is true, but this is quantitative, numerical evidence):

On Friday, I posted a quick blog article about porting R to the Beagle & Angstrom platform. Chris thought it would be very difficult, I thought it would be impossible, and so I offered $1,000 to anyone that could help.

On Saturday, I got about a dozen emails, and 3 folks who said they were going to try (4 if you include me, since I figured maybe I could do it after all).

On Sunday, I got an email from Koen with the following picture, and code screenshot printout:

Total elapsed time since blog post: less than 36 hours

Naturally, I wanted to make sure I could replicate it myself, and so I was able to run the following commands on the BeagleBoard (with a wifi internet connection up and running):


opkg install

opkg install

opkg update

opkg upgrade


opkg install -force-depends ./r_2.11.1-r0.5_armv7a.ipk

opkg bash

And then I popped it up, and got this:

2shay, Koen :-)

UPDATE: I just Googled around, and there was apparently also another possible solution, cooked up by HNS, although technically not doable with Angstrom (which is critical given some of the drivers and whatnot I've patched into my version of Angstrom), it gets R up and running with Debian:

---Copied from the mailing list---

Does this qualify as well?

Install Debian Lenny, u-boot and a kernel on a SD card from

boot and login. Make sure the host works as a internet router.

Linux bb-debian 2.6.32 #48 PREEMPT Tue Jun 8 14:21:52 CEST 2010 armv7l

The programs included with the Debian GNU/Linux system are free
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Jul 23 12:48:05 2010 from
bb-debian:~# apt-get install r-base
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libgfortran3 libpaper-utils libpaper1 r-base-core r-cran-boot r-cran-
cluster r-cran-codetools r-cran-foreign r-cran-kernsmooth r-cran-
lattice r-cran-mgcv r-cran-nlme r-cran-rpart r-cran-survival r-cran-vr
r-recommended tk8.4
unzip zip
Suggested packages:
ess r-doc-info r-doc-pdf r-doc-html r-mathlib
Recommended packages:
r-base-html r-base-latex r-base-dev
The following NEW packages will be installed:
libgfortran3 libpaper-utils libpaper1 r-base r-base-core r-cran-boot
r-cran-cluster r-cran-codetools r-cran-foreign r-cran-kernsmooth r-
cran-lattice r-cran-mgcv r-cran-nlme r-cran-rpart r-cran-survival r-
cran-vr r-recommended
tk8.4 unzip zip
0 upgraded, 20 newly installed, 0 to remove and 1 not upgraded.
Need to get 18.2MB of archives.
After this operation, 64.3MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 stable/main libgfortran3 4.3.2-1.1 [211kB]
Get:2 stable/main libpaper1 1.1.23+nmu1 [21.9kB]
Get:3 stable/main libpaper-utils 1.1.23+nmu1 [18.3kB]
Get:4 stable/main zip 2.32-1 [110kB]
Get:5 stable/main unzip 5.52-12 [163kB]
Get:6 stable/main tk8.4 8.4.19-2 [1022kB]
Get:7 stable/main r-base-core 2.7.1-1+lenny1 [11.0MB]
Get:8 stable/main r-cran-boot 1.2.33-1 [458kB]
Get:9 stable/main r-cran-cluster 1.11.11-1 [343kB]
Get:10 stable/main r-cran-foreign 0.8.27-1 [154kB]
Get:11 stable/main r-cran-vr 7.2.42-1 [971kB]
Get:12 stable/main r-cran-kernsmooth 2.22.22-1 [51.7kB]
Get:13 stable/main r-cran-lattice 0.17-10-1 [598kB]
Get:14 stable/main r-cran-mgcv 1.4-1-1 [658kB]
Get:15 stable/main r-cran-nlme 3.1.89-1 [1346kB]
Get:16 stable/main r-cran-survival 2.34-1-1 [833kB]
Get:17 stable/main r-cran-rpart 3.1.41-1 [160kB]
Get:18 stable/main r-cran-codetools 0.2-1-1 [39.8kB]
Get:19 stable/main r-recommended 2.7.1-1+lenny1 [2208B]
Get:20 stable/main r-base 2.7.1-1+lenny1[29.7kB]

Fetched 18.2MB in 21s (842kB/ s)

debconf: delaying package configuration, since apt-utils is not installed
Selecting previously deselected package libgfortran3.
(Reading database ... 25829 files and directories currently installed.)
Unpacking libgfortran3 (from .../libgfortran3_4.3.2-1.1_armel.deb) ... Selecting previously deselected package libpaper1.
Unpacking libpaper1 (from .../libpaper1_1.1.23+nmu1_armel.deb) ... Selecting previously deselected package libpaper-utils.
Unpacking libpaper-utils (from .../libpaper- utils_1.1.23+nmu1_armel.deb) ...
Selecting previously deselected package zip.
Unpacking zip (from .../archives/zip_2.32-1_armel.deb) ...
Selecting previously deselected package unzip.
Unpacking unzip (from .../unzip_5.52-12_armel.deb) ...
Selecting previously deselected package tk8.4.
Unpacking tk8.4 (from .../tk8.4_8.4.19-2_armel.deb) ...
Selecting previously deselected package r-base-core.
Unpacking r-base-core (from .../r-base-
core_2.7.1-1+lenny1_armel.deb) ...
Selecting previously deselected package r-cran-boot.
Unpacking r-cran-boot (from .../r-cran-boot_1.2.33-1_all.deb) ...
Selecting previously deselected package r-cran-cluster.
Unpacking r-cran-cluster (from .../r-cran-
cluster_1.11.11-1_armel.deb) ...
Selecting previously deselected package r-cran-foreign.
Unpacking r-cran-foreign (from .../r-cran-
foreign_0.8.27-1_armel.deb) ...
Selecting previously deselected package r-cran-vr.
Unpacking r-cran-vr (from .../r-cran-vr_7.2.42-1_armel.deb) ...
Selecting previously deselected package r-cran-kernsmooth.
Unpacking r-cran-kernsmooth (from .../r-cran-
kernsmooth_2.22.22-1_armel.deb) ...
Selecting previously deselected package r-cran-lattice.
Unpacking r-cran-lattice (from .../r-cran-
lattice_0.17-10-1_armel.deb) ...
Selecting previously deselected package r-cran-mgcv.
Unpacking r-cran-mgcv (from .../r-cran-mgcv_1.4-1-1_armel.deb) ...
Selecting previously deselected package r-cran-nlme.
Unpacking r-cran-nlme (from .../r-cran-nlme_3.1.89-1_armel.deb) ...
Selecting previously deselected package r-cran-survival.
Unpacking r-cran-survival (from .../r-cran-
survival_2.34-1-1_armel.deb) ...
Selecting previously deselected package r-cran-rpart.
Unpacking r-cran-rpart (from .../r-cran-rpart_3.1.41-1_armel.deb) ...
Selecting previously deselected package r-cran-codetools.
Unpacking r-cran-codetools (from .../r-cran-
codetools_0.2-1-1_all.deb) ...
Selecting previously deselected package r-recommended.
Unpacking r-recommended (from .../r-
recommended_2.7.1-1+lenny1_all.deb) ...
Selecting previously deselected package r-base.
Unpacking r-base (from .../r-base_2.7.1-1+lenny1_all.deb) ...
Setting up libgfortran3 (4.3.2-1.1) ...
Setting up libpaper1 (1.1.23+nmu1) ...

Creating config file /etc/papersize with new version
Setting up libpaper-utils (1.1.23+nmu1) ...
Setting up zip (2.32-1) ...
Setting up unzip (5.52-12) ...
Setting up tk8.4 (8.4.19-2) ...
Setting up r-base-core (2.7.1-1+lenny1) ...
Setting R_PAPERSIZE_USER default to 'a4'

Creating config file /etc/R/Renviron with new version
Setting up r-cran-boot (1.2.33-1) ...
Setting up r-cran-cluster (1.11.11-1) ...
Setting up r-cran-foreign (0.8.27-1) ...
Setting up r-cran-vr (7.2.42-1) ...
Setting up r-cran-kernsmooth (2.22.22-1) ...
Setting up r-cran-lattice (0.17-10-1) ...
Setting up r-cran-mgcv (1.4-1-1) ...
Setting up r-cran-nlme (3.1.89-1) ...
Setting up r-cran-survival (2.34-1-1) ...
Setting up r-cran-rpart (3.1.41-1) ...
Setting up r-cran-codetools (0.2-1-1) ...
Setting up r-recommended (2.7.1-1+lenny1) ...
Setting up r-base (2.7.1-1+lenny1) ...
bb-debian:~# R

R version 2.7.1 (2008-06-23)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> x <- c(10.4, 5.6, 3.1, 6.4, 21.7)
> y <- c(x, 0, x)
> 1/x

[1] 0.09615385 0.17857143 0.32258065 0.15625000 0.04608295
> q()

Save workspace image? [y/n/c]: n
bb-debian:~# uname -a
Linux bb-debian 2.6.32 #48 PREEMPT Tue Jun 8 14:21:52 CEST 2010 armv7l
bb-debian:~# cat /proc/cpu
cat: /proc/cpu: Is a directory
bb-debian:~# cat /proc/cpuinfo
Processor : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 696.20
Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x1
CPU part : 0xc08
CPU revision : 3

Hardware : OMAP3 Beagle Board
Revision : 0020
Serial : 0000000000000000


Matt said...

technically the last command you have to run is "R"

Matt said...

There's also another solution, which was discussed on the Beagle googlegroup mailing list using Debian Lenny, by HNS

Anonymous said...

Haste makes waste...................................................

Unknown said...

Debian is still compiled for armv4t without floating point support, so R will be dreadfully slow.