KW41Z Host Controlled Device Example Issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KW41Z Host Controlled Device Example Issue

1,128 Views
nxf50230
NXP Employee
NXP Employee

Hi,

i am trying to set up a host controlled thread network with a KW41Z following the Kinetis FSCI Host Application Programming Interface User’s Guide. 

I defined the THR_SERIAL_TUN_ROUTER=1 in the config.h.

When i run the make_tun.sh script, i get the message:

IPv6: ADDRCONF(NETDEV_UP): threadtun0: link is not ready

When i start Thread_KW_Tun i get this output and then it stops:

[THR] Set 802.15.4 channel OK!
[THR] Create Network OK!
[MESHCOP] Start Commissioner OK!
[MESHCOP] Add Expected Joiner OK!
[MESHCOP] Sync Steering Data OK!

TX:
0000 60 00 00 00 00 24 00 01 fe 80 00 00 00 00 00 00 `....$..........
0010 30 46 33 cd bb 98 40 4a ff 02 00 00 00 00 00 00 0F3...@J........
0020 00 00 00 00 00 00 00 16 3a 00 05 02 00 00 01 00 ........:.......
0030 8f 00 10 13 00 00 00 01 04 00 00 00 ff 02 00 00 ................
0040 00 00 00 00 00 00 00 00 00 00 00 02 ............
TX:
0000 60 00 00 00 00 24 00 01 fe 80 00 00 00 00 00 00 `....$..........
0010 30 46 33 cd bb 98 40 4a ff 02 00 00 00 00 00 00 0F3...@J........
0020 00 00 00 00 00 00 00 16 3a 00 05 02 00 00 01 00 ........:.......
0030 8f 00 10 13 00 00 00 01 04 00 00 00 ff 02 00 00 ................
0040 00 00 00 00 00 00 00 00 00 00 00 02 ............

I also can't see the network when i scan for thread networks from another KW41Z.

Does anybody has a clue what i am doing wrong?

Best regards,

Frieder

Labels (2)
0 Kudos
4 Replies

905 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

Did you install all the necessary prerequisites mentioned in the Chapter 4? Which distribution and version are you using ?

Also, there are some changes mentioned in the chapter 6 regarding the definitions

#define BR_ROUTER_MODE 0
#define BR_HOST_MODE 1

As well as this other requirement mentioned in page 16.

$ sudo ip tuntap add mode tun threadtun0
$ ip link show threadtun0
5: threadtun0: <POINTOPOINT,MULTICAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 500
link/none
$ sudo ip -6 addr add FD01::2 dev threadtun0
$ ip address show threadtun0
5: threadtun0: <POINTOPOINT,MULTICAST,NOARP> mtu 1500 qdisc noop state DOWN qlen 500
link/none
inet6 fd01::2/128 scope global
valid_lft forever preferred_lft forever

Could you please help me confirm you already made that ?

Regards ,

Estephania

0 Kudos

905 Views
nxf50230
NXP Employee
NXP Employee

Hi Estephania,

thanks for your hints. I figured out that i used an old version of the KW41Z SDK. With the newest version (2.2.1) and #define SERIAL_TUN_IF 1 the output is different:  

TX:
0000 60 00 00 00 00 24 00 01 fe 80 00 00 00 00 00 00 `....$..........
0010 63 c6 e9 3c 52 96 14 a6 ff 02 00 00 00 00 00 00 c..<R...........
0020 00 00 00 00 00 00 00 16 3a 00 05 02 00 00 01 00 ........:.......
0030 8f 00 bb c9 00 00 00 01 04 00 00 00 ff 02 00 00 ................
0040 00 00 00 00 00 00 00 00 00 00 00 02 ............

RX:
0000 33 33 00 01 00 02 00 60 37 00 fa 5c 86 dd 60 00 33.....`7..\..`.
0010 00 00 00 34 11 80 fe 80 00 00 00 00 00 00 02 60 ...4...........`
0020 37 ff fe 00 fa 5c ff 02 00 00 00 00 00 00 00 00 7....\..........
0030 00 00 00 01 00 02 02 22 02 23 00 34 f5 6f 01 9f .......".#.4.o..
0040 85 a9 00 08 00 02 1c 22 00 01 00 0a 00 03 00 1b ......."........
0050 00 60 37 00 fa 5c 00 19 00 0c 00 00 00 00 00 00 .`7..\..........
0060 00 00 00 00 00 00 00 0e 00 00 ..........
TUN write: Invalid argument

I am using Linux 4.14.104-imx8-sr Kernel with Debian GNU/Linux 10 and i did all the prerequisites mentioned in the tutorial.

My college with an Ubuntu host machine has the same behavior.

Do you have any idea what is going wrong?

Best regards,

Frieder

0 Kudos

905 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

I checked the manual and found this note

"On Linux OS, the kernel modules which handle TUN/TAP are usually built in. If not, these can be easily compiled from the Linux OS source, by enabling Universal TUN/TAP device driver when issuing make menuconfig, or by enabling CONFIG_TUN=y or m in the build system .config file. If the kernel module is built as an external module, insmod tun.ko enables the functionality in the system. "

Do you know if your distribution has this enabled?

Regards,

Estephania

0 Kudos

905 Views
nxf55573
NXP Employee
NXP Employee

Hello,

I am the above mentioned colleague trying it on a Ubuntu machine with the needed kernel modules for the TUN/TAP interface.

I managed to solve the "TUN write" error, but I am still not able to create a network and join with a second FRDM-KW41Z running the "Thread router eligible device" demo.

I am compiling with the following Macro definitions: SERIAL_TUN_IF 1, BR_ROUTER_MODE 0, BR_HOST_MODE 1.

The TUN device is created and configured with the "make_tun.sh" script and during program execution the threadtun0 link status is UP.

I modified these functions to remove the Ethernet header from the network frame as written in Chapter 6 to enable TUN mode (both are located in ip_if_serial_tun.c):

- IP_SerialTunSend6: content of the "if(pEnetDstInf)" condition commented out

-IP_serialtunRecv:

   enetHdr_t enetpkt;
    uint16_t protocol;
    //EDITED -- start
    uint8_t protocolFix[] = {134, 221};//ADDED, HEX DUMP WAS: 86 dd
    
    /* check if interface is initialized and packet has correct size */
    if ((NULL != mIpSerialtunInterfaceHandle) && (size > ENET_HEADER_SIZE))
    {
//        FLib_MemCpy(&enetpkt, pInData, ENET_HEADER_SIZE);
//          protocol = ntohas(enetpkt.type);

        protocol = ntohas(protocolFix);//ADDED

//        /* Make sure IP packet is aligned */
//        size -= ENET_HEADER_SIZE;
//        FLib_MemInPlaceCpy(pInData, (uint8_t *) pInData + ENET_HEADER_SIZE, size);
        //EDITED -- end
        IPIF_STATS_ENABLED((*mIpSerialtunInterfaceHandle)->stats.commonStats.rxTotal++);
        IPIF_STATS_ENABLED((*mIpSerialtunInterfaceHandle)->stats.rxOctets += size);

Attached you find a Wireshark log, the output of the Thread_KW_Tun program and the Uart log of the "Thread router eligible device" running on a second FRDM-KW41Z.

Regards,

Fynn

0 Kudos