"Build a Thread Network" Codelab: NCP image is not initializing nRF52840 board

132 views
Skip to first unread message

Rob Conaway

unread,
Jun 7, 2018, 6:16:05 PM6/7/18
to openthread-users
I'm working through the "Build a Thread Network" codelab.  After a lot of trial an error, I think I've discovered that the NCP build has something wrong with its initialization.  If this is the case, I could use some help figuring out how to fix it.

I'm working with an NCP Image, built as recommended for the NCP Joiner, and a CLI image, built as recommended for the Commissioner and Joiner.  There is one nRF52840 connected to a USB port on my laptop.  The laptop is running Ubuntu 16.04.

The NCP image is intermittent.  When it works, I can start wpantund and the output is:

wpantund[16597]: Starting wpantund 0.08.00d (Jun  7 2018 12:45:25) . . .
wpantund[16597]: SOURCE_VERSION = 0.07.01-216-g5b87c93
wpantund[16597]: BUILD_VERSION = 0.07.01-216-g5b87c93
wpantund[16597]: Configuration file "/etc/wpantund.conf" read.
wpantund[16597]: Ready. Using DBUS bus ":1.0"
wpantund[16597]: Running as root without dropping privileges!
wpantund[16597]: State change: "uninitialized" -> "offline"
wpantund[16597]: NCP is running "OPENTHREAD/20170716-00634-gddf177e-dirty; NRF52840; Jun  7 2018 16:33:08"
wpantund[16597]: Driver is running "0.08.00d (0.07.01-216-g5b87c93; Jun  7 2018 12:45:25)"
wpantund[16597]: HARDWARE ADDRESS IS INVALID, MULTICAST BIT IS SET!
wpantund[16597]: Network is not joinable
wpantund[16597]: Resetting interface(s). . .
wpantund[16597]: ../util/netif-mgmt.c:530: Requirement Failed ((ret) == 0)
wpantund[16597]: ../util/netif-mgmt.c:530: Requirement Failed ((ret) == 0)
wpantund[16597]: ../util/netif-mgmt.c:530: Requirement Failed ((ret) == 0)
wpantund[16597]: ../util/netif-mgmt.c:530: Requirement Failed ((ret) == 0)
wpantund[16597]: ../util/netif-mgmt.c:530: Requirement Failed ((ret) == 0)
wpantund[16597]: Finished initializing NCP

When it doesn't work, the output is:

wpantund[16425]: Starting wpantund 0.08.00d (Jun  7 2018 12:45:25) . . .
wpantund[16425]:  SOURCE_VERSION = 0.07.01-216-g5b87c93
wpantund[16425]:  BUILD_VERSION = 0.07.01-216-g5b87c93
wpantund[16425]: Configuration file "/etc/wpantund.conf" read.
wpantund[16425]: Ready. Using DBUS bus ":1.0"
wpantund[16425]: Running as root without dropping privileges!
wpantund[16425]: SpinelNCPInstance-Protothreads.cpp:414: Requirement Failed (IS_EVENT_FROM_NCP(event) && GetInstance(this)->mInboundHeader == mLastHeader)
wpantund[16425]: Resetting and trying again... (retry 1)
wpantund[16425]: SpinelNCPInstance-Protothreads.cpp:402: Requirement Failed (event == EVENT_NCP_RESET)
wpantund[16425]: Resetting and trying again... (retry 2)
wpantund[16425]: SpinelNCPInstance-Protothreads.cpp:402: Requirement Failed (event == EVENT_NCP_RESET)
wpantund[16425]: Resetting and trying again... (retry 3)
wpantund[16425]: SpinelNCPInstance-Protothreads.cpp:402: Requirement Failed (event == EVENT_NCP_RESET)
wpantund[16425]: The NCP is misbehaving: Repeatedly unable to initialize NCP. Entering fault state.
wpantund[16425]: State change: "uninitialized" -> "uninitialized:fault"

Here is the scenario where it works:

It doesn't seem to matter how many nRF52840 boards are attached.  The target board is at /dev/ttyACM0 with serial $SERIAL.

1) build the NCP image:

cd ~/openthread 
make -f examples/Makefile-nrf52840 clean
make -j4 -f examples/Makefile-nrf52840 JOINER=1
cd ~/openthread/output/nrf52840/bin
arm-none-eabi-objcopy -O ihex ot-ncp-ftd ~/work/ot-ncp-ftd.hex

2) build the CLI image:

cd ~/openthread
make -f examples/Makefile-nrf52840 clean
make -j4 -f examples/Makefile-nrf52840 COMMISSIONER=1 JOINER=1
cd ~/openthread/output/nrf52840/bin
arm-none-eabi-objcopy -O ihex ot-cli-ftd ~/work/ot-cli-ftd.hex

3) flash the CLI image to the board:

cd ~/nrfjprog/
./nrfjprog -f nrf52 -s $serial --chiperase --program ~/work/ot-cli-ftd.hex --reset

4) cycle the power on the board

5) open a cli session:

sudo screen /dev/ttyACM0 115200

6) press ENTER a couple of times until the > prompt is displayed

7) flash the NCP mage to the board:

cd ~/nrfjprog/
./nrfjprog -f nrf52 -s $serial --chiperase --program ~/work/ot-ncp-ftd.hex --reset

8) start wpantund:

sudo /usr/local/sbin/wpantund -o Config:NCP:SocketPath /dev/ttyACM0  \
        -o Config:TUN:InterfaceName utun7 \
        -o Daemon:SyslogMask " -info"

Anything else does not work.  In particular:
  • The board must be cycled after flashing the CLI image, otherwise the > prompt is never displayed.
  • The > prompt has to be displayed.  I'm guessing there is some initialization being forced by the first prompt.
  • The board cannot be cycled before or after flashing the NCP image.
My conclusion is that the board is being put in some persistent state by the first prompt in the CLI image.  The NCP image does not do this initialization, but probably should.

I've started digging through the source code to verify my conclusion, but I'm very much in learning mode which includes cleaning the rust off my C++.  It would be nice to have a clean, working system to experiment with.  Besides, if there is an error, I can testify you will reduce the total developer frustration in the universe since it takes a while to rule out everything else.  (And I realize I probably still haven't ruled out everything else.)

This is some exciting technology.  I'm looking forward to working with it.

Rob Conaway
Pillar Technology, Inc. 

Jonathan Hui

unread,
Jun 7, 2018, 6:39:12 PM6/7/18
to rcon...@pillartechnology.com, openthread-users
Thanks for sharing your experience.

On the Nordic platform, I generally experience more robust performance when using the nRF52840's native USB interface.  You can follow the NCP Support guide for instructions on building an NCP image or download a pre-built NCP image that includes native USB support.

Let us know if native USB helps resolve your issue.  If so, we'll update the codelab to help others avoid this issue in the future.

Thanks.

--
Jonathan Hui

--
You received this message because you are subscribed to the Google Groups "openthread-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openthread-use...@googlegroups.com.
To post to this group, send email to openthre...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/ef184978-32b3-4038-8da8-076691ec566b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rob Conaway

unread,
Jun 8, 2018, 11:07:34 AM6/8/18
to openthread-users
Jonathan, 

Thank you for your quick reply.  Your solution worked.

Rob

Loc Hoang Van

unread,
Jun 23, 2018, 7:24:47 AM6/23/18
to openthre...@googlegroups.com
Hi Rob. I got the same problem
5) open a cli session:

sudo screen /dev/ttyACM0 115200

6) press ENTER a couple of times until the > prompt is displayed
I can't get  '>' promp display. How did you solve this?
Reply all
Reply to author
Forward
0 new messages