Friday, February 13, 2015

Contiki and Z1

platform/z1/contiki-conf.h: change UIP_CONF_BUFFER_SIZE to 240 (from 140)

make z1-reset
make login

...to be continued

Quick Start: gnuplot - multiline graph

- Download and install gnuplot: http://www.gnuplot.info
- Creat a file data.txt:

Time    TX    RX    Total
1    0.00%    0.95%    0.95%
2    0.00%    1.03%    1.03%
3    0.09%    0.83%    0.92%
4    0.09%    1.09%    1.17%
5    0.00%    0.69%    0.69%
6    0.09%    1.07%    1.16%
7    0.00%    1.02%    1.02%
8    0.09%    1.15%    1.25%
9    0.09%    0.85%    0.94%
10    0.00%    0.92%    0.92%
11    0.18%    0.98%    1.16%
12    0.18%    1.19%    1.37%
13    0.18%    1.36%    1.54%
14    0.23%    1.30%    1.52%
15    0.00%    0.89%    0.89%
16    0.09%    1.17%    1.26%
17    0.09%    1.26%    1.35%
18    0.00%    1.13%    1.13%
19    0.18%    1.28%    1.46%
20    0.09%    0.84%    0.93%

- Run in gnuplot>

set xlabel 'Time (s)'
set ylabel 'Duty Cycle (%)'
set yrange [0:2]
set xrange [1:20]
set key autotitle columnheader
plot "data.txt" u 1:2 w linespoints lt -1 pt 5 dt 5, '' u 1:3 w linespoints lt -1 pt 4 dt 2, '' u 1:4 w linespoints lt -1 pt 3

- Output

Tuesday, August 19, 2014

Quickstart: Raspbian (Raspberry Pi) Common Errors

-  FAT-fs (mmcblk0p1): Volume was not properly unmounted

Reason: (http://lkml.org/lkml/2013/5/6/342) dosfstools should be at least v3.0.14, the current version is: 3.0.13-1
How to: (http://www.tuxlog.de/raspberrypi/2014/raspberry-pi-volume-not-properly-unmounted/)

sudo umount /boot
sudo git clone http://daniel-baumann.ch/git/software/dosfstools.git
sudo cd dosfstools
sudo make
sudo ./fsck.fat -V /dev/mmcblk0p1

0x25: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.
1) Remove dirty bit
2) No action
? 1

sudo ./fsck.fat -a /dev/mmcblk0p1
sudo mount /boot

(Updating...)

Monday, June 2, 2014

Border Router with Raspberry Pi for LLN with TelosBs

This tutorial aims to create a IPv6 Low-power and Lossy Network (LLN) of TelosB motes with a Rapsberry Pi (RPi) as a border router (LBR) to connect to other IPv6 networks. RPi is configured for routing traffic from the LLN to other IPv6 networks by creating a TUN network interface. An alternative to setup a LLN is to configure a bridge (TAP) as in Cetic-6LBR (https://github.com/cetic/6lbr/)

We are going to have two IPv6 networks associated to two network interfaces of the LBR RPi as shown in Fig.1.

Fig.1: Deployment


LBR
- eth0: bbbb::1/64 (Physical Ethernet interface to normal IPv6 network)
- tun0: aaaa::1/64 (TUN interface to LLN)

IPv6 Network:
- bbbb::2

LLN:
- aaaa::212:7400:13cb:44 (slip-radio)
- aaaa::212:7400:13cb:101a
- aaaa::212:7400:13ca:f3ac

1. LLN Network (see here)

- Flash radio-slip mote (contiki-2.7/examples/ipv6/slip-radio) to use as an IEEE 802.15.4 interface
- Flash other TelosB for LLN nodes (e.g., contiki-2.7/examples/ipv6/udp-server)

2. IPv6 Network
- Configure a machine with bbbb::/64 address (example with a Linux)
# sudo vi /etc/network/interfaces
auto eth0
iface eth0 inet6 static
address bbbb::2
netmask 64
gateway bbbb::100 (border router address)

(you may need to deactivate other network interfaces to check if it works properly)

3. RPi Border Router
Prepare RPi OS
- Download Raspbian

- Create a boot disk using SD card (>4G) using Win32 DiskImager
(Check here for Raspbian essentials)

- Plug radio-slip mote to RPi, recognized as /dev/ttyUSB0

- Enable IPv6 module?

# sudo modprobe ipv6
or to automatically enable it at boot, add ipv6 on a line at the end of /etc/modules.

- Enable IPv6 forwarding
# sudo sysctl -w net.ipv6.conf.all.forwarding=1

or edit /etc/sysctl.conf uncomment the line: net.ipv6.conf.all.forwarding=1

- Configure IPv6 address for eth0
# sudo vi /etc/network/interfaces
auto eth0
iface eth0 inet6 static
address bbbb::1
netmask 64

- Download contiki-2.7 source
- Go to examples/ipv6/native-border-router
- Fix source and build 
# vi border-router.c, line 161: remove ; (contiki 2.7 bug)
# vi slip-config.c, line 76: change -1 to 255 (RPi kernel??)
# make

- Run border router
# sudo modprobe ipv6 (optional)
# sudo sysctl -w net.ipv6.conf.all.forwarding=1 (optional)
# sudo ./border-router.native -L -v6 aaaa::1/64 (debug, ttyUSB0, 115200)

Autostart the border-router.native by adding it to /etc/rc.local (optional)
path_to_border-router.native aaaa::1/64

ex: /home/pi/contiki-2.7/examples/ipv6/native-border-router/border-router.native aaaa::1/64 &

4. Test

From IPv6 network computer ping to LLN
Ping: ping6 aaaa::212:7400:13cb:101a
Web browser: aaaa::212:7400:13cb:44

Thursday, May 29, 2014

Quickstart: Raspbian (Raspberry Pi) Essentials

Prepare booting SD card
SD card > 4G, http://www.raspberrypi.org/documentation/installation/installing-images/README.md

Example with Raspbian
- Download: http://downloads.raspberrypi.org/raspbian_latest
- Download the Win32DiskImager utility from Sourceforge Project
- Make booting SD card from the downloaded image using Win32DiskImager

USB Serial Console (no need a monitor and keyboard)
https://learn.adafruit.com/adafruits-raspberry-pi-lesson-5-using-a-console-cable/overview


VNC Server
http://elinux.org/RPi_VNC_Server

Youtube player
https://pypi.python.org/pypi/whitey

Enable IPv6
Easy. sudo modprobe ipv6 will enable it immediately. If you want it to automatically be enabled at boot, just add ipv6 on a line by itself at the end of /etc/modules.  

Tips
- SD card will appears in Windows only with its boot partition, which is few hundred kb
- If Ethernet doesn't work, check power source using official cable