Skip to content

The layer files for integrate the Matter and OpenThread into i.MX Yocto Linux

License

Notifications You must be signed in to change notification settings

jmeg-sfy/meta-matter

 
 

Repository files navigation

Introduction

This repo contains the i.MX MPU project Matter related Yocto recipes. Below is a list of modules that will be built with the meta-matter repo integrated.

All the software components revision are based on project Matter TE8/RC3.

The the Following Matter related binaries will be installed into the Yocto image root filesystem with this recipe repo:

  • chip-lighting-app: Matter lighting app demo
  • chip-all-clusters-app: Matter all-clusters demo
  • thermostat-app: Matter thermostat demo
  • ot-daemon: OpenThread Daemon for OpenThread client using OpenThread v1.2 spec (For Nodic RCP module)
  • ot-client-ctl: OpenThread ctrl tool for OpenThread client using OpenThread v1.2 spec (For Nodic RCP module)
  • ot-daemon-v11: OpenThread Daemon for OpenThread client using OpenThread v1.1 spec (For K32W RCP Module)
  • ot-client-ctl-v11: OpenThread Daemon for OpenThread client using OpenThread v1.1 spec (For K32W RCP Module)
  • otbr-agent: OpenThread Border Router agent using OpenThread v1.2 spec (For Nodic RCP module)
  • ot-ctl: OpenThread Border Router ctrl tool using OpenThread v1.2 spec (For Nodic RCP module)
  • otbr-agent-v11: OpenThread Border Router agent using OpenThread v1.1 spec (For K32W RCP Module)
  • ot-ctl-v11: OpenThread Border Router ctrl tool using OpenThread v1.1 spec (For K32W RCP Module)
  • otbr-web: OpenThread Border Router web management daemon

How to build the Yocto image with integrated OpenThread Border Router

Yocto build environment must first be setup.

The Yocto source code is maintained with a repo manifest, the tool repo is used to download the source code. This document is tested with the i.MX Yocto 5.10.35_2.0.0 release. The hardware tested in this documentation is the i.MX 8M Mini EVK. Run the commands below to download this release:

$ mkdir ~/bin
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ export PATH=${PATH}:~/bin

$ mkdir yocto # this directory will be the top directory of the Yocto source code
$ cd yocto
$ 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

Then integrate the meta-matter recipe into the Yocto code base

$ cd ${MY_YOCTO}/sources/
$ git clone https://github.com/NXPmicro/meta-matter.git

To build the Yocto Project, some packages need to be installed. The list of packages required are:

$ sudo apt-get install 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 npm

More information about the downloaded Yocto release can be found in the corresponding i.MX Yocto Project User’s Guide which can be found at NXP official website.

Change the current directory to the top directory of the Yocto source code and execute the commands below to generate the Yocto images.

$MACHINE=imx8mmevk DISTRO=fsl-imx-xwayland source sources/meta-matter/tools/imx-iot-setup.sh bld-xwayland
$bitbake imx-image-multimedia

After execution of previous two commands, the Yocto images will be generated under ${MY_YOCTO}/bld-xwayland/tmp/deploy/images/imx8mmevk/imx-image-multimedia-imx8mmevk.wic.bz2. The bzip2 command should be used to unzip this file then the dd command should be used to program the output file to a microSD card by running the commands below. Then a microSD card can be used to boot the image of an i.MX 8M Mini EVK.

Be cautious when executing the dd command below, make sure the of represents the microSD card device!, /dev/sdc in the command below represents a microSD card connected to the host machine with a USB adapter, however the output device name may vary. Use the command "ls /dev/sd*" to verify the name of the SD card device.

$ bzip2 -d imx-image-multimedia-imx8mmevk.wic.bz2
$ sudo dd if=imx-image-multimedia-imx8mmevk.wic of=/dev/sdc bs=4M conv=fsync

How to build OpenThread Border Router with Yocto SDK

