From 064f1ef89c2254c0c5acb75feb11063ec191a1d3 Mon Sep 17 00:00:00 2001 From: Philip Gladstone Date: Fri, 7 Oct 2022 18:56:42 -0400 Subject: [PATCH] FIx the chipid typo --- components/modules/node.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/modules/node.c b/components/modules/node.c index f87dac06..9f22738c 100644 --- a/components/modules/node.c +++ b/components/modules/node.c @@ -148,16 +148,18 @@ static int node_bootreason( lua_State *L) // Lua: node.chipid() static int node_chipid( lua_State *L ) { -#ifdef EFUSE_BLK0_DATA1_REG +#ifdef EFUSE_BLK0_RDATA1_REG // This matches the way esptool.py generates a chipid for the ESP32 as of // esptool commit e9e9179f6fc3f2ecfc568987d3224b5e53a05f06 // Oddly, this drops the lowest byte what's effectively the MAC address, so // it would seem plausible to encounter up to 256 chips with the same chipid - uint64_t word16 = REG_READ(EFUSE_BLK0_DATA1_REG); - uint64_t word17 = REG_READ(EFUSE_BLK0_DATA2_REG); + uint64_t word16 = REG_READ(EFUSE_BLK0_RDATA1_REG); + uint64_t word17 = REG_READ(EFUSE_BLK0_RDATA2_REG); const uint64_t MAX_UINT24 = 0xffffff; uint64_t cid = ((word17 & MAX_UINT24) << 24) | ((word16 >> 8) & MAX_UINT24); #else + // This makes the chipid the same as the mac on parts which don't have the + // EFUSE layout defined. uint8_t mac[8]; esp_read_mac(mac, ESP_MAC_WIFI_STA); uint64_t cid = ((uint64_t) mac[0] << 40) | ((uint64_t) mac[1] << 32) | (mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5];