Atmel AVR2070 User Manual

AVR2070: Route Under MAC (RUM) with IPv6
and 6LoWPAN

Features

A FREE 802.15.4 networking solution
- Multi-hop Route Under MAC (RUM)
- Many AVR
Completely Customizable Firmware
- Ready to use as the basis for a wireless product
- Standalone MAC data layer for small memory footprint
- Optional IPv6/6LoWPAN Interface layer provides worldwide wireless
connectivity over the IPv6 internet
®
microcontrollers supported

1 Introduction

Wireless Sensor Networks (WSN) have become a low power, low cost means for communicating data between sensor devices dispersed over an area. Many of these applications call for small embedded wireless networking solutions to substantially reduce the cost of all required components. Atmel MAC (RUM) with support for IPv6 and 6LoWPAN is a highly flexible stack solution for these low cost applications. Providing Internet Protocol (IP) over low power, low data rate wireless transceivers enables immediate interoperability with existing wired networks. With an IPv6 foundation, each wireless node on the network can be given a worldwide unique IPv6 address and directly communicate with any other IPv6 device in the world without the need for any translation or a complex gateway.
TM
transceivers supported
®
’s Route Under
MCU Wireless Solutions
Application Note
Free to Atmel customers, the Atmel RUM/6LoWPAN networking stack proves to be a ready and cost-effective solution for Wireless Sensor Networks.
Rev. 8240B-AVR-06/09

2 Stack Architecture

Route Under Mac (RUM) is a small 802.15.4 protocol developed by Atmel. This protocol routes packets at the MAC layer, as opposed to the application or IPv6 layer, which would be a route over scheme. The under comes from the fact that routing is done at a low level. This has a number of advantages:
Routers and end nodes can be simpler, and therefore less expensive. These nodes manage almost no routing information.
The coordinator knows all pertinent information about every node in its PAN, which means special “guessing” routing algorithms are not needed.
Higher level code does not have to be concerned with routing, and has only to send a packet to a destination address.
The main components of the stack include RUM, and IPv6 / 6LoWPAN. The complete stack features the following highlights:
Small object size. A minimal build, with only RUM and a tiny example application, is about 6KB for an AVR end node.
Self-forming network. Nodes power up, find a network, and associate to it.
Self-healing network. Nodes re-associate upon a failure to communicate.
Multi-hop routing. Nodes can be multiple hops away from the coordinator.
Source Code Included. Free for use and free to modify if used with Atmel
hardware.
Designed to be a base platform for customer applications.
Very configurable, with the ability to add or remove features at compile time.
Features include 6LoWPAN frames, end node sleeping, and a terminal mode.
Portable to almost any Atmel processor.
Figure 2-1 RUM Architecture
2
AVR2070
8240B-AVR-06/09

2.1 Overview of RUM

A RUM network is constructed around a coordinator. The coordinator is the only node that keeps any state information about the network, so that the other nodes do not have to store any network information. This allows for low cost hardware for both routers and end-nodes which comprise the bulk of the network. A router can act as a multi-hop intermediary for other nodes, while an end node can attach to a network, but cannot associate child nodes. Any node is usable as a data node or actuator.
The network is organized as a tree, with the coordinator having a number of associated nodes as children, and router nodes having their own associated children as well. Each node has exactly one parent, which is also the node's link to every other part of the network.
Figure 2-2 RUM Tree Topology Example
AVR2070
Appendix A contains a detailed description of the RUM protocol.

2.2 Overview of IPv6 and 6LoWPAN

The features of IPv6 and 6LoWPAN allow the RUM coordinator to act as an edge router in the worldwide network. The full functionality of these features are best utilized on the AT91SAM7X-EK development kit which provides an Ethernet connection. This application setup is described in section 4.
Any wireless node connected to the coordinator/edge router will obtain a unique IPv6 address based on its RUM short address. Depending on the application, the wireless node can then report sensor data directly to the coordinator/edge router, some other server or IPv6 addressable device via the IPv6 internet connection. This node can also receive commands when necessary based on application software.
More details about the interaction between RUM/6LoWPAN can be found in Appendix C.
8240B-AVR-06/09
3

2.3 Supported Hardware Platforms

The RUM software distributed with this application note can run on a variety of platforms. The PLATFORM keyword defines several parameters about a board. An example of these parameters is:
Which microcontroller is present on the platform board?
How the microcontroller is connected to the transceiver – which radio pins
connect to which port pins on the microcontroller.
Any ADC connections to the microcontroller.
Any LED and switch connections to the microcontroller.
Which band the board uses – 2.4GHz, 928MHz, 868MHz or 783MHz.
See the documentation included with the source code for implementation details.

2.3.1 AT91SAM7X-EK

2.3.2 Raven

The Atmel A distributor. This evaluation kit embeds an AT91SAM7X256 microcontroller which contains an Ethernet peripheral. By obtaining any of the AT86RF2xx transceivers, the platform can be assembled to operate as a RUM coordinator and/or IPv6 edge router.
This platform is further discussed in section 4.
The ATAVRRZRAVE contains two Raven boards (with LCD and joystick interface), and one Raven USB stick.
The Raven platform has two microcontrollers – one for the radio and one for the Raven user interface. The RUM software lives in the ATmega1284P microcontroller, and the user interface software – supplied with RUM – lives in the ATmega3290P microcontroller.
The user interface is not required – RUM can work as a coordinator, router, or end node without a user interface on the Raven.
To debug RUM on Raven, two miniature 10-pin headers (supplied with RZRAVEN) must be soldered to the board so that the programming tool can be plugged in. The JTAGICE mkII and AVRISP programming tools can each program the Raven board.
The batteries on Raven are not sufficient to run continuously while debugging, so an external 3V supply is recommended. Two AAA batteries make a suitable supply for debugging if no bench supply is available.
T91SAM7X-EK evaluation kit can be purchased from a local Atmel
N is the official development kit for the AT86RF230. The kit
4
The two processors communicate to each other using serial ports. There is an extra serial port on the ATmega1284P microcontroller that is dedicated to the DEBUG function. However, external wires must be added to access this port, and the signal levels are at low logic levels, not the high voltage levels required to drive a computer's serial port.
More information about the Raven board can be found in application note AVR2016.
AVR2070
8240B-AVR-06/09

