Difference between revisions of "NRF52840 Thread NCP"

From HiveTool
Jump to: navigation, search
(Set up the border router on the Pi:)
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
Pi Border Router with nRF52840 thread NCP
 
Pi Border Router with nRF52840 thread NCP
  
https://electronut.in/nrf52840-thread/
+
This is an attempt at turning the Pi into a thread border router using the nRF52840 dongle as the Network Co Processor (NCP).
  
 +
The nRF52840 dongle must be programmed with the NCP application.  One way is to use the nRF Connect program.
  
https://groups.google.com/forum/#!topic/openthread-users/9TFIATWWrxw
+
==Background Resources==
 +
 
 +
*OpenThread Border Router done with a different dongle: https://wiki.makerdiary.com/nrf52840-mdk-usb-dongle/OTBR/
 +
*Playing with Thread and MQTT-SN on Nordic nRF52840: https://electronut.in/nrf52840-thread/
 +
*Programming the nRF52840 Dongle from nRF Connect: https://groups.google.com/forum/#!topic/openthread-users/9TFIATWWrxw
 +
*Nordic nRF5 Software Development Kit for Thread and Zigbee: https://www.nordicsemi.com/DocLib/Content/SDK_Doc/Thread_SDK/v2-0-0/index
 +
*OpenThread CLI Reference: https://github.com/openthread/openthread/blob/2bce9557e62c451307d1a4d944c3eaf69f71573c/src/cli/README.md
 +
*Network Discovery and Formation: https://openthread.io/guides/thread-primer/network-discovery
 +
*Thread Commissioning https://openthread.io/guides/build/commissioning
  
https://www.nordicsemi.com/DocLib/Content/SDK_Doc/Thread_SDK/v2-0-0/index
 
  
 
==Install Network Co Processor (NCP) code on nRF52==
 
==Install Network Co Processor (NCP) code on nRF52==
Line 24: Line 32:
 
==Set up the border router on the Pi:==
 
==Set up the border router on the Pi:==
 
You need both border router and wpantund:
 
You need both border router and wpantund:
 +
 +
===Install borderrouter code===
  
 
https://openthread.io/guides/border-router/build
 
https://openthread.io/guides/border-router/build
Line 34: Line 44:
 
  sudo make install
 
  sudo make install
  
 +
===Install wpantund===
  
 
  git clone https://github.com/openthread/wpantund.git
 
  git clone https://github.com/openthread/wpantund.git
Line 42: Line 53:
 
  make
 
  make
 
  sudo make install
 
  sudo make install
 +
 +
===Install OpenThread===
  
 
  git clone https://github.com/openthread/openthread
 
  git clone https://github.com/openthread/openthread
Line 49: Line 62:
 
Check wpan status
 
Check wpan status
 
  sudo wpanctl status
 
  sudo wpanctl status
 
'''MUST ADD ROUTES ON ALL MACHINES!'''
 
route -6 add 2001:0002::/48 metric 1 dev eth0
 
  
 
==Install radvd==
 
==Install radvd==
Line 85: Line 95:
 
  sudo systemctl stop radvd
 
  sudo systemctl stop radvd
  
 +
===Add IPv6 routes ===
 +
 +
'''MUST ADD ROUTES ON ALL MACHINES!'''
 +
 +
route -6 add 2001:0002::/48 metric 1 dev eth0
 +
 +
On Pi:
 +
sudo route -6 add fd00:1122::/64 metric 1 dev eth0
 +
 +
On Debian
 +
ip -6 route add fd00:1122::/64 dev wlp1s0
  
 
==Install libcoap==
 
==Install libcoap==
 +
 +
https://learn.pimoroni.com/tutorial/sandyj/controlling-ikea-tradfri-lights-from-your-pi
 +
 +
https://github.com/smartuni/examples/wiki/libcoap
 +
 
  sudo apt-get install build-essential autoconf automake libtool
 
  sudo apt-get install build-essential autoconf automake libtool
 
  git clone --recursive https://github.com/obgm/libcoap.git
 
  git clone --recursive https://github.com/obgm/libcoap.git
Line 96: Line 122:
 
  make
 
  make
 
  sudo make install
 
  sudo make install
 +
 +
Or maybe just:
 +
sudo apt-get install libcoap-1-0-dev
 +
 +
