From 868f3747eaa55254a54d15b775cb8100d0499b99 Mon Sep 17 00:00:00 2001 From: Philip Gladstone Date: Thu, 6 Oct 2022 22:49:13 -0400 Subject: [PATCH] Removed some unused code. Also made chipid do something on all platforms --- components/modules/node.c | 14 ++++++++------ components/platform/platform.c | 7 +------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/components/modules/node.c b/components/modules/node.c index d2ceebb2..f87dac06 100644 --- a/components/modules/node.c +++ b/components/modules/node.c @@ -145,24 +145,28 @@ 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 ) { +#ifdef EFUSE_BLK0_DATA1_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_RDATA1_REG); - uint64_t word17 = REG_READ(EFUSE_BLK0_RDATA2_REG); + uint64_t word16 = REG_READ(EFUSE_BLK0_DATA1_REG); + uint64_t word17 = REG_READ(EFUSE_BLK0_DATA2_REG); const uint64_t MAX_UINT24 = 0xffffff; uint64_t cid = ((word17 & MAX_UINT24) << 24) | ((word16 >> 8) & MAX_UINT24); +#else + 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]; +#endif char chipid[17] = { 0 }; sprintf(chipid, "0x%llx", cid); lua_pushstring(L, chipid); return 1; } -#endif // Lua: node.heap() static int node_heap( lua_State* L ) @@ -850,9 +854,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) diff --git a/components/platform/platform.c b/components/platform/platform.c index 30a9d6e4..c708e0d5 100644 --- a/components/platform/platform.c +++ b/components/platform/platform.c @@ -189,11 +189,6 @@ static void task_usbcdc(void *pvParameters) { int len = usb_serial_jtag_read_bytes(post->data, 64, portMAX_DELAY); if (len > 0) { - for (int i = 0; i < len; i++) { - if (post->data[i] == '\r') { - post->data[i] = '\n'; - } - } post->size = len; xSemaphoreTake(usbcdc_sem, portMAX_DELAY); if (!task_post_medium(usbcdc_event_task_id, (task_param_t)post)) @@ -419,7 +414,7 @@ int platform_uart_start( unsigned id ) /* Disable buffering on stdin */ setvbuf(stdin, NULL, _IONBF, 0); - /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ + /* Minicom, screen, idf_monitor, esplorer send CR when ENTER key is pressed */ esp_vfs_dev_usb_serial_jtag_set_rx_line_endings(ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ esp_vfs_dev_usb_serial_jtag_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);