About

Supporting the site

Setting up a VM

Tip: DroboSpace forum user jasch has been kind enough to create and host a VMWare version of the VM created using this tutorial. You can download the ready-to-use VM here (625 MB).

To port apps to the DroboFS or Drobo5N, the easiest way is to have a virtual machine configured just for the purpose of cross-compiling. This avoids messing up the configuration of your own machines, and prevents undesired upgrades (which could break dependencies).

For this tutorial, we are using VirtualBox. Any virtualization software could be used just as well.

The operating system chosen for the VM is Ubuntu Precise Pangolin (a.k.a. 12.04.2 LTS) 32-bit. In principle, any version of Linux can be used, since the cross compiling toolchain provides everything needed for compiling, and missing libraries will have to be compiled as needed. The choice of 32-bit is recommended over a 64-bit VM since, as the DroboFS and Drobo5N are 32-bit machines, keeping the same architecture does simplify some things.

The cross-compiling toolchain is provided by CodeSourcery. The choice of toolchain depends on the versions of libc (GLIBC) and libstdc++ (GLIBCXX).

The DroboFS ships with GLIBC 2.5 (libc-2.5.so) and GLIBCXX 3.4.9 (libstdc++.so.6.0.9). The corresponding toolchain is the one from 2007q1.

The Drobo5N ships with GLIBC 2.11.1 (libc-2.11.1.so) and GLIBCXX 3.4.13 (libstdc++.so.6.0.13). The closest match is the toolchain 2010.09-50. This is not a perfect match, though. The toolchain ships with GLIBCXX 3.4.14 (libstdc++.so.6.0.14), which may cause some C++ apps to complain about missing symbols. This is easily solved by including the flag -static-libstdc++, as explained below.

The DroboShare ships with GLIBC 2.3.6 (libc-2.3.6.so) and GLIBCXX 3.4.7 (libstdc++.so.6.0.7). The corresponding toolchain is the one from 2006q1.

We start by creating a VM in VirtualBox. This VM needs just a minimum amount of resources. I have chosen:

  1. RAM: 512 MB
  2. Video Memory: 8 MB
  3. Storage: 4 GB (8 GB if you plan on compiling a lot of apps)
  4. Network: 2 adapters; one "NAT" (eth0), one "Host-only adapter" (eth1)

We need 2 network interfaces to make our lives easier later on. The first interface (eth0) gives us internet access, while the second interface (eth1) gives us an easy way to connect to the VM later on.

We boot the VM using the Ubuntu Minimal CD image for Precise Pangolin (27 MB). From there, it is a straight full disk install, just make sure that the OpenSSH server is installed. At some point you'll have to chose a "primary network interface". Pick eth0.

Once the install is finished, remove the install CD image from the VM, and reboot. At the VM window, log in and edit /etc/network/interfaces and add these two lines at the end:

auto eth1
iface eth1 inet dhcp

Save the file, and restart the network interfaces by running:

sudo /etc/init.d/networking restart

Once that is done, run "ifconfig" and you'll get something like this:

