High level description to enable a Linux + KW41Z Border Router. Similar to how it’s shown for the K64 solution in the Kinetis Thread Stack Application Development Guide.
- Configure the OpenWrt router to assign the IPv6 ULA prefix 2001:2002:2003::/48. On the LAN network, the router distributes addresses from range 2001:2002:2003::/60
- Plug an Ethernet cable between the OpenWrt router and the Linux box. Before creating the Thread network, the Linux box has a global address on its eth interface from range 2001:2002:2003::/60. After creating the Thread network, the BR configures on its Serial TAP interface an address from range 2001:2002:2003::/60. On its 6LoWPAN interface, the BR configures an address from range 2001:2002:2003:c::/64. This is achieved with DHCPv6 prefix delegation - the router is requested to assign a new prefix space to be used by the Thread network. The forth segment in the IPv6 range might be 2, 4, 8 or c, depending of the number of DHCP-PD requests made to the router. After 4 attempts, the router will not lease any other prefixes for some time. In order to force that, you'd require to restart the odhcpd deamon in the OpenWrt router with the following command: /etc/init.d/odhcpd restart .
- Join the router eligible device, which configures an address in 2001:2002:2003::1/60. We then ping the "Internet" (the LAN interface on the OpenWrt router) and it works.
“threadtap0” interface must be bridged with an uplink interface connected to an OpenWrt DHCPv6-PD enabled router; it will act identically as the K64F solution.
- Linux PC (Ubuntu)
- OpenWrt AP/Router with DHCPv6-PD support (OpenWrt version used in this guide: OpenWrt Chaos Calmer 15.05.1)
- For reference, hardware used on this guide: TP-Link Model TL-WR741ND 150Mbps Wireless N Router
- OpenWRT firmware supports multiple hardware available at https://openwrt.org/
- 1 FRDM-KW41Z (Host Controlled Device, connected to Linux)
- 1 FRDM-KW41Z (Router Eligible Device or any joiner device)
- Thread version 184.108.40.206 (from SDK builder at mcuxpresso.nxp.com)
Host Controlled Device firmware, make sure the following macros are enabled:
- THR_SERIAL_TUN_ROUTER /source/config.h -> Enables TAP interface by default (not TUN)
- THR_SERIAL_TUN_ENABLE_ND_HOST /app/common/app_serial_tun.h
- Configure IPv6 ULA-Prefix:
- Copy HSDK folder
- Create 'threadtap0' TAP interface:
…/host_sdk/hsdk/demo# sudo bash make_tap.sh
- Use "Thread_Shell" or modify “Thread_KW_Tun” demo to enable the SERIAL_TAP macro
…/host_sdk/hsdk/demo# nano Thread_KW_Tun.c
#define SERIAL_TAP 0 modify to: #define SERIAL_TAP 1
Note: For demo purposes, the "Thread_Shell" demo is recommended, it already uses TAP by default and allows input commands. If this is not required and only the TAP bridge is to be used, use the Thread_KW_Tun demo.
- Bridge the interfaces; assuming eno1 is the interface connected directly to OpenWrt:
# brctl addbr br0
# brctl addif br0 eno1
# brctl addif br0 threadtap0
# ifconfig br0 up
- Note: (Optional) Addresses on the bridged interfaces are lost and need to be reconfigured on the actual bridge. In this example, after bridging eno1 (interface to OpenWrt router), you’d have to run #dhclient br0 to get an IPv4 address on br0 for SSH to the router and/or #dhclient -6 br0 to get an IPv6 address to the br0 interface. There's a note here https://wiki.archlinux.org/index.php/Network_bridge#With_bridge-utils about this.
- Build C demos
- Run Thread_Shell or Thread_KW_Tun demo.
…/host_sdk/hsdk/demo# sudo ./bin/Thread_Shell /dev/ttyACM0 threadtap0 25
…/host_sdk/hsdk/demo# sudo ./bin/Thread_KW_Tun /dev/ttyACM0 threadtap0
Note: Try to run the demo without parameters to get some help on the input parameters
Joiner FRDM-KW41Z (shell)
- Join the Thread network
- Verify IP addresses
- Ping Eth LAN interface on OpenWrt router to verify “Internet” connectivity