world leader in high performance signal processing
This version (13 Jun 2014 11:24) was approved by mhennerich.The Previously approved version (13 Jun 2014 11:00) is available.Diff

ADF7242 Network MAC802154 Linux Driver

Supported Devices

Evaluation Boards

Description

Couldn't find description in http://www.analog.com/adf7242

Source Code

Status

Source Mainlined?
git No

This driver is not mainline - it can be found in the IEEE802.15.4/ZigBee Stack for Linux Project.

Files

Function File
driver adf7242.c
include adf7242.h

Firmware for Automatic IEEE 802.15.4 Operating Modes (AN-1082)

Example platform device initialization

For compile time configuration, it’s common Linux practice to keep board- and application-specific configuration out of the main driver file, instead putting it into the board support file.

For devices on custom boards, as typical of embedded and SoC-(system-on-chip) based hardware, Linux uses platform_data to point to board-specific structures describing devices and how they are connected to the SoC. This can include available ports, chip variants, preferred modes, default initialization, additional pin roles, and so on. This shrinks the board-support packages (BSPs) and minimizes board and application specific #ifdefs in drivers.

21 Oct 2010 16:10 · Michael Hennerich

Example Platform / Board file

Declaring SPI slave devices

Unlike PCI or USB devices, SPI devices are not enumerated at the hardware level. Instead, the software must know which devices are connected on each SPI bus segment, and what slave selects these devices are using. For this reason, the kernel code must instantiate SPI devices explicitly. The most common method is to declare the SPI devices by bus number.

This method is appropriate when the SPI bus is a system bus, as in many embedded systems, wherein each SPI bus has a number which is known in advance. It is thus possible to pre-declare the SPI devices that inhabit this bus. This is done with an array of struct spi_board_info, which is registered by calling spi_register_board_info().

For more information see: Documentation/spi/spi-summary

21 Oct 2010 16:10 · Michael Hennerich
#include <linux/spi/adf7242.h>
 
static const struct adf7242_platform_data adf7242_pdata = {
 
	.mode = ADF_IEEE802154_AUTO_CSMA_CA | ADF_IEEE802154_HW_AACK,
/*
 * Specifies number of attempts to
 * retransmit unacknowledged
 * frames while in automatic CSMA-CA 
 * Tx mode.
 */
	.max_frame_retries = 4,
/*
 * Specifies number of attempts to
 * repeat CSMA-CA algorithm prior to
 * cancellation of RC_TX command.
 * Valid range is 0 to 5; 
 * 7: CSMA-CA algorithm is off
 */
	.max_cca_retries = 4,
/* 
 * Specifies the maximum back-off
 * exponent used in the CSMA-CA
 * algorithm; valid range is 4 to 8
 * 
 */
	.max_csma_be = 6,
/*
 * Specifies the minimum back-off
 * exponent used in the CSMA-CA
 * algorithm; valid range is 0 to
 * csma_max_be
 */
	.min_csma_be = 1,
};
static struct spi_board_info bfin_spi_board_info[] __initdata = {
#if defined(CONFIG_IEEE802154_ADF7242) || defined(CONFIG_IEEE802154_ADF7242_MODULE)
	{
		.modalias = "adf7242",
		.max_speed_hz = 10000000,     /* max spi clock (SCK) speed in HZ */
		.irq = IRQ_PF6,
		.bus_num = 0,
		.chip_select = 0,	/* GPIO controlled SSEL */
		.controller_data = &adf7242_spi_chip_info, /* Blackfin only */
		.platform_data = &adf7242_pdata,
		.mode = SPI_MODE_0,
	},
#endif
};

Adding Linux driver support

Configure kernel with “make menuconfig” (alternatively use “make xconfig” or “make qconfig”)

The ADF7242 Driver depends on CONFIG_SPI and CONFIG_IEEE802154

