change(esp_phy): Add SOC_PHY_SUPPORTED to control phy mode

pull/13550/head
xiehang 2024-03-25 17:54:38 +08:00
rodzic d5c6e53e8a
commit 9d7bd6a8dd
19 zmienionych plików z 217 dodań i 155 usunięć

Wyświetl plik

@ -9,6 +9,8 @@ if(IDF_TARGET STREQUAL "esp32p4" OR IDF_TARGET STREQUAL "esp32c61")
return()
endif()
if(CONFIG_ESP_PHY_ENABLED)
set(srcs "src/phy_override.c" "src/lib_printf.c" "src/phy_common.c")
if(CONFIG_APP_NO_BLOBS)
@ -46,6 +48,7 @@ if(CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN_EMBED)
set(embed_files "${build_dir}/phy_multiple_init_data.bin")
endif()
endif()
endif()
# [refactor-todo]: requires "driver" component for periph_ctrl header file
idf_component_register(SRCS "${srcs}"
@ -55,6 +58,7 @@ idf_component_register(SRCS "${srcs}"
EMBED_FILES ${embed_files}
)
if(CONFIG_ESP_PHY_ENABLED)
set(target_name "${idf_target}")
target_link_directories(${COMPONENT_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}")
@ -122,3 +126,5 @@ if(CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION)
esptool_py_flash_target_image(${phy_name}-flash ${phy_name} "${phy_partition_offset}" "${phy_init_data_bin}")
esptool_py_flash_target_image(flash ${phy_name} "${phy_partition_offset}" "${phy_init_data_bin}")
endif()
endif()

Wyświetl plik

@ -1,170 +1,177 @@
menu "PHY"
config ESP_PHY_CALIBRATION_AND_DATA_STORAGE
bool "Store phy calibration data in NVS"
default y
help
If this option is enabled, NVS will be initialized and calibration data will be loaded from there.
PHY calibration will be skipped on deep sleep wakeup. If calibration data is not found, full calibration
will be performed and stored in NVS. Normally, only partial calibration will be performed.
If this option is disabled, full calibration will be performed.
config ESP_PHY_ENABLED
bool
default y if (SOC_PHY_SUPPORTED)
If it's easy that your board calibrate bad data, choose 'n'.
Two cases for example, you should choose 'n':
1.If your board is easy to be booted up with antenna disconnected.
2.Because of your board design, each time when you do calibration, the result are too unstable.
If unsure, choose 'y'.
if (ESP_PHY_ENABLED)
config ESP_PHY_CALIBRATION_AND_DATA_STORAGE
bool "Store phy calibration data in NVS"
default y
help
If this option is enabled, NVS will be initialized and calibration data will be loaded from there.
PHY calibration will be skipped on deep sleep wakeup. If calibration data is not found, full
calibration will be performed and stored in NVS. Normally, only partial calibration will be performed.
If this option is disabled, full calibration will be performed.
menuconfig ESP_PHY_INIT_DATA_IN_PARTITION
bool "Use a partition to store PHY init data"
depends on SOC_WIFI_SUPPORTED
default n
help
If enabled, PHY init data will be loaded from a partition.
When using a custom partition table, make sure that PHY data
partition is included (type: 'data', subtype: 'phy').
With default partition tables, this is done automatically.
If PHY init data is stored in a partition, it has to be flashed there,
otherwise runtime error will occur.
If it's easy that your board calibrate bad data, choose 'n'.
Two cases for example, you should choose 'n':
1.If your board is easy to be booted up with antenna disconnected.
2.Because of your board design, each time when you do calibration, the result are too unstable.
If unsure, choose 'y'.
If this option is not enabled, PHY init data will be embedded
into the application binary.
menuconfig ESP_PHY_INIT_DATA_IN_PARTITION
bool "Use a partition to store PHY init data"
depends on SOC_WIFI_SUPPORTED
default n
help
If enabled, PHY init data will be loaded from a partition.
When using a custom partition table, make sure that PHY data
partition is included (type: 'data', subtype: 'phy').
With default partition tables, this is done automatically.
If PHY init data is stored in a partition, it has to be flashed there,
otherwise runtime error will occur.
If unsure, choose 'n'.
If this option is not enabled, PHY init data will be embedded
into the application binary.
config ESP_PHY_DEFAULT_INIT_IF_INVALID
bool "Reset default PHY init data if invalid"
default n
depends on ESP_PHY_INIT_DATA_IN_PARTITION
help
If enabled, PHY init data will be restored to default if
it cannot be verified successfully to avoid endless bootloops.
If unsure, choose 'n'.
If unsure, choose 'n'.
if ESP_PHY_INIT_DATA_IN_PARTITION
config ESP_PHY_MULTIPLE_INIT_DATA_BIN
bool "Support multiple PHY init data bin"
config ESP_PHY_DEFAULT_INIT_IF_INVALID
bool "Reset default PHY init data if invalid"
default n
depends on ESP_PHY_INIT_DATA_IN_PARTITION
default n
help
If enabled, the corresponding PHY init data type can be automatically switched
according to the country code. China's PHY init data bin is used by default.
Can be modified by country information in API esp_wifi_set_country().
The priority of switching the PHY init data type is:
1. Country configured by API esp_wifi_set_country()
and the parameter policy is WIFI_COUNTRY_POLICY_MANUAL.
2. Country notified by the connected AP.
3. Country configured by API esp_wifi_set_country()
and the parameter policy is WIFI_COUNTRY_POLICY_AUTO.
If enabled, PHY init data will be restored to default if
it cannot be verified successfully to avoid endless bootloops.
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
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.
If unsure, choose 'n'.
config ESP_PHY_INIT_DATA_ERROR
bool "Terminate operation when PHY init data error"
depends on ESP_PHY_MULTIPLE_INIT_DATA_BIN
if ESP_PHY_INIT_DATA_IN_PARTITION
config ESP_PHY_MULTIPLE_INIT_DATA_BIN
bool "Support multiple PHY init data bin"
depends on ESP_PHY_INIT_DATA_IN_PARTITION
default n
help
If enabled, the corresponding PHY init data type can be automatically switched
according to the country code. China's PHY init data bin is used by default.
Can be modified by country information in API esp_wifi_set_country().
The priority of switching the PHY init data type is:
1. Country configured by API esp_wifi_set_country()
and the parameter policy is WIFI_COUNTRY_POLICY_MANUAL.
2. Country notified by the connected AP.
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_EMBED
bool "Support embedded multiple phy init data bin to app bin"
depends on ESP_PHY_MULTIPLE_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 ESP_PHY_INIT_DATA_ERROR
bool "Terminate operation when PHY init data error"
depends on ESP_PHY_MULTIPLE_INIT_DATA_BIN
default n
help
If enabled, when an error occurs while the PHY init data is updated,
the program will terminate and restart.
If not enabled, the PHY init data will not be updated when an error occurs.
endif
config ESP_PHY_MAX_WIFI_TX_POWER
int "Max WiFi TX power (dBm)"
range 10 20
default 20
help
Set maximum transmit power for WiFi radio. Actual transmit power for high
data rates may be lower than this setting.
config ESP_PHY_MAX_TX_POWER
int
default ESP_PHY_MAX_WIFI_TX_POWER
config ESP_PHY_MAC_BB_PD
bool "Power down MAC and baseband of Wi-Fi and Bluetooth when PHY is disabled"
depends on SOC_PM_SUPPORT_MAC_BB_PD && FREERTOS_USE_TICKLESS_IDLE
default n
help
If enabled, when an error occurs while the PHY init data is updated,
the program will terminate and restart.
If not enabled, the PHY init data will not be updated when an error occurs.
If enabled, the MAC and baseband of Wi-Fi and Bluetooth will be powered
down when PHY is disabled. Enabling this setting reduces power consumption
by a small amount but increases RAM use by approximately 4 KB(Wi-Fi only),
2 KB(Bluetooth only) or 5.3 KB(Wi-Fi + Bluetooth).
config ESP_PHY_REDUCE_TX_POWER
bool "Reduce PHY TX power when brownout reset"
depends on ESP_BROWNOUT_DET
default n
help
When brownout reset occurs, reduce PHY TX power to keep the code running.
config ESP_PHY_ENABLE_USB
bool "Keep the USB PHY enabled when initializing WiFi"
depends on SOC_WIFI_PHY_NEEDS_USB_WORKAROUND
default y if IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3 \
|| ESP_CONSOLE_USB_SERIAL_JTAG || ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG
default n
help
On some ESP targets, the USB PHY can interfere with WiFi thus lowering WiFi performance.
As a result, on those affected ESP targets, the ESP PHY library's initialization will automatically
disable the USB PHY to get best WiFi performance.
This option controls whether or not the ESP PHY library will keep the USB PHY enabled on
initialization.
Note: This option can be disabled to increase WiFi performance. However, disabling this option will
also mean that the USB PHY cannot be used while WiFi is enabled.
config ESP_PHY_ENABLE_CERT_TEST
bool "Enable RF certification test functions"
default n
depends on IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3
help
If enabled, you can use RF certification test APIs.
choice ESP_PHY_CALIBRATION_MODE
prompt "Calibration mode"
default ESP_PHY_RF_CAL_PARTIAL
help
Select PHY calibration mode. During RF initialization, the partial calibration
method is used by default for RF calibration. Full calibration takes about 100ms
more than partial calibration. If boot duration is not critical, it is suggested
to use the full calibration method. No calibration method is only used when the
device wakes up from deep sleep.
config ESP_PHY_RF_CAL_PARTIAL
bool "Calibration partial"
config ESP_PHY_RF_CAL_NONE
bool "Calibration none"
config ESP_PHY_RF_CAL_FULL
bool "Calibration full"
endchoice #ESP_PHY_CALIBRATION_MODE
config ESP_PHY_CALIBRATION_MODE
int
default 0 if ESP_PHY_RF_CAL_PARTIAL
default 1 if ESP_PHY_RF_CAL_NONE
default 2 if ESP_PHY_RF_CAL_FULL
config ESP_PHY_IMPROVE_RX_11B
bool "Improve Wi-Fi receive 11b pkts"
default n
depends on SOC_PHY_IMPROVE_RX_11B
help
This is a workaround to improve Wi-Fi receive 11b pkts for some modules using AC-DC power supply with
high interference, enable this option will sacrifice Wi-Fi OFDM receive performance.
But to guarantee 11b receive performance serves as a bottom line in this case.
config ESP_PHY_PLL_TRACK_DEBUG
bool "Enable pll track logging"
default n
help
If enabled, there will be some logs while pll tracking
endif
config ESP_PHY_MAX_WIFI_TX_POWER
int "Max WiFi TX power (dBm)"
range 10 20
default 20
help
Set maximum transmit power for WiFi radio. Actual transmit power for high
data rates may be lower than this setting.
config ESP_PHY_MAX_TX_POWER
int
default ESP_PHY_MAX_WIFI_TX_POWER
config ESP_PHY_MAC_BB_PD
bool "Power down MAC and baseband of Wi-Fi and Bluetooth when PHY is disabled"
depends on SOC_PM_SUPPORT_MAC_BB_PD && FREERTOS_USE_TICKLESS_IDLE
default n
help
If enabled, the MAC and baseband of Wi-Fi and Bluetooth will be powered
down when PHY is disabled. Enabling this setting reduces power consumption
by a small amount but increases RAM use by approximately 4 KB(Wi-Fi only),
2 KB(Bluetooth only) or 5.3 KB(Wi-Fi + Bluetooth).
config ESP_PHY_REDUCE_TX_POWER
bool "Reduce PHY TX power when brownout reset"
depends on ESP_BROWNOUT_DET
default n
help
When brownout reset occurs, reduce PHY TX power to keep the code running.
config ESP_PHY_ENABLE_USB
bool "Keep the USB PHY enabled when initializing WiFi"
depends on SOC_WIFI_PHY_NEEDS_USB_WORKAROUND
default y if IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3 \
|| ESP_CONSOLE_USB_SERIAL_JTAG || ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG
default n
help
On some ESP targets, the USB PHY can interfere with WiFi thus lowering WiFi performance. As a result, on
those affected ESP targets, the ESP PHY library's initialization will automatically disable the USB PHY to
get best WiFi performance. This option controls whether or not the ESP PHY library will keep the USB PHY
enabled on initialization.
Note: This option can be disabled to increase WiFi performance. However, disabling this option will also
mean that the USB PHY cannot be used while WiFi is enabled.
config ESP_PHY_ENABLE_CERT_TEST
bool "Enable RF certification test functions"
default n
depends on IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3
help
If enabled, you can use RF certification test APIs.
choice ESP_PHY_CALIBRATION_MODE
prompt "Calibration mode"
default ESP_PHY_RF_CAL_PARTIAL
help
Select PHY calibration mode. During RF initialization, the partial calibration
method is used by default for RF calibration. Full calibration takes about 100ms
more than partial calibration. If boot duration is not critical, it is suggested
to use the full calibration method. No calibration method is only used when the
device wakes up from deep sleep.
config ESP_PHY_RF_CAL_PARTIAL
bool "Calibration partial"
config ESP_PHY_RF_CAL_NONE
bool "Calibration none"
config ESP_PHY_RF_CAL_FULL
bool "Calibration full"
endchoice #ESP_PHY_CALIBRATION_MODE
config ESP_PHY_CALIBRATION_MODE
int
default 0 if ESP_PHY_RF_CAL_PARTIAL
default 1 if ESP_PHY_RF_CAL_NONE
default 2 if ESP_PHY_RF_CAL_FULL
config ESP_PHY_IMPROVE_RX_11B
bool "Improve Wi-Fi receive 11b pkts"
default n
depends on SOC_PHY_IMPROVE_RX_11B
help
This is a workaround to improve Wi-Fi receive 11b pkts for some modules using AC-DC power supply with
high interference, enable this option will sacrifice Wi-Fi OFDM receive performance.
But to guarantee 11b receive performance serves as a bottom line in this case.
config ESP_PHY_PLL_TRACK_DEBUG
bool "Enable pll track logging"
default n
help
If enabled, there will be some logs while pll tracking
endmenu # PHY

Wyświetl plik

@ -18,8 +18,10 @@
#include "esp_wpa.h"
#include "esp_netif.h"
#include "private/esp_coexist_internal.h"
#ifdef CONFIG_ESP_PHY_ENABLED
#include "esp_phy_init.h"
#include "esp_private/phy.h"
#endif
#if __has_include("esp_psram.h")
#include "esp_psram.h"
#endif
@ -183,7 +185,9 @@ static esp_err_t wifi_deinit_internal(void)
s_wifi_modem_sleep_lock = NULL;
}
#endif
#ifdef CONFIG_ESP_PHY_ENABLED
esp_wifi_power_domain_off();
#endif
#if CONFIG_ESP_WIFI_SLP_BEACON_LOST_OPT
wifi_beacon_monitor_config_t monitor_config = WIFI_BEACON_MONITOR_CONFIG_DEFAULT(false);
@ -217,8 +221,9 @@ static esp_err_t wifi_deinit_internal(void)
esp_wifi_internal_modem_state_configure(false);
esp_pm_unregister_skip_light_sleep_callback(sleep_modem_wifi_modem_state_skip_light_sleep);
#endif
#ifdef CONFIG_ESP_PHY_ENABLED
esp_phy_modem_deinit();
#endif
s_wifi_inited = false;
return err;
@ -379,7 +384,9 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config)
coex_init();
#endif
esp_wifi_set_log_level();
#ifdef CONFIG_ESP_PHY_ENABLED
esp_wifi_power_domain_on();
#endif
#ifdef CONFIG_ESP_WIFI_FTM_ENABLE
esp_chip_info_t info = {0};
esp_chip_info(&info);
@ -393,7 +400,9 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config)
esp_mac_bb_pd_mem_init();
esp_wifi_mac_pd_mem_init();
#endif
#ifdef CONFIG_ESP_PHY_ENABLED
esp_phy_modem_init();
#endif
#if CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
if (sleep_modem_wifi_modem_state_enabled()) {
esp_pm_register_skip_light_sleep_callback(sleep_modem_wifi_modem_state_skip_light_sleep);

Wyświetl plik

@ -51,6 +51,10 @@ config SOC_PCNT_SUPPORTED
bool
default y
config SOC_PHY_SUPPORTED
bool
default y
config SOC_WIFI_SUPPORTED
bool
default y

Wyświetl plik

@ -70,6 +70,7 @@
#define SOC_SDMMC_HOST_SUPPORTED 1
#define SOC_BT_SUPPORTED 1
#define SOC_PCNT_SUPPORTED 1
#define SOC_PHY_SUPPORTED 1
#define SOC_WIFI_SUPPORTED 1
#define SOC_SDIO_SLAVE_SUPPORTED 1
#define SOC_TWAI_SUPPORTED 1

Wyświetl plik

@ -27,6 +27,10 @@ config SOC_GPTIMER_SUPPORTED
bool
default y
config SOC_PHY_SUPPORTED
bool
default y
config SOC_BT_SUPPORTED
bool
default y

Wyświetl plik

@ -23,6 +23,7 @@
#define SOC_GDMA_SUPPORTED 1
#define SOC_AHB_GDMA_SUPPORTED 1
#define SOC_GPTIMER_SUPPORTED 1
#define SOC_PHY_SUPPORTED 1
#define SOC_BT_SUPPORTED 1
#define SOC_WIFI_SUPPORTED 1
#define SOC_ASYNC_MEMCPY_SUPPORTED 1

Wyświetl plik

@ -51,6 +51,10 @@ config SOC_XT_WDT_SUPPORTED
bool
default y
config SOC_PHY_SUPPORTED
bool
default y
config SOC_WIFI_SUPPORTED
bool
default y

Wyświetl plik

@ -29,6 +29,7 @@
#define SOC_USB_SERIAL_JTAG_SUPPORTED 1
#define SOC_TEMP_SENSOR_SUPPORTED 1
#define SOC_XT_WDT_SUPPORTED 1
#define SOC_PHY_SUPPORTED 1
#define SOC_WIFI_SUPPORTED 1
#define SOC_SUPPORTS_SECURE_DL_MODE 1
#define SOC_EFUSE_KEY_PURPOSE_FIELD 1

Wyświetl plik

@ -67,6 +67,10 @@ config SOC_TEMP_SENSOR_SUPPORTED
bool
default y
config SOC_PHY_SUPPORTED
bool
default y
config SOC_WIFI_SUPPORTED
bool
default y

Wyświetl plik

@ -33,6 +33,7 @@
#define SOC_ASYNC_MEMCPY_SUPPORTED 1
#define SOC_USB_SERIAL_JTAG_SUPPORTED 1
#define SOC_TEMP_SENSOR_SUPPORTED 1
#define SOC_PHY_SUPPORTED 1
#define SOC_WIFI_SUPPORTED 1
#define SOC_SUPPORTS_SECURE_DL_MODE 1
#define SOC_ULP_SUPPORTED 1

Wyświetl plik

@ -7,6 +7,10 @@ config SOC_UART_SUPPORTED
bool
default y
config SOC_PHY_SUPPORTED
bool
default y
config SOC_SUPPORTS_SECURE_DL_MODE
bool
default y

Wyświetl plik

@ -28,6 +28,7 @@
// #define SOC_ASYNC_MEMCPY_SUPPORTED 1 //TODO: [ESP32C61] IDF-9315
// #define SOC_USB_SERIAL_JTAG_SUPPORTED 1 //TODO: [ESP32C61] IDF-9319
// #define SOC_TEMP_SENSOR_SUPPORTED 1 //TODO: [ESP32C61] IDF-9322
#define SOC_PHY_SUPPORTED 1
// #define SOC_WIFI_SUPPORTED 1
#define SOC_SUPPORTS_SECURE_DL_MODE 1
// #define SOC_ULP_SUPPORTED 1

Wyświetl plik

@ -43,6 +43,10 @@ config SOC_TWAI_SUPPORTED
bool
default y
config SOC_PHY_SUPPORTED
bool
default y
config SOC_BT_SUPPORTED
bool
default y

Wyświetl plik

@ -27,6 +27,7 @@
#define SOC_PCNT_SUPPORTED 1
#define SOC_MCPWM_SUPPORTED 1
#define SOC_TWAI_SUPPORTED 1
#define SOC_PHY_SUPPORTED 1
#define SOC_BT_SUPPORTED 1
#define SOC_GPTIMER_SUPPORTED 1
#define SOC_IEEE802154_SUPPORTED 1

Wyświetl plik

@ -51,6 +51,10 @@ config SOC_PCNT_SUPPORTED
bool
default y
config SOC_PHY_SUPPORTED
bool
default y
config SOC_WIFI_SUPPORTED
bool
default y

Wyświetl plik

@ -49,6 +49,7 @@
#define SOC_RISCV_COPROC_SUPPORTED 1
#define SOC_USB_OTG_SUPPORTED 1
#define SOC_PCNT_SUPPORTED 1
#define SOC_PHY_SUPPORTED 1
#define SOC_WIFI_SUPPORTED 1
#define SOC_ULP_SUPPORTED 1
#define SOC_CCOMP_TIMER_SUPPORTED 1

Wyświetl plik

@ -35,6 +35,10 @@ config SOC_PCNT_SUPPORTED
bool
default y
config SOC_PHY_SUPPORTED
bool
default y
config SOC_WIFI_SUPPORTED
bool
default y

Wyświetl plik

@ -25,6 +25,7 @@
#define SOC_ADC_SUPPORTED 1
#define SOC_UART_SUPPORTED 1
#define SOC_PCNT_SUPPORTED 1
#define SOC_PHY_SUPPORTED 1
#define SOC_WIFI_SUPPORTED 1
#define SOC_TWAI_SUPPORTED 1
#define SOC_GDMA_SUPPORTED 1