From 2343653af27bb81827cbc87bf5668f90569e8e1a Mon Sep 17 00:00:00 2001 From: Tan Yan Quan Date: Mon, 22 Dec 2025 17:57:14 +0800 Subject: [PATCH] feat(openthread): support 154 debug features on RCP --- examples/openthread/ot_rcp/README.md | 40 +++++++++++++++++++ examples/openthread/ot_rcp/main/esp_ot_rcp.c | 6 +++ .../openthread/ot_rcp/main/idf_component.yml | 2 + examples/openthread/ot_rcp/sdkconfig.defaults | 6 --- .../ot_rcp/sdkconfig.defaults.debug | 9 +++++ 5 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 examples/openthread/ot_rcp/sdkconfig.defaults.debug diff --git a/examples/openthread/ot_rcp/README.md b/examples/openthread/ot_rcp/README.md index 0acd8e8899..c10b19caf1 100644 --- a/examples/openthread/ot_rcp/README.md +++ b/examples/openthread/ot_rcp/README.md @@ -64,3 +64,43 @@ Please refer to [ot_br](../ot_br) example for the setup steps. #### Thread Sniffer Please refer to [Thread Sniffer](https://openthread.io/guides/pyspinel/sniffer) for the detailed instructions. + +### Debug Feature: Turn on RCP console + +The RCP console feature allows you to send console commands to the RCP firmware via the Spinel protocol. This is useful for debugging IEEE 802.15.4 PHY register issues and accessing debug statistics. + +To enable the RCP console, you can either: + +**Option 1: Use the debug configuration file** + +Use the debug configuration file and rebuild: + +``` +idf.py -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.debug" set-target esp32h2 +idf.py -p build flash +``` + +This enables the following commands: + +- `phyreg -g` - Get IEEE 802.15.4 PHY register debug information, including PBUS registers, PHY calibration data, I2C checks, and register validation +- `help` - List all available console commands + +**Option 2: Configure manually via menuconfig** + +To enable other IEEE 802.15.4 debug commands (detailed in `examples/ieee802154/components/cmd_ieee802154_debug/README.md`), run `idf.py menuconfig` and enable the following options: + +``` +Component config → OpenThread → Thread Core Features → Thread Radio Co-Processor Feature → Enable RCP console via Spinel +Component config → IEEE 802.15.4 → Enable IEEE802154 Debug +Component config → IEEE 802.15.4 → IEEE 802.15.4 Debug Parameters → **Select relevant debug features as required** +Component config → Log → Log Level → Default log verbosity → Info +Component config → ESP System Settings → Task watchdog timeout period (seconds) → 10 +``` + +**Note:** It's recommended to increase the watchdog timer timeout to 10 seconds when enabling debug features, as large debug prints may take longer to complete. + +Then rebuild and flash: + +``` +idf.py -p build flash +``` diff --git a/examples/openthread/ot_rcp/main/esp_ot_rcp.c b/examples/openthread/ot_rcp/main/esp_ot_rcp.c index b3c4e6c26f..0da81bd75b 100644 --- a/examples/openthread/ot_rcp/main/esp_ot_rcp.c +++ b/examples/openthread/ot_rcp/main/esp_ot_rcp.c @@ -31,6 +31,9 @@ #if CONFIG_OPENTHREAD_RCP_SPINEL_CONSOLE #include "esp_console.h" +#if CONFIG_IEEE802154_DEBUG +#include "ieee802154_debug.h" +#endif #endif #define TAG "ot_esp_rcp" @@ -67,6 +70,9 @@ void app_main(void) esp_console_config_t console_config = ESP_CONSOLE_CONFIG_DEFAULT(); esp_console_init(&console_config); esp_console_register_help_command(); +#if CONFIG_IEEE802154_DEBUG + register_ieee802154_debug_cmd(); +#endif #endif ESP_ERROR_CHECK(esp_openthread_start(&config)); diff --git a/examples/openthread/ot_rcp/main/idf_component.yml b/examples/openthread/ot_rcp/main/idf_component.yml index 92e0e5b649..a434cd02ac 100644 --- a/examples/openthread/ot_rcp/main/idf_component.yml +++ b/examples/openthread/ot_rcp/main/idf_component.yml @@ -2,3 +2,5 @@ dependencies: ot_examples_common: path: ${IDF_PATH}/examples/openthread/ot_common_components/ot_examples_common + cmd_ieee802154_debug: + path: ${IDF_PATH}/examples/ieee802154/components/cmd_ieee802154_debug diff --git a/examples/openthread/ot_rcp/sdkconfig.defaults b/examples/openthread/ot_rcp/sdkconfig.defaults index d35408beb2..0419e6a33c 100644 --- a/examples/openthread/ot_rcp/sdkconfig.defaults +++ b/examples/openthread/ot_rcp/sdkconfig.defaults @@ -52,9 +52,3 @@ CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC=n CONFIG_OPENTHREAD_LOG_LEVEL_NONE=y CONFIG_OPENTHREAD_TIMING_OPTIMIZATION=y CONFIG_FREERTOS_HZ=1000 - -# -# Turn on RCP console by default, overriding default log level from above -# -CONFIG_OPENTHREAD_RCP_SPINEL_CONSOLE=y -CONFIG_LOG_DEFAULT_LEVEL_INFO=y diff --git a/examples/openthread/ot_rcp/sdkconfig.defaults.debug b/examples/openthread/ot_rcp/sdkconfig.defaults.debug new file mode 100644 index 0000000000..c5e10aa940 --- /dev/null +++ b/examples/openthread/ot_rcp/sdkconfig.defaults.debug @@ -0,0 +1,9 @@ +# +# Turn on RCP console, overriding default log level from sdkconfig.defaults +# We also increase the timeout for watchdog timer to account for large prints. +# +CONFIG_OPENTHREAD_RCP_SPINEL_CONSOLE=y +CONFIG_LOG_DEFAULT_LEVEL_INFO=y +CONFIG_ESP_TASK_WDT_TIMEOUT_S=10 +CONFIG_IEEE802154_DEBUG=y +CONFIG_IEEE802154_PRINT_PHY_REG=y