From 09cc100e8add98a0e5fa3cd2cb75bcb1b58d2f00 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 27 Oct 2025 11:41:28 +0100 Subject: [PATCH] Add ESP8266 GPIOViewer memory map if enabled with `#define GV_USE_ESPINFO` --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + tasmota/my_user_config.h | 1 + tasmota/tasmota_support/settings.ino | 3 + .../xdrv_121_gpioviewer.ino | 56 ++++++++++++++++++- 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8f71c19e..b4885374c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file. - HostedMCU file update using command `HostedLoad |` - Berry `gc_heap` and `gc_time` to `tasmota.memory()` (#24054) - Scripter array transfer via UFS (#24060) +- ESP8266 GPIOViewer memory map if enabled with `#define GV_USE_ESPINFO` ### Breaking Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 55e604ac4..ecd9649f6 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -114,6 +114,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ## Changelog v15.1.0.1 ### Added +- ESP8266 GPIOViewer memory map if enabled with `#define GV_USE_ESPINFO` - HostedMCU file update using command `HostedLoad |` - Scripter array transfer via UFS [#24060](https://github.com/arendst/Tasmota/issues/24060) - TLS enabled ECDSA by default for ESP8266 [#24009](https://github.com/arendst/Tasmota/issues/24009) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index a2847e178..8867d54fe 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -517,6 +517,7 @@ // #define USE_WEBGETCONFIG // Enable restoring config from external webserver (+0k6) // #define USE_WEBRUN // Enable executing a tasmota command file from external web server (+0.4 code) // #define USE_GPIO_VIEWER // Enable GPIO Viewer to see realtime GPIO states (+6k code) + #define GV_USE_ESPINFO // Add ESP8266 info (+2k1 code) // #define GV_SAMPLING_INTERVAL 100 // [GvSampling] milliseconds - Use Tasmota Scheduler (100) or Ticker (20..99,101..1000) #define USE_EMULATION_HUE // Enable Hue Bridge emulation for Alexa (+14k code, +2k mem common) #define USE_EMULATION_WEMO // Enable Belkin WeMo emulation for Alexa (+6k code, +2k mem common) diff --git a/tasmota/tasmota_support/settings.ino b/tasmota/tasmota_support/settings.ino index 268e546a0..46b239365 100644 --- a/tasmota/tasmota_support/settings.ino +++ b/tasmota/tasmota_support/settings.ino @@ -202,6 +202,9 @@ extern "C" uint32_t _FS_start; // 1M = 0x402fb000, 2M = 0x40300000, 4M = 0x const uint32_t FLASH_FS_START = (((uint32_t)&_FS_start - 0x40200000) / SPI_FLASH_SEC_SIZE); uint32_t SETTINGS_LOCATION = FLASH_FS_START -1; // 0xFA, 0x0FF or 0x0FF +extern "C" uint32_t _FS_end; +const uint32_t FLASH_FS_SIZE = (uint32_t)&_FS_end - (uint32_t)&_FS_start; + // From libraries/EEPROM/EEPROM.cpp EEPROMClass extern "C" uint32_t _EEPROM_start; // 1M = 0x402FB000, 2M = 0x403FB000, 4M = 0x405FB000 const uint32_t EEPROM_LOCATION = ((uint32_t)&_EEPROM_start - 0x40200000) / SPI_FLASH_SEC_SIZE; // 0xFB, 0x1FB or 0x3FB diff --git a/tasmota/tasmota_xdrv_driver/xdrv_121_gpioviewer.ino b/tasmota/tasmota_xdrv_driver/xdrv_121_gpioviewer.ino index 6656ded9f..b7ae9f615 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_121_gpioviewer.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_121_gpioviewer.ino @@ -81,7 +81,7 @@ #define XDRV_121 121 -#define GV_USE_ESPINFO // Provide ESP info +//#define GV_USE_ESPINFO // Add ESP8266 info //#define GV_DEBUG #ifndef GV_PORT @@ -439,6 +439,57 @@ void GVHandleEspInfo(void) { void GVHandlePartition(void) { String jsonResponse = "["; // Start of JSON array +#ifdef ESP8266 +#ifdef GV_USE_ESPINFO + int fl_tasmota = 0x0; + int fl_settings = (SETTINGS_LOCATION - CFG_ROTATES) * SPI_FLASH_SEC_SIZE; + int fl_filesystem = (FLASH_FS_SIZE) ? FLASH_FS_START * SPI_FLASH_SEC_SIZE : -1; + int fl_eeprom = EEPROM_LOCATION * SPI_FLASH_SEC_SIZE; // eeprom, rfcal, wifi + int fl_end = ESP.getFlashChipSize(); + int fl_ota = ((fl_filesystem > 0x100000) || (fl_eeprom > 0x100000)) ? 0x100000 : -1; + + int fl_settings_pend = fl_eeprom; + if (fl_ota > 0) { + fl_settings_pend = fl_ota; + } + else if (fl_filesystem > 0) { + fl_settings_pend = fl_filesystem; + } + int fl_ota_end = fl_eeprom; + if (fl_filesystem > 0) { + fl_ota_end = fl_filesystem; + } + + struct Partition { + String label; // Label, zero-terminated ASCII string + uint8_t type; // 0 = Application, 1 = Data + uint8_t subtype; // 0 = OTA selection, 1 = PHY init data, 16 = OTA0, 17 = OTA1, 131 = LITTLEFS + int address; // Starting address in flash + int size; // Size in bytes + }; + + static const Partition part_info[] = { + { "tasmota", 0, 16, fl_tasmota, fl_settings - fl_tasmota }, + { "settings", 1, 0, fl_settings, fl_settings_pend - fl_settings }, + { "ota1", 0, 17, fl_ota, fl_ota_end - fl_ota }, + { "littlefs", 1, 131, fl_filesystem, fl_eeprom - fl_filesystem }, + { "rfcal", 1, 1, fl_eeprom, fl_end - fl_eeprom } + }; + + for (uint32_t i = 0; i < 5; i++) { + if (part_info[i].address != -1) { + if (jsonResponse.length() > 2) { + jsonResponse += ","; + } + jsonResponse += "{\"label\":\"" + String(part_info[i].label); + jsonResponse += "\",\"type\":" + String(part_info[i].type); + jsonResponse += ",\"subtype\":" + String(part_info[i].subtype); + jsonResponse += ",\"address\":\"0x" + String(part_info[i].address, HEX); + jsonResponse += "\",\"size\":" + String(part_info[i].size) + "}"; + } + } +#endif // GV_USE_ESPINFO +#endif // ESP8266 #ifdef ESP32 bool firstEntry = true; // Used to format the JSON array correctly const esp_partition_t *cur_part = esp_ota_get_running_partition(); @@ -464,8 +515,7 @@ void GVHandlePartition(void) { } else if ((label == "app0") || (label == "app1")) { if (label = String(cur_part->label)) { - label = "tasmota-" + String(CODE_IMAGE_STR); - label.toLowerCase(); + label = "tasmota"; } } jsonResponse += "\"label\":\"" + label + "\",";