Skip to content

Commit

Permalink
Fix Reading MAC from efuse for ESP32 Arduino 2.x.x (espressif#6458) (e…
Browse files Browse the repository at this point in the history
…spressif#6459)

Also support ESP_IDF_VERSION_MAJOR > 3
Fixes espressif#6458

Co-authored-by: Rodrigo Garcia <[email protected]>
Co-authored-by: Me No Dev <[email protected]>
  • Loading branch information
3 people authored Mar 29, 2022
1 parent 5c5a112 commit 7c9b837
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion libraries/Ethernet/src/ETH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libraries/Ethernet/src/ETH.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 7c9b837

Please sign in to comment.