fix(esp_eth): fixed ESP32P4 EMAC REF RMII CLK output mode

fixed units returned and used by periph_rtc_mpll_freq_set function
This commit is contained in:
Ondrej Kosta
2025-02-24 09:14:50 +01:00
committed by Ondrej
parent 7c5b34f568
commit f3a3988649
11 changed files with 123 additions and 33 deletions

View File

@@ -53,6 +53,20 @@ menu "esp_eth TEST_APPS Configuration"
default 18
endif
config TARGET_RMII_CLK_OUT
bool "REF RMII CLK output"
default n
if TARGET_RMII_CLK_OUT
config TARGET_RMII_CLK_OUT_GPIO
int "REF RMII CLK Output GPIO"
default 23
config TARGET_RMII_CLK_IN_GPIO
int "REF RMII CLK Input GPIO"
default 32
endif # TARGET_RMII_CLK_OUT
endif # TARGET_USE_INTERNAL_ETHERNET
if TARGET_USE_SPI_ETHERNET

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@@ -39,6 +39,12 @@ esp_eth_mac_t *mac_init(void *vendor_emac_config, eth_mac_config_t *mac_config)
esp32_emac_config.smi_gpio.mdc_num = CONFIG_TARGET_IO_MDC;
esp32_emac_config.smi_gpio.mdio_num = CONFIG_TARGET_IO_MDIO;
#endif // CONFIG_TARGET_USE_DEFAULT_EMAC_CONFIG
#if CONFIG_TARGET_RMII_CLK_OUT
esp32_emac_config.clock_config.rmii.clock_mode = EMAC_CLK_OUT;
esp32_emac_config.clock_config.rmii.clock_gpio = CONFIG_TARGET_RMII_CLK_OUT_GPIO;
esp32_emac_config.clock_config_out_in.rmii.clock_mode = EMAC_CLK_EXT_IN;
esp32_emac_config.clock_config_out_in.rmii.clock_gpio = CONFIG_TARGET_RMII_CLK_IN_GPIO;
#endif // CONFIG_TARGET_TEST_RMII_CLK_OUT
if (vendor_emac_config == NULL) {
vendor_emac_config = &esp32_emac_config;
}

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@@ -564,3 +564,23 @@ TEST_CASE("internal emac erroneous frames", "[esp_emac]")
vEventGroupDelete(eth_event_group);
vSemaphoreDelete(mutex);
}
TEST_CASE("internal emac ref rmii clk out", "[esp_emac_clk_out]")
{
esp_eth_mac_t *mac = mac_init(NULL, NULL);
TEST_ASSERT_NOT_NULL(mac);
esp_eth_phy_t *phy = phy_init(NULL);
TEST_ASSERT_NOT_NULL(phy);
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy);
esp_eth_handle_t eth_handle = NULL;
// install Ethernet driver
// This is a simple test and it only verifies the REF RMII output CLK is configured and started, and the internal
// EMAC is clocked by it. It does not verify the whole system functionality. As such, it can be executed on the same
// test boards which are configured to input REF RMII CLK by default with only minor HW modification.
TEST_ESP_OK(esp_eth_driver_install(&eth_config, &eth_handle));
extra_eth_config(eth_handle);
TEST_ESP_OK(esp_eth_driver_uninstall(eth_handle));
TEST_ESP_OK(phy->del(phy));
TEST_ESP_OK(mac->del(mac));
extra_cleanup();
}

View File

@@ -315,6 +315,19 @@ def test_esp32p4_emac(dut: IdfDut) -> None:
ethernet_heap_alloc_test(dut)
@pytest.mark.eth_ip101
@pytest.mark.parametrize(
'config',
[
'rmii_clko_esp32p4',
],
indirect=True,
)
@idf_parametrize('target', ['esp32p4'], indirect=['target'])
def test_esp32p4_emac_clko(dut: IdfDut) -> None:
dut.run_all_single_board_cases(group='esp_emac_clk_out')
# ----------- LAN8720 -----------
@pytest.mark.eth_lan8720
@pytest.mark.parametrize(

View File

@@ -0,0 +1,17 @@
CONFIG_IDF_TARGET="esp32p4"
CONFIG_UNITY_ENABLE_FIXTURE=y
CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y
CONFIG_ETH_USE_ESP32_EMAC=y
CONFIG_ESP_TASK_WDT_EN=n
CONFIG_TARGET_USE_INTERNAL_ETHERNET=y
CONFIG_TARGET_ETH_PHY_DEVICE_IP101=y
CONFIG_TARGET_USE_DEFAULT_EMAC_CONFIG=y
CONFIG_TARGET_RMII_CLK_OUT=y
# Test board needs to be modified!
# Connect GPIO23 to GPIO32 via wire.
CONFIG_TARGET_RMII_CLK_OUT_GPIO=23
CONFIG_TARGET_RMII_CLK_IN_GPIO=32