在树莓派4B上构建芯科-EFR32的matter的开发环境
matter的开发环境需要在Liunx环境下构建。一般是使用Docker或Ubuntu构建matter的开发环境。使用树莓派4B构建matter的开发环境:
准备工作:
构建matter环境需要的工具:
- 树莓派4B
- 电脑一台(安装Windows系统)
- Micro SD卡
- SSH工具-这里使用PuTTY
- 树莓派镜像烧录器
Ubuntu Server安装和配置
1. 安装Ubuntu
使用”树莓派镜像烧录器“烧录"Ubuntu 22.04.01 LTS"到树莓派4B的SD卡。参考:https://www.raspberrypi.com/software
由于matter需要使用Bluetooth LE,Ubuntu 21.04之后的版本集成了bluez 5.55或更新的版本,包含了对Bluetooth LE的支持。Ubuntu 21并不是长期支持的Ubuntu版本。所以我们使用"Ubuntu Server 22.04.1 LTS"作为树莓派4B的系统。
具体安装过程可以参考官方的安装指导: “https://ubuntu.com/tutorials/how-to-install-ubuntu-on-your-raspberry-pi#1-overview”
注意,在烧录之前,点击设置功能,打开SSH,设置用户名,密码,Wi-Fi连接等参数。
2. 获取 Raspberry Pi 4B的 IP 地址:
- 登录路由器的管理界面查看
- 使用网络发现工具,例如IP Scanner扫描网络上的IP变化
3. 使用远程终端(例如:puty)连接树莓派4B,如下图
获取matter源码
1. 安装git:
cd ~/
sudo apt update
sudo apt upgrade -y
sudo apt install git
2. 安装软件依赖项:
sudo apt install -y git vim gcc g++ python-is-python3 python3 python3-venv python3-pip \
unzip pi-bluetooth avahi-daemon libavahi-client-dev libssl-dev libglib2.0-dev \
ninja-build git build-essential protobuf-compiler wpasupplicant wireless-tools rfkill \
libgirepository1.0-dev libcairo2-dev pkg-config python3-dev \
python3-widgetsnbextension python3-testresources libreadline-dev
sudo apt-get install git gcc g++ pkg-config libssl-dev libdbus-1-dev \
libglib2.0-dev libavahi-client-dev ninja-build python3-venv python3-dev \
python3-pip unzip libgirepository1.0-dev libcairo2-dev libreadline-dev
3. 安装Python的库
pip3 install pycairo
4. 克隆matter项目:
将matter项目克隆到树莓派4B本地根目录-芯科的matter项目现在在位于芯科的github仓库-“https://github.com/SiliconLabs/matter”。
git clone https://github.com/SiliconLabs/matter.git
5. 更新子模块
cd matter
git submodule update --init --recursive
6. 运行引导程序:
source scripts/bootstrap.sh
source scripts/activate.sh
如果上面的步骤都没有问题,matter的开发环境就己经搭建起来了
7. 编译灯泡示例程序
cd ~/matter
./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32/ ./out/lighting-app BRD4161A
或者直接使用 GN/Ninja
$ cd ~/matter/examples/lighting-app/efr32
$ git submodule update --init
$ source third_party/matter/scripts/activate.sh
$ export EFR32_BOARD=BRD4161A
$ gn gen out/debug
$ ninja -C out/debug
将灯泡编译为一个休眠的终端设备(Sleepy end device)
$ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32/ ./out/lighting-app_SED BRD4161A --sed
备注
手动安装usb驱动
在 Ubuntu 21.04 或更高版本上,USB 驱动程序和其他一些设备驱动程序在Ubuntu 21.04 中被移动到一个新包中以减小大小。可能需要手动安装它:
sudo apt install linux-modules-extra-raspi
sudo reboot
检查是否出现 USB 串行设备。例如:
ls /dev/ttyA*
PuTTy远程传文件给树莓派4B
putty不能直接传文件到远程的Linux主机。
要从电脑传文件到远程主机,可以使用putty的工具pscp工具传输文件,pscp在putty的安装目录。
cd C:\Program Files\PuTTY
pscp C:\...\filename ubuntu@192.168.1.112:
参考资料:
https://github.com/project-chip/connectedhomeip/tree/master/docs/guides
https://community.silabs.com/s/article/Matter-getting-start-guide?language=en_US
CSDN博客仅作为本人工作学习之余的笔记使用,无任何商业目的,如果侵犯了你的隐私或权益,请随时联系作者,本人将及时删除相关内容