2.3.3 Raven USB

2.3.4 ZigBit / ZigBit900

This is the USB stick that comes with the ATAVRRZRAVEN kit. This board has an AT90USB1287 microcontroller, which includes a built-in USB interface. Building for the RAVENUSB platform includes the driver code for the CDC-USB interface.
The Raven USB board requires that a miniature 10-pin header (supplied with RZRAVEN) must be soldered in for connection to the JTAG debugging port. The JTAGICE MKII programmer will program the Raven USB board. There is not an ISP programming header available on the USB stick.
The Raven USB stick can work as a coordinator, router, end node or sniffer with a CDC-USB interface.
More information about the Raven USB board can be found in application notes AVR2002 and AVR2016.
AVR2070
These two pl for the ZigBit microcontroller.
atforms are small radio modules containing a radio (either AT86RF230
TM
, or an AT86RF212 for the ZigBit900) and an ATmega1281V
8240B-AVR-06/09
5

3 AVR RUM Quickstart

In order to operate the RUM demo application, make sure one of the platforms described in this document has been selected, or that a custom platform has been properly defined in the hal_avr.h file. Also the use of an Atmel JTAGICE mkII or AVRISP programmer will be required to program the target microcontrolle r.

3.1 Source Code

3.2 Compiling RUM

After the target platforms and the programming tools required have been gathered, setup the software necessary for development. For Windows along with the free WinAVR tool chain can be used and downloaded free from
www.atmel.com
installed and run individually.
The RUM source code that accompanies this Application Note is spread out over several directories. The core RUM files are located in the \rum_src directory, and all of the other directories support the uTasker operating system, which is only used with the SAM7X version of RUM.
For AVR nodes, only the \rum_src directory is needed.
RUM has been written to work with the AVR version of the GCC compiler. AVR Studio will compile and debug the RUM software. Alternatively for Linux, a RUM application can be compiled and debugged using avr-gcc and other free tools.
Within the \rum_src directory, there are three AVR Stud io project files that will compile for the appropriate device of choice. There is also a Makefile that can be used with command line tools as well. These projects have all been pre-configured with default compile flags described in the table 3-1 below.
and www.sourceforge.net. For Linux® users, the tools have to be
®
users, AVR Studio®

3.2.1 Compile-time Options

6
AVR2070
s a very configurable protocol stack. Using a few compile-time flags, RUM can
Rum i be configured to run in a minimal amount of flash (less than 6K), or it can be configured to that handle 6LoWPAN packets, serve data on a periodic basis, and sleeps between readings. In AVR Studio, the compile-time flags described in table 3­1 are entered into the Project Options dialog box. This process is shown in figures 3-1 and 3-2.
Note:
In order to compile a small flash image size for an End Node device, the linker needs to be configured to remove any standard libraries like printf and floating point libraries. AVR Studio linker options can be found in the Custom Options tab of the Project options as shown in figure 3-2. The [Linker Options] selection is located in the file list of the left window pane. Linux users can adjust the Makefile to remove these libraries from the command line.
8240B-AVR-06/09
Figure 3-1 AVR Studio RUM Project Options
AVR2070
Figure 3-2 AVR Studio RUM Compile Flags
8240B-AVR-06/09
7
For command line operation using avr-gcc, options should be passed on the command line as define (-D) options, such as:
avr-gcc -mmcu=atmega1281 -DF_CPU=8000000UL -DPLATFORM=RAVEN -o radio.o radio.c (etc.)
Here is a list of available compile-time flags:
Table 3-1 Compile Time Flags
Option Name Possible values Meaning
PLATFORM RAVEN
RAVENUSB ZIGBIT9 ZIGBIT24
COORDNODE Undefined or 1 Set this variable to cause the node to be a
ROUTERNODE Undefined or 1 Set this variable to cause the node to be a
ENDNODE Undefined or 1 Set this variable to cause the node to be an
APP 0 (No application)
SENSOR IPSO
DEBUG 0
1
DEMO 0
1
RUMSLEEP 0
1
WDOG_SLEEP 0
1
Build RUM to work with the given platform. This option can set other options, such as the band the radio operates in (700/800/900MHz or 2.4GHz).
Note: Not required for the ARM version of RUM. Set PLATFORM to 0.
coordinator node. Note: The ARM version of RUM assumes
only a coordinator node.
router node.
end node. Compiles in (or leaves out) the sensor
application. New applications can be added to the list.
When DEBUG is set to 1, debugging messages can be sent out the debug port. Also, a simple terminal interface is available in debugging mode (Not all platforms support this with hardware).
Note: The definition of SERIAL or OTA_DEBUG must be used in order to use the DEBUG flag.
In demo mode, a node joining the network chooses to associate to the node with the best signal (RSSI). This allows demonstrating multi-hop functionality in a small area. In non-demo mode, a new node chooses its parent based on (in order):
1. Best LQI (Link Quality Indication)
2. Lowest number of hops to coordinator
3. Best RSSI. Sleep mode enables the ENDNODE to sleep.
If the sensor app (APP=SENSOR) is also compiled in, then the node will sleep between consecutive sensor readings.
Note: Coordinators and routers do not sleep, but the RUMSLEEP flag includes code to wake up end nodes and put them to sleep.
Setups the Watchdog timer to act as the timing source for the sleeping operation.
Note: If set to 0, sleeping relies on an external 32.768KHz crystal.
8
AVR2070
8240B-AVR-06/09
AVR2070
Option Name Possible values Meaning
IPV6LOWPAN 0
1
SENSOR_TYPE 0 (None)
SENSOR_RANDOM_T SENSOR_RANDOM_H SENSOR_THERMIST
PAN_CHANNEL 1-4 (700MHz)
0-10 (800/900Mhz) 11-26 (2.4GHz)
PAN_ID 0x0000 - 0xFFFF Sets a static PAN_ID for the specified
BAND BAND2400
BAND900
CHINA_MODE 0
1
DATA_RATE_212 BPSK-40 Can be changed to any of the supported
CAL 0
1
VLP 0
1
SERIAL 0
1
OTA_DEBUG 0
1
Compiles in 6LoWPAN functionality, which gives each node in the network a world­unique IPV6 address, and formats packets according to RFC4944. Without this option, smaller RUM-only frames are used.
Configures the sensor application (APP=SENSOR) to collect data from the given sensor type. SENSOR_RANDOM_T/_H uses a random number generator to create variable temp/humidity data. SENSOR_THERMIST reads a simple thermistor from the AVR's ADC.
Note: Not all platforms support this with hardware. SENSOR_TYPE does not apply to the ARM version of RUM.
Sets the operating channel to a static channel if specified. Leaving PAN_CHANNEL undefined will cause a coordinator node to scan all channels to select a quiet free channel, and will cause router/end nodes to scan all channels to find a network to join.
Note: If CHINA_MODE=1, then 700MHz channels are enabled.
network. Otherwise a random PAN_ID will be selected.
Note: A static PAN_ID is required for the IPv6 addresses in the demo. See Appendix C.
The BAND flag specifies which radio band to use. For AVR targets, this parameter is fixed for each PLATFORM to its correct value, and should not be directly passed to the compiler as a parameter. For the ARM target, this parameter can be passed as a compile-time option, or directly set in hal_arm.h.
Sets the use of 700MHz operation for the China band.
Note: This mode is only available when using the AT86RF212 (BAND=BAND900).
operating modes of the RF212.
Note: If using CHINA_MODE, the selected data rate is O-QPSK RC 250.
Enables the calibration feature with the SENSOR application.
This will allow a Very Low Power device to sleep between frame protocol operations (scan, associate, etc) to save power.
Used with DEBUG to send debug messages to a serial port.
Used with DEBUG to send debug messages over the air to the coordinator for processing.
8240B-AVR-06/09
9

