Building the Unify Matter Bridge#
This build guide cross-compiles for arm64 architecture to be run on Unify's reference platform, a Raspberry Pi 4 (RPi4) with the 64-bit version of Debian Bullseye.
Note: In the following subsections the commands should either be run on your local development machine or inside a running Docker container, as distinguished by the structure of the example.
some-command should be executed on your local machine.
dev-machine:~$ some-command
some-other-command should be executed inside the Docker container.
root@docker:/<dir>$ some-other-command
Check Out Submodules#
🔴 Assuming you have cloned the matter repo in
~/matter
Check out the necessary submodules with the following command.
dev-machine:~/matter$ ./scripts/checkout_submodules.py --platform linux
Clone and Stage the Unify SDK Repository#
🔴 Assuming you have cloned the matter repo in
~/matter
dev-machine:~/matter$ git clone --depth 1 https://github.com/SiliconLabs/UnifySDK.git --recursive ../uic-matter
Build the Docker Container (arm64 compilation)#
dev-machine:~/matter$ docker build -t unify-matter silabs_examples/unify-matter-bridge/docker/
Run the docker container (arm64 compilation)#
🔴 Make sure the directory structure is like follows where Unify repo
uic-matter/
and matter repomatter/
are at same directory level. ├── matter └── uic-matter
Start the docker from matter/
directory where you cloned the matter repo: Here we asuume matter/
is in ~
dev-machine:~$ cd matter/
dev-machine:~/matter$ docker run -it -v $PWD:/matter -v $PWD/../uic-matter:/uic unify-matter
Build libunify#
The Unify Matter Bridge depends on the libunify library from the Unify project.
This library must first be compiled for the target system, by changing directory to the /uic
directory and running the following:
root@docker:/uic$ cmake -DCMAKE_INSTALL_PREFIX=$PWD/stage -GNinja -DCMAKE_TOOLCHAIN_FILE=../cmake/arm64_debian.cmake -B build_unify_arm64/ -S components -DBUILD_TESTING=OFF
root@docker:/uic$ cmake --build build_unify_arm64
root@docker:/uic$ cmake --install build_unify_arm64 --prefix $PWD/stage
After cross-compiling the Unify library, set two paths in the PKG_CONFIG_PATH. The first path is for the staged Unify library and the second is for cross compiling to arm64.
root@docker:/uic$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$PWD/stage/share/pkgconfig
root@docker:/uic$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/aarch64-linux-gnu/pkgconfig
If you want to be able to use Zap to generate code from Unify XML files you need to export UCL_XML_PATH as well.
root@docker:/uic$ export UCL_XML_PATH=$PWD/stage/share/uic/ucl
Run activate in matter#
Once you have all the necessary submodules, source the Matter environment with the following command. This loads a number of build tools and makes sure the correct toolchains and compilers are used for compiling the Unify Matter Bridge.
Make sure you are in matter/
directory
root@docker:/matter$ source ./scripts/activate.sh
Compile the Unify Bridge#
root@docker:/matter$ cd silabs_examples/unify-matter-bridge/linux/
root@docker:/matter/silabs_examples/unify-matter-bridge/linux$ gn gen out/arm64 --args='target_cpu="arm64"'
root@docker:/matter/silabs_examples/unify-matter-bridge/linux$ ninja -C out/arm64
🔴 After building, the
unify-matter-bridge
binary is located at/matter/silabs_examples/unify-matter-bridge/linux/out/arm64/obj/bin/unify-matter-bridge
.
Compile the chip-tool#
The chip-tool
is a CLI tool that can be used to commission the bridge and to control end devices.
root@docker:/matter$ cd examples/chip-tool
root@docker:/matter/examples/chip-tool$ gn gen out/arm64 --args='target_cpu="arm64"'
root@docker:/matter/examples/chip-tool$ ninja -C out/arm64
🔴 After building, the chip-tool binary is located at
/matter/examples/chip-tool/out/arm64/obj/bin/chip-tool
.
Unit Testing#
Unit testing is always a good idea for quality software. Documentation on writing unit tests for the Matter Unify Bridge is in the
README.md in the linux/src/tests
folder.
Troubleshooting#
If you do not source the
matter/scripts/activate.sh
as described above in Set Up the Matter Build Environment,gn
and other common build tools will not be found.If you do not export the
pkgconfig
for theaarch64-linux-gnu
toolchain as described above in Build libunify you will get errors such asG_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));
If you are compiling unit tests, do not try to compile the Unify Matter Bridge at the same time. This will not work as when compiling unit tests you are also compiling unit tests for all other sub-components.
If you encounter errors linking to
libunify
, try redoing thelibunify
compile steps.Encountering problems with the submodules can be due to trying to check out the submodules inside the docker container.
If the Unify Matter Bridge gets stuck while booting. Try to pass
--args="chip_config_network_layer_ble=false"
togn gen
command while building