|
1 | 1 | /* |
2 | | - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD |
| 2 | + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: Unlicense OR CC0-1.0 |
5 | 5 | */ |
|
13 | 13 | #include "driver/spi_master.h" |
14 | 14 | #endif // CONFIG_ETH_USE_SPI_ETHERNET |
15 | 15 | #include "esp_log.h" |
| 16 | +#include "esp_mac.h" |
16 | 17 | #include "driver/gpio.h" |
17 | 18 | #include "freertos/FreeRTOS.h" |
18 | 19 | #include "freertos/task.h" |
@@ -153,11 +154,12 @@ static esp_netif_t *eth_start(void) |
153 | 154 | ESP_ERROR_CHECK(esp_eth_driver_install(&config, &s_eth_handle)); |
154 | 155 | #if !CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET |
155 | 156 | /* 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` |
157 | 159 | */ |
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)); |
161 | 163 | #endif |
162 | 164 | // combine driver with netif |
163 | 165 | s_eth_glue = esp_eth_new_netif_glue(s_eth_handle); |
|
0 commit comments