ricardo@drobocompiler:~$ ifconfig 
eth0      Link encap:Ethernet  HWaddr 08:00:27:65:01:36  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe65:136/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14249 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3402 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:11899619 (11.8 MB)  TX bytes:186585 (186.5 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:c9:9c:0f  
          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fec9:9c0f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11963 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6340 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1788542 (1.7 MB)  TX bytes:1633872 (1.6 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Notice that the IP address of eth1 is 192.168.56.101. Now you can use a terminal instead of the VirtualBox console. The best reason to do so is that the Terminal actually allows you to copy and paste text, which will be very convenient in the future. To access the VM via SSH, type in a Terminal window on your hosting machine:

ssh <username>@<ip.address.of.eth1>

Now that we have SSH access to the VM, we can make some basic folder structure and add some necessary packages for cross-compiling:

sudo apt-get install autoconf autogen build-essential libtool pkg-config cmake bison flex cvs bzr git subversion nano
sudo mkdir -p /mnt/DroboFS/Shares/DroboApps
sudo chmod 777 /mnt/DroboFS/Shares/DroboApps
mkdir ~/bin ~/code
cd ~/code

Next up is the cross-compilation toolchain. This depends on the device. For the DroboFS, type:

wget https://sourcery.mentor.com/GNUToolchain/package1490/public/arm-none-linux-gnueabi/arm-2007q1-21-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
sudo tar -C /usr/local -jxf arm-2007q1-21-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

For the Drobo5N:

wget https://sourcery.mentor.com/GNUToolchain/package1600/public/arm-none-linux-gnueabi/arm-2010.09-50-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
sudo tar -C /usr/local -jxf arm-2010.09-50-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

For the DroboShare:

wget https://sourcery.mentor.com/GNUToolchain/package2727/public/arm-none-linux-gnueabi/arm-2006q1-6-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
sudo tar -C /usr/local -jxf arm-2006q1-6-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
sudo mv /usr/local/arm-none-linux-gnueabi /usr/local/arm-2006q1

Keep in mind that this toolchain for the Drobo5N uses the same GLIBC 2.11.1 as the 5N, but a slightly more recent GLIBCXX (3.4.14, whereas the 5N ships with 3.4.13). This not much of a problem, since this toolchain includes GCC 4.5.1 which supports the cflag "-static-libstdc++". In other words, first try to compile without the static linking of libstdc++, and if it fails to run, then try again with a static link.

Also for convenience, to compile for the DroboFS create the file ~/bin/crosscompile.drobofs.sh containing this:

export DROBO=fs
export TOOLCHAIN=/usr/local/arm-2007q1
export ARCH=armv5te
export PATH=$TOOLCHAIN/bin:$PATH
export CFLAGS="-march=${ARCH} -mtune=arm926ej-s"
export CC=$TOOLCHAIN/bin/arm-none-linux-gnueabi-gcc
export CXX=$TOOLCHAIN/bin/arm-none-linux-gnueabi-g++
export AR=$TOOLCHAIN/bin/arm-none-linux-gnueabi-ar
export RANLIB=$TOOLCHAIN/bin/arm-none-linux-gnueabi-ranlib
export STRIP=$TOOLCHAIN/bin/arm-none-linux-gnueabi-strip
export DROBOAPPS=/mnt/DroboFS/Shares/DroboApps

Before cross-compiling for the FS, type this:

. ~/bin/crosscompile.drobofs.sh

To compile for the Drobo5N, create the file ~/bin/crosscompile.drobo5n.sh containing this:

export DROBO=5n
export TOOLCHAIN=/usr/local/arm-2010.09
export ARCH=armv7-a
export PATH=$TOOLCHAIN/bin:$PATH
export CFLAGS="-march=${ARCH} -mcpu=cortex-a9 -mfpu=vfpv3-d16 -mfloat-abi=softfp"
export CC=$TOOLCHAIN/bin/arm-none-linux-gnueabi-gcc
export CXX=$TOOLCHAIN/bin/arm-none-linux-gnueabi-g++
export AR=$TOOLCHAIN/bin/arm-none-linux-gnueabi-ar
export RANLIB=$TOOLCHAIN/bin/arm-none-linux-gnueabi-ranlib
export STRIP=$TOOLCHAIN/bin/arm-none-linux-gnueabi-strip
export DROBOAPPS=/mnt/DroboFS/Shares/DroboApps

Before cross-compiling type this instead:

. ~/bin/crosscompile.drobo5n.sh

To compile for the DroboShare, create the file ~/bin/crosscompile.droboshare.sh containing this:

export DROBO=share
export TOOLCHAIN=/usr/local/arm-2006q1
export ARCH=armv5te
export PATH=$TOOLCHAIN/bin:$PATH
export CFLAGS="-march=${ARCH} -mtune=arm926ej-s"
export CC=$TOOLCHAIN/bin/arm-none-linux-gnueabi-gcc
export CXX=$TOOLCHAIN/bin/arm-none-linux-gnueabi-g++
export AR=$TOOLCHAIN/bin/arm-none-linux-gnueabi-ar
export RANLIB=$TOOLCHAIN/bin/arm-none-linux-gnueabi-ranlib
export STRIP=$TOOLCHAIN/bin/arm-none-linux-gnueabi-strip
export DROBOAPPS=/mnt/DroboFS/Shares/DroboApps

Before cross-compiling type this instead:

. ~/bin/crosscompile.droboshare.sh

Also create the file ~/bin/uncrosscompile.sh (which will remove the exports from the previous script) containing this:

export PATH=`echo $PATH | sed "s|$TOOLCHAIN/bin:||g"`
export -n DROBO
export -n TOOLCHAIN
export -n ARCH
export -n CFLAGS
export -n CXXFLAGS
export -n LDFLAGS
export -n CC
export -n CXX
export -n AR
export -n RANLIB
export -n STRIP

Finally, create the file ~/bin/package.sh, containing this:

#!/bin/sh
appname=`basename \`pwd\``
appfile="../${appname}.tgz"

if [ -f ${appfile} ]; then
  echo Removing old ${appfile}
  rm ${appfile}
fi

tar --numeric-owner --owner=0 --group=0 -czf ${appfile} *
echo New ${appfile} created

Finally, make the three scripts executable:

chmod a+x ~/bin/crosscompile*.sh ~/bin/uncrosscompile.sh ~/bin/package.sh

Congratulations! Your cross-compiling VM for the DroboFS is ready. Time to go over to the app repository to try out some of the HOWTOs.

Comments