【Matter】esp-matter开发环境搭建

简介: 【Matter】esp-matter开发环境搭建

前提准备

1.Ubuntu22.04(磁盘容量不小于80G)

2.科学上网环境

由于后面的 esp-matter 测试的时候需要使用到梯子,所以我们需要提前确保 linux 环境能够使用魔法。

具体方式可前往我的个人网站查看文章 ubuntu下使用魔法

esp-idf 开发环境搭建

1.ESP-IDF 依赖环境安装

参考https://docs.espressif.com/projects/esp-idf/en/v4.4.3/esp32/get-started/linux-setup.html

sudo apt-get install git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0

由于在克隆官方esp-idf仓库的时候一般会发生如下两个错误:

  • Problem1:执行 git submodule 速度慢
  • Problem2:执行install.sh 速度慢

所以我们这里特别着重讲解,注意,这里解决问题的顺序与esp-idf环境搭建是一起进行的,读者可以顺着流程走。

2.Problem1 solution

首先使用递归克隆命令克隆整个仓库到文件夹下

mkdir /home/kurisaw/Desktop/esp
git clone --recursive https://github.com/espressif/esp-idf.git
git submodule update --init --recursive

由于 esp-idf 仓库下有很多递归的下游仓库,一般使用 GitHub 下载的话也会导致递归下载失败,所以乐鑫官方提供了两种解决方案,包括镜像仓库使用、submodule 更新、开发工具安装等,可加速环境的搭建。解决方案如下:

  • jihu-mirror 使用(推荐)
  • submodule-update 使用(不推荐)

2.1 jihu-mirror 使用(推荐)

  • Step 1:
git clone https://gitee.com/EspressifSystems/esp-gitee-tools.git
cd esp-gitee-tools
  • Step 2:
// 使用如下命令将仓库的 URL 进行替换:
git config --global url.https://jihulab.com/esp-mirror/espressif/esp-idf.insteadOf https://github.com/espressif/esp-idf

当我们使用命令 git clone https://github.com/espressif/esp-idf 时,默认的 URL https://github.com/espressif/esp-idf 将被自动替换成 https://jihulab.com/esp-mirror/espressif/esp-idf

  • Step 3:
// 启用镜像URL
./jihu-mirror.sh set

使用命令 ./jihu-mirror.sh unset 恢复,不使用镜像的 URL。

  • Step 4:当使用镜像 URL 之后,再递归克隆 esp-idf 仓库
git clone --recursive https://github.com/espressif/esp-idf.git

当然如果不想使用镜像的URL可以使用如下命令进行恢复:

./jihu-mirror.sh unset

2.2 submodule-update 使用(不推荐)

  • Step 1:
git clone https://gitee.com/EspressifSystems/esp-gitee-tools.git
  • Step 2:
// 仅克隆 esp-idf,不包含子模块
git clone https://gitee.com/EspressifSystems/esp-idf.git
  • Step 3:

可以有两种方式来更新 submodules。

  • 方式一
    进入 esp-gitee-tools 目录,export submodule-update.sh 所在路径,方便后期使用,如:
cd esp-gitee-tools
export EGT_PATH=$(pwd)
  • 进入 esp-idf 目录执行 submodule-update.sh 脚本:
cd esp-idf
$EGT_PATH/submodule-update.sh
  • 方式二
    submodule-update.sh 脚本支持将待更新 submodules 的工程路径作为参数传入,例如:submodule-update.sh PATH_OF_PROJ
    假如 Step 2 中 clone 的 esp-idf 位于 ~/git/esp32-sdk/esp-idf 目录,可使用以下方式来更新:
cd esp-gitee-tools
./submodule-update.sh ~/git/esp32-sdk/esp-idf
  • 如果要更新其他工程,可以同样方式。

值得吐槽的是, submodule-update 这种方法还需要保持上游代码分支的提交历史一致,如果官方未及时更新则会导致该脚本暂时失效,不推荐使用,避坑!!

3.Problem2 solution

下面说第二个问题:执行./install.sh速度慢的问题

在 Espressif Systems 的 esp-idf 开发框架中,某些组件的构建过程需要从 GitHub 的 release 页面下载预编译的二进制文件。然而,在中国大陆访问 GitHub 的速度往往较慢并且不稳定,为了改善这个问题,Espressif Systems 将这些预编译的二进制文件托管在国内的服务器上,并提供了一个名为 IDF_GITHUB_ASSETS 的环境变量来指定这个地址。在设置了 IDF_GITHUB_ASSETS 变量之后,构建过程将会从这个指定的地址下载预编译的二进制文件

export IDF_GITHUB_ASSETS="dl.espressif.com/github_assets"

然后再执行安装命令

./install.sh

在这还报了一个错误

我们根据提示安装python3.10-venv,并再次执行安装命令:

apt install python3.10-venv
./install.sh

至此,esp-idf 的安装工具就告一段落了。

esp-matter开发环境搭建

参考:【乐鑫 Matter SDK GitHub】

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

注意:如果上面的 esp-idf 开发环境的搭建使用的是 jihu-mirror 方式,那么你需要取消esp镜像,按理说这部分错误不应该发生,但实际上确实存在这部分问题,请执行命令:./jihu-mirror.sh unset取消esp镜像!!

若过程有报错,请执行下面命令在Git 仓库中获取到所有子模块,并将所有子模块及其下层子模块更新至最新版本。

git submodule update --init --recursive

执行安装命令:

./install.sh

本以为到这就结束了,但不出意外的话意外发生了,在安装过程中发生了报错…

Building wheel for pycryptodome (setup.py): started
  error: subprocess-exited-with-error
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  note: This error originates from a subprocess, and is likely not a problem with pip.
  Building wheel for pycryptodome (setup.py): finished with status 'error'
  ERROR: Failed building wheel for pycryptodome
  Running setup.py clean for pycryptodome
  Building wheel for gevent (pyproject.toml): started
  ......

我们查看install.sh文件

#!/usr/bin/env bash
set -e
basedir=$(dirname "$0")
ESP_MATTER_PATH=$(cd "${basedir}"; pwd)
MATTER_PATH=${ESP_MATTER_PATH}/connectedhomeip/connectedhomeip
export ESP_MATTER_PATH
echo ""
echo "Running Matter Setup"
echo ""
source ${MATTER_PATH}/scripts/bootstrap.sh
echo ""
echo "Installing zap-cli"
echo ""
# Run the zap_download.py and extract the path of installed binary
# eg output before cut: "export ZAP_INSTALL_PATH=zap/zap-v2023.03.06-nightly"
# output after cut: zap/zap-v2023.03.06-nightly
# TODO: Remove the zap-version after https://github.com/project-chip/connectedhomeip/pull/25727 merged
zap_path=`python3 ${ESP_MATTER_PATH}/connectedhomeip/connectedhomeip/scripts/tools/zap/zap_download.py \
    --sdk-root ${ESP_MATTER_PATH}/connectedhomeip/connectedhomeip --zap RELEASE --zap-version v2023.03.27-nightly \
    --extract-root .zap 2>/dev/null | cut -d= -f2`
# Check whether the download is successful.
if [ -z $zap_path ]; then
    echo "Failed to install zap-cli"
    deactivate
    exit 1
fi
# Move files to one directory up, so that binaries will be in $ESP_MATTER_PATH/.zap/ directory and export.sh can leverage the fixed path
if [ -d "${ESP_MATTER_PATH}/.zap" ]; then
    rm -r ${ESP_MATTER_PATH}/.zap
