Merge branch 'contrib/github_pr_18275' into 'master'

fix(esp_eth): Fixed designated initializer order in ETH_ESP32_EMAC_DEFAULT_CONFIG (GitHub PR)

Closes IDFGH-17286

See merge request espressif/esp-idf!46583
This commit is contained in:
Guilherme Ferreira
2026-04-01 00:29:20 +08:00
3 changed files with 68 additions and 1 deletions
+1 -1
View File
@@ -225,7 +225,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 = \
@@ -246,6 +245,7 @@ typedef bool (*ts_target_exceed_cb_from_isr_t)(esp_eth_mediator_t *eth, void *us
.clock_gpio = -1 \
} \
}, \
.mdc_freq_hz = 0, \
}
#endif // CONFIG_IDF_TARGET_ESP32P4
@@ -4,6 +4,7 @@ idf_component_register(SRCS "esp_eth_test_main.c"
"esp_eth_test_utils.c"
"esp_eth_test_esp_emac.c"
"esp_eth_test_emac_sleep_retention.c"
"esp_eth_test_emac_init.cpp"
INCLUDE_DIRS "."
PRIV_INCLUDE_DIRS "."
PRIV_REQUIRES unity esp_eth esp_netif esp_http_client esp_driver_gpio esp_driver_uart
@@ -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(&eth_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