Skip to content

Commit

Permalink
V/0.0.16 (#38)
Browse files Browse the repository at this point in the history
* bump 0.0.16 and minor fixes

* improved esp8266 stability

* fix boot script

* linted

* minor tweaks

---------

Co-authored-by: Matteo Crippa <[email protected]>
  • Loading branch information
matteocrippa and Matteo Crippa authored Apr 27, 2024
1 parent 83fb863 commit 2db6981
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 78 deletions.
24 changes: 7 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

The following versions of LeafMiner are currently supported with security updates:

- 0.0.15
- 0.0.16

## Reporting a Vulnerability

Expand Down
2 changes: 1 addition & 1 deletion src/current.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ void current_setJob(const Notification &notification)

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());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/leafminer.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
23 changes: 6 additions & 17 deletions src/miner/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
#endif
38 changes: 27 additions & 11 deletions src/network/autoupdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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<size_t>(http.getSize()))
{
l_debug(TAG_AUTOUPDATE, "Written: %d", written);
if (Update.end())
Expand Down
26 changes: 8 additions & 18 deletions src/network/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 2db6981

Please sign in to comment.