From 18d4868554e1687ba71c1666f20b503135234291 Mon Sep 17 00:00:00 2001 From: bitmaker Date: Fri, 12 Sep 2025 00:16:24 +0200 Subject: [PATCH 1/5] add custom AP name support via SPIFFS - read custom AP name from /apname.txt if present - fallback to default AP name if file doesn't exist - initialize SPIFFS early for AP name reading - update WiFiManager calls to use custom/default name --- src/wManager.cpp | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/wManager.cpp b/src/wManager.cpp index 992845e..d956251 100644 --- a/src/wManager.cpp +++ b/src/wManager.cpp @@ -16,6 +16,10 @@ #include "mining.h" #include "timeconst.h" +#ifdef NVMEM_SPIFFS +#include +#endif + // Flag for saving data bool shouldSaveConfig = false; @@ -31,6 +35,23 @@ nvMemory nvMem; extern SDCard SDCrd; +String readCustomAPName() { +#ifdef NVMEM_SPIFFS + if (SPIFFS.exists("/apname.txt")) { + File file = SPIFFS.open("/apname.txt", "r"); + if (file) { + String name = file.readString(); + file.close(); + name.trim(); + if (name.length() > 0 && name.length() < 32) { + return name; + } + } + } +#endif + return ""; +} + void saveConfigCallback() // Callback notifying us of the need to save configuration { @@ -76,6 +97,19 @@ void init_WifiManager() Serial.begin(115200); #endif //MONITOR_SPEED //Serial.setTxTimeoutMs(10); + + // Initialize SPIFFS to read custom AP name +#ifdef NVMEM_SPIFFS + if (!SPIFFS.begin(false)) { + SPIFFS.begin(true); + } +#endif + + // Check for custom AP name, otherwise use default + String customAPName = readCustomAPName(); + const char* apName = customAPName.length() > 0 ? customAPName.c_str() : DEFAULT_SSID; + Serial.print("Using AP name: "); + Serial.println(apName); //Init pin 15 to eneble 5V external power (LilyGo bug) #ifdef PIN_ENABLE5V @@ -204,7 +238,7 @@ void init_WifiManager() wm.setConfigPortalBlocking(true); //Hacemos que el portal SI bloquee el firmware drawSetupScreen(); mMonitor.NerdStatus = NM_Connecting; - wm.startConfigPortal(DEFAULT_SSID, DEFAULT_WIFIPW); + wm.startConfigPortal(apName, DEFAULT_WIFIPW); if (shouldSaveConfig) { @@ -238,7 +272,7 @@ void init_WifiManager() wm.setConfigPortalBlocking(true); wm.setEnableConfigPortal(true); // if (!wm.autoConnect(Settings.WifiSSID.c_str(), Settings.WifiPW.c_str())) - if (!wm.autoConnect(DEFAULT_SSID, DEFAULT_WIFIPW)) + if (!wm.autoConnect(apName, DEFAULT_WIFIPW)) { Serial.println("Failed to connect to configured WIFI, and hit timeout"); if (shouldSaveConfig) { From f070ab28385b0ed5023180d65c5b20f2111188f8 Mon Sep 17 00:00:00 2001 From: bitmaker Date: Fri, 12 Sep 2025 23:59:12 +0200 Subject: [PATCH 2/5] fix ESP32 boards crashes --- src/NerdMinerV2.ino.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NerdMinerV2.ino.cpp b/src/NerdMinerV2.ino.cpp index f99d6ee..548740c 100644 --- a/src/NerdMinerV2.ino.cpp +++ b/src/NerdMinerV2.ino.cpp @@ -132,8 +132,8 @@ void setup() Serial.println("Initiating tasks..."); static const char monitor_name[] = "(Monitor)"; #if defined(CONFIG_IDF_TARGET_ESP32) - // Reduced stack for ESP32 classic to save memory - BaseType_t res1 = xTaskCreatePinnedToCore(runMonitor, "Monitor", 8000, (void*)monitor_name, 5, NULL,1); + // Increased stack for ESP32 classic due to NVS operations + BaseType_t res1 = xTaskCreatePinnedToCore(runMonitor, "Monitor", 9500, (void*)monitor_name, 5, NULL,1); #else BaseType_t res1 = xTaskCreatePinnedToCore(runMonitor, "Monitor", 10000, (void*)monitor_name, 5, NULL,1); #endif From 2277dfed1ab53ab5bddcd2bc94b39745ffec1c8c Mon Sep 17 00:00:00 2001 From: bitmaker Date: Fri, 12 Sep 2025 23:59:34 +0200 Subject: [PATCH 3/5] add new board ESP32-2432S024 --- platformio.ini | 58 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 2fbecf8..8f8b9f2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ [platformio] globallib_dir = lib -default_envs = NerdminerV2, NerdminerV2-T-HMI, wt32-sc01, wt32-sc01-plus, han_m5stack, M5Stick-C, M5Stick-C-Plus2, M5Stick-CPlus, esp32cam, ESP32-2432S028R, ESP32_2432S028_2USB, Lilygo-T-Embed, ESP32-devKitv1, NerdminerV2-S3-DONGLE, NerdminerV2-S3-GEEK, NerdminerV2-S3-AMOLED, NerdminerV2-S3-AMOLED-TOUCH, NerdminerV2-T-QT, NerdminerV2-T-Display_V1, TTGO-T-Display, M5-StampS3, ESP32-S3-devKitv1, ESP32-S3-mini-wemos, ESP32-S2-mini-wemos, ESP32-S3-mini-weact, ESP32-D0WD-V3-weact, ESP32-C3-super-mini, ESP32-C3-devKitmv1, ESP32-C3-042-OLED, ESP32-S3-042-OLED, ESP32-C3-spotpear, esp32-s3-devkitc1-n32r8 +default_envs = NerdminerV2, NerdminerV2-T-HMI, wt32-sc01, wt32-sc01-plus, han_m5stack, M5Stick-C, M5Stick-C-Plus2, M5Stick-CPlus, esp32cam, ESP32-2432S028R, ESP32_2432S028_2USB, ESP32-2432S024, Lilygo-T-Embed, ESP32-devKitv1, NerdminerV2-S3-DONGLE, NerdminerV2-S3-GEEK, NerdminerV2-S3-AMOLED, NerdminerV2-S3-AMOLED-TOUCH, NerdminerV2-T-QT, NerdminerV2-T-Display_V1, TTGO-T-Display, M5-StampS3, ESP32-S3-devKitv1, ESP32-S3-mini-wemos, ESP32-S2-mini-wemos, ESP32-S3-mini-weact, ESP32-D0WD-V3-weact, ESP32-C3-super-mini, ESP32-C3-devKitmv1, ESP32-C3-042-OLED, ESP32-S3-042-OLED, ESP32-C3-spotpear, esp32-s3-devkitc1-n32r8 ; Global configuration for all environments [env] @@ -1014,6 +1014,62 @@ lib_ignore = ;-------------------------------------------------------------------- +[env:ESP32-2432S024] +platform = espressif32@6.6.0 +board = esp32dev +framework = arduino +extra_scripts = + pre:auto_firmware_version.py + post:post_build_merge.py +monitor_speed = 115200 +monitor_filters = + esp32_exception_decoder + time + colorize + ;debug +upload_speed = 921600 +;build_type = debug +board_build.partitions = huge_app.csv +build_flags = + ;-DDEBUG_MEMORY=1 + -D ESP32_2432S028R=1 + -DUSER_SETUP_LOADED=1 + -DILI9341_2_DRIVER=1 + -DTFT_WIDTH=240 + -DTFT_HEIGHT=320 + -DTFT_BACKLIGHT_ON=HIGH + -DTFT_MOSI=13 + -DTFT_SCLK=14 + -DTFT_CS=15 + -DTFT_DC=2 + -DTFT_RST=12 + -DTFT_BL=27 + -DETOUCH_CS=33 + -DTOUCH_CLK=25 + -DTOUCH_MISO=39 + -DTOUCH_MOSI=32 + -DTOUCH_IRQ=36 + -DLOAD_GLCD=1 + -DLOAD_FONT2=1 + -DLOAD_GFXFF=1 + -DSMOOTH_FONT=1 + -DSPI_FREQUENCY=55000000 + -DSPI_READ_FREQUENCY=20000000 + -DSPI_TOUCH_FREQUENCY=2500000 + +lib_deps = + https://github.com/takkaO/OpenFontRender#v1.2 + bblanchon/ArduinoJson@^6.21.5 + https://github.com/tzapu/WiFiManager.git#v2.0.17 + mathertel/oneButton@^2.6.1 + arduino-libraries/NTPClient@^3.2.1 + bodmer/TFT_eSPI@^2.5.43 + https://github.com/achillhasler/TFT_eTouch +lib_ignore = + HANSOLOminerv2 + +;-------------------------------------------------------------------- + [env:NerdminerV2-T-HMI] platform = espressif32@6.6.0 board = lilygo-t-hmi From 881f8f4804745fd4036e94666882615f918d4d9b Mon Sep 17 00:00:00 2001 From: bitmaker Date: Sat, 13 Sep 2025 00:01:35 +0200 Subject: [PATCH 4/5] feature custom APname on TDIsplayS3 or Devkit (learning purposes) - Added in order to help NodeNation classes and let studens configure their own miner with different APname --- src/wManager.cpp | 80 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/src/wManager.cpp b/src/wManager.cpp index d956251..d812981 100644 --- a/src/wManager.cpp +++ b/src/wManager.cpp @@ -16,9 +16,8 @@ #include "mining.h" #include "timeconst.h" -#ifdef NVMEM_SPIFFS -#include -#endif +#include +#include // Flag for saving data @@ -36,19 +35,59 @@ nvMemory nvMem; extern SDCard SDCrd; String readCustomAPName() { -#ifdef NVMEM_SPIFFS - if (SPIFFS.exists("/apname.txt")) { - File file = SPIFFS.open("/apname.txt", "r"); - if (file) { - String name = file.readString(); - file.close(); - name.trim(); - if (name.length() > 0 && name.length() < 32) { - return name; - } - } + Serial.println("DEBUG: Attempting to read custom AP name from flash at 0x3F0000..."); + + // Leer directamente desde flash + const size_t DATA_SIZE = 128; + uint8_t buffer[DATA_SIZE]; + memset(buffer, 0, DATA_SIZE); // Clear buffer + + // Leer desde 0x3F0000 + esp_err_t result = esp_flash_read(NULL, buffer, 0x3F0000, DATA_SIZE); + if (result != ESP_OK) { + Serial.printf("DEBUG: Flash read error: %s\n", esp_err_to_name(result)); + return ""; } -#endif + + Serial.println("DEBUG: Successfully read from flash"); + String data = String((char*)buffer); + + // Debug: show raw data read + Serial.printf("DEBUG: Raw flash data: '%s'\n", data.c_str()); + + if (data.startsWith("WEBFLASHER_CONFIG:")) { + Serial.println("DEBUG: Found WEBFLASHER_CONFIG marker"); + String jsonPart = data.substring(18); // Después del marcador "WEBFLASHER_CONFIG:" + + Serial.printf("DEBUG: JSON part: '%s'\n", jsonPart.c_str()); + + DynamicJsonDocument doc(256); + DeserializationError error = deserializeJson(doc, jsonPart); + + if (error == DeserializationError::Ok) { + Serial.println("DEBUG: JSON parsed successfully"); + + if (doc.containsKey("apname")) { + String customAP = doc["apname"].as(); + customAP.trim(); + + if (customAP.length() > 0 && customAP.length() < 32) { + Serial.printf("✅ Custom AP name from webflasher: %s\n", customAP.c_str()); + return customAP; + } else { + Serial.printf("DEBUG: AP name invalid length: %d\n", customAP.length()); + } + } else { + Serial.println("DEBUG: 'apname' key not found in JSON"); + } + } else { + Serial.printf("DEBUG: JSON parse error: %s\n", error.c_str()); + } + } else { + Serial.println("DEBUG: WEBFLASHER_CONFIG marker not found - no custom config"); + } + + Serial.println("DEBUG: Using default AP name"); return ""; } @@ -98,18 +137,9 @@ void init_WifiManager() #endif //MONITOR_SPEED //Serial.setTxTimeoutMs(10); - // Initialize SPIFFS to read custom AP name -#ifdef NVMEM_SPIFFS - if (!SPIFFS.begin(false)) { - SPIFFS.begin(true); - } -#endif - - // Check for custom AP name, otherwise use default + // Check for custom AP name from flasher config, otherwise use default String customAPName = readCustomAPName(); const char* apName = customAPName.length() > 0 ? customAPName.c_str() : DEFAULT_SSID; - Serial.print("Using AP name: "); - Serial.println(apName); //Init pin 15 to eneble 5V external power (LilyGo bug) #ifdef PIN_ENABLE5V From 9e6f5115fb1087dfb74af92c269c84768b487efd Mon Sep 17 00:00:00 2001 From: bitmaker Date: Sat, 13 Sep 2025 00:02:59 +0200 Subject: [PATCH 5/5] version v1.8.3 --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index fab1cd8..f3f5124 100644 --- a/src/version.h +++ b/src/version.h @@ -1,6 +1,6 @@ #ifndef VERSION_H #define VERSION_H -#define CURRENT_VERSION "V1.8.2" +#define CURRENT_VERSION "V1.8.3" #endif // VERSION_H