Skip to content

Commit 7f1b752

Browse files
committed
Merge branch 'backport/support_eth_mac_using_esp_read_mac_v53' into 'release/v5.3'
feat(eth) configure eth mac using esp_read_mac(Backport v5.3) See merge request espressif/esp-idf!31093
2 parents ab8e197 + 34a7bc5 commit 7f1b752

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

examples/common_components/protocol_examples_common/eth_connect.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Unlicense OR CC0-1.0
55
*/
@@ -13,6 +13,7 @@
1313
#include "driver/spi_master.h"
1414
#endif // CONFIG_ETH_USE_SPI_ETHERNET
1515
#include "esp_log.h"
16+
#include "esp_mac.h"
1617
#include "driver/gpio.h"
1718
#include "freertos/FreeRTOS.h"
1819
#include "freertos/task.h"
@@ -153,11 +154,12 @@ static esp_netif_t *eth_start(void)
153154
ESP_ERROR_CHECK(esp_eth_driver_install(&config, &s_eth_handle));
154155
#if !CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET
155156
/* The SPI Ethernet module might doesn't have a burned factory MAC address, we cat to set it manually.
156-
02:00:00 is a Locally Administered OUI range so should not be used except when testing on a LAN under your control.
157+
We set the ESP_MAC_ETH mac address as the default, if you want to use ESP_MAC_EFUSE_CUSTOM mac address, please enable the
158+
configuration: `ESP_MAC_USE_CUSTOM_MAC_AS_BASE_MAC`
157159
*/
158-
ESP_ERROR_CHECK(esp_eth_ioctl(s_eth_handle, ETH_CMD_S_MAC_ADDR, (uint8_t[]) {
159-
0x02, 0x00, 0x00, 0x12, 0x34, 0x56
160-
}));
160+
uint8_t eth_mac[6] = {0};
161+
ESP_ERROR_CHECK(esp_read_mac(eth_mac, ESP_MAC_ETH));
162+
ESP_ERROR_CHECK(esp_eth_ioctl(s_eth_handle, ETH_CMD_S_MAC_ADDR, eth_mac));
161163
#endif
162164
// combine driver with netif
163165
s_eth_glue = esp_eth_new_netif_glue(s_eth_handle);

0 commit comments

Comments
 (0)