Skip to content

Building Instant Sparrow

Niclas Finne edited this page Mar 31, 2017 · 5 revisions

This page describes the steps how to build a new Instant Sparrow from scratch and how to update relevant parts.

Guide for creating a VMWare image with Ubuntu Desktop 16.04

Download Ubuntu Desktop 16.04 64-bit version from Ubuntu. It is possible to use 32-bit version and it might be easier to find some pre-compiled toolchains and use Cooja on 32-bit systems but 64-bit systems has other advantages such as use of more memory. This guide assumes a 64-bit system.

Create a new VMWare image in VMWare with at least 10 GB disk and select the downloaded Ubuntu Desktop image as start media. The user name and password for Instant Sparrow is usually set to user / user. VMWare should then be able to use easy install to finish installing Ubuntu in the VMWare image.

After the installation is done, update the system to latest version but do not upgrade to new release (dist-upgrade).

> sudo apt update
> sudo apt upgrade

Install development tools for Sparrow

> sudo apt install build-essential libncurses5-dev doxygen git curl mg wireshark
> sudo apt install lib32z1
> sudo apt install cmake autoconf python-serial
> sudo apt install emacs
> sudo usermod -a -G wireshark user

Install ARM compiler

An ARM compiler is needed to compile for ARM-based platforms such as Felicia and Zoul. Sparrow has been tested with ARM Embedded 6.2.1.

> sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
> sudo apt update
> sudo apt install srecord gcc-arm-embedded

Install MSP430 compiler

A compiler for MSP430 is needed to use the Cooja network simulator in Sparrow. It is possible to install a GCC compiler for MSP430 from the Ubuntu package repository but that version is too old to support the full memory of newer versions of MSP430. Instructions to compile MSP430 GCC 4.7.2 can be found here. Currently the instructions do not seem to be updated for newer versions of Ubuntu but it is possible to compile in an older version of Ubuntu and copy the binaries.

If there is no need to use the full memory of newer MSP430 CPUs, an older version of MSP430 GCC can be installed from the package repositories.

> sudo apt install gcc-msp430

Install Java for the Cooja network simulator

> sudo apt install default-jdk
> sudo apt install ant

Cooja needs to have the environment variable JAVA_HOME set to work with native Contiki nodes.

> update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Nothing to configure.

Set JAVA_HOME with the path found above in .profile

> mg ~/.profile

Add the following line:

export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"

Save with ctrl-x ctrl-s, exit with ctrl-x ctrl-c.

Install JTAG software for CC2538 (optional)

Many platforms such as Zolertia Zoul can be programmed via builtin USB but for programming a device using a JTAG dongle, Segger J-Link has been verified to work well with CC2538. The software for Segger J-Link can be downloaded from Segger. Download the installation file for Debian Linux.

> sudo dpkg --install jlink_4.98.5_i386.deb

Install Copper in Firefox for CoAP

Start Firefox and install the addon Copper (https://addons.mozilla.org/en-US/firefox/addon/copper-270430/). This will allow Firefox to open coap links.

Configure Instant Sparrow

User access to USB

To be able to access the USB without using sudo, the user should be part of the groups plugdev and dialout.

> sudo usermod -a -G plugdev $USER
> sudo usermod -a -G dialout $USER

Improve stability for CC2538

The modem manager might interfere with the USB for CC2538.

  1. Edit /lib/udev/rules.d/77-mm-usb-device-blacklist.rules
> sudo mg /lib/udev/rules.d/77-mm-usb-device-blacklist.rules
  1. Add the following line
ATTRS{idVendor}=="0451", ATTRS{idProduct}=="16c8", ENV{ID_MM_DEVICE_IGNORE}="1"
  1. Save with ctrl-x ctrl-s, exit with ctrl-x ctrl-c

Aliases

Optionally add .bash_aliases

> cat >>~/.bash_aliases
alias cp='cp -i'
alias rm='rm -i'
alias mv='mv -i'
[end by pressing ctrl-d]

Set host name

Optionally change the default host name from ubuntu to sparrow.

> sudo hostnamectl set-hostname sparrow

Add the new host name in /etc/hosts if it does not already exist.

After configuration

Reboot the system after all configurations have been made.

Clone Sparrow

> git clone --recursive https://github.com/sics-iot/sparrow.git

Cleaning up and compressing the VMWare image for distribution

Remove unnecessary packages to free disk space

Some packages are not needed for a development system and can be removed to free disk space.

> sudo apt remove --purge libreoffice*
> sudo apt remove --purge shotwell*
> sudo apt remove --purge eog totem
> sudo apt remove --purge transmission-gtk thunderbird remmina
> sudo apt remove --purge usb-creator-gtk
> sudo apt remove --purge imagemagick*
> sudo apt remove --purge rhythmbox*
> sudo apt remove --purge cheese
> sudo apt remove --purge gnome-mahjongg gnome-sudoku aisleriot gnome-mines
> sudo apt autoremove
> sudo apt clean

Remove old kernels to free disk space

If the system has been recently updated it should be restarted before continuing. Then run the following command to see which kernel is running.

> uname -r

That is the kernel that must not be removed. The following command lists all kernels.

> dpkg --list | grep linux-image

If there is an older unused kernel, it can be removed with the following command. Note: if a used kernel is removed, the system might not boot again.

> sudo apt remove --purge linux-image-XXXXX-generic

Clear free disk space

By clearing the free disk space, the VMWare image can be compressed better.

> cat /dev/zero >zeroes
> rm -f zeroes

Compress the VMWare image

Power down the Ubuntu in the VMWare image. Make sure it is a real power shutdown and not a hibernation. Remove the log files from the VMWare directory and then compress the VMWare image. 7z is very good at compressing VMWare images and is available on most platforms.

> 7za a -mx9 -r InstantSparrow.7z InstantSparrow

Updating Instant Sparrow

Updating Linux

> sudo apt update
> sudo apt upgrade

Updating Sparrow

> cd sparrow
> git fetch origin
> git merge origin/master

Updating Sparrow submodules

> cd sparrow
> git submodule update --remote apps/tinydtls