ESP32 MAC address - is it unique?

chaitz
Posts: 14
Joined: Wed Apr 26, 2017 2:24 pm

ESP32 MAC address - is it unique?

Postby chaitz » Mon Sep 04, 2017 10:49 am

Hi,

I am looking at a method to uniquely identify every ESP32 device .Is the MAC address obtained using the 'esp_wifi_get_mac()' truly unique for every device?

tobewinner
Posts: 30
Joined: Thu Dec 10, 2015 5:27 am

Re: ESP32 MAC address - is it unique?

Postby tobewinner » Mon Sep 04, 2017 11:16 am

use esp_efuse_mac_get_default instead. this func return base MAC address which is factory-programmed by Espressif in BLK0 of EFUSE.
The original MAC address in efuse is unique, Hower it can be changed by user.

chaitz
Posts: 14
Joined: Wed Apr 26, 2017 2:24 pm

Re: ESP32 MAC address - is it unique?

Postby chaitz » Tue Sep 05, 2017 2:00 pm

Thanks. Doesn't esp_wifi_get_mac() get the address from EFUSE?

halfro
Posts: 18
Joined: Sat Jul 15, 2017 11:13 am

Re: ESP32 MAC address - is it unique?

Postby halfro » Tue Sep 05, 2017 9:59 pm

That is a 50-50 question as the specific MAC is computed in software except the Wifi station mode which is equal to the base MAC from the EFUSE. The EFUSE MAC is ideally unique. I did some digging and the ethernet MAC, wifi soft access point mode MAC and bluetooth MAC(Classic/BLE) are all derived from the base MAC address which is 6 bytes long.

I wrote this down so I will just copy paste from my notes:

Code: Select all

The following MAC addresses are derived from the BASE MAC in the EFUSE BLK0.
#ESP_MAC_WIFI_STA
#ESP_MAC_WIFI_SOFTAP
#ESP_MAC_BT
#ESP_MAC_ETH

For 2 universal MAC addresses, the BT and Wifi are both enabled. Ethernet is disabled. Here:
#ESP_MAC_WIFI_STA=ESP_MAC_WIFI_SOFTAP=BASE MAC.
#ESP_MAC_BT=BASE MAC+1

For 4 Universal MAC addresses, the BT, Wifi and ethernet are all enabled. Here:
#ESP_MAC_WIFI_STA=BASE MAC.
#ESP_MAC_WIFI_SOFTAP=BASE MAC+1
#ESP_MAC_BT=BASE MAC+2
#ESP_MAC_ETH=BASE MAC+3
You can refer more from the components/esp32/system_api.c file within esp idf. Look for the function esp_read_mac. The number of universal mac addresses can be set within menuconfig.

Also as an addition: The 4 MAC addresses above are computed in software at runtime. The first 24 bits of the address of any of the MACs above identify the OUI (organisationally unique identifier) which when I check on the OUI lookup tool from wireshark https://www.wireshark.org/tools/oui-lookup.html :

24:0A:C4

Which gives:

24:0A:C4 Espressif Espressif Inc.

So my geuss is every Espressif Base MAC's should be mutually spaced by 4 bits from the next for true uniqueness. only an espressif representative I believe can answer this but but since they can only assign (2^24 )/(1 billion device) MACs, my thinking is that each devices base MAC is spaced from the next by 1. They separated the MACs by usage. A devices BT MAC will always be spaced 4 bits from the next and the bluetooth usage niche is different from wifi/ethernet. Where it gets tricky is the ethernet.

In theory one device's Wifi MAC may collide with another device's ethernet MAC, but since not much of espressif's market may use the ethernet peripheral, there may be hardly any collisions in practice.

chaitz
Posts: 14
Joined: Wed Apr 26, 2017 2:24 pm

Re: ESP32 MAC address - is it unique?

Postby chaitz » Wed Sep 06, 2017 3:04 pm

Thanks for the detailed explanation.

dovoto
Posts: 27
Joined: Tue Apr 20, 2021 3:51 pm

Re: ESP32 MAC address - is it unique?

Postby dovoto » Tue Sep 14, 2021 11:16 pm

Here is a good explanation on how mac addresses are derived on the ESP32:

https://docs.espressif.com/projects/esp ... dress.html

And here is a good explanation for how many universal (unique) mac addresses are allocated to each ESP32

https://docs.espressif.com/projects/esp ... ystem.html

The answer is either 2 or 4 which is why the api has different ways to derive the BT mac depending on configuration. In the default case, 4 are allocated (but only one fused) so no chance of different interfaces colliding. I am not sure off hand to differentiate which mac configuration was burned in to the chip.

As of the middle of August 2021, ESP32 has 92 blocks of mac addresses (enough for about 400 million ESP32s with 4 per ESP32).

So yes, all 4 interface macs will be unique (though only the WiFi station mac is stored in the EFUSE)

markuskooche
Posts: 1
Joined: Tue Jan 24, 2023 8:32 am

Re: ESP32 MAC address - is it unique?

Postby markuskooche » Tue Jan 24, 2023 8:38 am

How do you know that there are 92 blocks available to the ESP32?
Is there a source for this?

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 126 guests