Skip to content

Commit d2f37d0

Browse files
Lukasz Majewskikartben
authored andcommitted
net: Extend echo_client README.rst file to setup OTBR based echo_server
This description provides information about setting up RCP (nRF21540-DK) and OT HOST (mimxrt1020_evk) to communicate with HOST PC's echo_server via OpenThread Border Router (OTBR). Signed-off-by: Lukasz Majewski <[email protected]>
1 parent f6fe628 commit d2f37d0

File tree

1 file changed

+158
-0
lines changed

1 file changed

+158
-0
lines changed

samples/net/sockets/echo_client/README.rst

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,161 @@ on how to test TLS with Linux host samples.
179179
See the :zephyr:code-sample:`sockets-echo-server` documentation for an alternate
180180
way of running, with the echo-client on the Linux host and the echo-server
181181
in QEMU.
182+
183+
OpenThread RCP+Zephyr HOST (SPINEL connection via UART)
184+
=======================================================
185+
186+
Prerequisites:
187+
--------------
188+
189+
- Build ``echo-server`` for HOST PC (x86_64)
190+
(https://github.com/zephyrproject-rtos/net-tools) SHA1:1c4fdba
191+
192+
.. code-block:: console
193+
194+
$ make echo-server
195+
196+
- Program nRF RCP from Nordic nrf SDK (v2.7.0):
197+
198+
.. code-block:: console
199+
200+
(v2.7.0) ~/ncs$ west build -p always -b nrf21540dk/nrf52840 -S logging nrf/samples/openthread/coprocessor
201+
202+
203+
- Build mimxrt1020_evk HOST (Zephyr):
204+
205+
.. zephyr-app-commands::
206+
:zephyr-app: samples/net/sockets/echo_client
207+
:board: mimxrt1020_evk
208+
:conf: "prj.conf overlay-ot-rcp-host-uart.conf"
209+
:goals: build
210+
:compact:
211+
212+
And flash
213+
214+
.. code-block:: console
215+
216+
$ west flash -r pyocd -i 0226000047784e4500439004d9170013e56100009796990
217+
218+
219+
- Connect the nRF RCP with IMXRT1020 (HOST) via UART
220+
221+
.. code-block:: c
222+
223+
/*
224+
* imxrt1020_evk -> HOST
225+
* nRF21540-DK -> RCP (nrf/samples/openthread/coprocessor)
226+
* LPUART2 used for communication:
227+
* nRF21540 (P6) P0.08 RXD -> IMXRT1020-EVK (J17) D1 (GPIO B1 08) (TXD)
228+
* nRF21540 (P6) P0.07 CTS -> IMXRT1020-EVK (J19) D8 (GPIO B1 07) (RTS)
229+
* nRF21540 (P6) P0.06 TXD -> IMXRT1020-EVK (J17) D0 (GPIO B1 09) (RXD)
230+
* nRF21540 (P6) P0.05 RTS -> IMXRT1020-EVK (J17) D7 (GPIO B1 06) (CTS)
231+
*/
232+
233+
234+
- Install the OTBR (OpenThread Border Router) docker container on your HOST PC (x86_64)
235+
Follow steps from https://docs.nordicsemi.com/bundle/ncs-2.5.1/page/nrf/protocols/thread/tools.html#running_otbr_using_docker
236+
237+
**Most notable ones:**
238+
239+
1. Create ``otbr0`` network bridge to have access to OT network from HOST
240+
Linux PC
241+
242+
.. code-block:: console
243+
244+
sudo docker network create --ipv6 --subnet fd11:db8:1::/64 -o com.docker.network.bridge.name=otbr0 otbr
245+
246+
247+
2. Pull docker container for OTBR:
248+
249+
.. code-block:: console
250+
251+
docker pull nrfconnect/otbr:84c6aff
252+
253+
254+
3. Start the docker image:
255+
256+
.. code-block:: console
257+
258+
sudo modprobe ip6table_filter
259+
sudo docker run -it --rm --privileged --name otbr --network otbr -p 8080:80 --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" --volume /dev/ttyACM5:/dev/radio nrfconnect/otbr:84c6aff --radio-url spinel+hdlc+uart:///dev/radio?uart-baudrate=1000000
260+
261+
262+
4. Add proper routing (``fd11:22::/64`` are the IPv6 addresses - On-Mesh - which allow accessing the OT devices) on HOST PC (x86_64)
263+
264+
.. code-block:: console
265+
266+
sudo ip -6 route add fd11:22::/64 dev otbr0 via fd11:db8:1::2
267+
268+
269+
And the output for on-OT address:
270+
271+
.. code-block:: console
272+
273+
ip route get fd11:22:0:0:5188:1678:d0c0:6893
274+
fd11:22::5188:1678:d0c0:6893 from :: via fd11:db8:1::2 dev otbr0 src fd11:db8:1::1 metric 1024 pref medium
275+
276+
277+
5. Start the console to the docker image:
278+
279+
.. code-block:: console
280+
281+
sudo docker exec -it otbr /bin/bash
282+
283+
284+
Test with e.g.
285+
286+
.. code-block:: console
287+
288+
ot-ctl router table
289+
ot-ctl ipaddr
290+
291+
292+
293+
Configure OTBR
294+
--------------
295+
296+
On the HOST PC's webbrowser: http://localhost:8080/
297+
298+
Go to ``Form`` and leave default values - e.g:
299+
300+
* Network Key: ``00112233445566778899aabbccddeeff``
301+
* On-Mesh Prefix: ``fd11:22::``
302+
* Channel: ``15``
303+
304+
305+
to "FORM" the OT network.
306+
307+
*Note:*
308+
The "On-Mesh Prefix" shall match the one setup in ``otbr0`` routing.
309+
310+
311+
Configure RCP (nRF21540-DK) + OT HOST (mimxrt1020)
312+
--------------------------------------------------
313+
314+
.. code-block:: console
315+
316+
ot factoryreset
317+
ot dataset networkkey 00112233445566778899aabbccddeeff
318+
ot ifconfig up
319+
320+
321+
In the HOST PC www webpage interface please:
322+
Commission -> Joiner PSKd* set to ``J01NME`` -> START COMMISSION
323+
324+
.. code-block:: console
325+
326+
ot joiner start J01NME
327+
ot thread start
328+
329+
330+
The ``ot ipaddr`` shall show IPv6 address starting from ``fd11:22:0:0:``.
331+
This one can be accessed from HOST's PC network (via e.g.
332+
``ping -6 fd11:22:0:0:e8bf:266b:63ca:eff4``).
333+
334+
Start ``echo-server`` on HOST PC (x86-64)
335+
-----------------------------------------
336+
337+
.. code-block:: console
338+
339+
./echo-server -i otbr0

0 commit comments

Comments
 (0)