Skip to content

MAC from efuse broken in ESP32 Arduino 2.x.x #6458

Closed
@smuellener

Description

@smuellener

Board

ESP32 Dev Module

Device Description

ESP32-WROOM-32

Hardware Configuration

Version

latest master

IDE Name

Arduino IDE

Operating System

Windows 11

Flash frequency

40Mhz

PSRAM enabled

yes

Upload speed

115200

Description

With ESP32 Ardunio < 2.0.0 it was possible to use ESP IDF functionality to use the custom MAC address from the efuse (see https://docs.espressif.com/projects/esp-idf/en/v4.4/esp32/api-reference/system/system.html?highlight=esp_base_mac_addr_set#custom-base-mac).

With ESP32 Arduino 2.x.x this functionality is broken because in ETH.begin() the interface is both reset and set up again. It will still look like the MAC address is custom but the low-level MAC address of the network interface is not custom but the internal one. This can be verified e.g. by using ARP scan (e.g. in Windows cmd: "arp -a").

The functionality could be reintroduced and the problem fixed by providing an additional argument to ETH.begin() where the user can select to read in the MAC Address from efuse. The custom MAC address can then be read in between the reset and setting up the interface.

Sketch

//The following code does NOT work anymore after updating to ESP32 Arduino 2.x.x

#include <ETH.h>
#include <WiFi.h>

void setup()
{
    Serial.begin(115200);

    uint8_t p[6] = { 0x00,0x00,0x00,0x00,0x00,0x00 };
    esp_efuse_mac_get_custom(p);
    esp_base_mac_addr_set(p);

    ETH.begin(); // in ESP32 Arduino 2.x.x this is undoing the step above
}

void loop()
{
}

Debug Message

-

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions