From 09a034d61b7c320914b56ae4500d85304bece57e Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Fri, 4 Jun 2021 16:45:45 +0800 Subject: [PATCH] esp_wifi: support multi phy init data bin embedded --- components/esp_phy/CMakeLists.txt | 9 +++- components/esp_phy/Kconfig | 8 +++ components/esp_phy/Makefile.projbuild | 2 +- .../{ => esp32}/phy_multiple_init_data.bin | Bin .../esp32c3/phy_multiple_init_data.bin | Bin 0 -> 1072 bytes .../esp32s2/phy_multiple_init_data.bin | Bin 0 -> 1072 bytes .../esp32s3/phy_multiple_init_data.bin | Bin 0 -> 1072 bytes components/esp_phy/src/phy_init.c | 46 +++++++++++++++--- components/esp_wifi/lib | 2 +- 9 files changed, 57 insertions(+), 10 deletions(-) rename components/esp_phy/{ => esp32}/phy_multiple_init_data.bin (100%) create mode 100644 components/esp_phy/esp32c3/phy_multiple_init_data.bin create mode 100644 components/esp_phy/esp32s2/phy_multiple_init_data.bin create mode 100644 components/esp_phy/esp32s3/phy_multiple_init_data.bin diff --git a/components/esp_phy/CMakeLists.txt b/components/esp_phy/CMakeLists.txt index 9f3064e125..b59948788e 100644 --- a/components/esp_phy/CMakeLists.txt +++ b/components/esp_phy/CMakeLists.txt @@ -17,7 +17,9 @@ endif() idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "include" "${idf_target}/include" PRIV_REQUIRES nvs_flash - LDFRAGMENTS "${ldfragments}") + LDFRAGMENTS "${ldfragments}" + EMBED_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${idf_target}/phy_multiple_init_data.bin" + ) idf_build_get_property(build_dir BUILD_DIR) @@ -52,7 +54,10 @@ if(CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION) partition_table_get_partition_info(phy_partition_offset "--partition-type data --partition-subtype phy" "offset") if(CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN) - set(phy_init_data_bin "${CMAKE_CURRENT_SOURCE_DIR}/phy_multiple_init_data.bin") + set(phy_init_data_bin "${CMAKE_CURRENT_SOURCE_DIR}/${idf_target}/phy_multiple_init_data.bin") + if(CONFIG_ESP32_MULTIPLE_PHY_DATA_BIN_EMBEDDED) + set(COMPONENT_EMBED_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${idf_target}/phy_multiple_init_data.bin") + endif() else() set(phy_init_data_bin "${build_dir}/phy_init_data.bin") diff --git a/components/esp_phy/Kconfig b/components/esp_phy/Kconfig index e3bb40f3db..b929df68b3 100644 --- a/components/esp_phy/Kconfig +++ b/components/esp_phy/Kconfig @@ -57,6 +57,14 @@ menu "PHY" 3. Country configured by API esp_wifi_set_country() and the parameter policy is WIFI_COUNTRY_POLICY_AUTO. + config ESP32_MULTIPLE_PHY_DATA_BIN_EMBEDDED + bool "Support embedded multiple phy init data bin to app bin" + depends on ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN + default n + help + If enabled, multiple phy init data bin will embedded into app bin + If not enabled, multiple phy init data bin will still leave alone, and need to be flashed by users. + config ESP32_PHY_INIT_DATA_ERROR bool "Terminate operation when PHY init data error" depends on ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN diff --git a/components/esp_phy/Makefile.projbuild b/components/esp_phy/Makefile.projbuild index d759446c3e..0d70e7b710 100644 --- a/components/esp_phy/Makefile.projbuild +++ b/components/esp_phy/Makefile.projbuild @@ -3,7 +3,7 @@ ifdef CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION ESP_PHY_COMPONENT_PATH := $(COMPONENT_PATH) ifdef CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN -PHY_INIT_DATA_BIN = $(ESP_PHY_COMPONENT_PATH)/phy_multiple_init_data.bin +PHY_INIT_DATA_BIN = $(ESP_PHY_COMPONENT_PATH)/$(IDF_TARGET)/phy_multiple_init_data.bin else PHY_INIT_DATA_OBJ = $(BUILD_DIR_BASE)/phy_init_data.o PHY_INIT_DATA_BIN = $(BUILD_DIR_BASE)/phy_init_data.bin diff --git a/components/esp_phy/phy_multiple_init_data.bin b/components/esp_phy/esp32/phy_multiple_init_data.bin similarity index 100% rename from components/esp_phy/phy_multiple_init_data.bin rename to components/esp_phy/esp32/phy_multiple_init_data.bin diff --git a/components/esp_phy/esp32c3/phy_multiple_init_data.bin b/components/esp_phy/esp32c3/phy_multiple_init_data.bin new file mode 100644 index 0000000000000000000000000000000000000000..0f754a2c496b5cf7b712c49b15e83a02082692f4 GIT binary patch literal 1072 zcmWIWi1hUH3}Ikk2nY!9@$vBS@Nn^Rb8}+&PdWe^LLOjbSQY?v$8?!PY};f-av2%e z85*#fhVD*AH)QbN0U6-pVKtbrAR}WeW;ik0_`raTjm>`(4;U~pF+u0KfB;aOuvJ)9 zFfx6`W5oeSoe&_c1ImJiwtrssC9tu-K0r;SRWb w3?s(5*M1#v=@ZrIO2NDtzejZLX7AB00 zj7&_-EUb(W1(cAC49fzb?hyLH_hWADy;4R7c7_HlW>Vx%CMOi21Oiy>z$wJYypA&a znSg-?0Zc$3EGTGfjMFkK5{yhI2G)M|?*nT;t2edm2PIw&VDxuj31*x^jBKscvY)*8 RXAz~yew-d7Qi7532LJ?cYux|< literal 0 HcmV?d00001 diff --git a/components/esp_phy/esp32s3/phy_multiple_init_data.bin b/components/esp_phy/esp32s3/phy_multiple_init_data.bin new file mode 100644 index 0000000000000000000000000000000000000000..0f754a2c496b5cf7b712c49b15e83a02082692f4 GIT binary patch literal 1072 zcmWIWi1hUH3}Ikk2nY!9@$vBS@Nn^Rb8}+&PdWe^LLOjbSQY?v$8?!PY};f-av2%e z85*#fhVD*AH)QbN0U6-pVKtbrAR}WeW;ik0_`raTjm>`(4;U~pF+u0KfB;aOuvJ)9 zFfx6`W5oeSoe&_c1ImJiwtrssC9tu-K0r;SRWb w3?s(5*M1#vcheck_algorithm) == PHY_CRC_ALGORITHM) { err = phy_crc_check_init_data(init_data_control_info->multiple_bin_checksum, init_data_control_info->control_info_checksum, sizeof(phy_control_info_data_t) - sizeof(init_data_control_info->control_info_checksum)); @@ -745,6 +762,9 @@ static esp_err_t phy_get_multiple_init_data(const esp_partition_t* partition, return ESP_FAIL; } +#if CONFIG_ESP32_MULTIPLE_PHY_DATA_BIN_EMBEDDED + memcpy(init_data_multiple, multi_phy_init_data_bin_start + init_data_store_length + sizeof(phy_control_info_data_t), sizeof(esp_phy_init_data_t) * init_data_control_info->number); +#else err = esp_partition_read(partition, init_data_store_length + sizeof(phy_control_info_data_t), init_data_multiple, sizeof(esp_phy_init_data_t) * init_data_control_info->number); if (err != ESP_OK) { @@ -753,7 +773,7 @@ static esp_err_t phy_get_multiple_init_data(const esp_partition_t* partition, ESP_LOGE(TAG, "failed to read PHY init data multiple bin partition (0x%x)", err); return ESP_FAIL; } - +#endif if ((init_data_control_info->check_algorithm) == PHY_CRC_ALGORITHM) { err = phy_crc_check_init_data(init_data_multiple, init_data_control_info->multiple_bin_checksum, sizeof(esp_phy_init_data_t) * init_data_control_info->number); @@ -785,6 +805,19 @@ static esp_err_t phy_get_multiple_init_data(const esp_partition_t* partition, esp_err_t esp_phy_update_init_data(phy_init_data_type_t init_data_type) { +#if CONFIG_ESP32_MULTIPLE_PHY_DATA_BIN_EMBEDDED + esp_err_t err = ESP_OK; + const esp_partition_t* partition = NULL; + size_t init_data_store_length = sizeof(phy_init_magic_pre) + + sizeof(esp_phy_init_data_t) + sizeof(phy_init_magic_post); + uint8_t* init_data_store = (uint8_t*) malloc(init_data_store_length); + if (init_data_store == NULL) { + ESP_LOGE(TAG, "failed to allocate memory for updated country code PHY init data"); + return ESP_ERR_NO_MEM; + } + memcpy(init_data_store, multi_phy_init_data_bin_start, init_data_store_length); + ESP_LOGI(TAG, "load embedded multi phy init data"); +#else const esp_partition_t* partition = esp_partition_find_first( ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_PHY, NULL); if (partition == NULL) { @@ -805,6 +838,7 @@ esp_err_t esp_phy_update_init_data(phy_init_data_type_t init_data_type) ESP_LOGE(TAG, "failed to read updated country code PHY data partition (0x%x)", err); return ESP_FAIL; } +#endif if (memcmp(init_data_store, PHY_INIT_MAGIC, sizeof(phy_init_magic_pre)) != 0 || memcmp(init_data_store + init_data_store_length - sizeof(phy_init_magic_post), PHY_INIT_MAGIC, sizeof(phy_init_magic_post)) != 0) { diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 0c3f24cc83..681c8bfeb7 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 0c3f24cc83d595f60e3b785e3eb098c3bc5ce2d3 +Subproject commit 681c8bfeb739c2fcd579e404b1df8b19acc07497