https://github.com/RichardChambers/raspberrypi/tree/master/coap
 +
 +
 +
 +
 +
 +
 +
 +
==Commissioning==
 +
 +
https://openthread.io/guides/build/commissioning
 +
 +
 +
===wpanctl===
 +
 +
 +
 +
wpanctl:wpan0> join OpenThread -p 0xABCD
 +
Joining WPAN "OpenThread" as node type "end-device", panid:0xABCD
 +
Partial (insecure) join. Credentials needed. Update key to continue.
 +
wpanctl:wpan0> join OpenThread -x 0xDEAD00BEEF00CAFE
 +
Joining WPAN "OpenThread" as node type "end-device", xpanid:0xDEAD00BEEF00CAFE
 +
Partial (insecure) join. Credentials needed. Update key to continue.
 +
 +
==nRF52840 CoAP code examples==
 +
 +
https://github.com/cellabox/cellabox

Latest revision as of 03:42, 23 January 2019

Pi Border Router with nRF52840 thread NCP

This is an attempt at turning the Pi into a thread border router using the nRF52840 dongle as the Network Co Processor (NCP).

The nRF52840 dongle must be programmed with the NCP application. One way is to use the nRF Connect program.

Background Resources


Install Network Co Processor (NCP) code on nRF52

Download nRF Connect program.

./nrfconnect-2.6.1-x86_64.AppImage

Downloaded the nRF5 SDK for Thread and Zigbee 2.0.0

https://www.nordicsemi.com/Software-and-Tools/Software/nRF5-SDK-for-Thread-and-Zigbee/Download

Write the NCP hex file to the dongle.

Set up the border router on the Pi:

You need both border router and wpantund:

Install borderrouter code

https://openthread.io/guides/border-router/build

git clone https://github.com/openthread/borderrouter
cd borderrouter
./script/bootstrap
.configure --enable-debug  --enable-ncp --enable-ftd --enable-commissioner --enable-joiner --enable-border-agent --enable-border-router --enable-commissioner --enable-udp-forward
make
sudo make install

Install wpantund

git clone https://github.com/openthread/wpantund.git
cd wpantund
./bootstrap.sh
./configure --sysconfdir=/etc --enable-debug
make -j4  // -j4 (use 4 cores) may have locked it up
make
sudo make install

Install OpenThread

git clone https://github.com/openthread/openthread

./configure --enable-ncp --enable-ftd --enable-commissioner --enable-joiner --enable-border-agent --enable-border-router --enable-commissioner --enable-udp-forward


Check wpan status

sudo wpanctl status

Install radvd

Add interface wlan0

sudo vi /etc/radvd.conf
interface wlan0
{
   AdvSendAdvert on;
   prefix FD00:1122::/64
   {
       AdvOnLink off;
       AdvAutonomous on;
       AdvRouterAddr on;
   };
};

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


sudo systemctl stop radvd

Add IPv6 routes

MUST ADD ROUTES ON ALL MACHINES!

route -6 add 2001:0002::/48 metric 1 dev eth0

On Pi:

sudo route -6 add fd00:1122::/64 metric 1 dev eth0

On Debian

ip -6 route add fd00:1122::/64 dev wlp1s0

Install libcoap

https://learn.pimoroni.com/tutorial/sandyj/controlling-ikea-tradfri-lights-from-your-pi

https://github.com/smartuni/examples/wiki/libcoap

sudo apt-get install build-essential autoconf automake libtool
git clone --recursive https://github.com/obgm/libcoap.git
cd libcoap
git checkout dtls
git submodule update --init --recursive
./autogen.sh
./configure --disable-documentation --disable-shared
make
sudo make install

Or maybe just:

sudo apt-get install libcoap-1-0-dev

https://github.com/RichardChambers/raspberrypi/tree/master/coap




Commissioning

https://openthread.io/guides/build/commissioning


wpanctl

wpanctl:wpan0> join OpenThread -p 0xABCD
Joining WPAN "OpenThread" as node type "end-device", panid:0xABCD
Partial (insecure) join. Credentials needed. Update key to continue.
wpanctl:wpan0> join OpenThread -x 0xDEAD00BEEF00CAFE
Joining WPAN "OpenThread" as node type "end-device", xpanid:0xDEAD00BEEF00CAFE
Partial (insecure) join. Credentials needed. Update key to continue.

nRF52840 CoAP code examples

https://github.com/cellabox/cellabox