Unverified Commit 7c9b837c authored by Steven Müllener's avatar Steven Müllener Committed by GitHub

Fix Reading MAC from efuse for ESP32 Arduino 2.x.x (#6458) (#6459)

Also support ESP_IDF_VERSION_MAJOR > 3
Fixes #6458
Co-authored-by: default avatarRodrigo Garcia <rodrigo.garcia@espressif.com>
Co-authored-by: default avatarMe No Dev <me-no-dev@users.noreply.github.com>
parent 5c5a112f
......@@ -226,12 +226,19 @@ ETHClass::ETHClass()
ETHClass::~ETHClass()
{}
bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_type_t type, eth_clock_mode_t clock_mode)
bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_type_t type, eth_clock_mode_t clock_mode, bool use_mac_from_efuse)
{
#if ESP_IDF_VERSION_MAJOR > 3
eth_clock_mode = clock_mode;
tcpipInit();
if (use_mac_from_efuse)
{
uint8_t p[6] = { 0x00,0x00,0x00,0x00,0x00,0x00 };
esp_efuse_mac_get_custom(p);
esp_base_mac_addr_set(p);
}
tcpip_adapter_set_default_eth_handlers();
esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH();
......@@ -363,6 +370,14 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
}
tcpipInit();
if (use_mac_from_efuse)
{
uint8_t p[6] = { 0x00,0x00,0x00,0x00,0x00,0x00 };
esp_efuse_mac_get_custom(p);
esp_base_mac_addr_set(p);
}
err = esp_eth_init(&eth_config);
if(!err){
initialized = true;
......
......@@ -75,7 +75,7 @@ class ETHClass {
ETHClass();
~ETHClass();
bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE);
bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE, bool use_mac_from_efuse=false);
bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment