Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node.chipid() returns "0x_unknown" for ESP32xx chips #3651

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions components/modules/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ static int node_bootreason( lua_State *L)
return 2;
}

#if defined(CONFIG_IDF_TARGET_ESP32)
// Lua: node.chipid()
static int node_chipid( lua_State *L )
{
#if defined(CONFIG_IDF_TARGET_ESP32)
// 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
Expand All @@ -169,10 +169,12 @@ static int node_chipid( lua_State *L )
uint64_t cid = ((word17 & MAX_UINT24) << 24) | ((word16 >> 8) & MAX_UINT24);
char chipid[17] = { 0 };
sprintf(chipid, "0x%llx", cid);
#else
const char *chipid = "0x_unknown";
#endif
lua_pushstring(L, chipid);
return 1;
}
#endif

// Lua: node.heap()
static int node_heap( lua_State* L )
Expand Down Expand Up @@ -865,9 +867,7 @@ LROT_END(node_wakeup, NULL, 0)

LROT_BEGIN(node, NULL, 0)
LROT_FUNCENTRY( bootreason, node_bootreason )
#if defined(CONFIG_IDF_TARGET_ESP32)
LROT_FUNCENTRY( chipid, node_chipid )
#endif
LROT_FUNCENTRY( compile, node_compile )
LROT_FUNCENTRY( dsleep, node_dsleep )
#if defined(CONFIG_LUA_VERSION_51)
Expand Down