【KW41z】Deploy KW41z TUN/TAP on RaspberryPi
First, let me talk about TUN/TAP.
It is actually a virtual network device.
Pure software simulation.
Those who have played with Linux should know that
Linux has a very interesting joke.
USB devices can be virtualized into a network device.
In the Thread of KW41z,
there are Framework Serial Connectivity Interface (FSCI) and Thread Host Control Interface (THCI).
Literally, it means a whole serial communication interface (USB, UART, SPI), which is quite awesome.
It can encapsulate/unpack IP packets into serial data.
If there is a router with a u port, plus software
, a KW41z board can complete the function of a border router.
As early as a few years ago, in the forum ATMEL R21 ZigBee event,
a forum master ported Contiki to R21.
With the help of the Slip protocol in Contiki, with the OPENWRT router and tunslip6 software, the
border router was completed.
This time, Enchapi's information
is once again awesome. The source code contains the border router routine
. At the same time,
the source code They are in ..\SDK_2.2_FRDM-KW41Z\tools\wireless\host_sdk\hsdk\demo.
It is really awesome.
Tried to deploy a version on the Raspberry Pi
-----------------Work on KW41z side------------------
Burn firmware on two boards separately
One is thread_host_controlled_device, theoretically similar projects under hybrid are also OK
The other is thread_router_eligible_device, theoretically other projects are also OK
Pay special attention
In the first project,
#define THR_SERIAL_TUN_ROUTER in the source\config.h file must be configured as 1.
Put the board with thread_host_controlled_device
burned
into the Raspberry Pi
The other one is on standby
------------------Work on the Raspberry Pi side------------------
2. Install dependencies
[C] Plain text view Copy code
1
2
|
apt-get install update
apt-get install build-essential libudev-dev libpcap-dev
|
3. Make a few times
In ..\host_sdk\hsdk, make once, then make install
In ..\host_sdk\hsdk\demo, execute make; make spi
At this time,
the executable code streams
GetKinetisDevices PCAPTest SPITest Thread_KW_Tun
will be generated in ..\host_sdk\hsdk\demo\bin./GetKinetisDevice
can view the KW41z board connected to the USB port
Execute it and you can see: NXP Kinetis-W device on /dev/ttyACM0.
The port number may be different for different systems./Thread_KW_Tun
is the program for processing IP packets
It will be used later Then
edit a sh file and add the virtual network interface
nano tun.sh
[C] Plain text view Copy code
01
02
03
04
05
06
07
08
09
10
11
12
13
|
#!/bin/bash
# Create a new TUN interface for Thread interaction.
ip -6 tuntap add mode tun fslthr0
# Assign it a global IPv6 address.
ip -6 addr add FD01::2 dev fslthr0
# Add route to default address of Serial TUN embedded interface.
ip -6 route add FD01::1 dev fslthr0
# Add route to Unique Local /64 Prefix via fslthr0.
ip -6 route add FD01:0000:0000:3EAD::/64 dev fslthr0
# The interface is ready.
ip link set fslthr0 up
# Enable IPv6 routing on host.
sysctl -w net.ipv6.conf.all.forwarding=1
|
The general meaning is to create an IPv6 virtual network interface called fslthr0
.
Run
ifconfig in ./tun.sh and you
will see something like this.
[C] Plain text view Copy code