fi
mkdir ${ESP_MATTER_PATH}/.zap
mv $zap_path/* ${ESP_MATTER_PATH}/.zap/
rm -r $zap_path
chmod +x ${ESP_MATTER_PATH}/.zap/zap-cli
echo ""
echo "Building host tools"
echo ""
gn --root="${MATTER_PATH}" gen ${MATTER_PATH}/out/host
ninja -C ${MATTER_PATH}/out/host
echo ""
echo "Host tools built at: ${MATTER_PATH}/out/host"
echo ""
echo ""
echo "Exit Matter environment"
echo ""
deactivate
echo ""
echo "Installing python dependencies for mfg_tool"
echo ""
python3 -m pip install -r ${ESP_MATTER_PATH}/tools/mfg_tool/requirements.txt
echo ""
echo "Installing python dependencies for Matter"
echo ""
python3 -m pip install -r ${ESP_MATTER_PATH}/requirements.txt
echo "All done! You can now run:"
echo ""
echo "  . ${basedir}/export.sh"
echo ""

发现问题出在第10到13行,我尝试安装系统必要的依赖项来解决这个问题,成功解决!命令如下:

sudo apt install build-essential python3-dev
sudo apt-get install pkg-config
sudo apt-get install libglib2.0-dev libglib2.0-dev-bin libgio2.0-cil-dev

接着在安装zap-cli的时候再次发生报错,需要安装以下依赖库,并再次运行安装脚本命令,等待编译

sudo apt-get install libssl-dev
sudo apt-get install pip
./install.sh

最后看到All done!即代表环境安装成功!

至此,esp-matter开发环境搭建成功!

目录
相关文章
|
11月前
|
Ubuntu 物联网 Linux
【Matter】使用chip tool在ESP32-C3上进行matter开发
【Matter】使用chip tool在ESP32-C3上进行matter开发
677 0
|
11月前
|
传感器 监控 安全
【Matter】Matter学习笔记1(下)
【Matter】Matter学习笔记1
11911 1
|
11月前
|
传感器 网络协议 安全
【Matter】Matter学习笔记1(上)
【Matter】Matter学习笔记1
407 1
|
11月前
|
存储 Ubuntu Linux
【Matter】Matter 环境构建参考文档
【Matter】Matter 环境构建参考文档
256 0
|
12月前
|
网络协议 安全 Unix
Coroutine made DPDK development easy
This is a English translation of the article 《有了协程库,开发DPDK应用程序第一次可以这么简单》. The original link is https://developer.aliyun.com/article/1208390
|
安全 网络协议 物联网
1. 【Matter】解密Matter协议(一)--- 什么是Matter协议
目前的智能家居行业使用解决方案众多,相互之间隔离严重,有WiFi、蓝牙、ZigBee、蜂窝或者有线等等不同通讯协议的设备。不仅不同协议之间的设备不能互通,而且连相同通讯协议之间的设备也不能互通。例如谷歌助手控制谷歌产品,亚马逊语音设备可以用于亚马逊的设备,苹果使用Siri来驱动其产品,而国内小米、阿里等物联网平台也都有自己的生态。而Matter协议就是为了解决这些兼容性问题而诞生的, 并且在2022年十月CSA(连接标准联盟)正式发布了Matter标准协议1.0版本。
880 0
1. 【Matter】解密Matter协议(一)--- 什么是Matter协议
|
Web App开发
【VCS】Unified Simulation Profiler使用
【VCS】Unified Simulation Profiler使用
238 0
【VCS】Unified Simulation Profiler使用
|
前端开发 开发工具 git
react项目实战学习笔记-学习11-warning: adding embedded git repository:xxxxxxxxxxhint: You‘ve added another git
react项目实战学习笔记-学习11-warning: adding embedded git repository:xxxxxxxxxxhint: You‘ve added another git
91 0
Win系统 - Hands-Free 和 Stereo 区别?
Win系统 - Hands-Free 和 Stereo 区别?
284 0
Win系统 - Hands-Free 和 Stereo 区别?
|
SQL 编译器 API
Efficiently Compiling Efficient Query Plans for Modern Hardware 论文解读
这应该是SQL查询编译的一篇经典文章了,作者是著名的Thomas Neumann,主要讲解了TUM的HyPer数据库中对于CodeGen的应用。 在morsel-driven那篇paper 中,介绍了HyPer的整个执行框架,会以task为单位处理一个morsel的数据,而执行的处理逻辑(一个pipeline job)就被编译为一个函数。这篇paper则具体讲如何实现动态编译。
374 0
Efficiently Compiling Efficient Query Plans for Modern Hardware 论文解读

热门文章

最新文章