Friday, February 11, 2022

Build and run OpenThread Border Router for NXP i.MX6ULL with Silicon Labs EFR32 as RCP

This tutorial shows you how to build and run OpenThread Border Router for NXP i.MX6ULL with Silicon Labs EFR32 as RCP.

1. Setup build environment and build OpenThread Border Router for NXP i.MX6ULL EVK.

 sudo apt-get install -y gcc make perl curl nodejs npm
  • 1.3 Setup Yocto build environment.
mkdir ~/bin
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
export PATH=${PATH}:~/bin

sudo update-ca-certificates
mkdir yocto-otbr
cd yocto-otbr
git config --global user.email "youremail@email.com"
git config --global user.name "yourname"
repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-hardknott -m imx-5.10.35-2.0.0.xml
repo sync
  • 1.4 Integrate the meta-matter recipe into the Yocto code base
cd yocto-otbr/sources
git clone https://github.com/NXPmicro/meta-matter.git
  • 1.5 Install necessary package to build the Yocto Project.
sudo apt-get install -y gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm
  • 1.6 Download 0001-Add-TUN-device-support-for-arm.patch into yocto-otbr/sources/meta-imx folder and run the following git command to patch it (This will build /dev/net/tun on i.MX6ULL system for otbr-agent).
git am -3 0001-Add-TUN-device-support-for-arm.patch
  • 1.7 Generate the Yocto image with OpenThread Border Router support.
MACHINE=imx6ullevk DISTRO=fsl-imx-xwayland source sources/meta-matter/tools/imx-iot-setup.sh bld-xwayland
bitbake imx-image-multimedia
  • 1.8 After previous two commands are excuted successfully, the Yocto image imx-image-multimedia-imx6ullevk.wic.bz2 will be generated under yocto-otbr/bld-xwayland/tmp/deploy/images/imx6ullevk/. imx-image-multimedia-imx6ullevk.wic.bz2 should be unzip to imx-image-multimedia-imx6ullevk.wic.
 
  • 1.9 Use "ls /dev/sd*" to check the sd card name. In my , it's "sdb" Use dd command to program imx-image-multimedia-imx6ullevk.wic.bz2 to a microSD.
 sudo dd if=imx-image-multimedia-imx6ullevk.wic of=/dev/sdb bs=4096 conv=fsync status=progress
  •  1.10 After previous step is done, the microSD card can be used to boot i.MX6ULL EVK with OpenThread Border Router capability.
 

2. Download OT-RCP into Silicon Labs BRD4161A (EFR32 radio board) using Simplicity Studio v5.

  • 2.1 Instead of building OT-RCP for Silicon Labs BRD4161A by myself, I install Simplicity Studio v5 and Gecko SDK Suite v3.2.3 with OpenThread 1.2.3.0
 


  • 2.2 Download prebuilt OT-RCP into Silicon Labs BRD4161A directly.


3. Connect NXP i.MX6ULL EVK with Silicon Labs EFR32 as RCP to test OpenThread Border Router.

  • 3.1 Connect Silicon Labs BRD4161A+BRD4001A to i.MX6ULL EVK with USB cable and put the the microSD (built in step 1) to power on i.MX6ULL EVK.
 

  • 3.2 Use root to login i.MX6ULL EVK debug console and run the following command to start otbr-agent
 otbr-agent -I wpan0 -B eth0 spinel+hdlc+uart:///dev/ttyACM0 &
 
P.S.Since we use Silicon Labs BRD4161A+BRD4001A, it should emulate ttyACM0 after connecting to i.MX6ULL EVK with USB cable. If you use othe OT-RCP hardware, you might need to check physical device name that is emulated by your hardware.
  • 3.3 Run ot-ctl, which is a command line utility provided with OTBR. It is used to communicate with the Thread PAN interface (default is wpan0) that otbr-agent is bound to in the RCP design, to start test everything.
 P.S. If you see "connection session failed: No such file or directory" problem when running ot-ctl, you can use "cat /var/log/syslog" to check what's wrong with otbr-agent.
 

  • 3.4 You can refer to step 5, 6, and 7 in this post to test OTBR and an OT-CLI-FTD node.

 

P.S. Thanks Elven Wang @NXP and Jonathan Hui @Google for their great help to make all of these work together. The followings are reference links of previous works that help me lots.

https://github.com/openthread/ot-br-posix/issues/1200#

https://github.com/NXPmicro/meta-matter

No comments:

Post a Comment