------------------- Linux Kernel Configuration ----------------------

  [*] Networking support  --->
       Networking options  --->
         <*> IEEE Std 802.15.4 Low-Rate Wireless Personal Area Networks support (EXPERIMENTAL)
            <*>   Generic IEEE 802.15.4 Soft Networking Stack (mac802154)


  [*] Network device support  --->
     --- Network device support
     < >   Dummy net driver support
     < >   Bonding driver support
     < >   MAC-VLAN support (EXPERIMENTAL)
     < >   EQL (serial line load balancing) support
     < >   Universal TUN/TAP device driver support
     < >   Virtual ethernet pair device
     -*-   PHY Device support and infrastructure  --->
     [*]   Ethernet (10 or 100Mbit)  --->
     [ ]   Ethernet (1000 Mbit)  --->
     [ ]   Ethernet (10000 Mbit)  --->
     [*]   Wireless LAN  --->
           *** Enable WiMAX (Networking options) to see the WiMAX drivers ***
     [ ]   Wan interfaces support  --->
     <*>   IEEE 802.15.4 drivers  --->
     	 --- IEEE 802.15.4 drivers
     	< >   Fake LR-WPAN driver with several interconnected devices
     	< >   Fake LR-WPAN driver with several interconnected devices
     	< >   Simple LR-WPAN UART driver
     	< >   AT86RF230 transceiver driver
     	<M>   ADF7242 transceiver driver

     < >   PPP (point-to-point protocol) support
     < >   SLIP (serial line) support
     < >   Network console logging support (EXPERIMENTAL)

Hardware configuration

There is no dedicated Blackfin STAMP evaluation board for the ADF7242. During test and driver development we used the ADF7242 Evaluation Board.

On the EVAL-ADF724x-EBZ:

  • Populate Header J6
  • Populate Header J4

The EVAL-ADF724x-EBZ can be easily wired to the Blackfin STAMP SPI header.

EVAL-ADF724x-EBZ Board (J6) BF537-STAMP (P9) SPI header
PIN Function PIN Function
1 CSN 9 SPI_SSEL1
2 SI 5 SPI_MOSI
3 SCLK 8 SPI_SCK
4 SO 6 SPI_MISO
5 IRQ_GP4 14 IRQ_PF6
6 TRCLK_CKO_GP3
7 TRFS_GP2
8 DT_GP1
9 DR_GPO
10 GND 20 GND
EVAL-ADF724x-EBZ Board (J4) BF537-STAMP (P9) SPI header
PIN Function PIN Function
5 VDD_RF_BAT 2 +3.3 Volt

Driver testing

Userspace tools for Linux IEEE 802.15.4 stack

iz

Usage: iz [options] [command]
Manage IEEE 802.15.4 network interfaces

Options:
  -d, --debug[=N]                print netlink messages and other debug information
  -v, --version                  print version
  -h, --help                     print help

Common commands:
  help  [command]
     Print detailed help for a command.

  event  [iface]
     Monitor events from the kernel (^C to stop).


PHY 802.15.4 commands:
  listphy  [phy]
     List phys(s).

  add  phy [iface]
     Add an interface attached to specified phy.

  del  [phy] iface
     Delete the specified interface.


MAC 802.15.4 commands:
  scan  <iface> <ed|active|passive|orphan> <channels> <duration>
     Perform network scanning on specified channels.

  assoc  <iface> <pan> <coord> <chan> ['short']
     Associate with a given network via coordinator.

  disassoc  <iface> <addr> <reason>
     Disassociate from a network.

  list  [iface]
     List interface(s).


Report bugs to linux-zigbee-devel@lists.sourceforge.net

Userspace tools for Linux IEEE 802.15.4 stack homepage <http://linux-zigbee.sourceforge.net/>

izcoordinator

root:/> izcoordinator
Usage: izcoordinator [OPTION]... -i IFACE
Provide a userspace part of IEEE 802.15.4 coordinator on specified IFACE.

 -l lease_file      Where we store lease file.
 -d debug_level     Set debug level of application.
                    Will not demonize on levels > 0.
 -m range_min       Minimal new 16-bit address allocated.
 -n range_max       Maximal new 16-bit address allocated.
 -i iface           Interface to work with.
 -s addr            16-bit address of coordinator (hexadecimal).
 -p addr            16-bit PAN ID (hexadecimal).
 -c chan            number of channel to use.
 -h, --help         This usage information.
 -v, --version      Print version information.

Report bugs to linux-zigbee-devel@lists.sourceforge.net

Userspace tools for Linux IEEE 802.15.4 stack homepage <http://linux-zigbee.sourceforge.net/>

Simple Demo Example

