This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf5 SDK IoT cannot ping nrf52840 from router

Hi!

I'm trying to do the TCP example with the nRF5_SDK_16.0.0_98a08e2, a nrf52840 DK board and a Raspberry Pi 3 B+ as a gateway but I got some problems.

For connecting the board to the Raspberry Pi I've followed the instructions from the tutorials (https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.iotsdk.v0.9.0/iot_getting_started.html?cp=7_4_2). My shell script derived from the tutorial looks like this:

#!/bin/sh
# Mount debugfs file system
mount -t debugfs none /sys/kernel/debug

# Load 6LoWPAN module
modprobe bluetooth_6lowpan

# Enable 6LoWPAN
echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable

# Set IPv6 forwarding
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding

# Run Router-Advertisement Daemon (radvd)
service radvd restart

# Look for available HCI devices
# hciconfig

# Reset HCI device
hciconfig hci0 reset

# Read BLE-Address from nRF51
timeout 3s hcitool lescan

# Connect to the device
echo "connect 00:81:1D:38:22:71 1" > /sys/kernel/debug/bluetooth/6lowpan_control
sleep 3

# Add the IP prefix to the Bluetooth Interface bt0
ip address add 2001:db8::2/64 dev bt0
ifconfig bt0

# Restart radvd service
service radvd restart

echo "ping the BLE device using the global address"
ping6 2001:db8:1::281:1dff:fe38:22:71 -c 5

Further, I have the following radvd.conf file:

interface bt0
{
    AdvSendAdvert on;
    prefix 2001:db8::/64
    {
        AdvOnLink off;
        AdvAutonomous on;
        AdvRouterAddr on;
    };
};

Now if I run the script, it is not possible to ping the nrf52840 board. The output I get is as follows:

bt0: flags=4161<UP,RUNNING,MULTICAST>  mtu 1280
        inet6 fe80::b827:ebff:fef5:2a08  prefixlen 64  scopeid 0x20<link>
        inet6 2001:db8::2  prefixlen 64  scopeid 0x0<global>
        unspec B8-27-EB-F5-2A-08-78-B3-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
        RX packets 1  bytes 20 (20.0 B)
        RX errors 0  dropped 2  overruns 0  frame 0
        TX packets 12  bytes 1173 (1.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ping the BLE device using the global address
ping: 2001:db8:1::281:1dff:fe38:22:71: Name or service not known

Also, if I send an echo request to discover all devices that are currently attached to the RasPi router, I only get responses from the bt0 interface an no response from the BLE device:

sudo ping6 -I bt0 ff02::1
PING ff02::1(ff02::1) from fe80::b827:ebff:fef5:2a08%bt0 bt0: 56 data bytes
64 bytes from fe80::b827:ebff:fef5:2a08%bt0: icmp_seq=1 ttl=64 time=0.154 ms
64 bytes from fe80::b827:ebff:fef5:2a08%bt0: icmp_seq=2 ttl=64 time=0.147 ms
64 bytes from fe80::b827:ebff:fef5:2a08%bt0: icmp_seq=3 ttl=64 time=0.123 ms

Another observation that I made is that every time approximately after 30 seconds the nrf52840 BLE device loses its BLE connection.

My Raspberry Pi has kernel version 4.19.66-v7+ and runs Raspbian Stretch.

I tried changing BLE_6LOWPAN_LEGACY_MODE in the sdk_config.h from 1 to 0 (according to this post with a similar problem: https://devzone.nordicsemi.com/f/nordic-q-a/44801/nrf-sdk-iot-mqtt-publisher-example-can-t-ping-from-bt0-and-interface-go-down) but it didn't change anything.

Even if I simply run the given instructions (see below) from the tutorial I cannot ping the board.

#!/bin/sh

# Mount debugfs file system.
mount -t debugfs none /sys/kernel/debug

# Load 6LoWPAN module.
modprobe bluetooth_6lowpan

# Enable the bluetooth 6lowpan module.
echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable

# Look for available HCI devices.
hciconfig

# Reset HCI device - for example hci0 device.
hciconfig hci0 reset
sleep 2

# Read 00:AA:BB:XX:YY:ZZ address of the nRF5x device.
timeout 3s hcitool lescan

# Connect to the device.
echo "connect 00:81:1D:38:22:71 1" > /sys/kernel/debug/bluetooth/6lowpan_control
sleep 3

# Check if you have established a connection.
ifconfig

# Try to ping the device using its link-local address, for example, on bt0 interface.
ping6 -I bt0 fe80::281:1dff:fe38:2271

When sending the ping to the link local address I do not get any response:

ping6: Warning: source address might be selected on device other than: bt0
PING fe80::281:1dff:fe38:2271(fe80::281:1dff:fe38:2271) from :: bt0: 56 data bytes
^C
--- fe80::281:1dff:fe38:2271 ping statistics ---
27 packets transmitted, 0 received, 100% packet loss, time 26620ms

I searched the Nordic forums a lot, but in almost every post that I found, people were at least able to ping the BLE board.

If maybe somebody experienced the same problem and could help me I would be very glad.

Parents
  • Can you check if  6lowpan_enable and forwarding are actually set by running:

    cat /proc/sys/net/ipv6/conf/all/forwarding
    cat /sys/kernel/debug/bluetooth/6lowpan_enable

    if you install wireshark you can sniff the bt0 interface and see the traffic that is going though the bt0 interface. If you post the log here I can try and see if there's something wrong.

    Which example are you running from the SDK, and have you made any changes? If you connect a terminal to the DK what is the log telling you?

    There is still a typing mistake in the ping command in your last post. The last two bytes should be 2271, not 22:71

    The ping command where you ping the link local address is correct, but here you don't add the global address to the bt0 interface, or restart radvd. You need to add the global address to the bt0 interface every time you reconnect to the BLE device.

  • Hi Stian thanks for your response!

    1. Thanks for mentioning the typo in the address. I removed it but unfortunately it didn't solve the problem.

    2. I ran the two "cat" commands you mentioned and both times the result was 1, so the values were set correctly.

    3. I am running the TCP server example from $(SDK_ROOT)/examples/iot/tcp/server

    4. The log from a connected terminal is always the same an doesn't really help. It just confirms that the BLE connect was successful and that the ipv6 interface was initialized:

    <info> app_timer: RTC: initialized.␍␍␊
    <info> app: Application started.␍␍␊
    <info> app: Physical layer in connectable mode.␍␍␊
    <info> app: Physical layer: connected.␍␍␊
    <info> app: IPv6 interface up.␍␍␊

    5. Concerning the ping of the link local address I did another try, but this time ensuring that the radvd service is stopped before and I also ensured that no global address to the bt0 interface is added. The shell script I wrote for this is the following:

    #!/bin/sh
    # execute as superuser!!!
    
    # stop a possibly running radvd service
    service radvd stop
    # Mount debugfs file system.
    mount -t debugfs none /sys/kernel/debug
    # Load 6LoWPAN module.
    modprobe bluetooth_6lowpan
    # Enable the bluetooth 6lowpan module.
    echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable
    # Look for available HCI devices.
    hciconfig
    # Reset HCI device - for example hci0 device.
    hciconfig hci0 reset
    sleep 2
    # Read 00:AA:BB:XX:YY:ZZ address of the nRF5x device.
    #timeout 3s hcitool lescan
    # Connect to the device.
    echo "Connecting to device 00:81:1D:38:22:71"
    echo "connect 00:81:1D:38:22:71 1" > /sys/kernel/debug/bluetooth/6lowpan_control
    sleep 20 #sleep long enough to refresh wireshark interfaces
    # Check if you have established a connection.
    ifconfig bt0
    echo "discover the link local addresses of the board"
    ping6 -I bt0 ff02::1 -c 5
    sleep 2
    # Try to ping the device using its link-local address, for example, on bt0 interface.
    echo " "
    ping6 -I bt0 fe80::281:1dff:fe38:2271 -c 5

    The corresponding terminal output to this shell script is:

    mount: none is already mounted or /sys/kernel/debug busy
    hci0:	Type: Primary  Bus: UART
    	BD Address: B8:27:EB:F5:2A:08  ACL MTU: 1021:8  SCO MTU: 64:1
    	UP RUNNING 
    	RX bytes:2825 acl:49 sco:0 events:140 errors:0
    	TX bytes:5831 acl:53 sco:0 commands:104 errors:0
    
    Connecting to device 00:81:1D:38:22:71
    bt0: flags=4161<UP,RUNNING,MULTICAST>  mtu 1280
            inet6 fe80::b827:ebff:fef5:2a08  prefixlen 64  scopeid 0x20<link>
            unspec B8-27-EB-F5-2A-08-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
            RX packets 1  bytes 28 (28.0 B)
            RX errors 0  dropped 2  overruns 0  frame 0
            TX packets 17  bytes 1361 (1.3 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    discover the link local addresses of the board
    PING ff02::1(ff02::1) from fe80::b827:ebff:fef5:2a08%bt0 bt0: 56 data bytes
    64 bytes from fe80::b827:ebff:fef5:2a08%bt0: icmp_seq=1 ttl=64 time=0.185 ms
    64 bytes from fe80::b827:ebff:fef5:2a08%bt0: icmp_seq=2 ttl=64 time=0.198 ms
    64 bytes from fe80::b827:ebff:fef5:2a08%bt0: icmp_seq=3 ttl=64 time=0.168 ms
    64 bytes from fe80::b827:ebff:fef5:2a08%bt0: icmp_seq=4 ttl=64 time=0.103 ms
    64 bytes from fe80::b827:ebff:fef5:2a08%bt0: icmp_seq=5 ttl=64 time=0.106 ms
    
    --- ff02::1 ping statistics ---
    5 packets transmitted, 5 received, 0% packet loss, time 4194ms
    rtt min/avg/max/mdev = 0.103/0.152/0.198/0.039 ms
     
    PING fe80::281:1dff:fe38:2271(fe80::281:1dff:fe38:2271) from fe80::b827:ebff:fef5:2a08%bt0 bt0: 56 data bytes
    From fe80::b827:ebff:fef5:2a08%bt0 icmp_seq=1 Destination unreachable: Address unreachable
    From fe80::b827:ebff:fef5:2a08%bt0 icmp_seq=2 Destination unreachable: Address unreachable
    From fe80::b827:ebff:fef5:2a08%bt0 icmp_seq=3 Destination unreachable: Address unreachable
    From fe80::b827:ebff:fef5:2a08%bt0 icmp_seq=4 Destination unreachable: Address unreachable
    From fe80::b827:ebff:fef5:2a08%bt0 icmp_seq=5 Destination unreachable: Address unreachable
    
    --- fe80::281:1dff:fe38:2271 ping statistics ---
    5 packets transmitted, 0 received, +5 errors, 100% packet loss, time 4148ms

    Apparently, the RaspberryPi's bt0 interface is not able to discover the link local address of the BLE board and therefore also cannot ping it.

    The data sniffed by whireshark on the bt0 interface was as follows:
    ble_ipv6_nrf_sdk_local.pcapng
    It just shows the ping requests from the bt0 interface but no response from the nrf52840 dk.

    The serial terminal log output was again similar as shown above in point 4.

    6. I could show you similar results for my try with radvd enabled and a global bt0 address (to address your point here: I indeed added/add the global address every time I reconnect the BLE device), but I don't think that the problem lies in the configuration of radvd, ipv6 forwarding and global addresses, if I'm even not able to detect and ping the BLE device's link local address.

    I hope this gives you more information for further debugging help. Thank you very much!!!

Reply
  • Hi Stian thanks for your response!

    1. Thanks for mentioning the typo in the address. I removed it but unfortunately it didn't solve the problem.

    2. I ran the two "cat" commands you mentioned and both times the result was 1, so the values were set correctly.

    3. I am running the TCP server example from $(SDK_ROOT)/examples/iot/tcp/server

    4. The log from a connected terminal is always the same an doesn't really help. It just confirms that the BLE connect was successful and that the ipv6 interface was initialized:

    <info> app_timer: RTC: initialized.␍␍␊
    <info> app: Application started.␍␍␊
    <info> app: Physical layer in connectable mode.␍␍␊
    <info> app: Physical layer: connected.␍␍␊
    <info> app: IPv6 interface up.␍␍␊

    5. Concerning the ping of the link local address I did another try, but this time ensuring that the radvd service is stopped before and I also ensured that no global address to the bt0 interface is added. The shell script I wrote for this is the following:

    #!/bin/sh
    # execute as superuser!!!
    
    # stop a possibly running radvd service
    service radvd stop
    # Mount debugfs file system.
    mount -t debugfs none /sys/kernel/debug
    # Load 6LoWPAN module.
    modprobe bluetooth_6lowpan
    # Enable the bluetooth 6lowpan module.
    echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable
    # Look for available HCI devices.
    hciconfig
    # Reset HCI device - for example hci0 device.
    hciconfig hci0 reset
    sleep 2
    # Read 00:AA:BB:XX:YY:ZZ address of the nRF5x device.
    #timeout 3s hcitool lescan
    # Connect to the device.
    echo "Connecting to device 00:81:1D:38:22:71"
    echo "connect 00:81:1D:38:22:71 1" > /sys/kernel/debug/bluetooth/6lowpan_control
    sleep 20 #sleep long enough to refresh wireshark interfaces
    # Check if you have established a connection.
    ifconfig bt0
    echo "discover the link local addresses of the board"
    ping6 -I bt0 ff02::1 -c 5
    sleep 2
    # Try to ping the device using its link-local address, for example, on bt0 interface.
    echo " "
    ping6 -I bt0 fe80::281:1dff:fe38:2271 -c 5

    The corresponding terminal output to this shell script is:

    mount: none is already mounted or /sys/kernel/debug busy
    hci0:	Type: Primary  Bus: UART
    	BD Address: B8:27:EB:F5:2A:08  ACL MTU: 1021:8  SCO MTU: 64:1
    	UP RUNNING 
    	RX bytes:2825 acl:49 sco:0 events:140 errors:0
    	TX bytes:5831 acl:53 sco:0 commands:104 errors:0
    
    Connecting to device 00:81:1D:38:22:71
    bt0: flags=4161<UP,RUNNING,MULTICAST>  mtu 1280
            inet6 fe80::b827:ebff:fef5:2a08  prefixlen 64  scopeid 0x20<link>
            unspec B8-27-EB-F5-2A-08-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
            RX packets 1  bytes 28 (28.0 B)
            RX errors 0  dropped 2  overruns 0  frame 0
            TX packets 17  bytes 1361 (1.3 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    discover the link local addresses of the board
    PING ff02::1(ff02::1) from fe80::b827:ebff:fef5:2a08%bt0 bt0: 56 data bytes
    64 bytes from fe80::b827:ebff:fef5:2a08%bt0: icmp_seq=1 ttl=64 time=0.185 ms
    64 bytes from fe80::b827:ebff:fef5:2a08%bt0: icmp_seq=2 ttl=64 time=0.198 ms
    64 bytes from fe80::b827:ebff:fef5:2a08%bt0: icmp_seq=3 ttl=64 time=0.168 ms
    64 bytes from fe80::b827:ebff:fef5:2a08%bt0: icmp_seq=4 ttl=64 time=0.103 ms
    64 bytes from fe80::b827:ebff:fef5:2a08%bt0: icmp_seq=5 ttl=64 time=0.106 ms
    
    --- ff02::1 ping statistics ---
    5 packets transmitted, 5 received, 0% packet loss, time 4194ms
    rtt min/avg/max/mdev = 0.103/0.152/0.198/0.039 ms
     
    PING fe80::281:1dff:fe38:2271(fe80::281:1dff:fe38:2271) from fe80::b827:ebff:fef5:2a08%bt0 bt0: 56 data bytes
    From fe80::b827:ebff:fef5:2a08%bt0 icmp_seq=1 Destination unreachable: Address unreachable
    From fe80::b827:ebff:fef5:2a08%bt0 icmp_seq=2 Destination unreachable: Address unreachable
    From fe80::b827:ebff:fef5:2a08%bt0 icmp_seq=3 Destination unreachable: Address unreachable
    From fe80::b827:ebff:fef5:2a08%bt0 icmp_seq=4 Destination unreachable: Address unreachable
    From fe80::b827:ebff:fef5:2a08%bt0 icmp_seq=5 Destination unreachable: Address unreachable
    
    --- fe80::281:1dff:fe38:2271 ping statistics ---
    5 packets transmitted, 0 received, +5 errors, 100% packet loss, time 4148ms

    Apparently, the RaspberryPi's bt0 interface is not able to discover the link local address of the BLE board and therefore also cannot ping it.

    The data sniffed by whireshark on the bt0 interface was as follows:
    ble_ipv6_nrf_sdk_local.pcapng
    It just shows the ping requests from the bt0 interface but no response from the nrf52840 dk.

    The serial terminal log output was again similar as shown above in point 4.

    6. I could show you similar results for my try with radvd enabled and a global bt0 address (to address your point here: I indeed added/add the global address every time I reconnect the BLE device), but I don't think that the problem lies in the configuration of radvd, ipv6 forwarding and global addresses, if I'm even not able to detect and ping the BLE device's link local address.

    I hope this gives you more information for further debugging help. Thank you very much!!!

Children
No Data
Related