This is more of a brain dump for yours truly, since as a day job, I’m dealing with OpenThread a lot, and so there’s lots of little tricks out there for building it on various platforms and configurations. The following is not so much a how-to guide, but a quick brain dump of different things I’ve learned over the past year or so of messing with OpenThread.
Verbose builds
To get a print out of every invocation of the toolchain with all flags, specify V=1
on the call to make
:
$ make -f examples/Makefile-${PLATFORM} …${ARGS}… V=1
Running one step at a time
To disable the parallel builds when debugging the build system, append BuildJobs=1
to your make
call:
$ make -f examples/Makefile-${PLATFORM} …${ARGS}… BuildJobs=1
Building a border router NCP image
General case
$ make -f examples/Makefile-${PLATFORM} …${ARGS}… BORDER_AGENT=1 BORDER_ROUTER=1 COMMISSIONER=1 UDP_FORWARD=1
For TI CC2538
# Normal CC2538 (e.g. Zolertia Firefly)
$ make -f examples/Makefile-cc2538 BORDER_AGENT=1 BORDER_ROUTER=1 COMMISSIONER=1 UDP_FORWARD=1
# CC2538 + CC2592
$ make -f examples/Makefile-cc2538 BORDER_AGENT=1 BORDER_ROUTER=1 COMMISSIONER=1 UDP_FORWARD=1 CC2592=1
If you want to run the latter image on a WideSky Hub, you’ll need to edit examples/platform/cc2538/uart.c
and comment out line 117 before compiling as it uses a simple diode for 5V to 3.3V level shifting, and this requires the internal pull-up to be enabled:
115 // rx pin
116 HWREG(IOC_UARTRXD_UART0) = IOC_PAD_IN_SEL_PA0;
117 HWREG(IOC_PA0_OVER) = IOC_OVERRIDE_DIS; // ← comment out this to allow UART RX to work
118 HWREG(GPIO_A_BASE + GPIO_O_AFSEL) |= GPIO_PIN_0;
For Nordic nRF52840
# Nordic development board (PCA10056) via J2 (near battery)
$ make -f examples/Makefile-nrf52840 BORDER_AGENT=1 BORDER_ROUTER=1 COMMISSIONER=1 UDP_FORWARD=1
# Ditto, but instead using J3 (near middle of bottom edge)
$ make -f examples/Makefile-nrf52840 BORDER_AGENT=1 BORDER_ROUTER=1 COMMISSIONER=1 UDP_FORWARD=1 USB=1
# Nordic dongle (PCA10059)
$ make -f examples/Makefile-nrf52840 BORDER_AGENT=1 BORDER_ROUTER=1 COMMISSIONER=1 UDP_FORWARD=1 USB=1 BOOTLOADER=USB
I’m working on what needs to be done for the Fanstel BT840X… watch this space.
Building certification test images
For CC2538
$ make -f examples/Makefile-cc2538 BORDER_ROUTER=1 COMMISSIONER=1 DHCP6_CLIENT=1 JOINER=1
Running CI tests outside of Travis CI
You will need:
- Python 3.5 or later. 3.6 recommended.
pycryptodome
(notpycrypto
: if you get anAttributeError
referencingAES.MODE_CCM
, that’s why!enum34
(for now… I suspect this will disappear once the Python 2.7 requirement is dropped for Android tools)ipaddress
pexpect
The test suites work by running the POSIX ot-cli-${TYPE}
(where ${TYPE}
is ftd
or mtd
).
Running tests
From the root of the OpenThread tree:
$ make -f examples/Makefile-posix check
Making tests
The majority of the tests lurk under tests/scripts/thread-cert
. Don’t be fooled by the name, lots of non-Thread tests live there.
The file node.py
wraps pexpect
up in an object with methods for calling the various CLI commands or waiting for things to be printed to the console.
The tests themselves are written using using the standard Python unittest
framework, with setUp
creating a few Node
objects (node.py
) and tearDown
cleaning them up. The network is simulated.
The test files must be executable, and call unittest.main()
after checking if the script is called directly.
Logs during the test runs
During the tests, the logs are stashed in build/${CHOST}/tests/scripts/thread-cert
and will be named ${SCRIPTNAME}.log
. (e.g test_coap_observe.py.log
). Also present is the .pcap
file (Packet dump).
Logs after the tests
The test suite will report the logs are at tests/scripts/thread-cert/test-suite.log
. This is relative to the build directory… so look in build/${CHOST}/tests/scripts/thread-cert/test-suite.log
.
make pretty
with clang
8.0
Officially this isn’t supported, but you can “fool” OpenThread’s build system into using clang
8.0 anyway:
$ cat ~/bin/clang-format-6.0
#!/bin/bash
if [ "$1" == "--version" ]; then
echo "clang-format version 6.0"
else
clang-format "$@"
fi
Put that file in your ${PATH}
, make it executable, then OpenThread will think you’ve got clang-format
version 6 installed. This appears to work without ill effect, so maybe a future release of OpenThread will support it.
Recent Comments