Matter(connectedhomeip)TI CC13x4_CC26x4 平台 OpenThread 库构建配置完全指南 物联网智能家居嵌入式通信【免费下载链接】connectedhomeipMatter (formerly Project CHIP) creates more connections between more objects, simplifying development for manufacturers and increasing compatibility for consumers, guided by the Connectivity Standards Alliance.项目地址https://gitcode.com/GitHub_Trending/co/connectedhomeip点击查看免费下载本文是 docs/platforms/ti/matter-users-guide/ti_openthread_library_usage.md 的深度展开版系统讲解在 TI CC13x4_CC26x4如 LP_EM_CC1354P10_6、CC2674R10平台上Matter 示例应用如何通过 GN 构建参数决定 Thread 代码的链接方式。读完本文你将掌握三种 OpenThread 集成模式TI 认证库、源码构建、自定义库的完整配置步骤、FTD/MTD 角色切换方法以及底层ot-ti-cert目标是如何根据构建参数挑选 FTD/MTD 静态库的可直接复用到 lighting-app、lock-app 等任意 TI 示例工程。一、总体机制Thread 代码的三种包含方式TI Matter 示例应用为“如何把 Thread 代码编进固件”提供了三个层次的选择对应不同开发阶段与诉求TI 认证 OpenThread 库Certified Library针对 Matter 深度裁剪与优化的预编译库推荐用于开发与量产。它会关闭诸如 Thread Joiner加入者等特性以节省 Flash/RAM 占用。全源码构建Full Source直接把 OpenThread 源码编进工程适合开发调试阶段按需调整行为。自定义库Custom Library在 TI 官方库基础上加入额外特性或修改协议栈后自行编译得到的 FTD/MTD 库通过自定义库目录接入。无论采用哪种方式真正决定“链接哪个库”的逻辑都集中在ot-ti-cert这个 GN source_set 中见 third_party/openthread/platforms/ti/BUILD.gn。该文件同时是openthread_external_platform目标libopenthread-ti的定义处source_set(libopenthread-ti)负责 TI 平台层的移植代码包括alarm.c、alarm_micro.c、diag.c、entropy.c、misc.c、radio.c、settings.c等平台适配源文件以及examples/platforms/utils/下的mac_frame.cpp、link_metrics.cpp等公共工具当开启chip_build_libshell时还会额外加入 CLI 串口实现cli_uart.cpp。source_set(ot-ti-cert)本身不编译源码而是按chip_openthread_ftd的值选择链接libopenthread-ftd.a或libopenthread-mtd.a。其选择逻辑BUILD.gn可概括为if ( ! ot_ti_lib_dir) { library_dir ot_ti_lib_dir # 自定义库目录优先 } else { library_dir ${openthread_ti_root}/libs/${ti_simplelink_device_family} # 默认 TI 认证库目录 } if (chip_openthread_ftd) { libs [ ${library_dir}/libopenthread-ftd.a ] # FTD 全功能设备 } else { libs [ ${library_dir}/libopenthread-mtd.a ] # MTD 最小线程设备 }即ot_ti_lib_dir决定库的目录chip_openthread_ftd决定挑 FTD 还是 MTD 库。下面各节将分别给出三种模式的完整配置。二、FTD 与 MTD一个参数切换设备角色配置任何 TI 示例工程的第一步是打开该示例的args.gni文件例如 lighting-app 为 examples/lighting-app/ti/cc13x4_26x4/args.gni设定设备角色chip_openthread_ftd true设为true设备作为FTDFull Thread Device全功能线程设备能够保持路由表、担任 Router/Leader功能完整但 Flash/RAM 占用更高设为false设备作为MTDMinimal Thread Device最小线程设备只保留参与 Thread 网络所需的最小能力集适合资源受限的终结点。该参数不仅驱动库选择还会在openthread_ti_config中注入对应的编译配置chip_openthread_ftd为真时追加openthread_ftd_config否则追加openthread_mtd_config见 BUILD.gn从而影响 OpenThread 功能宏的定义。chip_openthread_ftd属于 CHIP 全局构建参数declare_args所有示例、甚至非 TI 平台同样遵守这一语义因此在工程中切换角色只改这一处即可。三、方式一TI 认证 OpenThread 库推荐认证库是 TI 面向 Matter 认证场景预编译并裁减过的 FTD/MTD 库默认位于${openthread_ti_root}/libs/${ti_simplelink_device_family}目录。配置三步如下ot_ti_lib_dir置空——让构建系统回落到默认的 TI 认证库目录ot_ti_lib_dir chip_openthread_target指向 TI 认证库依赖目标——即ot-ti-certsource_set由它负责挑选libopenthread-ftd.a/libopenthread-mtd.achip_openthread_target ${chip_root}/third_party/openthread/platforms/ti:ot-ti-certopenthread_external_platform指向平台层构建依赖——libopenthread-tisource_set 提供 TI 平台移植源码openthread_external_platform ${chip_root}/third_party/openthread/platforms/ti:libopenthread-ti这组配置正是 lighting-app 默认工程所采用的examples/lighting-app/ti/cc13x4_26x4/args.gni其中还保留了同义的注释“When using TI Certified Openthread libs set to ...:ot-ti-cert; For source builds, set to empty string.”认证要点由于认证库已针对 Matter 裁剪例如关闭 Joiner 功能若你的 Matter 应用需要走 Thread 认证流程请参照原文档中提到的ti_matter_production_certification.md说明为认证申请填写对应的 cert ID切勿使用自编译库代替认证库送测。四、方式二OpenThread 全源码构建适用于开发期希望自由修改 OpenThread 行为、或在无法获取预编译库时使用。此时不链接任何预编译.a而是把平台层源码与 OpenThread 核心源码一起编译ot_ti_lib_dir置空ot_ti_lib_dir chip_openthread_target置空——告知构建系统不使用ot-ti-cert不链接预编译库chip_openthread_target openthread_external_platform仍指向平台层依赖——源码模式同样需要 TI 平台移植代码openthread_external_platform ${chip_root}/third_party/openthread/platforms/ti:libopenthread-ti需要说明的是源码构建模式下 OpenThread 核心源码来自openthread_root指向的目录CHIP 默认在 build_overrides/openthread.gni 中定义为//third_party/openthread/repoTI 示例工程会在自己的 args.gni 中覆盖为 TI 定制版 OpenThread 的路径工程初始化时通过子模块或 TI 工具链自动拉取。五、方式三自定义 OpenThread 库当需要实现额外特性或以任何方式修改协议栈如调整安全策略、扩展命令、改动 MAC 行为时自行编译生成自定义的libopenthread-ftd.a/libopenthread-mtd.a然后通过目录接入ot_ti_lib_dir指向包含自定义 FTD/MTD 库的目录注意末尾的/可以是仓库内目录或绝对路径ot_ti_lib_dir ${chip_root}/CUSTOM_LIB_DIR_PATH/此时 BUILD.gn 中的library_dir会取该值从而绕过默认的认证库目录。chip_openthread_target置空chip_openthread_target openthread_external_platform仍指向平台层依赖openthread_external_platform ${chip_root}/third_party/openthread/platforms/ti:libopenthread-ti关于 FTD/MTD 库的产出方式TI 的独立 OpenThread 应用构建流程会在生成独立应用时自动编译出对应的 FTD/MTD 静态库可参照原文档指向的third_party/openthread/ot-ti/README.md该目录由 TI OpenThread 子模块提供随 SDK 初始化一并填充获取详细构建步骤。六、两类配置头文件认证库基线 vs 可调参数TI 平台涉及两个 OpenThread 配置头文件职责不同1. 认证库的配置基线只读TI 认证 FTD/MTD 库基于以下头文件裁剪特性集third_party/openthread/ot-ti/src/openthread-core-cc13xx_cc26xx-config-matter.h该头文件位于 TI OpenThread 子模块内定义了面向 Matter 的默认 OpenThread 特性开关例如精简后的线程版本配置、关闭 Joiner 等以压缩 Flash/RAM 占用。由于它是预编译库的编译期基线使用认证库时不应修改它——需要改特性时应切换到源码构建或自定义库。2. 工程级可调配置允许修改从源码构建或使用自定义库时可在以下文件中调整 OpenThread 特性${chip_root}/examples/platform/ti/cc13x4_26x4/project_include/OpenThreadConfig.h该文件examples/platform/ti/cc13x4_26x4/project_include/OpenThreadConfig.h的当前实现非常精简#pragma once #define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_APP // Use the TI-supplied default platform configuration for remainder #ifdef OPENTHREAD_PROJECT_CORE_CONFIG_FILE #include OPENTHREAD_PROJECT_CORE_CONFIG_FILE #endif它做了两件事把 OpenThread 日志输出重定向到应用层日志OPENTHREAD_CONFIG_LOG_OUTPUT_APP便于与 CHIP/Matter 日志统一打印其余配置通过OPENTHREAD_PROJECT_CORE_CONFIG_FILE宏引入 TI 提供的平台默认配置。你可以在#pragma once之后追加自己的#define OPENTHREAD_CONFIG_XXX ...来按需裁剪特性。该文件之所以生效是因为平台层 args.gni 做了如下接线examples/platform/ti/cc13x4_26x4/args.gniopenthread_config_file OpenThreadConfig.h openthread_core_config_deps [ ${chip_root}/examples/platform/ti/cc13x4_26x4:openthread_core_config_cc13x4_26x4_chip_examples ]即通过openthread_config_file指定配置文件、openthread_core_config_deps指定配置目标OpenThread 核心构建会将其作为工程级配置头引入。七、三种模式速查与选型建议配置项TI 认证库源码构建自定义库ot_ti_lib_dir自定义库目录路径如${chip_root}/CUSTOM_LIB_DIR_PATH/chip_openthread_target.../platforms/ti:ot-ti-certopenthread_external_platform.../platforms/ti:libopenthread-ti.../platforms/ti:libopenthread-ti.../platforms/ti:libopenthread-ti适用阶段开发与量产推荐开发调试需要改协议栈/加特性Flash/RAM 占用已针对 Matter 裁剪最优取决于特性宏配置取决于自编译配置可否送认证可以按ti_matter_production_certification.md填 cert ID不可不可选型建议默认开发与量产直接使用方式一认证库无需任何额外构建产物且出厂即满足 Matter Thread 认证所需的库基线调试 OpenThread 行为切到方式二源码构建配合OpenThreadConfig.h自由增删特性宏快速验证后再回到认证库以控制固件体积深度定制协议栈使用方式三自定义库把修改后的协议栈编译为 FTD/MTD 静态库放入自定义目录即可无缝接入现有 Matter 构建链。八、相关资源索引本文档出处docs/platforms/ti/matter-users-guide/ti_openthread_library_usage.md库选择与平台移植实现third_party/openthread/platforms/ti/BUILD.gn默认示例配置照明应用examples/lighting-app/ti/cc13x4_26x4/args.gni平台级构建参数含 OpenThread 配置头接线examples/platform/ti/cc13x4_26x4/args.gni工程级 OpenThread 配置头examples/platform/ti/cc13x4_26x4/project_include/OpenThreadConfig.hOpenThread 根目录默认值build_overrides/openthread.gni赞分享物联网智能家居嵌入式通信【免费下载链接】connectedhomeipMatter (formerly Project CHIP) creates more connections between more objects, simplifying development for manufacturers and increasing compatibility for consumers, guided by the Connectivity Standards Alliance.项目地址https://gitcode.com/GitHub_Trending/co/connectedhomeip点击查看免费下载相关推荐Matter Shell 在 TI CC13XX_26XX 平台的构建、烧录与调试全指南connectedhomeip 仓库Matter Shell 在 TI CC13XX_26XX 平台的构建、烧录与调试全指南connectedhomeip 仓库 本文以 connectedho物联网智能家居嵌入式通信MatterconnectedhomeipTI SimpleLink 平台开发指南CC13x4_26x4 架构、BLE/Thread 协议栈与 GN 构建实战MatterconnectedhomeipTI SimpleLink 平台开发指南CC13x4_26x4 架构、BLE/Thread 协议栈与 GN 构建物联网智能家居嵌入式通信Matter (connectedhomeip) ESP32 平台开发环境搭建ESP-IDF 与 Matter 环境配置指南Matter connectedhomeip ESP32 平台开发环境搭建ESP IDF 与 Matter 环境配置指南 本篇指南面向在 ESP32 系列 S物联网智能家居嵌入式通信创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考