Networking

[中文]

Ethernet

esp_eth_phy_802_3_reset_hw() API Changes

This change only applies if you maintain your own Ethernet PHY driver based on esp_eth/src/phy/esp_eth_phy_802_3.c common functions. The esp_eth_phy_802_3_reset_hw() API accepts only one parameter now and resets the Ethernet PHY with internal timing configuration which is defined during initialization. Previously, the API required a reset_assert_us parameter to specify the reset pin assertion time. This parameter has been removed.

Usage example:

esp_eth_phy_802_3_reset_hw(phy_802_3);

Removed RMII Clock Kconfig Options

Removed the following RMII clock Kconfig options from components/esp_eth. Clock configuration is now handled exclusively through EMAC config structures.

Removed Options: - ETH_PHY_INTERFACE_RMII, ETH_RMII_CLK_INPUT, ETH_RMII_CLK_OUTPUT - ETH_RMII_CLK_IN_GPIO, ETH_RMII_CLK_OUTPUT_GPIO0, ETH_RMII_CLK_OUT_GPIO

Migration:

// Before: Configuration via Kconfig
// CONFIG_ETH_RMII_CLK_INPUT=y

// After: Explicit configuration in code
eth_esp32_emac_config_t emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG();
emac_config.clock_config.rmii.clock_mode = EMAC_CLK_OUT;  // or EMAC_CLK_EXT_IN
emac_config.clock_config.rmii.clock_gpio = 0;  // GPIO0 for ESP32

Impact: Applications using ETH_ESP32_EMAC_DEFAULT_CONFIG() continue to work. Custom clock configurations must be set explicitly in the EMAC config structure or use the Ethernet Init component.

ESP-NETIF

Removal of deprecated esp_netif_next()

The deprecated iteration helper esp_netif_next() has been removed from ESP-NETIF. This API was inherently unsafe because it did not lock the interface list or the TCP/IP context during iteration.

Use one of the following alternatives:

Migration

Before:

esp_netif_t *it = NULL;
while ((it = esp_netif_next(it)) != NULL) {
    // use "it"
}

After (iterate unsafely in a controlled context):

esp_netif_t *it = NULL;
while ((it = esp_netif_next_unsafe(it)) != NULL) {
    // use "it"
}

Recommended (iterate within TCP/IP context):

static esp_err_t iterate_netifs(void *ctx)
{
    esp_netif_t *it = NULL;
    while ((it = esp_netif_next_unsafe(it)) != NULL) {
        // use "it"
    }
    return ESP_OK;
}

// Execute iteration safely in TCP/IP context
ESP_ERROR_CHECK(esp_netif_tcpip_exec(iterate_netifs, NULL));

Alternative (find with predicate):

static bool match_by_key(void *ctx, esp_netif_t *netif)
{
    const char *wanted = (const char *)ctx;
    const char *key = esp_netif_get_ifkey(netif);
    return key && strcmp(key, wanted) == 0;
}

esp_netif_t *target = esp_netif_find_if(match_by_key, (void *)"WIFI_STA_DEF");
if (target) {
    // use "target"
}

Was this page helpful?