3.3 Build Sizes

This section shows various build sizes using different compile flags described from Table 3-1.
Table 3-2 Various Build Sizes for AVR and ARM
Raven USB Coordinator
IPv6 off DEBUG on Sensor App SLEEP on
Raven - all features
IPv6 on DEBUG off Sensor App SLEEP on
Raven without Ipv6
IPv6 off DEBUG off Sensor App SLEEP on
Raven Minimal Size
All options off RUM network only
SAM7X Coordinator
IPv6 on DEBUG on Sensor App SLEEP on
Coordinator Router End Node
25332 bytes FLASH 4811 bytes SRAM
(Cannot build IPv6 coordinator on AVR target)
13354 bytes FLASH 2377 bytes SRAM
8864 bytes FLASH 1875 bytes SRAM
102K bytes FLASH 17K bytes SRAM
21138 bytes FLASH 1901 bytes SRAM
15218 bytes Flash 1093 bytes SRAM
7984 bytes FLASH 568 bytes SRAM
19280 bytes FLASH 1356 bytes SRAM
13208 bytes FLASH 548 bytes SRAM
5716 bytes FLASH 412 bytes SRAM

3.4 Fuse settings

10
AVR2070
The fuses for the AVR platforms vary on the target microcontroller. These fuse settings have been listed below for the appropriate platforms. These fuse settings can be entered into the target of choice using AVR Studio or AVR Dude for command line operation.
Raven (1284p): 0xFE; 0x91; 0xE2 Raven LCD (3290p): 0xFE; 0x91; 0xE2 Raven USB: 0xFB; 0x99; 0xDE ZigBit/ZigBit900: 0xFE; 0x91; 0xE2
8240B-AVR-06/09

4 AT91SAM7X-EK RUM Quickstart

The Atmel RUM protocol is integrated to run on the AT91SAM7X-EK board which contains an AT91SAM7X256 microcontroller. Additionally, the IPv6/6LoWPAN layers can be compiled in. Compiling in the IPv6 layer will allow the SAM7X platform to act as an IPv6 Edge Router in addition to an 802.15.4 PAN Coordinator. Furthermore, the SAM7X platform supports all the Atmel 802.15.4 transceivers: AT86RF230, AT86RF231 and AT86RF212.
The PAN Coordinator performs the classical functions defined in section 5.3 of the IEEE 802.15.4-2006 specification. It will start and maintain a non-beaconing network. The edge router functionality will route IPv6 network traffic to the appropriate end and router nodes based on their specific IPv6 addresses. The RUM protocol implementation differs slightly from the IEEE 802.15.4 standard. Please have a look at the documentation of the Route Under MAC (RUM) Protocol described in Appendix A.
The SAM7X provides multiple interfaces for users to interact with the 802.15.4 wireless network. Among these are RS232, USB, telnet and simple direct web interface. The remainder of this section will describe the implementation of low level drivers, radio drivers, timers, uTasker RTOS integration and web interfaces.

4.1 uTasker RTOS

