shawshuai
shawshuai
发布于 2025-05-05 / 2 阅读
0
0

Matter 开发环境配置

本文记录配置ESP32的Matter开发环境。搜索打开ESPRESSIF文档,第一章是关于Matter的一些介绍。 切换到2.Developing with theSDK可以查看如何针对ESP设备安装SDK并进行配置。

在设备上配置开发环境、获取Git仓库以及构建和烧写的介绍。

支持的操作系统

  • Ubuntu 20.04 or 22.04 LTS

  • macOS 10.15 or later

  • Windows需要使用WSL

使用ESP-IDF和Matter的前提条件:

获取仓库

在获取仓库之前确认前提条件都已经满足。 使用如下命令克隆:

git clone --recursive https://github.com/espressif/esp-idf.git
cd esp-idf; git checkout 6b1f40b9bf; git submodule update --init --recursive;
./install.sh
cd ..

克隆esp-matter仓库会因为上游 connectedhomeip中包含许多子模块而花费较多时间。可以使用以下命令浅克隆:

  • Linux机器

cd esp-idf
source ./export.sh
cd ..

git clone --depth 1 https://github.com/espressif/esp-matter.git
cd esp-matter
git submodule update --init --depth 1
cd ./connectedhomeip/connectedhomeip
./scripts/checkout_submodules.py --platform esp32 linux --shallow
cd ../..
./install.sh
cd ..
  • macOS机器

cd esp-idf
source ./export.sh
cd ..

git clone --depth 1 https://github.com/espressif/esp-matter.git
cd esp-matter
git submodule update --init --depth 1
cd ./connectedhomeip/connectedhomeip
./scripts/checkout_submodules.py --platform esp32 darwin --shallow
cd ../..
./install.sh
cd ..

注意:Host工具构建需要对于平台的模块linuxdarwin

使用如下命令克隆esp-matter仓库和其所有子模块:

cd esp-idf
source ./export.sh
cd ..

git clone --recursive https://github.com/espressif/esp-matter.git
cd esp-matter
./install.sh
cd ..

图:获取仓库

安装完成之后可以看到提示运行脚本。

执行此如果发现类似以下的错误,可能是网络连接问题,绝大多数情况下科学的上网环境可以解决这个问题。

dial tcp 108.160.167.174:443: connect: connection refused
ConnectionResetError: [Errno 104] Connection reset by peer

配置环境

每次打开一个新的终端,都应该执行命令:

cd esp-idf; source ./export.sh; cd ..
cd esp-matter; source ./export.sh; cd ..

为IDF构建启用Ccache

Ccache是编辑器缓存。Matter构建通常非常慢,需要花费很多时间Ccache缓存之前的编译并加速重编译和后续的编译。

export IDF_CCACHE_ENABLE=1

也可以将以上的内容添加到你自己shell的配置文件中 (.profile, .bashrc, .zprofile 等)来让每一次开启新的终端都启用Ccache。之后按照文档提示启动相关脚本。

大大的Matter Logo在终端显示出来!太激动啦!

到这里,基于ESP32的Matter开发环境就搭建完成了。可以参考其它文章继续进行Matter的开发。


评论