Skip to content
Paul Sokolovsky edited this page Oct 23, 2017 · 5 revisions

How to configure Linux 802.15.4 interface for interconnectivity to Zephyr.

Reference hardware:

Zephyr side:

samples/net/ieee802154 or samples/net/echo_server (the latter lacks frdm_kw41z config in the mainline so far).

Configuring Linux:

  1. An older way to configure 802.15.4 interfaces/subsysem is lowpan-tools package (iz, etc. executable). That's what e.g. Ubuntu 16.04 ships. But it's not flexible enough for our use, e.g. it doesn't allow to configure 15.4 channel number and other similar params.
  2. Instead, newer wpan-tools should be used, which allows to configure fine-grained params like above. On distros which lack native package, it can be built from source (tested on Ubuntu 16.04).
  3. List available phy devices: iwpan list.
  4. List available 15.4 interfaces: iwpan dev.
  5. Configure channel to used by default by Zephyr: sudo iwpan phy phy0 set channel 0 26.
  6. Configure PAN ID to used by default by Zephyr: sudo iwpan dev wpan0 set pan_id 0xabcd.
  7. wpan0 is an 15.4 interface, not suitable for IP networking directly (one sign of that is that it has 15.4 MTU, ~ 127). For IPv6 networking, we need to wrap it in 6LoWPAN interface: ip link add link wpan0 name lowpan0 type lowpan. Created lowpan0 interface will have the standard IPv6 MTU (1280), can have IPv6 addresses configured, etc.
  8. Make sure that both interfaces are up: sudo ifconfig wpan0 up, sudo ifconfig lowpan0 up.
  9. Configure Zephyr's standard sample IPv6 address: sudo ip address add 2001:db8::2/64 dev lowpan0
  10. Verify that the device can be pinged: ping6 -I lowpan0 2001:db8::1, then ping6 2001:db8::1.

Script for more or less automated setup:

set -ex

PHY=$1
WPAN=$2

if [ -z "$PHY" ]; then
    PHY=$(./iwpan phy | awk '/^wpan_phy/ {print $2}')
fi

if [ -z "$WPAN" ]; then
    WPAN=$(./iwpan dev | awk '/Interface/ {print $2}')
fi

ifconfig lowpan0 down
ifconfig wpan0 down
./iwpan phy $PHY set channel 0 26
./iwpan dev $WPAN set pan_id 0xabcd
ip link add link wpan0 name lowpan0 type lowpan || true
ifconfig wpan0 up
ifconfig lowpan0 up
ip address add 2001:db8::2/64 dev lowpan0

ping6 2001:db8::1
Clone this wiki locally