AVR2070
To jump start development and provide a solid foundation for ARM operation, the uTasker RTOS was chosen to build upon. uTasker is not a pre-emptive type RTOS, rather it is a task-event-state driven type. A task was created called RUM Task that is responsible for processing radio events as well as timer events associated with the radio protocol. For a complete description of the uTasker RTOS visit
www.utasker.com
In addition to RUM, IPv6, and 6LoWPAN, a FAT file system has been integrated into the uTasker system. For more details see www.efsl.be documentation. RUM and IPv6 are described accordingly within this document.
Most of the RUM application code to interact with the uTasker RTOS is located in:
rumtask.[c/h]
arm_app.[c/h]
Most of the RUM stack shares the same code base between the SAM7X and the AVR microcontroller platforms. There are, however, specific files that only pertain to the ARM build or the AVR build. Low level files specific to the SAM7X build are:
arm_timer.[c/h]
arm_timer_event.[c/h]
hal_arm.[c/h]
Additional modifications are:
Enabling a telnet and a user menu interface.
.
and the Doxygen
8240B-AVR-06/09
IPv6 and 6LoWPAN
The EFSL FAT file system
See section 3.3 for specific build size of uTasker and RUM compiled for the SAM7X.
11

4.1.1 uTasker Patches

Since uTasker is a licensed RTOS, only a binary image has been provided for demonstration purposes. If access to the uTasker source code is required, a license can be acquired via www.utasker.com no or minimal cost.
With a license to uTasker, the source code can be patched to implement the RUM architecture. These modifications add support for the RUM system and user interaction. For instance, a user interface or menu system allows the user to change the operating channel and other radio values. The code modifications can be found in these files:
Application Level:
application.c
application.h
config.h
TaskConfig.h
app_hw_sam7x.h
debug.c
webInterface.c
. uTasker offers excellent licensing programs at
types.h
Stack Level:
Tty_drv.c
driver.h
Ethernet.c
ppp.c
Since uTasker is provided in source code form, patch files have been produced for all modifications needed to implement RUM with uTasker. To implement the patch files the following procedure should be followed.
1. Download and Install WinAVR from www.sourceforge.net patch.exe program needed to patch the uTasker project with RUM source.
2. Open the uTasker OS source code package (only available with a uTasker license from www.utasker.com
3. Be sure to download uTasker SP4 and apply the service pack to the original uTasker OS source files. (Explained on uTasker website - simple copy and replace files to apply service pack)
4. After the service pack has been installed, locate the upatch.bat and utasker­patch files in the \patch folder within the source download package.
5. Copy these files to the same directory containing the uTasker OS with SP4 (eg. C:\project\... should contain these two files plus uTasker directory).
).
which provides the
12
6. Using Windows Explorer, double click the .bat file to patch the uTasker source for use with RUM. Note: Only run this patch procedure once.
AVR2070
8240B-AVR-06/09

4.2 Radio Interface

4.2.1 Hardware

This project should now include the original uTasker OS, SP4, and RUM patch files. A test compile can now be tried using the IDE of choice. Appendix D explains two common IDE’s that can be configured to compile uTasker with RUM supp ort.
The radio interface is composed of two parts - hardware and firmware. The hardware is generally a radio board with physical connections to a microcontroller with the firmware to manage the interface between the two.
AVR2070
In order to choice, the following diagram shows the generic connections needed to interface the two parts.
Figure 4-2-1 Microcontroller to Transceiver Connections
connect one of the AT86RF2xx transceivers to the microcontroller of
8240B-AVR-06/09
There are various evaluation boards available that provide standalone transceiver evaluation which provide header pins for easy connection to the AT91SAM7X-EK board. See Appendix E for examples of connecting various evaluation boards.
This section highlights the required connections for the SAM7X and any one of the three transceivers. Using the above generic connections, the AT91SAM7X-EK board provides many GPIO pins for co nnectio n of the transceiver of choice. The table below shows one method of connecting the two devices together with SPI1 and GPIO.
Table 4-2-1 AT91SAM7X-EK Connections
SAM7X
TRX Pin
MISO 56 PA24 SPI1_MISO MOSI 55 PA23 SPI1_MOSI
MCU Pin Port Port Function
13

4.2.2 Firmware

SAM7X
TRX Pin
SCK 50 PA22 SPI1_SPCK
SEL 49 PA21 SPI1_NPCS0 IRQ 80 PA30 IRQ0
CLKM 70 PB24 TIOB0
SLEEP_TR 13 PA8 PA8
RST 14 PA9 PA9
MCU Pin
Port Port Function
The low level driver code is located in two files:
hal_arm.c hal_arm.h
These files initialize SPI-1 and the discreet IO. Additionally, these files implement handler functions that the remainder of the code uses to interact with the radio. For instance, radio interaction is accomplished through functions such as
hal_frame_read and hal_frame_write
for receiving and transmitting a frame over the air. Other functions such as

4.3 Serial Interfaces

hal_register_read and hal_register_write
allow access to radio control registers. Please refer to the detailed documentation produced as a result of the integrated Doxygen comments in each source file. The radio registers are fully described in the files at86rf212_registermap.h and at86rf23x_registermap.h.
By default, none of the serial interfaces are enabled. Possible serial interfaces are USB and RS232. (There are two RS232 COM ports on the SAM7X board.) The telnet interface provides more than adequate user capabilities without the hassle of configuring a serial interface such as Hyperterminal.
uTasker provides built in serial IO capabilities for RS232 and USB. To enable serial IO for terminal interaction by the user the following defines can be enabled in config.h:
#define USB_INTERFACE #define SERIAL_INTERFACE
The baud rate parameters for the RS232 port are:
19,200 BAUD
8N1
14
AVR2070
To use the USB connection on a PC running Microsoft Windows, a Windows USB driver must be installed. This USB driver is titled uTaskerAtmelVirtualCOM.inf and can be downloaded from the uTasker website site at
www.utasker.com/software/softwareV1.3.html
found at www.utasker.com/docs/uTasker/uTaskerV1.3_USB_Demo.PDF
and complete documentation can be
. However,
8240B-AVR-06/09

4.4 Network Interfaces

