From 302e636a13ecd2ee37ca2eb8c76bc36a93b809ea Mon Sep 17 00:00:00 2001 From: yinqingzhao Date: Wed, 29 Apr 2026 13:55:28 +0800 Subject: [PATCH] feat(phy): support change multiple phy init bin path --- components/esp_phy/CMakeLists.txt | 21 ++++++++++++++++++--- components/esp_phy/Kconfig | 12 ++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/components/esp_phy/CMakeLists.txt b/components/esp_phy/CMakeLists.txt index 3890353a9d9..74f8fad7e68 100644 --- a/components/esp_phy/CMakeLists.txt +++ b/components/esp_phy/CMakeLists.txt @@ -41,10 +41,25 @@ if(CONFIG_ESP_PHY_ENABLED) if(CONFIG_SOC_WIFI_SUPPORTED) if(CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN) - if(NOT EXISTS "${build_dir}/phy_multiple_init_data.bin") - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${idf_target}/phy_multiple_init_data.bin - DESTINATION "${build_dir}") + set(_phy_multi_src "${CMAKE_CURRENT_SOURCE_DIR}/${idf_target}/phy_multiple_init_data.bin") + if(NOT "${CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN_CUSTOM_PATH}" STREQUAL "") + idf_build_get_property(project_dir PROJECT_DIR) + set(_phy_multi_custom_path "${CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN_CUSTOM_PATH}") + if(NOT IS_ABSOLUTE "${_phy_multi_custom_path}") + get_filename_component(_phy_multi_custom_path + "${project_dir}/${_phy_multi_custom_path}" ABSOLUTE) + endif() + if(IS_DIRECTORY "${_phy_multi_custom_path}") + set(_phy_multi_custom_path "${_phy_multi_custom_path}/phy_multiple_init_data.bin") + endif() + if(EXISTS "${_phy_multi_custom_path}") + set(_phy_multi_src "${_phy_multi_custom_path}") + endif() endif() + # Refresh copied bin each configure so sdkconfig/path edits match embed + flash contents. + # configure_file(COPYONLY) tracks the source file as a configure dependency. + message(STATUS "esp_phy: phy_multiple_init_data.bin <- ${_phy_multi_src}") + configure_file("${_phy_multi_src}" "${build_dir}/phy_multiple_init_data.bin" COPYONLY) endif() if(CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN_EMBED) diff --git a/components/esp_phy/Kconfig b/components/esp_phy/Kconfig index fcb9bca0db9..e51102d1da3 100644 --- a/components/esp_phy/Kconfig +++ b/components/esp_phy/Kconfig @@ -63,6 +63,18 @@ menu "PHY" 3. Country configured by API esp_wifi_set_country() and the parameter policy is WIFI_COUNTRY_POLICY_AUTO. + config ESP_PHY_MULTIPLE_INIT_DATA_BIN_CUSTOM_PATH + string "Custom path to phy_multiple_init_data.bin" + depends on ESP_PHY_MULTIPLE_INIT_DATA_BIN + default "" + help + Absolute path, or path relative to the project directory, to the file + phy_multiple_init_data.bin, or to a directory containing that file. + + If this field is left empty, or the file cannot be found at the resolved path, + the default binary located at components/esp_phy//phy_multiple_init_data.bin + will be used. + config ESP_PHY_MULTIPLE_INIT_DATA_BIN_EMBED bool "Support embedded multiple phy init data bin to app bin" depends on ESP_PHY_MULTIPLE_INIT_DATA_BIN