ZHCADP2A January 2024 – November 2025 AM3351 , AM3352 , AM3354 , AM3356 , AM3357 , AM3358 , AM3358-EP , AM3359 , AM4372 , AM4376 , AM4377 , AM4378 , AM4379 , AM623 , AM625 , AM625SIP , AM62A1-Q1 , AM62A3 , AM62A7 , AM62L , AM62P , AM6411 , AM6412 , AM6421 , AM6422 , AM6441 , AM6442
在演示中,我们使用了 AM62P 和 AM62L。一般情况下,可以使用任何支持 Linux 并可连接网络的 SoC。如需更多信息,请参阅:AM62P 和 AM62L。关于软件,可按照以下步骤在主机 PC 上进行交叉编译:
在 Ubuntu 主机上,下载并安装与您要使用的内核版本相对应的 SDK,例如:AM62L 11.00 SDK 安装程序。
使用以下命令,解压缩 SDK 中的 rootfs:
cd <SDK Install Path>/filesystem/<device>
tar -xf tisdk-default-image-am62lxx-evm.rootfs.tar.xz -C temp/妥善留存此解压缩目录的路径。
使用以下命令,克隆并更新 Matter 存储库:
git clone --recurse-submodules git@github.com:project-chip/connectedhomeip.git
cd connectedhomeip
git pull
git submodule update --init存储库体积较大,克隆过程需要耗费一些时间。
下载 build_matter_example.sh 脚本,并将其放在 Matter 的根目录中:
#!/bin/bash
set -e
# =============================================================================
# Matter aarch64 Cross-Compilation Build Script (Unified)
#
# This script handles all necessary fixes and configurations:
# - Bluezoo dependency fix for Python 3.10
# - TI SDK toolchain wrapper creation
# - Complete Matter build process
# =============================================================================
if [[ $# -ne 1 ]]; then
echo "Error: Please enter exactly one example-name as argument"
echo "Usage: $0 <your_argument>"
exit 1
fi
EXAMPLE_NAME="$1"
# =============================================================================
# CONFIGURATION - MODIFY THESE VARIABLES FOR YOUR SETUP
# =============================================================================
# SDK Path
SDK_PATH="/home/<user>/ti-processor-sdk-linux-am62lxx-evm-11.00.15.05"
# Path to your aarch64 sysroot
SYSROOT_AARCH64="$SDK_PATH/filesystem/am62lxx-evm/temp" # TI SDK sysroot
# Toolchain binary prefix (TI SDK uses aarch64-oe-linux)
TOOLCHAIN_TARGET="aarch64-oe-linux" # TI SDK compatible target
# Path to your aarch64 cross-compilation toolchain (using TI SDK native toolchain)
TOOLCHAIN_PREFIX="$SDK_PATH/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/$TOOLCHAIN_TARGET" # TI SDK toolchain
# Path to connectedhomeip repository (relative to script location)
REPO_PATH="." # CHANGE THIS if different
echo "=== Matter aarch64 Cross-Compilation Build Script (Unified) ==="
echo "Toolchain: $TOOLCHAIN_TARGET"
echo "Sysroot: $SYSROOT_AARCH64"
echo "Example: $EXAMPLE_NAME"
echo ""
echo "============================================================================="
echo "STEP 1: FIX BLUEZOO DEPENDENCY ISSUE"
echo "============================================================================="
REQUIREMENTS_FILE="$REPO_PATH/scripts/tests/requirements.txt"
if [ -f "$REQUIREMENTS_FILE" ]; then
# Check if bluezoo is already commented out
if grep -q "^bluezoo" "$REQUIREMENTS_FILE"; then
echo "Commenting out bluezoo dependency (requires Python 3.11+)..."
sed -i 's/^bluezoo/#bluezoo/' "$REQUIREMENTS_FILE"
echo "✓ Bluezoo dependency commented out"
else
echo "✓ Bluezoo dependency already fixed"
fi
else
echo "Warning: Requirements file not found at $REQUIREMENTS_FILE"
fi
echo "============================================================================="
echo "STEP 2: VERIFY PATHS AND TOOLCHAIN"
echo "============================================================================="
# Construct toolchain binary paths
export CC_AARCH64="$TOOLCHAIN_PREFIX/${TOOLCHAIN_TARGET}-gcc"
export CXX_AARCH64="$TOOLCHAIN_PREFIX/${TOOLCHAIN_TARGET}-g++"
export AR_AARCH64="$TOOLCHAIN_PREFIX/${TOOLCHAIN_TARGET}-ar"
export STRIP_AARCH64="$TOOLCHAIN_PREFIX/${TOOLCHAIN_TARGET}-strip"
export LD_AARCH64="$TOOLCHAIN_PREFIX/${TOOLCHAIN_TARGET}-ld"
# Add toolchain to PATH for any remaining usage
export PATH="$TOOLCHAIN_PREFIX:$PATH"
if [ ! -f "$CC_AARCH64" ]; then
echo "Error: Compiler not found at $CC_AARCH64"
echo "Please check your TOOLCHAIN_PREFIX and TOOLCHAIN_TARGET variables"
exit 1
fi
if [ ! -d "$SYSROOT_AARCH64" ]; then
echo "Error: Sysroot not found at $SYSROOT_AARCH64"
echo "Please check your SYSROOT_AARCH64 path"
exit 1
fi
if [ ! -d "$REPO_PATH" ]; then
echo "Error: Repository not found at $REPO_PATH"
echo "Please check your REPO_PATH variable"
exit 1
fi
echo "✓ Toolchain: $($CC_AARCH64 --version | head -1)"
echo "✓ Sysroot: $SYSROOT_AARCH64"
echo "✓ Repository: $REPO_PATH"
echo "============================================================================="
echo "STEP 3: CREATE TOOLCHAIN WRAPPER"
echo "============================================================================="
cd "$REPO_PATH"
#
# # Create toolchain wrapper directory
WRAPPER_DIR="$PWD/toolchain-wrapper-bin"
mkdir -p "$WRAPPER_DIR"
# Create symbolic links with the names GN expects
echo "Creating symbolic links for GN compatibility..."
ln -sf "$TOOLCHAIN_PREFIX/${TOOLCHAIN_TARGET}-gcc" "$WRAPPER_DIR/aarch64-linux-gnu-gcc"
ln -sf "$TOOLCHAIN_PREFIX/${TOOLCHAIN_TARGET}-g++" "$WRAPPER_DIR/aarch64-linux-gnu-g++"
ln -sf "$TOOLCHAIN_PREFIX/${TOOLCHAIN_TARGET}-ar" "$WRAPPER_DIR/aarch64-linux-gnu-ar"
ln -sf "$TOOLCHAIN_PREFIX/${TOOLCHAIN_TARGET}-strip" "$WRAPPER_DIR/aarch64-linux-gnu-strip"
ln -sf "$TOOLCHAIN_PREFIX/${TOOLCHAIN_TARGET}-ld" "$WRAPPER_DIR/aarch64-linux-gnu-ld"
ln -sf "$TOOLCHAIN_PREFIX/${TOOLCHAIN_TARGET}-objdump" "$WRAPPER_DIR/aarch64-linux-gnu-objdump"
ln -sf "$TOOLCHAIN_PREFIX/${TOOLCHAIN_TARGET}-nm" "$WRAPPER_DIR/aarch64-linux-gnu-nm"
echo "✓ Created toolchain wrapper directory: $WRAPPER_DIR"
echo "Contents:"
ls -la "$WRAPPER_DIR/"
# Add wrapper to PATH
export PATH="$PWD/toolchain-wrapper-bin:$PATH"
echo "============================================================================="
echo "STEP 4: SETUP BUILD ENVIRONMENT"
echo "============================================================================="
source scripts/activate.sh
echo "Testing cross-compilation..."
echo 'int main(){return 0;}' > test.c
$CC_AARCH64 --sysroot="$SYSROOT_AARCH64" -o test test.c
file test
rm test test.c
echo "✓ Cross-compilation test passed"
echo "============================================================================="
echo "STEP 5: CONFIGURE AND BUILD"
echo "============================================================================="
#Check if the example exists
if [ ! -d "examples/${EXAMPLE_NAME}" ]; then
echo -e "No such '$EXAMPLE_NAME' exists in examples!! \nExiting !!"
exit 1
#Check if example does not need specific platform like linux to build
elif [[ $(find ./examples/ -maxdepth 2 -type f -name args.gni | grep -c "$EXAMPLE_NAME") -gt 0 ]]; then
ROOT_PATH="examples/$EXAMPLE_NAME"
#Check if example needs specific platform to build and linux platform is available
elif [[ $(find ./examples/ -type f -name "args.gni" -path "*/linux/*" | grep -c "$EXAMPLE_NAME") -gt 0 ]]; then
ROOT_PATH="examples/$EXAMPLE_NAME/linux"
#Check if example needs specific platform to build but linux platform is NOT available
else
echo -e "'$EXAMPLE_NAME' is not supported on Linux!! \nExiting !!"
exit 1
fi
gn gen "out/${EXAMPLE_NAME}-arm64" --root="$ROOT_PATH" --args="
target_cpu=\"arm64\"
target_os=\"linux\"
sysroot=\"$SYSROOT_AARCH64\"
is_clang=false
treat_warnings_as_errors=false
target_cflags = [
\"-D_GNU_SOURCE\",
\"-D__USE_GNU\",
\"-pthread\",
\"-DCHIP_DEVICE_CONFIG_WIFI_STATION_IF_NAME=\\\"wlan0\\\"\",
\"-DCHIP_DEVICE_CONFIG_LINUX_DHCPC_CMD=\\\"udhcpc -b -i %s \\\"\",
]
target_ldflags=[\"-pthread\"]
"
echo "Building $EXAMPLE_NAME..."
ninja -C "out/${EXAMPLE_NAME}-arm64"
echo "============================================================================="
echo "STEP 6: VERIFY BUILD RESULTS"
echo "============================================================================="
EXECUTABLE_NAME=$(awk -F'"' '/executable\("/ {print $2}' $ROOT_PATH/BUILD.gn)
echo "Expected executable name: $EXECUTABLE_NAME"
BINARY_PATH="out/${EXAMPLE_NAME}-arm64/${EXECUTABLE_NAME}"
if [ -f "$BINARY_PATH" ]; then
file "$BINARY_PATH"
echo "✓ Build complete! Binary located at: $BINARY_PATH"
else
echo "Error: Build failed, binary not found at $BINARY_PATH"
exit 1
fi
echo "============================================================================="
echo "BUILD SUMMARY"
echo "============================================================================="
echo "Target: aarch64 (ARM64)"
echo "Toolchain: $TOOLCHAIN_TARGET"
echo "Example: $EXAMPLE_NAME"
echo "Output: out/${EXAMPLE_NAME}-arm64/${EXECUTABLE_NAME}"
echo ""
echo "All fixes applied:"
echo "✓ Bluezoo dependency commented out for Python 3.10 compatibility"
echo "✓ TI SDK native toolchain configured for compatibility"
echo "✓ Toolchain wrapper created for GN naming conventions"
echo "✓ Matter build completed successfully"
echo ""
echo "To modify configuration, edit the variables at the top of this script:"
echo "- TOOLCHAIN_PREFIX: $TOOLCHAIN_PREFIX"
echo "- SYSROOT_AARCH64: $SYSROOT_AARCH64"
echo "- TOOLCHAIN_TARGET: $TOOLCHAIN_TARGET"
echo "- EXAMPLE_NAME: $EXAMPLE_NAME"
echo ""
echo "To build a different example, run the script with other example's name as argument."修改 build_matter_example.sh,以更新以下变量:
SDK_PATH -> 安装的处理器 SDK 的路径。
SYSROOT_AARCH64 -> 处理器 SDK 中提取的文件系统的路径。
使用以下命令运行脚本:
# sudo ./build_matter_example.sh <example-name>
# For example:
sudo ./build_matter_example.sh chip-tool
sudo ./build_matter_example.sh lock-app注意:在运行上述脚本时,如果您卡在“第 4 步: 设置构建环境”,或您的环境已过时,请退出脚本并运行以下命令:
sudo -E bash scripts/bootstrap.sh这会从头开始重新创建环境,并将耗费一些时间。再次运行 build_matter_example.sh。
成功构建后,脚本将提及输出二进制文件的路径:<Matter root>/out/<example_directory>/<example_executable>。
将可执行文件复制到目标。在示例中,我们复制了 'chip-lock-app'(在 AM62L 上)和 'chip-tool'(在 AM62P 上),两个器件连接了相同的网络。
本应用手册中的实验,在最新版本修订时已通过以下 SDK/存储库版本的测试验证:
11.00.15.05
提交:e156205783(主分支)