the source code and precompiled code have USB disabled. Due to limitations on the SAM7X board, if a reset is necessary, the USB cable must be removed and any open USB terminal sessions closed and then the board can be reconnected and the USB terminal session restarted.
uTasker also supports a telnet interface through the RJ45 network connector. The telnet interface is nearly identical to the serial interface. It offers the same menu selections and utilizes the default IP address of 192.168.1.125. This address can be changed with the “I” menu selection. The network interface also provides the connection for the on board simple web server.
Figure 4-4-1 shows an example menu interface. The complete menu commands are fully described in Table 5-1.
To access the telnet interface, the RJ45 cable can be connected directly to the PC's network interface card or to a hub/router.
Note:
If connecting a PC directly to the SAM7X, the Network Interface Card (NIC) on the computer will need to be configured to communicate on the same IP subnet as the SAM7X.
To start the telnet session simply type “telnet 192.168.1.125” at the DOS prompt and press enter. Alternately, on a Linux machine, type “telnet -e / 192.168.1.125” at the terminal prompt and press enter. The “-e /” defines the escape character. Once the telnet session is started, type “/” and a telnet prompt will appear “telnet>”. Type “mode line” and press enter twice to return to the SAM7X telnet session. The “mode line” command forces the Linux telnet session to echo characters typed by the user to the telnet screen.
AVR2070

4.5 AT91SAM-ICE

Figure 4-4-1. Main Menu
The ARM® is programmed via the AT91SAM-ICE JTAG adapter, see the web site:
www.atmel.com/dyn/products/tools_card.asp?tool_id=3892
this device. For Linux based systems the CrossConnect JTAG device is recommended, see the web site: www.rowley.co.uk/arm/CrossConnect.htm information on this device.
for more information on
for more
8240B-AVR-06/09
15

4.6 Loading the Program

Note:
The SAM-ICE running the Rowley Crossworks IDE.
In order to load the uTasker RUM demo, the AT91SAM-ICE comes with a SAM-BA® programmer GUI interface. This needs to be installed on the local PC that is directly connected to SAM-ICE JTAG device. The software can also be downloaded from
www.segger.com/download_jlink.html
EK target have been explained in Appendix D, but his method only describes the SAM-BA method.
The SAM-ICE JTAG should first be connected to the USB port of the local PC. This USB driver can be found with the SAM-BA download package. Provided the SAMB­BA package has been extracted to the local PC, the USB driver should be installed automatically.
Once the SAM-BA v2.8 program has been successfully installed, open the program and see the image shown in figure 4-6-1.
Figure 4-6-1 SAM-BA Opening Message
TM
JTAG adapter does not work for Linux based systems
. Various methods to program the AT91SAM7X-
This pop-up window allows the selection of the SAM-ICE JTAG device connected to the local PC. Click the “Connect” button to continue.
The next screen allows for the uTasker RUM demo .bin image to be selected for programming into the AT91SAM7X256. The .bin file can be found in the \bin folder of the source code package.
Note:
The FLASH tab is selected as the image needs to be loaded into the flash location of the AT91SAM7X256. Be sure the FLASH address is set to 0x100000.
16
AVR2070
8240B-AVR-06/09
Figure 4-6-2 SAM-BA File Selection
AVR2070

4.7 Simple Web Interface

Once the image has been selected in the “Send File Name” field, connect the SAM­ICE JTAG unit to the AT91SAM7X-EK development board. Power on the target and press the “Send File” button.
The programmer will begin communication with the AT91SAM7X-EK board and a lock region message should pop-up shown in figure 4-6-3.
Figure 4-6-3 SAM-BA Lock Regions
Simply select the “No” button to begin programming. Upon completion of programming the target, the SAM-BA interface can be closed which will disconnect the SAM-ICE JTAG programmer from the AT91SAM7X-EK board causing a RESET. The uTasker RUM demo should initialize and begin flashing the DS1 LED on board the evaluation kit at a rate of ~ twice per second.
In order to connect to the simple web interface, the webpages must first be loaded into the SAM7X via FTP. In the source code package, locate the \web_pages folder and notice the simple webpage files. If running Windows, open and run the Copy_all.bat file to initiate the FTP transfer. This can be manually done for command line operation.
8240B-AVR-06/09
17
Once the webpages are transferred, the default IP address of 192.168.1.125 must be entered into the selected internet browser of choice to show the main webserver page.
The simple web interface provides a quick and easy method for allowing the user to find IPv6 address of the edge router (SAM7X) as well as the IPv6 addresses of the connected nodes (provided the devices had code compiled with IPV6LOWPAN=1). Additionally, a node can be pinged via its short address. Simply enter the hexadecimal address into the ping address box and click the ping button.
Figures 4-7-1 and 4-7-2 show both pages of the simple web interface.
Figure 4-7-1 Simple Webserver Main Page
18
AVR2070
8240B-AVR-06/09
Figure 4-7-2 Simple Webserver Network Table
AVR2070

4.8 SD File Handling

The maximum size of SD card is 2 GB. The card should be formatted as FAT32. Note that the SD file handling is rudimentary. Users needing more advanced file handling can adapt the system as source code is available. See the files in the directory path “../utasker/Applications/uTaskerV1.3/efsl/”. This file system was adapted from
www.efsl.be
For the RUM demo described in the next section, it is recommended to initialize (reset) the SAM7X with the SD card inserted. This will allow the EFSL to properly initialize the data logging feature. In Table 5-1, the SD card handling commands are described to demo operation.
please refer to the originators for comprehensive details.
8240B-AVR-06/09
19

5 Running the RUM Demo

Now that all the platforms have been properly configured with RUM, operating the RUM demo without IPv6 is described in this section. It is assumed there is only one PAN Coordinator per network and the PAN Coordinator can be either the AT91SAM7X-EK board with radio interface, or another small AVR 8-bit based platform described in section 2 (see Appendix E for third-party platforms).

5.1 Operation

