User Tools

Site Tools


content:meshextender:prototyping_on_mp2

This is an old revision of the document!


Future availability of the Mesh Potato 2

The MP2.0 when available will have 16MB FLASH and 64MB RAM, 11 GPIO lines, and a USB port, making it ideal for prototyping the mesh helper.

But it isn't available yet …

Interim use of TP-LINK TL-WR703N + USB-connected Radio

In the meantime, we have some TP-LINK TL-WR703Ns (version 1.2 models according to their labels), which use the same Atheros 9331 chipset, but have only 4MB FLASH and 32MB RAM, a USB port and no 12v in capability – but still better than the Dragino.

The concept is to connect an Arduino-UNO or compatible board to the USB port, and connect the radio to that. We will then use the usual serial port interface on the Arduino to talk to it.

The TL-WR703N is well supported by OpenWRT: http://wiki.openwrt.org/toh/tp-link/tl-wr703n

Installing base OpenWRT on the WR703N

WARNING: The following can brick newer WR703Ns (Firmware 1.7, Ver:1.6 or Ver:1.7 etc on the bottom of the unit. Ver:1.2 is known to be safe). This is an issue with the OpenWRT firmware listed below. You can safely use these instruction with your own built OpenWRT distro, provided it is new enough. We will do that later.

Some more info on getting OpenWRT onto the WR703n can be found here:

http://daviddarts.com/piratebox-diy-openwrt/

This more or less boils down to:

  1. Plug in and boot WR703N
  2. Connect to it using an ethernet cable (it will offer you an IP address by DHCP)
  3. Browse to http://192.168.1.1. If Prompted, login as admin/admin
  4. Choose last menu item on the left.
  5. Choose 3rd menu item.
  6. Choose the file from the first step above and flash it.

You should now have OpenWRT on your WR703N.

Then login with telnet 192.168.1.1 and use passwd root to set a root password (just use root as the password to keep things easy while experimenting). Once you have set a root password, telnet will be disabled, and ssh will be enabled. Log in using ssh root@192.168.1.1 after that.

Enabling External USB Storage

The WR703N only has 4MB of flash, which is too small for a Serval or Commotion build. We use the USB port to solve this problem by connecting a USB memory stick. We are using 16GB ones.

You will need to install the following OpenWRT packages:

  • kmod-lib-crc16_3.3.8-1_ar71xx.ipk
  • kmod-scsi-core_3.3.8-1_ar71xx.ipk
  • kmod-usb-serial-cp210x_3.3.8-1_ar71xx.ipk
  • kmod-usb-serial-pl2303_3.8-rc3-1_ib42x0.ipk
  • kmod-usb-serial_3.3.8-1_ar71xx.ipk
  • kmod-usb-storage-extras_3.3.8-1_ar71xx.ipk
  • kmod-usb-storage_3.3.8-1_ar71xx.ipk
  • libuuid_2.21.2-1_ar71xx.ipk
  • libblkid_2.21.2-1_ar71xx.ipk
  • libcom_err_1.42.4-1_ar71xx.ipk
  • libpthread_0.9.33.2-1_ar71xx.ipk
  • libext2fs_1.42.4-1_ar71xx.ipk
  • e2fsprogs_1.42.4-1_ar71xx.ipk
  • fdisk_2.21.2-1_ar71xx.ipk

Because of the small flash size, you will need to scp them into /tmp/ which is a RAMfs. Note that there are some interdependencies here, so the order of installation will be different.

Install these packages, and if required reboot the 703. Then plug a USB memory stick in. Typing dmesg should show that it has been recognised, e.g., as sda:

45503.970000] USB Mass Storage support registered.
[45504.960000] scsi 0:0:0:0: Direct-Access     SanDisk  Cruzer Switch    1.26 PQ: 0 ANSI: 5
[45504.970000] sd 0:0:0:0: [sda] 31266816 512-byte logical blocks: (16.0 GB/14.9 GiB)
[45504.970000] sd 0:0:0:0: [sda] Write Protect is off
[45504.980000] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[45504.980000] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[45505.000000]  sda: sda1
[45505.010000] sd 0:0:0:0: [sda] Attached SCSI removable disk''

Next, use fdisk to partition the USB memory stick. Note that fsck requires about 1MB of RAM for every 1GB of partition size, so I recommend making a 1GB partition that will be used to replace /overlay on the router, and dividing the remaining space into partitions of a few GB each.

On our 16GB sticks I used 1GiB+7GiB+7GiB, the other GiB being missing due to the “marketing GB” differing from the binary GB. You might also like to make a partition for swap and/or /tmp

Then use mkfs.ext4 to create the file system(s), e.g. mkfs.ext4 /dev/sda1

Then uninstall the following packages to make space for the ext4 kernel module (yes, the space is that tight, but don't worry, we can put it back later):

opkg remove e2fsprogs

Now that you have enough space, install the following packages:

  • kmod-fs-ext4_3.3.8-1_ar71xx.ipk
  • blkid_2.21.2-1_ar71xx.ipk
  • swap-utils_2.21.2-1_ar71xx.ipk
  • block-mount_0.2.0-9_ar71xx.ipk

You should now be able to mount your 1GB partition that we will use for /overlay:

mount /dev/sda1 /mnt

Now run the following commands on the router (taken from http://blog.night-shade.org.uk/2013/01/more-storage-on-openwrt/):

tar -C /overlay -cvf - . | tar -C /mnt -xf -

uci add fstab mount
uci set fstab.@mount[-1].device=/dev/sda1
uci set fstab.@mount[-1].options=$options
uci set fstab.@mount[-1].enabled_fsck=0
uci set fstab.@mount[-1].enabled=1
uci set fstab.@mount[-1].target=/overlay
uci set fstab.@mount[-1].fstype=$fstype

mkdir /home
uci add fstab mount
uci set fstab.@mount[-1].device=/dev/sda2
uci set fstab.@mount[-1].options=$options
uci set fstab.@mount[-1].enabled_fsck=0
uci set fstab.@mount[-1].enabled=1
uci set fstab.@mount[-1].target=/home
uci set fstab.@mount[-1].fstype=$fstype

mkdir /serval
uci add fstab mount
uci set fstab.@mount[-1].device=/dev/sda3
uci set fstab.@mount[-1].options=$options
uci set fstab.@mount[-1].enabled_fsck=0
uci set fstab.@mount[-1].enabled=1
uci set fstab.@mount[-1].target=/serval
uci set fstab.@mount[-1].fstype=$fstype

uci commit fstab

/etc/init.d/fstab enable

Reboot and you should have 1GB in /overlay, mounted from USB, as well as large /home and /serval partitions.

Installing and setting up servald

In the short preparation time we have for KiwiEx, we have not had time to configure a single OpenWRT package that includes all setup, so the following recipe is required:

  1. Build yourself a serval ipk from our OpenWRT repository at https://github.com/servalproject/commotion-openwrt (more detailed instructions on doing this will be forthcoming – but the short story is use menuconfig to enable building of Serval as a module and then build it).
  2. Install librt_0.9.33.2-1_ar71xx.ipk
  3. Install the serval-*.ipk you built in step 1
  4. Install the following files in the described locations, and then reboot:

/etc/config/network

Change the IP address in this file from 29.167.164.237 to something random between 28.0.0.0 and 29.255.255.255

config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config interface 'lan'
	option ifname 'eth0'
#	option type 'bridge'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'

config interface public
	option proto 	static
	option ipaddr	192.168.100.1
	option netmask	255.255.255.0

config interface mesh
    option ifname wlan0-1
    option proto    static
      option ipaddr 29.167.164.237
    option netmask 254.0.0.0

/etc/config/wireless

Change the mac address 5c:63:bf:bb:41:90 to the mac address written on the back of the WR703N case.

config wifi-device radio0
        option type       mac80211
        option channel    6                           
        option hwmode     11ng
        option macaddr	5c:63:bf:bb:41:90
	option htmode	HT20
	list ht_capab	SHORT-GI-20
	list ht_capab	SHORT-GI-40
	list ht_capab	RX-STBC1
	list ht_capab	DSSS_CCK-40
                                                      
config wifi-iface mesh                                
        option device   radio0
        option ssid     mesh.servalproject.org        
        option network  mesh                          
        option mode     adhoc
        option bssid    02:ca:ff:dd:ca:ce             
        option bgscan   0                             
                                                      
config wifi-iface public                      
        option device     radio0
        option network    public              
        option mode       ap                  
        option isolate    0                   
        option ssid       public.servalproject.org
        option hidden     0                       
        option encryption none

/etc/rc.d/S41servald

Don't forget to chmod 755 this file once you have installed it

#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org

START=41

start() {
  # Start servald
  export SERVALINSTANCE_PATH=/etc/serval
  mkdir -p $SERVALINSTANCE_PATH
  servald start
}

stop() {
  export SERVALINSTANCE_PATH=/etc/serval
  servald stop
}

/etc/serval/servald.conf

rhizome.datastore_path=/serval
interfaces.1.type=catear
interfaces.1.dummy=/dev/ttyUSB0
interfaces.2.match=eth0
interfaces.2.type=ethernet
interfaces.3.type=wifi
interfaces.3.match=wlan0
interfaces.4.type=wifi
interfaces.4.match=wlan0-1

/etc/config/dhcp

config dnsmasq
	option domainneeded	1
	option boguspriv	1
	option filterwin2k	0  # enable for dial on demand
	option localise_queries	1
	option rebind_protection 1  # disable if upstream must serve RFC1918 addresses
	option rebind_localhost 1  # enable for RBL checking and similar services
	#list rebind_domain example.lan  # whitelist RFC1918 responses for domains
	option local	'/lan/'
	option domain	'lan'
	option expandhosts	1
	option nonegcache	0
	option authoritative	1
	option readethers	1
	option leasefile	'/tmp/dhcp.leases'
	option resolvfile	'/tmp/resolv.conf.auto'
	#list server		'/mycompany.local/1.2.3.4'
	#option nonwildcard	1
	#list interface		br-lan
	#list notinterface	lo
	#list bogusnxdomain     '64.94.110.11'

config dhcp lan
	option interface	lan
	option start 	100
	option limit	150
	option leasetime	12h

config dhcp public
        option interface	public
	option start 	50
	option limit	250
	option leasetime	12h

USB Serial Port Drivers on OpenWRT

CP210x

CP2012 datasheet is at http://www.silabs.com/products/interface/usbtouart/Pages/usb-to-uart-bridge.aspx

Follow that, and install the CP210x USB serial adapter drivers from http://downloads.openwrt.org/attitude_adjustment/12.09-beta2/ar71xx/generic/packages/

You will need kmod-usb-serial-cp210x_3.3.8-1_ar71xx.ipk and kmod-usb-serial_3.3.8-1_ar71xx.ipk or similar. Use scp to copy these onto your 703, and then use:

opkg install kmod-usb-serial_3.3.8-1_ar71xx.ipk opkg install kmod-usb-serial-cp210x_3.3.8-1_ar71xx.ipk

FTDI

Yet to be explored.

USB Serial Port Drivers on OSX

CP210x

On OSX to use the SiLabs CP2012 USB adapters on mac, you need to install the drivers from http://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx

Install those, and the USB to serial adapter works on the mac.

FTDI

Powering the WR703N & Radio

Whether using the TL-WR703N, we should use a better voltage regulator to tolerate the 12v - 15v we can expect to see on the LiFePO4 batteries. Jaycar sell such a kit for AUD$7.95 that can provide 5V @ 1A, which should be enough, and is quite easy to build: http://www.jaycar.com.au/productView.asp?ID=KA1797

The TL-WR703N itself uses <1W with nothing connected to the USB port, leaving 4W for the radio and USB memory stick for Rhizome mass storage, which should be enough. Once we get the MP2.0's, they will power themselves and the USB mass storage, leaving all 1A for the Arduino and radio.

The RFD900 radio can use 4W on its' own, so a separate 5v 1A supply is probably a good idea. Our solution for now is to use two of the KA1797 kits.

Arduino Hardware

For the Arduino, we want one that can plug in the USB port, because that is easiest. However, the availability of radio hardware that supports TTL serial with nice firmware, we can skip the Arduino for now. See below for discussion of the radio hardware.

Radio Hardware

Talking with Tridge @ #LCA2013, there is a nice radio that he has already written point-to-point firmware for, that could be easily integrated with the TL-WR703N via a USB to TTL serial adapter.

The radio units are the http://rfdesign.com.au/index.php/rfd900

At Make.Hack.Void in Canberra started testing this with some of Tridge's gear.

We now have a convenient way to test the radios on both Mac and on the WR703N itself, which will allow fairly easy development and integration with servald.

Have ordered an RFD900 bundle from rfdesign.com.au, with a couple of the FTDI brand USB/TTL converters that they supply, just to get things started smoothly. Then once the CP2012s arrive (probably in 3 - 5 weeks), we can use those on future units.

Interfacing with the RFD900 Radios via FTDI on OSX

For ease of development, we will plug the RFD900 into a USB port on a mac, where it will appear as a serial port. On my mac, my first RFD900 shows up as /dev/tty.usbserial-A1011UQN

We can talk to the radio module using something like:

sudo cu -l /dev/tty.usbserial-A1011UQN -s 57600

And then entering +++ to drop to the AT command prompt of the modem. AT commands are the same as listed at http://code.google.com/p/ardupilot-mega/wiki/3DRadio

After plugging both radios in, they synchonised in a few seconds, and I was able to use the AT&T=RSSI to get a running report on the RSSI output from the radio.

With the radio TX power set to +20dbm and +2.1db stub antennae RSSI results were 217 for both left and right antennae, and the noise floor was usually in the range 50 – 60 in my house in suburban Adelaide.

These units are are approximately 0.5dB, where 25 probably somewhere around -121dBm. In my case, the link budget is about 157 RSSI. Using the more accurate formula from the 3Dradio, the RSSI corresponds to -12.8dBm, and the noise floor to -95.4dBm, for a link budget of 82.6dBm.

As the radios are about 30cm apart on my desk, and each 6.02dB allows a doubling of range, this suggests a maximum range of about 30cm x 2^13.7 = 30cm x 13300, or about 4km. The antenna gain is only +2.1dB, so we could increase TX power by another 7dB, which should double the range to around 8km, assuming clear line of sight – which is pretty good for a 1W radio in a suburban area. A lower noise floor could easily increase range to a few tens of kilometres. This is pretty exciting for enabling long-range mesh communications, especially when compared with WiFi's suburban range of <160m.

So the next step is to modify servald to be able to use the radios as a link, and then get it working on the 703N.

For servald, it will be fairly easy to patch the dummynet driver that already reads and writes to an ordinary file. We will just need to implement flow control/throttling, and packet encapsulation in case of communications errors.

Configuring RFD900 Radios for use

Connect as described above and set air speed to 250kbit, and serial speed to 57600, and TX power to +24dBm with a command sequence like:

ATS1=57
ATS2=250
ATS4=24
ATI5
AT&W

(We could use 115200, but that would require a recompile of servald, which currently assumes radios at 57600, and the gain would be small, because 250k/2=115kbit total bandwidth, shared among both ends gives 57600 for each end.)

content/meshextender/prototyping_on_mp2.1360824837.txt.gz · Last modified: 13/02/2013 22:53 by Paul Gardner-Stephen