From 436dbee5d7acb1f53e8ebc4ed4346154eb089438 Mon Sep 17 00:00:00 2001 From: heianto <129732040+antohei@users.noreply.github.com> Date: Thu, 12 Mar 2026 22:27:50 -0300 Subject: [PATCH 1/2] fix(esp_eth): Fixed designated initializer order in ETH_ESP32_EMAC_DEFAULT_CONFIG Merges https://github.com/espressif/esp-idf/pull/18275 Signed-off-by: Guilherme Ferreira --- components/esp_eth/include/esp_eth_mac_esp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_eth/include/esp_eth_mac_esp.h b/components/esp_eth/include/esp_eth_mac_esp.h index a756b01e93..da0357b0d0 100644 --- a/components/esp_eth/include/esp_eth_mac_esp.h +++ b/components/esp_eth/include/esp_eth_mac_esp.h @@ -279,7 +279,6 @@ typedef bool (*ts_target_exceed_cb_from_isr_t)(esp_eth_mediator_t *eth, void *us }, \ .dma_burst_len = ETH_DMA_BURST_LEN_32, \ .intr_priority = 0, \ - .mdc_freq_hz = 0, \ .emac_dataif_gpio = \ { \ .rmii = \ @@ -300,6 +299,7 @@ typedef bool (*ts_target_exceed_cb_from_isr_t)(esp_eth_mediator_t *eth, void *us .clock_gpio = (emac_rmii_clock_gpio_t) -1 \ } \ }, \ + .mdc_freq_hz = 0, \ } #endif // CONFIG_IDF_TARGET_ESP32P4 From 8b6ba4aa13f5da351b6f857fca0d2c8919f252a9 Mon Sep 17 00:00:00 2001 From: Guilherme Ferreira Date: Mon, 16 Mar 2026 19:09:38 -0300 Subject: [PATCH 2/2] ci(esp_eth): add C++ regression guard for ethernet macros --- .../esp_eth/test_apps/main/CMakeLists.txt | 1 + .../test_apps/main/esp_eth_test_emac_init.cpp | 66 +++++++++++++++++++ .../esp_eth/test_apps/main/idf_component.yml | 4 ++ 3 files changed, 71 insertions(+) create mode 100644 components/esp_eth/test_apps/main/esp_eth_test_emac_init.cpp create mode 100644 components/esp_eth/test_apps/main/idf_component.yml diff --git a/components/esp_eth/test_apps/main/CMakeLists.txt b/components/esp_eth/test_apps/main/CMakeLists.txt index ff51914b32..c116aa538e 100644 --- a/components/esp_eth/test_apps/main/CMakeLists.txt +++ b/components/esp_eth/test_apps/main/CMakeLists.txt @@ -3,6 +3,7 @@ idf_component_register(SRCS "esp_eth_test_apps.c" "esp_eth_test_esp_emac.c" "esp_eth_test_common.c" "esp_eth_test_main.c" + "esp_eth_test_emac_init.cpp" INCLUDE_DIRS "." PRIV_INCLUDE_DIRS "." PRIV_REQUIRES unity test_utils esp_eth esp_netif esp_http_client esp_driver_gpio diff --git a/components/esp_eth/test_apps/main/esp_eth_test_emac_init.cpp b/components/esp_eth/test_apps/main/esp_eth_test_emac_init.cpp new file mode 100644 index 0000000000..79d429873e --- /dev/null +++ b/components/esp_eth/test_apps/main/esp_eth_test_emac_init.cpp @@ -0,0 +1,66 @@ +/* + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ + +// Initialize the Ethernet stack compiling as C++ to catch possible C++ specific build issues. +#include "sdkconfig.h" +#include "esp_eth_mac.h" +#include "esp_eth_mac_esp.h" +#include "esp_eth_phy.h" +#include "esp_eth_driver.h" + +#if CONFIG_ETH_USE_ESP32_EMAC +static void cpp_eth_init_internal_emac(void) __attribute__((unused)); +static void cpp_eth_init_internal_emac(void) +{ + eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG(); + + eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG(); + eth_esp32_emac_config_t esp32_config = ETH_ESP32_EMAC_DEFAULT_CONFIG(); + + esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&esp32_config, &mac_config); + if (mac == nullptr) { + return; + } + esp_eth_phy_t *phy = esp_eth_phy_new_generic(&phy_config); + if (phy == nullptr) { + (void)mac->del(mac); + return; + } + esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy); + esp_eth_handle_t handle = nullptr; + if (esp_eth_driver_install(ð_config, &handle) != ESP_OK) { + (void)phy->del(phy); + (void)mac->del(mac); + return; + } + (void)esp_eth_driver_uninstall(handle); + (void)phy->del(phy); + (void)mac->del(mac); +} + +#endif // CONFIG_ETH_USE_ESP32_EMAC + +#if CONFIG_ETH_USE_SPI_ETHERNET +#include "ethernet_init.h" + +static void cpp_eth_spi_custom_driver_config(void) __attribute__((unused)); +static void cpp_eth_spi_custom_driver_config(void) +{ + volatile eth_spi_custom_driver_config_t cfg = ETH_DEFAULT_SPI; + (void)cfg; +} + +static void cpp_eth_init_spi(void) __attribute__((unused)); +static void cpp_eth_init_spi(void) +{ + esp_eth_handle_t *handles = nullptr; + uint8_t cnt = 0; + (void)ethernet_init_all(&handles, &cnt); + if (handles != nullptr && cnt > 0) { + (void)ethernet_deinit_all(handles); + } +} +#endif // CONFIG_ETH_USE_SPI_ETHERNET diff --git a/components/esp_eth/test_apps/main/idf_component.yml b/components/esp_eth/test_apps/main/idf_component.yml new file mode 100644 index 0000000000..b187568955 --- /dev/null +++ b/components/esp_eth/test_apps/main/idf_component.yml @@ -0,0 +1,4 @@ +## IDF Component Manager Manifest File +dependencies: + espressif/ethernet_init: + version: "^1.3.0"