On this demo network we will have 3 radios connected to different boards. On each of these radio interfaces, we will start 1 node which will have short addresses 0x1234, 0x8001 and 0x8002. Node with short address 0x1234 will act as a coordinator and shall run izcoordinator on it, which will handle network with PAN ID 0x10. Nodes 0x8001 and 0x8002 will associate with coordinator and will receive addresses after association. We will start izchat tool on these nodes.

Start the network coordinator

  • Add wpan-phy0
  • Set 64-bit (IEEE) address
  • Bring up interface wpan0
  • Start izcoordinator:
    • PAN ID: 0x10
    • 16-bit Short Address: 0x1234
    • Channel: 12

root:/> iz add wpan-phy0
Registered new device ('wpan0') on phy wpan-phy0

root:/> ip link set wpan0 address 11:22:33:44:55:66:77:88

root:/> ifconfig wpan0 up

root:/> izcoordinator -i wpan0 -s 0x1234 -c 12 -p 10

In case the izcoordinator daemon is started successfully we see it in the process list

root:/> ps
  PID USER       VSZ STAT COMMAND
    1 root       572 S    /init
    2 root         0 SW   [kthreadd]
    3 root         0 SW   [ksoftirqd/0]
    4 root         0 SW   [watchdog/0]
    5 root         0 SW   [events/0]
    6 root         0 SW   [khelper]
    9 root         0 SW   [async/mgr]
   41 root         0 SW   [sync_supers]
   43 root         0 SW   [bdi-default]
   45 root         0 SW   [kblockd/0]
   64 root         0 SW   [khungtaskd]
   65 root         0 SW   [kswapd0]
  104 root         0 SW   [mtdblockd]
  105 root         0 SW   [bfin-spi.0]
  118 root         0 SW   [wpan-phy0]
  144 root       798 S    -/bin/sh
  145 root       493 S    /sbin/inetd
  146 root       786 S    /sbin/syslogd -n
  147 root       782 S    /sbin/klogd -n
  148 root       483 S    /bin/watchdogd -f -s
  155 root       848 S    izcoordinator -i wpan0 -s 0x1234 -c 12 -p 10
  156 root       786 R    ps
root:/>

Following output from ifconfig indicates that wpan phy0 was successfully added and is running. The ip command also assigned the 64-bit (IEEE) address to the device.

root:/> ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wpan0     Link encap:UNSPEC  HWaddr 11-22-33-44-55-66-77-88-00-00-00-00-00-00-00-00
          UP BROADCAST RUNNING NOARP  MTU:127  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root:/>

Start NODE1

Associate with a given network via coordinator

  • Add wpan-phy0
  • Set 64-bit (IEEE) address
  • Bring up interface wpan0
  • Issue assoc command:
    • Interface: wpan0
    • PAN ID: 0x10
    • Channel: 12
    • 16-bit Short Addressing:

root:/> iz add wpan-phy0
Registered new device ('wpan0') on phy wpan-phy0

root:/> ip link set wpan0 address 11:22:33:44:55:66:77:11

root:/> ifconfig wpan0 up

root:/> iz assoc wpan0 10 0x1234 12 short
Received ASSOC-RESP status 0, addr 8001
Received short address 8001, status 00
root:/>

The network coordinator assigned short address 8001 to this node.

Start NODE2

Associate with a given network via coordinator

  • Add wpan-phy0
  • Set 64-bit (IEEE) address
  • Bring up interface wpan0
  • Issue assoc command:
    • Interface: wpan0
    • PAN ID: 0x10
    • Channel: 12
    • 16-bit Short Addressing:

root:/> iz add wpan-phy0
Registered new device ('wpan0') on phy wpan-phy0

root:/> ip link set wpan0 address 11:22:33:44:55:66:77:22

root:/> ifconfig wpan0 up

root:/> iz assoc wpan0 10 0x1234 12 short
Received ASSOC-RESP status 0, addr 8002
Received short address 8002, status 00
root:/>

The network coordinator assigned short address 8002 to this node.

Start chat application

Two nodes associated with the network. Now start simple chat program (0x8001 and 0x8002 are the short addresses are received during association):

Node 1:

root:/> izchat 10 8001 8002
Hello World!
>Thanks 

Node 2:

root:/> izchat 10 8002 8001
>Hello World!
Thanks

This is a pretty simple two way communication. The ASCII strings are encapsulated in IEEE802.15.4 DATA frames

More Information