A PAN Coordinator will start a network by first locating a clear channel to begin operations on. The PAN Coordinator will select a random PAN_ID, unless a static one has been defined during compile time, and will begin accepting association requests from router and end nodes. This mechanism is very similar to that described in section 5.3 of the IEEE 802.15.4-2006 specification.

5.1.1 Network Formation

Note:
If an AVR based platform is selected, there is no Ethernet interface directly supported, just the optional serial interface. Therefore, any Telnet and Webserver communication will not be available for network control.

5.1.2 Application Interface

5.1.3 Main Menu

The net Coordinator has selected a channel to operate on, other nodes can begin to join the network. The PAN Coordinator will issue beacons in response to beacon requests. When a node wishes to join the network, it will send an association request to the PAN Coordinator and the PAN Coordinator will respond with an association response. From this, the node will retrieve its own short address. For more details about the RUM protocol, see Appendix A.
The typical described in table 5-1. If an AVR platform is used as the PAN Coordinator, a different menu is available via a serial interface described in table 5-2. The simple web server will show a simple network table and allow the user to ping a specific node.
In order to communicate with the SAM7X telnet menu via the default IP address, see section 4.4 for a description on how to configure the SAM7X and the local PC.
The telnet and se more detailed description is offered here.
work formed by the RUM protocol is a non-beaconing network. After the PAN
user interface to a running system with the SAM7X is the telnet menu
rial menu selections are meant to be self descriptive however a
Note:
Many of these are only available with the compile flag APP=SENSOR. Also, for the ARM some of these require the compile flag IPV6LOWPAN=1.
20
AVR2070
8240B-AVR-06/09
AVR2070
Table 5-1 ARM Telnet Menu Commands
ASCII Command Description
a (lowercase) IP Address. This is the current IPv4 address of the SAM7X. A (uppercase)
b Break. This allows the user to stop collecting data to the SD card. c (lowercase) Channel. This allows the user to change the operating channel. C (uppercase)
d Dump. This shows the current content of the radio control registers. f
i (lowercase)
I (uppercase i)
l (lowercase L)
n
o
p Ping. Ping a user selected node. Q Quit. Quit the telnet session. r
t (lowercase) Table. Display a table of nodes and their relationships. T (uppercase)
w
X
IPv6 Address. This is the IPv6 address that has been self configured or configured as a result of connecting to a true IPv6 router.
Calibrate. Allows the user to calibrate the end node both single and double set points.
Filename. This allows the user to set a new file name for data collection on the SD card.
Info. This provides a quick display of current radio settings including, PANID, Channel, Short Address, etc.
New IP address. This allows the user to set a new IPv4 address. Once entered the old one will no longer respond.
Log. This will resume data collection to the SD card. It is the corollary to the “b” command.
Name. Allows the user to set the name of a node – 11 characters max.
Toggle node readings. Nodes report sensor readings on a periodic basis (if APP=1). This allows readings to be displayed as they are received. Does not affect collecting data to SD card.
Read interval. Allows the user to alter the interval at which the end or router nodes will report data to the PAN Coordinator.
Touch. Provides a method to either ping or change the interval of all nodes on the network.
Wake. If a node has been loaded with code that allows sleep (SLEEP=1) then it must be woken up before it can respond to commands such as “r”.
Max power. The PAN Coordinator is set to transmit at the lowest power setting in demo mode. This turns up the transmit power to +3dBm for the RF230 and the RF231. The Max power setting for the RF212 is +8dBm for 900MHz operation and +5dBm for 700MHz operation.
8240B-AVR-06/09
21
Table 5-2 AVR Serial Menu Commands
ASCII Command Description
T Touch. Ping or send a Reading (asks for ‘p’ or ‘r’ & interval time). c Channel. This allows the user to change the operating channel. d Dump. This shows the current content of the radio control registers. i
n
p (lowercase) Ping. Ping a user selected node. P (uppercase) Pause. Pause or un-pause serial display (stop serial input). r
t Table. Display a table of nodes and their relationships. s
w
Info. This provides a quick display of current radio settings including, PANID, Channel, Short Address, etc.
Name. Allows the user to set the name of a node – 11 characters max.
Read interval. Allows the user to alter the interval at which the end or router nodes will report data to the PAN Coordinator.
Stream Mode. This will stream ASCII data between any two nodes in the network provided each device has a serial connection to a host PC.
Note: This only works for AVR based devices
Wake. If a node has been loaded with code that allows sleep (SLEEP=1) then it must be woken up before it can respond to commands such as “r”.
22
AVR2070
8240B-AVR-06/09

6 Running the IPv6 Demo

This demo requires the AT91SAM7X-EK to be used as the PAN Coordinator, due to the Ethernet interface available on the board. The demo is separated into four parts. The first is the ‘ping’ demo which simply verifies IPv6 network connectivity. The next is the ‘UDP’ demo which demonstrates remote control of a node. The example sensor application used in section 5 will then be run on IPv6. Finally a TFTP client will be used to load new code onto an end node using IPv6. In these simple demos sleeping will be disabled. Enabling sleep modes will be discussed later.
Familiarity of using the RUM network is required to fully understand these demos. In particular the demo in section 5 should have been followed, verifying the webserver on the coordinator (SAM7X) board can be reached.
In the 6LoWPAN world, the board which connects the 802.15.4 low-power wireless network to the real IPv6 network, be it either Ethernet or WiFi, is called the “edge router”. It lives at the edge of the 6LoWPAN network and connects it to the other IPv6 network. In this network the edge router is the PAN coordinator, or SAM7X board.
This demo may be used with full IPv6 internet connectivity if available. This is not required to access the nodes from the local network; it is only required to access the nodes from outside the local network.
The PAN coordinator board and AVR boards must be compiled with 6LoWPAN support enabled. This is set by defining the IPV6LOWPAN macro to ‘1’ at build time
on both the ARM and AVR.
AVR2070

