mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
Merge branch 'feat/update_phy_lib_20260827_v6.1' into 'release/v6.1'
feat(esp_phy): update phylib(backport v6.1) See merge request espressif/esp-idf!52500
This commit is contained in:
@@ -14,7 +14,7 @@ set(embed_files)
|
|||||||
|
|
||||||
if(CONFIG_ESP_PHY_ENABLED)
|
if(CONFIG_ESP_PHY_ENABLED)
|
||||||
|
|
||||||
set(srcs "src/phy_override.c" "src/lib_printf.c" "src/phy_common.c")
|
set(srcs "src/phy_override.c" "src/lib_printf.c" "src/phy_common.c" "src/phy_debug.c")
|
||||||
|
|
||||||
if(CONFIG_APP_NO_BLOBS)
|
if(CONFIG_APP_NO_BLOBS)
|
||||||
set(link_binary_libs 0)
|
set(link_binary_libs 0)
|
||||||
|
|||||||
22
components/esp_phy/include/esp_private/phy_debug.h
Normal file
22
components/esp_phy/include/esp_private/phy_debug.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "esp_phy_init.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_ESP_PHY_RECORD_USED_TIME
|
||||||
|
void phy_record_time(bool enabled, esp_phy_modem_t modem);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Submodule components/esp_phy/lib updated: 5695f4f381...b88e4b76e0
@@ -35,7 +35,25 @@ static const char* TAG = "phy_comm";
|
|||||||
static volatile uint16_t s_phy_modem_flag = 0;
|
static volatile uint16_t s_phy_modem_flag = 0;
|
||||||
|
|
||||||
#if !CONFIG_ESP_PHY_DISABLE_PLL_TRACK
|
#if !CONFIG_ESP_PHY_DISABLE_PLL_TRACK
|
||||||
|
#define RFPLL BIT(0)
|
||||||
|
#define WIFI_POWER BIT(1)
|
||||||
|
#define BT154_POWER BIT(2)
|
||||||
|
#define RXCAL BIT(3)
|
||||||
|
#define TXCAL BIT(4)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int16_t temp_curr;
|
||||||
|
int16_t temp_rfpll;
|
||||||
|
int16_t temp_wifi_power;
|
||||||
|
int16_t temp_bt_power;
|
||||||
|
int16_t temp_rxcal;
|
||||||
|
int16_t temp_txcal;
|
||||||
|
uint16_t flag;
|
||||||
|
} phy_param_track_result_t;
|
||||||
|
|
||||||
extern void phy_param_track_tot(bool en_wifi, bool en_ble_154);
|
extern void phy_param_track_tot(bool en_wifi, bool en_ble_154);
|
||||||
|
extern const phy_param_track_result_t* phy_debug_get_track_result();
|
||||||
|
|
||||||
static esp_timer_handle_t phy_track_pll_timer;
|
static esp_timer_handle_t phy_track_pll_timer;
|
||||||
#if CONFIG_ESP_WIFI_ENABLED
|
#if CONFIG_ESP_WIFI_ENABLED
|
||||||
static volatile int64_t s_wifi_prev_timestamp;
|
static volatile int64_t s_wifi_prev_timestamp;
|
||||||
@@ -97,15 +115,37 @@ static void phy_track_pll_internal(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (wifi_track_pll || ble_154_track_pll) {
|
if (wifi_track_pll || ble_154_track_pll) {
|
||||||
|
phy_param_track_tot(wifi_track_pll, ble_154_track_pll);
|
||||||
#if CONFIG_ESP_PHY_PLL_TRACK_DEBUG
|
#if CONFIG_ESP_PHY_PLL_TRACK_DEBUG
|
||||||
|
// TODO:Support other targets
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32S31
|
||||||
|
const phy_param_track_result_t* result = phy_debug_get_track_result();
|
||||||
|
if (result && result->flag != 0) {
|
||||||
#if CONFIG_IEEE802154_ENABLED || CONFIG_BT_ENABLED
|
#if CONFIG_IEEE802154_ENABLED || CONFIG_BT_ENABLED
|
||||||
ESP_LOGI("PLL_TRACK", "BT or IEEE802154 tracks PLL: %s", ble_154_track_pll ? "True" : "False");
|
ESP_LOGI("TEMP_TRACK", "BT or IEEE802154 tracks: %s", ble_154_track_pll ? "True" : "False");
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_ESP_WIFI_ENABLED
|
#if CONFIG_ESP_WIFI_ENABLED
|
||||||
ESP_LOGI("PLL_TRACK", "Wi-Fi tracks PLL: %s", wifi_track_pll ? "True" : "False");
|
ESP_LOGI("TEMP_TRACK", "Wi-Fi tracks: %s", wifi_track_pll ? "True" : "False");
|
||||||
|
#endif
|
||||||
|
if (result->flag & RFPLL) {
|
||||||
|
ESP_LOGI("TEMP_TRACK", "RFPLL processed, temperature: %d", result->temp_rfpll);
|
||||||
|
}
|
||||||
|
if (result->flag & WIFI_POWER) {
|
||||||
|
ESP_LOGI("TEMP_TRACK", "WIFI_POWER processed, temperature: %d", result->temp_wifi_power);
|
||||||
|
}
|
||||||
|
if (result->flag & BT154_POWER) {
|
||||||
|
ESP_LOGI("TEMP_TRACK", "BT154_POWER processed, temperature: %d", result->temp_bt_power);
|
||||||
|
}
|
||||||
|
if (result->flag & RXCAL) {
|
||||||
|
ESP_LOGI("TEMP_TRACK", "RXCAL processed, temperature: %d", result->temp_rxcal);
|
||||||
|
}
|
||||||
|
if (result->flag & TXCAL) {
|
||||||
|
ESP_LOGI("TEMP_TRACK", "TXCAL processed, temperature: %d", result->temp_txcal);
|
||||||
|
}
|
||||||
|
ESP_LOGI("TEMP_TRACK", "Current temperature: %d", result->temp_curr);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
phy_param_track_tot(wifi_track_pll, ble_154_track_pll);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +161,7 @@ void phy_track_pll_init(void)
|
|||||||
{
|
{
|
||||||
const esp_timer_create_args_t phy_track_pll_timer_args = {
|
const esp_timer_create_args_t phy_track_pll_timer_args = {
|
||||||
.callback = &phy_track_pll_timer_callback,
|
.callback = &phy_track_pll_timer_callback,
|
||||||
.name = "phy-track-pll-timer"
|
.name = "phy-track-timer"
|
||||||
};
|
};
|
||||||
ESP_ERROR_CHECK(esp_timer_create(&phy_track_pll_timer_args, &phy_track_pll_timer));
|
ESP_ERROR_CHECK(esp_timer_create(&phy_track_pll_timer_args, &phy_track_pll_timer));
|
||||||
ESP_ERROR_CHECK(esp_timer_start_periodic(phy_track_pll_timer, PHY_TRACK_PLL_PERIOD_IN_US));
|
ESP_ERROR_CHECK(esp_timer_start_periodic(phy_track_pll_timer, PHY_TRACK_PLL_PERIOD_IN_US));
|
||||||
|
|||||||
74
components/esp_phy/src/phy_debug.c
Normal file
74
components/esp_phy/src/phy_debug.c
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "esp_attr.h"
|
||||||
|
#include "esp_err.h"
|
||||||
|
#include "esp_phy_init.h"
|
||||||
|
#include "esp_timer.h"
|
||||||
|
|
||||||
|
#include "esp_private/phy.h"
|
||||||
|
#include "esp_private/phy_debug.h"
|
||||||
|
|
||||||
|
#if CONFIG_ESP_PHY_RECORD_USED_TIME
|
||||||
|
|
||||||
|
#define ESP_PHY_MODEM_COUNT_MAX (__builtin_ffs(PHY_MODEM_MAX - 1))
|
||||||
|
#define ESP_PHY_IS_VALID_MODEM(modem) (__builtin_popcount(modem) == 1 && __builtin_ctz(modem) < ESP_PHY_MODEM_COUNT_MAX)
|
||||||
|
|
||||||
|
static DRAM_ATTR struct {
|
||||||
|
uint64_t used_time;
|
||||||
|
uint64_t enabled_time;
|
||||||
|
uint64_t disabled_time;
|
||||||
|
} s_phy_rf_used_info[ESP_PHY_MODEM_COUNT_MAX];
|
||||||
|
|
||||||
|
void IRAM_ATTR phy_record_time(bool enabled, esp_phy_modem_t modem)
|
||||||
|
{
|
||||||
|
uint8_t index = __builtin_ctz(modem);
|
||||||
|
|
||||||
|
if (enabled) {
|
||||||
|
s_phy_rf_used_info[index].enabled_time = esp_timer_get_time();
|
||||||
|
} else {
|
||||||
|
s_phy_rf_used_info[index].disabled_time = esp_timer_get_time();
|
||||||
|
s_phy_rf_used_info[index].used_time += s_phy_rf_used_info[index].disabled_time - s_phy_rf_used_info[index].enabled_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t phy_query_used_time(uint64_t *used_time, esp_phy_modem_t modem)
|
||||||
|
{
|
||||||
|
if (!ESP_PHY_IS_VALID_MODEM(modem)) {
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t index = __builtin_ctz(modem);
|
||||||
|
_lock_t phy_lock = phy_get_lock();
|
||||||
|
_lock_acquire(&phy_lock);
|
||||||
|
*used_time = s_phy_rf_used_info[index].used_time;
|
||||||
|
if (s_phy_rf_used_info[index].disabled_time < s_phy_rf_used_info[index].enabled_time) {
|
||||||
|
*used_time += esp_timer_get_time() - s_phy_rf_used_info[index].enabled_time;
|
||||||
|
}
|
||||||
|
_lock_release(&phy_lock);
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t phy_clear_used_time(esp_phy_modem_t modem)
|
||||||
|
{
|
||||||
|
if (!ESP_PHY_IS_VALID_MODEM(modem)) {
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t index = __builtin_ctz(modem);
|
||||||
|
_lock_t phy_lock = phy_get_lock();
|
||||||
|
_lock_acquire(&phy_lock);
|
||||||
|
if (s_phy_rf_used_info[index].enabled_time > s_phy_rf_used_info[index].disabled_time) {
|
||||||
|
s_phy_rf_used_info[index].enabled_time = esp_timer_get_time();
|
||||||
|
} else {
|
||||||
|
s_phy_rf_used_info[index].enabled_time = s_phy_rf_used_info[index].disabled_time;
|
||||||
|
}
|
||||||
|
s_phy_rf_used_info[index].used_time = 0;
|
||||||
|
_lock_release(&phy_lock);
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -58,6 +58,7 @@
|
|||||||
#if SOC_PM_REGDMA_MODEM_LINK_PROTECT
|
#if SOC_PM_REGDMA_MODEM_LINK_PROTECT
|
||||||
#include "esp_private/esp_pau.h"
|
#include "esp_private/esp_pau.h"
|
||||||
#endif // SOC_PM_REGDMA_MODEM_LINK_PROTECT
|
#endif // SOC_PM_REGDMA_MODEM_LINK_PROTECT
|
||||||
|
#include "esp_private/phy_debug.h"
|
||||||
|
|
||||||
#ifndef PHY_INIT_MODEM_CLOCK_REQUIRED_BITS
|
#ifndef PHY_INIT_MODEM_CLOCK_REQUIRED_BITS
|
||||||
#warning "PHY_INIT_MODEM_CLOCK_REQUIRED_BITS not defined; using default value 0"
|
#warning "PHY_INIT_MODEM_CLOCK_REQUIRED_BITS not defined; using default value 0"
|
||||||
@@ -190,59 +191,6 @@ static phy_country_to_bin_type_t s_country_code_map_type_table[] = {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_ESP_PHY_RECORD_USED_TIME
|
|
||||||
#define ESP_PHY_MODEM_COUNT_MAX (__builtin_ffs(PHY_MODEM_MAX - 1))
|
|
||||||
#define ESP_PHY_IS_VALID_MODEM(modem) (__builtin_popcount(modem) == 1 && __builtin_ctz(modem) < ESP_PHY_MODEM_COUNT_MAX)
|
|
||||||
|
|
||||||
static DRAM_ATTR struct {
|
|
||||||
uint64_t used_time;
|
|
||||||
uint64_t enabled_time;
|
|
||||||
uint64_t disabled_time;
|
|
||||||
} s_phy_rf_used_info[ESP_PHY_MODEM_COUNT_MAX];
|
|
||||||
|
|
||||||
static IRAM_ATTR void phy_record_time(bool enabled, esp_phy_modem_t modem) {
|
|
||||||
uint8_t index = __builtin_ctz(modem);
|
|
||||||
if (enabled) {
|
|
||||||
s_phy_rf_used_info[index].enabled_time = esp_timer_get_time();
|
|
||||||
} else {
|
|
||||||
s_phy_rf_used_info[index].disabled_time = esp_timer_get_time();
|
|
||||||
s_phy_rf_used_info[index].used_time += s_phy_rf_used_info[index].disabled_time - s_phy_rf_used_info[index].enabled_time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t phy_query_used_time(uint64_t *used_time, esp_phy_modem_t modem) {
|
|
||||||
if (!ESP_PHY_IS_VALID_MODEM(modem)) {
|
|
||||||
return ESP_ERR_INVALID_ARG;
|
|
||||||
}
|
|
||||||
uint8_t index = __builtin_ctz(modem);
|
|
||||||
_lock_acquire(&s_phy_access_lock);
|
|
||||||
*used_time = s_phy_rf_used_info[index].used_time;
|
|
||||||
if (s_phy_rf_used_info[index].disabled_time < s_phy_rf_used_info[index].enabled_time) {
|
|
||||||
// phy is being used
|
|
||||||
*used_time += esp_timer_get_time() - s_phy_rf_used_info[index].enabled_time;
|
|
||||||
}
|
|
||||||
_lock_release(&s_phy_access_lock);
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t phy_clear_used_time(esp_phy_modem_t modem) {
|
|
||||||
if (!ESP_PHY_IS_VALID_MODEM(modem)) {
|
|
||||||
return ESP_ERR_INVALID_ARG;
|
|
||||||
}
|
|
||||||
uint8_t index = __builtin_ctz(modem);
|
|
||||||
_lock_acquire(&s_phy_access_lock);
|
|
||||||
if (s_phy_rf_used_info[index].enabled_time > s_phy_rf_used_info[index].disabled_time) {
|
|
||||||
// phy is being used
|
|
||||||
s_phy_rf_used_info[index].enabled_time = esp_timer_get_time();
|
|
||||||
} else {
|
|
||||||
s_phy_rf_used_info[index].enabled_time = s_phy_rf_used_info[index].disabled_time;
|
|
||||||
}
|
|
||||||
s_phy_rf_used_info[index].used_time = 0;
|
|
||||||
_lock_release(&s_phy_access_lock);
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint32_t IRAM_ATTR phy_enter_critical(void)
|
uint32_t IRAM_ATTR phy_enter_critical(void)
|
||||||
{
|
{
|
||||||
if (xPortInIsrContext()) {
|
if (xPortInIsrContext()) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "esp_private/esp_modem_clock.h"
|
#include "esp_private/esp_modem_clock.h"
|
||||||
#endif
|
#endif
|
||||||
#include "phy_init_deps.h"
|
#include "phy_init_deps.h"
|
||||||
|
#include "esp_private/phy_debug.h"
|
||||||
|
|
||||||
#ifndef PHY_INIT_MODEM_CLOCK_REQUIRED_BITS
|
#ifndef PHY_INIT_MODEM_CLOCK_REQUIRED_BITS
|
||||||
#warning "PHY_INIT_MODEM_CLOCK_REQUIRED_BITS not defined; using default value 0"
|
#warning "PHY_INIT_MODEM_CLOCK_REQUIRED_BITS not defined; using default value 0"
|
||||||
@@ -29,59 +30,6 @@ static _lock_t s_phy_access_lock;
|
|||||||
/* Reference count of enabling PHY */
|
/* Reference count of enabling PHY */
|
||||||
static bool s_phy_is_enabled = false;
|
static bool s_phy_is_enabled = false;
|
||||||
|
|
||||||
#if CONFIG_ESP_PHY_RECORD_USED_TIME
|
|
||||||
#define ESP_PHY_MODEM_COUNT_MAX (__builtin_ffs(PHY_MODEM_MAX - 1))
|
|
||||||
#define ESP_PHY_IS_VALID_MODEM(modem) (__builtin_popcount(modem) == 1 && __builtin_ctz(modem) < ESP_PHY_MODEM_COUNT_MAX)
|
|
||||||
|
|
||||||
static DRAM_ATTR struct {
|
|
||||||
uint64_t used_time;
|
|
||||||
uint64_t enabled_time;
|
|
||||||
uint64_t disabled_time;
|
|
||||||
} s_phy_rf_used_info[ESP_PHY_MODEM_COUNT_MAX];
|
|
||||||
|
|
||||||
static IRAM_ATTR void phy_record_time(bool enabled, esp_phy_modem_t modem) {
|
|
||||||
uint8_t index = __builtin_ctz(modem);
|
|
||||||
if (enabled) {
|
|
||||||
s_phy_rf_used_info[index].enabled_time = esp_timer_get_time();
|
|
||||||
} else {
|
|
||||||
s_phy_rf_used_info[index].disabled_time = esp_timer_get_time();
|
|
||||||
s_phy_rf_used_info[index].used_time += s_phy_rf_used_info[index].disabled_time - s_phy_rf_used_info[index].enabled_time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t phy_query_used_time(uint64_t *used_time, esp_phy_modem_t modem) {
|
|
||||||
if (!ESP_PHY_IS_VALID_MODEM(modem)) {
|
|
||||||
return ESP_ERR_INVALID_ARG;
|
|
||||||
}
|
|
||||||
uint8_t index = __builtin_ctz(modem);
|
|
||||||
_lock_acquire(&s_phy_access_lock);
|
|
||||||
*used_time = s_phy_rf_used_info[index].used_time;
|
|
||||||
if (s_phy_rf_used_info[index].disabled_time < s_phy_rf_used_info[index].enabled_time) {
|
|
||||||
// phy is being used
|
|
||||||
*used_time += esp_timer_get_time() - s_phy_rf_used_info[index].enabled_time;
|
|
||||||
}
|
|
||||||
_lock_release(&s_phy_access_lock);
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t phy_clear_used_time(esp_phy_modem_t modem) {
|
|
||||||
if (!ESP_PHY_IS_VALID_MODEM(modem)) {
|
|
||||||
return ESP_ERR_INVALID_ARG;
|
|
||||||
}
|
|
||||||
uint8_t index = __builtin_ctz(modem);
|
|
||||||
_lock_acquire(&s_phy_access_lock);
|
|
||||||
if (s_phy_rf_used_info[index].enabled_time > s_phy_rf_used_info[index].disabled_time) {
|
|
||||||
// phy is being used
|
|
||||||
s_phy_rf_used_info[index].enabled_time = esp_timer_get_time();
|
|
||||||
} else {
|
|
||||||
s_phy_rf_used_info[index].enabled_time = s_phy_rf_used_info[index].disabled_time;
|
|
||||||
}
|
|
||||||
s_phy_rf_used_info[index].used_time = 0;
|
|
||||||
_lock_release(&s_phy_access_lock);
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint32_t IRAM_ATTR phy_enter_critical(void)
|
uint32_t IRAM_ATTR phy_enter_critical(void)
|
||||||
{
|
{
|
||||||
if (xPortInIsrContext()) {
|
if (xPortInIsrContext()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user