There are 3 module for OpenThread Border Router (OTBR): otbr-agent, ot-ctl and otbr-web. The otbr-web need liboost static and jsoncpp modules which are not included into default built Yocto images.

To build these binaries, the Yocto SDK with meta-matter generated must be used. This SDK can be generated by below command:

$cd ${MY_YOCTO}/bld-xwayland
$bitbake imx-image-multimedia -c populate_sdk

Install the NXP Yocto SDK and set toolchain environment variables. Run the SDK installation script with root permission.

$ sudo tmp/deploy/sdk/fsl-imx-xwayland-glibc-x86_64-imx-image-multimedia-cortexa53-crypto-imx8mmevk-toolchain-5.10-hardknott.sh

After the Yocto SDK is installed on the host machine, an environment setup script is also generated, and there are prompt lines telling the user to source the script each time when using the SDK in a new shell, for example:

$ . /opt/fsl-imx-xwayland/5.10-hardknott/environment-setup-cortexa53-crypto-poky-linux

After the SDK package installed in the build machine, import the Yocto build environment using the command:

$source ${SDK_INSTALLED_PATH}/environment-setup-cortexa53-crypto-poky-linux

Fetch latest otbr source codes and execute the build:

$git clone https://github.com/openthread/ot-br-posix
$git checkout -t origin/main
$git submodule update --init
$ ./script/cmake-build -DOTBR_BORDER_ROUTING=ON -DOTBR_REST=ON -DOTBR_WEB=ON \
-DBUILD_TESTING=OFF -DOTBR_DBUS=ON -DOTBR_DNSSD_DISCOVERY_PROXY=ON \
-DOTBR_SRP_ADVERTISING_PROXY=ON -DOT_THREAD_VERSION=1.1 \
-DOTBR_INFRA_IF_NAME=mlan0 \
-DCMAKE_TOOLCHAIN_FILE=./examples/platforms/nxp/linux-imx/aarch64.cmake

The otbr-agent is built in ${MY_OTBR}/build/otbr/src/agent/otbr-agent . Please copy it into Yocto's /usr/sbin/. The ot-ctl is built in ${MY_OTBR}/build/otbr/third_party/openthread/repo/src/posix/ot-ctl . Please copy it into Yocto's /usr/sbin/. The otbr-web is built in ${MY_OTBR}/build/otbr/src/web/otbr-web . Please copy it into Yocto's /usr/sbin/.

How to setup OpenThread Border Router environment within the Yocto

After the OTBR boot, the i.MX8M Mini must connect the OTBR to the target Wi-Fi AP network.

$modprobe moal mod_para=nxp/wifi_mod_para.conf
$wpa_passphrase ${SSID} ${PASSWORD} > imxrouter.conf
$wpa_supplicant -d -B -i mlan0 -c ./imxrouter.conf
$udhcpc -i mlan0
$echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
$echo 1 > /proc/sys/net/ipv4/ip_forward
$echo 2 > /proc/sys/net/ipv6/conf/all/accept_ra

Plugin the Thread module into the USB OTG port of i.MX8M Mini. A USB device should be visible as /dev/ttyUSB. Once the USB device is detected, start te OTBR related services.

When using the NXP K32W0 USB module, programmed with OpenThread Spinel firmware image, execute the following commands:

$otbr-agent-v11 -I wpan0 -B mlan0 spinel+hdlc+uart:///dev/ttyUSB0 &
If you are using Nodic USB Dongle, you need run:
$otbr-agent -I wpan0 -B mlan0 spinel+hdlc+uart:///dev/ttyACM0 &
$iptables -A FORWARD -i mlan0 -o wpan0 -j ACCEPT
$iptables -A FORWARD -i wpan0 -o mlan0 -j ACCEPT
$otbr-web &

How to build Matter application

A document described how to build Matter application for i.MX platforms can be found in Matter community.

A Matter official document about how to use chip-tool as Matter controller can be found in here.

About

The layer files for integrate the Matter and OpenThread into i.MX Yocto Linux

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • BitBake 92.6%
  • Shell 7.4%