ESP IDF + MATTER guide For MacOS

Brew required

Install Brew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install tools

brew install ninja
brew install cmake
brew install esptool

Cloning esp-idf:

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

Cloning esp-matter:

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 ..

Tips

This should be done each time a new terminal is opened.

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

Enable Ccache for faster IDF builds.

export IDF_CCACHE_ENABLE=1

Error notes

If you facing following error…
ERROR: /Users/xxx/.espressif/python_env/idf5.2_py3.12_env/bin/python doesn’t exist! Please run the install script or “idf_tools.py install-python-env” in order to create it.
Do:

cd esp-idf; ./install.sh; cd ..

If you have any questions, as follow
Official Guide

—-

Build matter example project

cd ~/Documents/esp
cd esp-idf; source ./export.sh; cd ..
cd esp-matter; source ./export.sh; cd ..
export IDF_CCACHE_ENABLE=1

Change directory to project.

cd ~/Documents/esp/esp-matter/examples/light
idf.py fullclean
idf.py set-target esp32c3
idf.py build
idf.py erase-flash flash monitor

打开multi_controller
idf.py erase-flash flash monitor -p /dev/serial/by-id/usb-1a86_USB_Single_Serial_553C016917-if00

Modify the device identification code

cd ~/Documents/esp
cd esp-idf; source ./export.sh; cd ..
cd esp-matter; source ./export.sh; cd ..
cd esp-matter/tools/mfg_tool
Install python dependencies
pip install -r requirements.txt

Build chip-cert

cd ~/Documents/esp/esp-matter/connectedhomeip/connectedhomeip
source scripts/activate.sh
gn gen out/host
ninja -C out/host

Add the tools path to $PATH

export PATH="$PATH:/Users/marcel/Documents/esp/esp-matter/connectedhomeip/connectedhomeip/out/host"

Generate a new device certificate

cd esp-matter/tools/mfg_tool

./mfg_tool.py -n 1 -cn "My light" -v 0xFFF2 -p 0x8001 --pai -k /Users/marcel/Documents/esp/esp-matter/connectedhomeip/connectedhomeip/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Key.pem -c /Users/marcel/Documents/esp/esp-matter/connectedhomeip/connectedhomeip/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Cert.pem -cd /Users/marcel/Documents/esp/esp-matter/connectedhomeip/connectedhomeip/credentials/test/certification-declaration/Chip-Test-CD-FFF2-8001.der --dac-in-secure-cert --target esp32c3

Write the device certificate to the development board

esptool.py -p /dev/tty.usbserial-DDE10 write_flash 0x10000 /Users/marcel/Documents/esp/esp-matter/tools/mfg_tool/out/fff2_8001/7168b5df-19d3-4c3c-bbdd-e6e97d2e1f9c/7168b5df-19d3-4c3c-bbdd-e6e97d2e1f9c-partition.bin


esptool.py -p /dev/tty.usbserial-DDE20 write_flash 0x10000 /Users/marcel/Documents/esp/esp-matter/tools/mfg_tool/out/fff2_8001/9cd2c5da-2853-476d-8e44-9300c02b9bfe/9cd2c5da-2853-476d-8e44-9300c02b9bfe-partition.bin

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *