From 136de02f43cada91816582ecb33e1fc0dbe08442 Mon Sep 17 00:00:00 2001 From: Daniel Campora Date: Wed, 8 Feb 2017 15:02:04 +0100 Subject: [PATCH] Fix read_mac function for the ESP32 The current read_mac function in esptool is not returning the same MAC address as: ```esp_wifi_get_mac(WIFI_IF_STA, ...)```. It's only returning the last 4 bytes of the MAC address combined with the CRC at the end. --- esptool.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esptool.py b/esptool.py index a47c3b74a..165b9bd9a 100755 --- a/esptool.py +++ b/esptool.py @@ -900,11 +900,11 @@ def chip_id(self): def read_mac(self): """ Read MAC from EFUSE region """ - words = [self.read_efuse(1), self.read_efuse(2)] + words = [self.read_efuse(2), self.read_efuse(1)] bitstring = struct.pack(">II", *words) - bitstring = bitstring[:6] # trim 2 byte CRC + bitstring = bitstring[2:8] # trim the 2 byte CRC try: - return tuple(ord(b) for b in bitstring) # trim 2 byte CRC + return tuple(ord(b) for b in bitstring) except TypeError: # Python 3, bitstring elements are already bytes return tuple(bitstring)