Easy TinyOS development on a Virtual Machine


Install VirtualBox, the appropriate VirtualBox Extension Pack and Vagrant.

You will also need to install the vagrant plugin vagrant-vbguest. It will automatically install the new guest additions into the VM.

$ vagrant plugin install vagrant-vbguest

Create a Vagrantfile file with the contents below on your project folder or another convenient place. We are using Ubuntu Server 12.04 32 bits.

$script = <<SCRIPT
TOSADDR="deb natty main"
echo $TOSADDR | tee -a $TOSPROD

apt-get update -q
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confdef" \
                                       -o Dpkg::Options::="--force-confold" \
                                       -qy dist-upgrade
apt-get install tinyos-2.1.2 tinyos-tools msp430-46 \
                g++ python-dev nesc vim -qy --force-yes

read -d '' PROFILE_SNIPPET <<"EOF"
export TOSROOT=/opt/tinyos-2.1.2
export TOSDIR=$TOSROOT/tos
export CLASSPATH=$CLASSPATH:$TOSROOT/support/sdk/java/tinyos.jar
export MAKERULES=$TOSROOT/support/make/Makerules
export PATH=/opt/msp430/bin:$PATH
echo "$PROFILE_SNIPPET" | tee -a /home/vagrant/.profile

chown vagrant:vagrant  -R /opt/tinyos-2.1.2/
gpasswd -a vagrant dialout

Vagrant.configure(2) do |config| = 'hashicorp/precise32'
  config.ssh.forward_agent = true

  config.vm.provider 'virtualbox' do |vb|
    vb.gui = true

  config.vm.provision 'shell', inline: $script

We are now ready to spin up the VM. If this is your first time using the hashicorp/precise32 box it’ll take a little while to download it.

$ vagrant up

Login into the provisioned VM and test a few builds

$ cd /opt/tinyos-2.1.2/apps/RadioCountToLeds/
$ make iris
    writing TOS image
$ make iris sim
*** Successfully built iris TOSSIM library.

When the VM is launched a standard VirtualBox GUI is launched, use it to attach the USB devices from the host to the guest machine. Hack on!