ESP32 MAC address - is it unique?

chaitz
Posts: 7
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: 27
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: 7
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: 7
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.

Who is online

Users browsing this forum: No registered users and 18 guests