6.1 Computer/Network Setup

The demo will require IPv6 support on the host computer. If using Windows XP, type the following at a command prompt to enable IPv6 support:
If using Windows Vista®, or any Linux distribution with a kernel 2.24.0 or newer, IPv6 is already supported and enabled.
User interface and debug capabilities are provided through the telnet interface described in section 4.4.

6.2 Ping Demo

Power the coordinator on, with the AVR nodes off. Navigate to the IPv4 address of the webserver on the SAM7X board, and view the Network Table. There the IPv6 addresses for each interface will be shown. The board obtains the IPv6 prefix for the Ethernet interface from another IPv6 router if one is detected. If no router is detected, the hard-coded default prefix of 2001:db8:1e1:0::/64 is used and the board advertises itself as the default router.
ipv6 install
Note
Since this device becomes the default router, ALL IPv6 traffic on the IPv6 network may be sent to it. However the device cannot actually route this traffic, as it only has a connection to the 6LoWPAN network. If only the 6LoWPAN network is being accessed this is fine; however, if other IPv6 connectivity is requested this will break the network. To avoid this, the SAM7X does NOT advertise itself as a default router when another IPv6 router is detected on the network.
8240B-AVR-06/09
23
If an IP address for the Ethernet side is not seen, this means an IPv6 router was discovered on the network. However the router is NOT advertising a prefix using stateless auto configuration. Router advertisements must either be disabled on the router, or set the router to allow stateless auto configuration.
The IPv6 prefix for the 6LoWPAN side (aka: 802.15.4 radio) is obtained from the setting on the first webpage. The prefix always has a 64-bit length, and the AVR nodes will acquire this prefix automatically. It may take up to 30 seconds after the board boots for the IPv6 address of the 6LoWPAN side to show up. Refresh the Network Table to check if the address is valid yet.
Note
If another IPv6 router is on the network, it must be manually configured to forward any packets destined for the 6LoWPAN network to the SAM7X board. On a Linux-based router the command to run would be:
ip -6 route add 2001:db8:1e1:1::/64 via 2001:db8:1e1:0:1af0:9fff:fee5:18f2
This will forward any traffic destined to the 2001:db8:1e1:1::/64 prefix (the RUM IPv6 6LoWPAN prefix) to the IPv6 address of the ethernet interface on the SAM7X board.
Connectivity of the coordinator board should now be tested. At a command prompt, ping the coordinator board’s Ethernet address, where the IP address is the one printed on the debug port or on the website. For example:
ping6 2001:db8:1e1:0:1af0:9fff:fee5:18f2
There should be several ping replies. If not, double-check the IP address of the Ethernet port printed in the debug message or on the IPv4 website.
Next, attempt to ping the 6LoWPAN address of the coordinator board. This proves that the local computer will be able to see wireless nodes. For example:
ping6 2001:db8:1e1:1:e789:ff:fe00:0
Note that the 6LoWPAN addresses may change on every reboot of the board. The addresses are based on the PAN_ID, which can either be set to a fixed value or set to randomly change. If fixed IPv6 addresses are desired, set the macro PAN_ID to the desired PAN_ID when building. For example setting PAN_ID=0xe789 would give an IP address like above.
Note
If pinging the Ethernet interface is successful but pinging the 6LoWPAN interface fails, most likely there is an IPv6 router on the network which has not been properly configured to forward packets to the edge router board. A rule must be manually inserted into the routing tables that forwards any packets destined for the 6LoWPAN network to the IPv6 address of the Ethernet interface on the edge router.
Finally, the association and pinging of a node can be tested. To do so turn on a node, and check it associates in the IPv4 website. It should appear in the network list, and its IPv6 address will also appear. If no IPv6 address appears, most likely the node does not have IPv6 support enabled.
24
Then try to ping the node:
ping6 2001:db8:1e1:1:baad:ff:fe00:1
Several ping replies should be seen, along with an LED blink for each ping on the node. This validates that the 6LoWPAN / IPv6 network is working as expected.
AVR2070
8240B-AVR-06/09

6.3 Using the 6LoWPAN / IPv6 Code on End Nodes

The 6LoWPAN / IPv6 API is documented using the Doxygen documentation system. What follows is an overview of how the example application works, and is not the full API documentation. Refer to Appendix C for the entire API documentation.
The code is designed primarily to pass data around using the UDP protocol. The user application can send data to any arbitrary IP address, or the user can respond to an incoming UDP packet.
A user function is called when a UDP packet is received by the node. The user is told the source port, the destination port, the pointer to memory where the payload is stored, and the size of the payload. To send data back to the device, the user simply replaces the payload with what they wish to send, and returns how much data they have placed in the payload. The stack will automatically send this message back to the source IP address, with the destination and source ports swapped. Since most UDP-based protocols function this way, implementation is made quick and easy.
If more control is required, functions to create an arbitrary UDP packet are provided. Also provided are functions for generating ICMP echo requests destined to any arbitrary address. The stack will automatically respond to any incoming echo requests with an echo response.

6.4 IPSO App Example

AVR2070
The IPSO App demo showcases a wireless sensor reporting system. It uses UDP and allows simple control of end nodes. Running the demo will require the 'netcat6' program, which should come with most Linux distributions. This can be checked by attempting to run the 'nc6' command.
To run the demo, the AVR devices must be built with APP set to ‘IPSO’ in addition to IPv6 being enabled. The ping demo should still work, and provides a good sanity check.
Note:
To communicate with other IPv6 nodes outside the local network, a native IPv6 connection, or IPv6 tunnel end point, is required. A tunnel can be created by using a tunnel broker such as Hurricane Electric (www.he.net
Windows users can find copies of netcat6.exe available online at www.sphinx-
soft.com/tools/index.html.
Netcat6 is used to simply send and receive raw packets; in this case it is being used for UDP. By typing any ASCII character and pressing enter results in a UDP packet being sent with whatever was typed as the payload. For example, if a user typed 'hello' and pressed enter, then netcat6 will send a UDP packet with the payload as 6 bytes: 0x68, 0x65, 0x65, 0x6C, 0x6F, 0x0A. This is ASCII for "hello" followed by a new-line. If the node responds by sending “Hi There” in ASCII, that will be printed back to the first node.
This allows simple communication with a node without the need for special software. Communication with a node operates like a wireless serial port. The only difference is the node is physically located across the world, and not connected to a local computer with a wire.
).
8240B-AVR-06/09
25

6.4.1 Commands on Port 61616

The IPSO demo has two parts to it. The first part is an interactive control to allow polling of the sensor and configuration tasks. The second part is to have the sensor automatically send data to a central server.
The wireless sensor node listens on three UDP ports, their use is as follows:
Table 6-4-1. UDP Ports
Port Description
61616 The sensor will listen for requests on this port 61617 The sensor will listen for data from other nodes on this port 61618 The sensor will listen for administrative commands on this port
Tip
If both the destination and source ports are in the range 0xF0B0 to 0xF0BF (61616 – 61631), 6LoWPAN can compress the destination and source ports, saving four bytes of transmitted data.
The acceptable commands on each port are listed in the next sections.
The no
de will accept the following commands on port 61616, and all commands must end with either a line-feed, or carriage-return line-feed combination (<LF> or <CR><LF>).
Table 6-4-2. UDP Commands on Port 61616
Command Description
Get the current temperature. Return value will be 'T22.5' for example for a
T
H
L
A A1 Turn the LED on. No return value. A0 Turn the LED off. No return value.
22.5 C temperature. Get the current humidity. Return value will be 'H13' for example for 13%
humidity. Get the current light reading, from 0-100. Return value would be 'H50' for
example. Get the status of the LED. Either 'A0' to indicate LED is off, or 'A1' to
indicate LED is on.
Unknown commands will result in a return value of the byte 0xFF followed by the unknown command.
As an example connect to the node with netcat6 on port 61616. For these examples <enter> means to press enter, and anything that is underlined is a response back from the node.
26
AVR2070
C:\> nc6 -u 2001:db8:1e1:1:baad:ff:fe00:1 61616 <enter> T<enter> T22.5 H<enter> H50
8240B-AVR-06/09

6.4.2 Commands on Port 61618

A<enter> A0 A1<enter> A<enter> A1 HTL<enter> H50T22.5L50 A0A<enter> A0
AVR2070
This also demonstrates how multiple commands could be sent at once. The sensor always sends its packets back to the source port specified in the original packet.
Note
If a response is not received, try sending either the 'A1' or 'A0'
command to turn on and off the LED. If the LED responds, the node is
receiving the message, but the response is not being passed back.
Running Wireshark on the interface may provide some useful
information, such as if the UDP response packet has an incorrect
checksum.
s the administrative port, and allows control of various settings in the device.
This i The commands which can be sent are shown in the following table, and must also end with either a <LF> or <CR><LF> combination.
Table 6-4-3. UDP Commands on Port 61618
Command Description
Set the server IP address to
S2001:0db8:01e1:0000:459D:00ff:fe29:bcf5
Ds
D2001:0db8:01e1:0001:baad:00ff:fe00:0002
BST22.5
BP H Remotely simulate a button press
G
C Clear the last message received by this node.
2001:db8:1e1::459d:ff:fe29:bcf5 Set the destination IP of the button press to
the server address (aka: what was stored with 'S')
Set the destination IP of the button press to the IP 2001:db8:1e1:1:baad:ff:fe00:2
Send the string 'T22.5' to the IP specified with 'D' when the button is pressed.
Send an ICMP echo request (ping) to the node specified with 'D' when the button is pressed
Get the last message received by this node, typically in response to the action occurring on the button press.
8240B-AVR-06/09
All commands except for 'G' will be acknowledged with an 'OK' from the wireless sensor.
27
When setting an IP address, the full IP address must be specified with all zeros present. If the address is short any bytes, the node will respond “length error”.
The 'server address' is the IP address which the node automatically sends readings to. The 'button press address' is the IP address which the node sends a certain message to only when the button is pressed.
The 'G' command returns a timestamp in front of the last received message. This timestamp is in milliseconds, and is a 16-bit value. Hence there will be a range of 0 – 65536, after which point the timestamp will overflow back to zero.
As a simple first example, a wireless node will be setup to ping the connected computer. This assumes the computer's IPv6 address is 2001:db8:1e1::459d:ff:fe29:bcf5.
C:\> nc6 -u 2001:db8:1e1:1:baad:ff:fe00:1 61618 <enter> D2001:0db8:01e1:0000:459d:00ff:fe29:bcf5 <enter> OK BP <Enter> OK H <enter> OK G <enter> [10293] Ping took 13 mS

6.5 Sensor App Example

Note that when the 'H' command is issued, this is no different from just hitting the button on the node.
Next let's assume there was another node on the network, and the first node wanted to query the temperature on the second node. The following commands would cause the first node to send the 'T' command to the second node whenever the button is pressed. The 'G' command is then used to receive the data the second node sent the first.
C:\> nc6 -u 2001:db8:1e1:1:baad:ff:fe00:1 61618 <enter> D2001:0db8:01e1:0001:baad:00ff:fe00:0002 <enter> OK BST <Enter> OK H <enter> OK G <enter> [12313] T22.3
The RUM example described in section 5 uses the RUM networking layer to pass messages around. This allows end nodes to communicate with the coordinator to exchange sensor readings, calibration data, etc. With IPv6 support enabled however, these messages can then be passed along an IPv6 link instead.
28
AVR2070
8240B-AVR-06/09
Loading...
+ 65 hidden pages