diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 382bac1..c79a7e5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,28 +49,18 @@ jobs: - name: Archive Firmware run: | find .pio/build -name "firmware.bin" -exec sh -c 'cp "{}" "artifacts/firmware_$(basename $(dirname {})).bin"' \; - working-directory: ${{ github.workspace }} - name: Archive OTA ESP32 run: | - declare -A ota_map=( - ["esp32"]="0xe000_boot" - ["esp32-s2"]="0xe000_boot" - ["esp32-s3"]="0xe000_boot" - ["lilygo-t-display-s3"]="0xe000_boot" - ) - for board in "${!ota_map[@]}"; do - if [ ! -d ".pio/build/$board" ]; then - continue - fi - for address in ${board_map[$board]}; do - address_prefix=$(echo $address | cut -d'_' -f1) - file_type=$(echo $address | cut -d'_' -f2) - find .pio/build/$board -name "firmware.bin" -exec sh -c '~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin "{}" "artifacts/'"${address_prefix}_${file_type}_${board}.bin"'"' \; - done + for board in $(find .pio/build -maxdepth 1 -type d -printf '%f\n'); do + case "$board" in + "geekmagic-smalltv"|"esp8266") + continue;; + *) + cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin "artifacts/0xe000_boot_${board}.bin";; + esac done - working-directory: ${{ github.workspace }} - name: Archive Artifacts with Address diff --git a/CHANGELOG.md b/CHANGELOG.md index 1129bf3..8bdfa87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,4 @@ -# v0.0.15 +# v0.0.16 -- Fix setup.html adding auto update -- Fix configuration dump -- Tweak ESP8266 hash rate print -- Add 0xe000 for esp32 for boot +- Fix ESP8266 stuck after few minutes +- Reworked the CI bundle diff --git a/README.md b/README.md index 4c8a83a..b9cf6a1 100644 --- a/README.md +++ b/README.md @@ -57,12 +57,12 @@ _Legend_ | Board | Link | | :------------------------------------------------------- | :----------------------------------------------------------- | -| [ESP8266](https://s.click.aliexpress.com/e/_EuwffHJ) | [0.0.15](https://github.com/matteocrippa/leafminer/releases) | -| [GeekMagic SmartTV]() | [0.0.15](https://github.com/matteocrippa/leafminer/releases) | -| [ESP32](https://s.click.aliexpress.com/e/_Ey6AJnT) | [0.0.15](https://github.com/matteocrippa/leafminer/releases) | -| [ESP32-S2](https://s.click.aliexpress.com/e/_EGJcibR) | [0.0.15](https://github.com/matteocrippa/leafminer/releases) | -| [ESP32-S3](https://s.click.aliexpress.com/e/_EJbAXyl) | [0.0.15](https://github.com/matteocrippa/leafminer/releases) | -| [LILYGO-T-S3](https://s.click.aliexpress.com/e/_ExRWk6H) | [0.0.15](https://github.com/matteocrippa/leafminer/releases) | +| [ESP8266](https://s.click.aliexpress.com/e/_EuwffHJ) | [0.0.16](https://github.com/matteocrippa/leafminer/releases) | +| [GeekMagic SmartTV]() | [0.0.16](https://github.com/matteocrippa/leafminer/releases) | +| [ESP32](https://s.click.aliexpress.com/e/_Ey6AJnT) | [0.0.16](https://github.com/matteocrippa/leafminer/releases) | +| [ESP32-S2](https://s.click.aliexpress.com/e/_EGJcibR) | [0.0.16](https://github.com/matteocrippa/leafminer/releases) | +| [ESP32-S3](https://s.click.aliexpress.com/e/_EJbAXyl) | [0.0.16](https://github.com/matteocrippa/leafminer/releases) | +| [LILYGO-T-S3](https://s.click.aliexpress.com/e/_ExRWk6H) | [0.0.16](https://github.com/matteocrippa/leafminer/releases) | - Browse to [ESPWebtool](https://esp.huhn.me/) using a Chrome based browser and upload the file according to the address in the file name. diff --git a/SECURITY.md b/SECURITY.md index 292f625..b4186b9 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,7 +4,7 @@ The following versions of LeafMiner are currently supported with security updates: -- 0.0.15 +- 0.0.16 ## Reporting a Vulnerability diff --git a/src/current.cpp b/src/current.cpp index 423b5d2..5f79545 100644 --- a/src/current.cpp +++ b/src/current.cpp @@ -90,8 +90,8 @@ void current_setJob(const Notification ¬ification) current_job = new Job(notification, *current_subscribe, current_difficulty); current_job_is_valid = 1; - l_info(TAG_CURRENT, "Job: %s ready to be mined", current_job->job_id.c_str()); current_increment_processedJob(); + l_info(TAG_CURRENT, "Job: %s ready to be mined", current_job->job_id.c_str()); } /** diff --git a/src/leafminer.h b/src/leafminer.h index 7107427..91a7e10 100644 --- a/src/leafminer.h +++ b/src/leafminer.h @@ -1,7 +1,7 @@ #ifndef LEAFMINER_H #define LEAFMINER_H -#define _VERSION "0.0.15" +#define _VERSION "0.0.16" #define DIFFICULTY 1e-4 // Mining diff --git a/src/miner/miner.cpp b/src/miner/miner.cpp index b415456..170e392 100644 --- a/src/miner/miner.cpp +++ b/src/miner/miner.cpp @@ -16,17 +16,11 @@ void miner(uint32_t core) uint32_t winning_nonce = 0; uint8_t hash[SHA256M_BLOCK_SIZE]; - while (1) + while (current_job_is_valid) { - if (current_job_is_valid == 0) - { - return; - } - #if defined(ESP8266) ESP.wdtFeed(); -#endif // ESP8266 - +#endif current_increment_hashes(); if (!current_job->pickaxe(core, hash, winning_nonce)) @@ -37,11 +31,10 @@ void miner(uint32_t core) diff_hash = diff_from_target(hash); if (diff_hash > current_getDifficulty()) { + l_debug(TAG_MINER, "[%d] > Hash %.12f > %.12f", core, diff_hash, current_getDifficulty()); break; } -#if defined(ESP32) current_update_hashrate(); -#endif } #if defined(HAS_LCD) @@ -51,10 +44,6 @@ void miner(uint32_t core) l_info(TAG_MINER, "[%d] > [%s] > 0x%.8x - diff %.12f", core, current_job->job_id.c_str(), winning_nonce, diff_hash); network_send(current_job->job_id, current_job->extranonce2, current_job->ntime, winning_nonce); -#if defined(ESP8266) - current_update_hashrate(); -#endif - current_setHighestDifficulty(diff_hash); if (littleEndianCompare(hash, current_job->target.value, 32) < 0) @@ -68,10 +57,10 @@ void miner(uint32_t core) void mineTaskFunction(void *pvParameters) { uint32_t core = (uint32_t)pvParameters; - while (1) + while (current_job_is_valid) { miner(core); - vTaskDelay(33 / portTICK_PERIOD_MS); + vTaskDelay(33 / portTICK_PERIOD_MS); // Add a small delay to prevent tight loop } } -#endif \ No newline at end of file +#endif diff --git a/src/network/autoupdate.cpp b/src/network/autoupdate.cpp index 592882a..ceaccb7 100644 --- a/src/network/autoupdate.cpp +++ b/src/network/autoupdate.cpp @@ -42,28 +42,44 @@ extern Configuration configuration; // 1 if version1 is newer // 0 if both versions are equal // -1 if version2 is newer -int compareVersions(const char* version1, const char* version2) { +int compareVersions(const char *version1, const char *version2) +{ int major1, minor1, patch1; int major2, minor2, patch2; sscanf(version1, "%d.%d.%d", &major1, &minor1, &patch1); sscanf(version2, "%d.%d.%d", &major2, &minor2, &patch2); - if (major1 > major2) { + if (major1 > major2) + { return 1; - } else if (major1 < major2) { + } + else if (major1 < major2) + { return -1; - } else { - if (minor1 > minor2) { + } + else + { + if (minor1 > minor2) + { return 1; - } else if (minor1 < minor2) { + } + else if (minor1 < minor2) + { return -1; - } else { - if (patch1 > patch2) { + } + else + { + if (patch1 > patch2) + { return 1; - } else if (patch1 < patch2) { + } + else if (patch1 < patch2) + { return -1; - } else { + } + else + { return 0; // Versions are equal } } @@ -169,7 +185,7 @@ void autoupdate() { l_debug(TAG_AUTOUPDATE, "Begin Update"); size_t written = Update.writeStream(http.getStream()); - if (written == http.getSize()) + if (written == static_cast(http.getSize())) { l_debug(TAG_AUTOUPDATE, "Written: %d", written); if (Update.end()) diff --git a/src/network/network.cpp b/src/network/network.cpp index 3bea3f0..3fe603e 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -27,7 +27,6 @@ uint64_t requestJobId = 0; uint8_t isRequestingJob = 0; uint32_t authorizeId = 0; uint8_t isAuthorized = 0; -uint8_t isListening = 0; extern Configuration configuration; char payloads[MAX_PAYLOADS][MAX_PAYLOAD_SIZE]; // Array of payloads size_t payloads_count = 0; @@ -404,34 +403,25 @@ void network_send(const std::string &job_id, const std::string &extranonce2, con void network_listen() { -#if defined(ESP8266) - if (isListening == 1) - { - return; - } - isListening = 1; -#endif + uint32_t len = 0; - int len = 0; - if (isConnected() == -1) - { - current_resetSession(); - return; // Handle connection failure - } do { char data[NETWORK_BUFFER_SIZE]; len = client.readBytesUntil('\n', data, sizeof(data) - 1); + l_debug(TAG_NETWORK, "<<< len: %d", len); data[len] = '\0'; if (data[0] != '\0') { response(data); } - } while (len > 0); + if (isConnected() == -1) + { + current_resetSession(); + return; // Handle connection failure + } -#if defined(ESP8266) - isListening = 0; -#endif + } while (len > 0); } void network_submit(const char *payload) diff --git a/version.json b/version.json index bbea812..15aeebc 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "current": "0.0.15", + "current": "0.0.16", "link": "https://github.com/matteocrippa/leafminer/releases/download/v{{version}}/firmware_{{device}}.bin", "devices": [ "esp8266",