Merge branch 'dev'

This commit is contained in:
BitMaker 2023-11-29 00:31:36 +01:00
commit 2b34e8aeb1
25 changed files with 15363 additions and 2476 deletions

View File

@ -51,6 +51,7 @@ Every time an stratum job notification is received miner update its current work
- LILYGO T-Dongle S3 ([Aliexpress link\*](https://s.click.aliexpress.com/e/_DmQCPyj))
- ESP32-2432S028R 2,8" ([Aliexpress link\*](https://s.click.aliexpress.com/e/_DdXkvLv) / Dev support: @nitroxgas / ⚡jadeddonald78@walletofsatoshi.com)
- ESP32-cam ([Board Info](https://lastminuteengineers.com/getting-started-with-esp32-cam/) / Dev support: @elmo128)
- M5-StampS3 ([Aliexpress link\*](https://s.click.aliexpress.com/e/_DevABY3) / Dev support: @gyengus)
\*Affiliate links
@ -61,7 +62,7 @@ Every time an stratum job notification is received miner update its current work
Easyiest way to flash firmware. Build your own miner using the folowing firwmare flash tool:
1. Get a TTGO T-display S3 or any other supported board
1. Go to NM2 flasher online: https://bitmaker-hub.github.io/diyflasher/
1. Go to NM2 flasher online: https://flasher.bitronics.store/
#### Standard tool
@ -130,7 +131,8 @@ Recommended low difficulty share pools:
| public-pool.io | 21496 | https://web.public-pool.io | Open Source Solo Bitcoin Mining Pool supporting open source miners |
| nerdminers.org | | https://nerdminers.org | Team domain for future pool - Currently pointing to public-pool.io |
| pool.nerdminer.io | 3333 | https://nerdminer.io | Mantained by CHMEX |
| pool.vkbit.com | 3333 | https://vkbit.com/ | Mantained by djerfy |
| pool.vkbit.com | 3333 | https://vkbit.com/ | Mantained by djerfy - public-pool fork |
| pool.pyblock.xyz | 3333 | https://pool.pyblock.xyz/ | Mantained by curly60e |
Other standard pools not compatible with low difficulty share:
@ -207,6 +209,6 @@ With the USB-C port to the right:
If you would like to contribute and help dev team with this project you can send a donation to the following LN address ⚡teamnerdminer@getalby.com⚡ or using one of the affiliate links above.
If you want to order a fully assembled Nerdminer you can contribute to my job at [bitronics.store](https://bitronics.store).
If you want to order a fully assembled Nerdminer you can contribute to my job at 🛒[bitronics.store](https://bitronics.store)🛒
Enjoy

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -10,7 +10,7 @@
[platformio]
globallib_dir = lib
default_envs = esp32cam, ESP32-2432S028R, NerminerV2, ESP32-devKitv1, NerminerV2-S3-DONGLE, NerminerV2-S3-AMOLED, NerminerV2-T-QT, NerdminerV2-T-Display_V1, ESP32-2432S028R, M5-StampS3
default_envs = NerminerV2 ; esp32cam, ESP32-2432S028R, NerminerV2, ESP32-devKitv1, NerminerV2-S3-DONGLE, NerminerV2-S3-AMOLED, NerminerV2-T-QT, NerdminerV2-T-Display_V1, ESP32-2432S028R, M5-StampS3

View File

@ -0,0 +1,398 @@
/************************************************************************************
* written by: Bitmaker
* based on: Blockstream Jade shaLib
* thanks to @LarryBitcoin
* Description:
* NerdSha256plus is a custom C implementation of sha256d based on Blockstream Jade
code https://github.com/Blockstream/Jade
The folowing file can be used on any ESP32 implementation using both cores
*************************************************************************************/
#define NDEBUG
#include <stdio.h>
#include <string.h>
#include <Arduino.h>
#include <esp_log.h>
#include <esp_timer.h>
#include "nerdSHA256plus.h"
#include <math.h>
#include <string.h>
#define ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n)))
#ifndef PUT_UINT32_BE
#define PUT_UINT32_BE(n, data, offset) \
{ \
u.num = n; \
p = (data) + (offset); \
*p = u.b[3]; \
*(p + 1) = u.b[2]; \
*(p + 2) = u.b[1]; \
*(p + 3) = u.b[0]; \
}
#endif
#ifndef GET_UINT32_BE
#define GET_UINT32_BE(b, i) \
(((uint32_t)(b)[(i)] << 24) | ((uint32_t)(b)[(i) + 1] << 16) | ((uint32_t)(b)[(i) + 2] << 8) \
| ((uint32_t)(b)[(i) + 3]))
#endif
//DRAM_ATTR static const uint32_t K[] = {
DRAM_ATTR static const uint32_t K[64] = {
0x428A2F98L, 0x71374491L, 0xB5C0FBCFL, 0xE9B5DBA5L, 0x3956C25BL,
0x59F111F1L, 0x923F82A4L, 0xAB1C5ED5L, 0xD807AA98L, 0x12835B01L,
0x243185BEL, 0x550C7DC3L, 0x72BE5D74L, 0x80DEB1FEL, 0x9BDC06A7L,
0xC19BF174L, 0xE49B69C1L, 0xEFBE4786L, 0x0FC19DC6L, 0x240CA1CCL,
0x2DE92C6FL, 0x4A7484AAL, 0x5CB0A9DCL, 0x76F988DAL, 0x983E5152L,
0xA831C66DL, 0xB00327C8L, 0xBF597FC7L, 0xC6E00BF3L, 0xD5A79147L,
0x06CA6351L, 0x14292967L, 0x27B70A85L, 0x2E1B2138L, 0x4D2C6DFCL,
0x53380D13L, 0x650A7354L, 0x766A0ABBL, 0x81C2C92EL, 0x92722C85L,
0xA2BFE8A1L, 0xA81A664BL, 0xC24B8B70L, 0xC76C51A3L, 0xD192E819L,
0xD6990624L, 0xF40E3585L, 0x106AA070L, 0x19A4C116L, 0x1E376C08L,
0x2748774CL, 0x34B0BCB5L, 0x391C0CB3L, 0x4ED8AA4AL, 0x5B9CCA4FL,
0x682E6FF3L, 0x748F82EEL, 0x78A5636FL, 0x84C87814L, 0x8CC70208L,
0x90BEFFFAL, 0xA4506CEBL, 0xBEF9A3F7L, 0xC67178F2L
};
#define SHR(x, n) ((x & 0xFFFFFFFF) >> n)
#define S0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3))
#define S1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10))
#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
#define F0(x, y, z) ((x & y) | (z & (x | y)))
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define R(t) (W[t] = S1(W[t - 2]) + W[t - 7] + S0(W[t - 15]) + W[t - 16])
#define P(a, b, c, d, e, f, g, h, x, K) \
{ \
temp1 = h + S3(e) + F1(e, f, g) + K + x; \
temp2 = S2(a) + F0(a, b, c); \
d += temp1; \
h = temp1 + temp2; \
}
uint32_t rotlFixed(uint32_t x, uint32_t y)
{
return (x << y) | (x >> (sizeof(y) * 8 - y));
}
uint32_t ByteReverseWord32(uint32_t value){
value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8);
return rotlFixed(value, 16U);
}
void ByteReverseWords(uint32_t* out, const uint32_t* in, uint32_t byteCount)
{
uint32_t count, i;
count = byteCount/(uint32_t)sizeof(uint32_t);
for (i = 0; i < count; i++) out[i] = ByteReverseWord32(in[i]);
}
IRAM_ATTR void nerd_mids(nerdSHA256_context* midstate, uint8_t* dataIn)
{
uint32_t A[8] = { 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19 };
uint32_t temp1, temp2, W[64];
uint8_t i;
W[0] = GET_UINT32_BE(dataIn, 0);
W[1] = GET_UINT32_BE(dataIn, 4);
W[2] = GET_UINT32_BE(dataIn, 8);
W[3] = GET_UINT32_BE(dataIn, 12);
W[4] = GET_UINT32_BE(dataIn, 16);
W[5] = GET_UINT32_BE(dataIn, 20);
W[6] = GET_UINT32_BE(dataIn, 24);
W[7] = GET_UINT32_BE(dataIn, 28);
W[8] = GET_UINT32_BE(dataIn, 32);
W[9] = GET_UINT32_BE(dataIn, 36);
W[10] = GET_UINT32_BE(dataIn, 40);
W[11] = GET_UINT32_BE(dataIn, 44);
W[12] = GET_UINT32_BE(dataIn, 48);
W[13] = GET_UINT32_BE(dataIn, 52);
W[14] = GET_UINT32_BE(dataIn, 56);
W[15] = GET_UINT32_BE(dataIn, 60);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[0], K[0]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], W[1], K[1]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], W[2], K[2]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], W[3], K[3]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], W[4], K[4]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], W[5], K[5]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], W[6], K[6]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], W[7], K[7]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[8], K[8]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], W[9], K[9]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], W[10], K[10]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], W[11], K[11]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], W[12], K[12]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], W[13], K[13]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], W[14], K[14]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], W[15], K[15]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(16), K[16]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(17), K[17]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(18), K[18]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(19), K[19]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(20), K[20]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(21), K[21]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(22), K[22]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(23), K[23]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(24), K[24]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(25), K[25]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(26), K[26]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(27), K[27]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(28), K[28]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(29), K[29]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(30), K[30]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(31), K[31]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(32), K[32]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(33), K[33]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(34), K[34]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(35), K[35]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(36), K[36]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(37), K[37]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(38), K[38]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(39), K[39]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(40), K[40]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(41), K[41]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(42), K[42]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(43), K[43]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(44), K[44]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(45), K[45]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(46), K[46]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(47), K[47]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(48), K[48]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(49), K[49]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(50), K[50]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(51), K[51]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(52), K[52]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(53), K[53]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(54), K[54]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(55), K[55]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(56), K[56]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(57), K[57]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(58), K[58]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(59), K[59]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(60), K[60]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(61), K[61]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(62), K[62]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(63), K[63]);
midstate->digest[0] = 0x6A09E667 + A[0];
midstate->digest[1] = 0xBB67AE85 + A[1];
midstate->digest[2] = 0x3C6EF372 + A[2];
midstate->digest[3] = 0xA54FF53A + A[3];
midstate->digest[4] = 0x510E527F + A[4];
midstate->digest[5] = 0x9B05688C + A[5];
midstate->digest[6] = 0x1F83D9AB + A[6];
midstate->digest[7] = 0x5BE0CD19 + A[7];
}
IRAM_ATTR bool nerd_sha256d(nerdSHA256_context* midstate, uint8_t* dataIn, uint8_t* doubleHash)
{
uint32_t temp1, temp2;
uint8_t temp3, temp4;
uint32_t* buffer32;
//*********** Init 1rst SHA ***********
uint32_t W[16] = { GET_UINT32_BE(dataIn, 0), GET_UINT32_BE(dataIn, 4),
GET_UINT32_BE(dataIn, 8), GET_UINT32_BE(dataIn, 12), 0x80000000, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 640};
uint32_t A[8] = { midstate->digest[0], midstate->digest[1], midstate->digest[2], midstate->digest[3],
midstate->digest[4], midstate->digest[5], midstate->digest[6], midstate->digest[7] };
union {
uint32_t num;
uint8_t b[4];
} u;
uint8_t* p = NULL;
uint8_t i;
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[0], K[0]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], W[1], K[1]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], W[2], K[2]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], W[3], K[3]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], W[4], K[4]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], W[5], K[5]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], W[6], K[6]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], W[7], K[7]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[8], K[8]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], W[9], K[9]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], W[10], K[10]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], W[11], K[11]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], W[12], K[12]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], W[13], K[13]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], W[14], K[14]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], W[15], K[15]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(16), K[16]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(17), K[17]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(18), K[18]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(19), K[19]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(20), K[20]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(21), K[21]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(22), K[22]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(23), K[23]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(24), K[24]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(25), K[25]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(26), K[26]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(27), K[27]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(28), K[28]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(29), K[29]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(30), K[30]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(31), K[31]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(32), K[32]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(33), K[33]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(34), K[34]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(35), K[35]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(36), K[36]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(37), K[37]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(38), K[38]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(39), K[39]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(40), K[40]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(41), K[41]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(42), K[42]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(43), K[43]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(44), K[44]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(45), K[45]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(46), K[46]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(47), K[47]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(48), K[48]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(49), K[49]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(50), K[50]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(51), K[51]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(52), K[52]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(53), K[53]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(54), K[54]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(55), K[55]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(56), K[56]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(57), K[57]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(58), K[58]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(59), K[59]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(60), K[60]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(61), K[61]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(62), K[62]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(63), K[63]);
//*********** end SHA_finish ***********
/* Calculate the second hash (double SHA-256) */
W[0] = A[0] + midstate->digest[0];
W[1] = A[1] + midstate->digest[1];
W[2] = A[2] + midstate->digest[2];
W[3] = A[3] + midstate->digest[3];
W[4] = A[4] + midstate->digest[4];
W[5] = A[5] + midstate->digest[5];
W[6] = A[6] + midstate->digest[6];
W[7] = A[7] + midstate->digest[7];
W[8] = 0x80000000;
W[9] = 0;
W[10] = 0;
W[11] = 0;
W[12] = 0;
W[13] = 0;
W[14] = 0;
W[15] = 256;
A[0] = 0x6A09E667;
A[1] = 0xBB67AE85;
A[2] = 0x3C6EF372;
A[3] = 0xA54FF53A;
A[4] = 0x510E527F;
A[5] = 0x9B05688C;
A[6] = 0x1F83D9AB;
A[7] = 0x5BE0CD19;
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[0], K[0]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], W[1], K[1]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], W[2], K[2]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], W[3], K[3]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], W[4], K[4]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], W[5], K[5]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], W[6], K[6]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], W[7], K[7]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[8], K[8]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], W[9], K[9]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], W[10], K[10]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], W[11], K[11]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], W[12], K[12]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], W[13], K[13]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], W[14], K[14]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], W[15], K[15]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(16), K[16]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(17), K[17]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(18), K[18]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(19), K[19]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(20), K[20]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(21), K[21]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(22), K[22]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(23), K[23]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(24), K[24]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(25), K[25]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(26), K[26]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(27), K[27]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(28), K[28]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(29), K[29]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(30), K[30]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(31), K[31]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(32), K[32]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(33), K[33]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(34), K[34]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(35), K[35]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(36), K[36]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(37), K[37]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(38), K[38]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(39), K[39]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(40), K[40]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(41), K[41]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(42), K[42]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(43), K[43]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(44), K[44]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(45), K[45]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(46), K[46]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(47), K[47]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(48), K[48]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(49), K[49]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(50), K[50]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(51), K[51]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(52), K[52]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(53), K[53]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(54), K[54]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(55), K[55]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(56), K[56]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(57), K[57]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(58), K[58]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(59), K[59]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(60), K[60]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(61), K[61]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(62), K[62]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(63), K[63]);
PUT_UINT32_BE(0x5BE0CD19 + A[7], doubleHash, 28);
if(doubleHash[31] !=0 || doubleHash[30] !=0) return false;
PUT_UINT32_BE(0x6A09E667 + A[0], doubleHash, 0);
PUT_UINT32_BE(0xBB67AE85 + A[1], doubleHash, 4);
PUT_UINT32_BE(0x3C6EF372 + A[2], doubleHash, 8);
PUT_UINT32_BE(0xA54FF53A + A[3], doubleHash, 12);
PUT_UINT32_BE(0x510E527F + A[4], doubleHash, 16);
PUT_UINT32_BE(0x9B05688C + A[5], doubleHash, 20);
PUT_UINT32_BE(0x1F83D9AB + A[6], doubleHash, 24);
return true;
}

View File

@ -0,0 +1,34 @@
/************************************************************************************
* written by: Bitmaker
* based on: Blockstream Jade shaLib
* thanks to @LarryBitcoin
* Description:
* NerdSha256plus is a custom C implementation of sha256d based on Blockstream Jade
code https://github.com/Blockstream/Jade
The folowing file can be used on any ESP32 implementation using both cores
*************************************************************************************/
#ifndef nerdSHA256plus_H_
#define nerdSHA256plus_H_
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
struct nerdSHA256_context {
uint8_t buffer[64];
uint32_t digest[8];
};
/* Calculate midstate */
IRAM_ATTR void nerd_mids(nerdSHA256_context* midstate, uint8_t* dataIn);
IRAM_ATTR bool nerd_sha256d(nerdSHA256_context* midstate, uint8_t* dataIn, uint8_t* doubleHash);
void ByteReverseWords(uint32_t* out, const uint32_t* in, uint32_t byteCount);
#endif /* nerdSHA256plus_H_ */

View File

@ -356,6 +356,68 @@ void esp32_2432S028R_GlobalHashScreen(unsigned long mElapsed)
printheap();
#endif
}
void esp32_2432S028R_BTCprice(unsigned long mElapsed)
{
if (hasChangedScreen) tft.pushImage(0, 0, priceScreenWidth, priceScreenHeight, priceScreen);
hasChangedScreen = false;
clock_data data = getClockData(mElapsed);
Serial.printf(">>> Completed %s share(s), %s Khashes, avg. hashrate %s KH/s\n",
data.completedShares.c_str(), data.totalKHashes.c_str(), data.currentHashRate.c_str());
// Create background sprite to print data at once
createBackgroundSprite(270,36);
// Print background screen
background.pushImage(0, -130, priceScreenWidth, priceScreenHeight, priceScreen);
// Hashrate
render.setFontSize(25);
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), 95, 0, TFT_BLACK);
// Print BlockHeight
render.setFontSize(18);
render.rdrawString(data.blockHeight.c_str(), 254, 9, TFT_WHITE);
// Push prepared background to screen
background.pushSprite(0, 130);
// Delete sprite to free the memory heap
background.deleteSprite();
createBackgroundSprite(169,105);
// Print background screen
background.pushImage(-130, -3, priceScreenWidth, priceScreenHeight, priceScreen);
// Print BTC Price
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.currentTime.c_str(), 202-130, 0, GFXFF);
// Print Hour
background.setFreeFont(FF23);
background.setTextSize(2);
background.setTextColor(0xDEDB, TFT_BLACK);
background.drawString(data.btcPrice.c_str(), 0, 50, GFXFF);
// Push prepared background to screen
background.pushSprite(130, 3);
// Delete sprite to free the memory heap
background.deleteSprite();
#ifdef ESP32_2432S028R
printPoolData();
#endif
#ifdef DEBUG_MEMORY
// Print heap
printheap();
#endif
}
void esp32_2432S028R_LoadingScreen(void)
{
@ -443,7 +505,7 @@ void esp32_2432S028R_DoLedStuff(unsigned long frame)
}
CyclicScreenFunction esp32_2432S028RCyclicScreens[] = {esp32_2432S028R_MinerScreen, esp32_2432S028R_ClockScreen, esp32_2432S028R_GlobalHashScreen};
CyclicScreenFunction esp32_2432S028RCyclicScreens[] = {esp32_2432S028R_MinerScreen, esp32_2432S028R_ClockScreen, esp32_2432S028R_GlobalHashScreen, esp32_2432S028R_BTCprice};
DisplayDriver esp32_2432S028RDriver = {
esp32_2432S028R_Init,

View File

@ -195,6 +195,49 @@ void tDisplay_GlobalHashScreen(unsigned long mElapsed)
background.pushSprite(0, 0);
}
void tDisplay_BTCprice(unsigned long mElapsed)
{
clock_data data = getClockData(mElapsed);
data.currentDate ="01/12/2023";
//if(data.currentDate.indexOf("12/2023")>) { tDisplay_ChristmasContent(data); return; }
// Print background screen
background.pushImage(0, 0, priceScreenWidth, priceScreenHeight, priceScreen);
Serial.printf(">>> Completed %s share(s), %s Khashes, avg. hashrate %s KH/s\n",
data.completedShares.c_str(), data.totalKHashes.c_str(), data.currentHashRate.c_str());
// Hashrate
render.setFontSize(25);
render.setCursor(19, 122);
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), 94, 129, TFT_BLACK);
// Print BlockHeight
render.setFontSize(18);
render.rdrawString(data.blockHeight.c_str(), 254, 138, TFT_WHITE);
// Print Hour
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.currentTime.c_str(), 222, 3, GFXFF);
// Print BTC Price
background.setFreeFont(FF24);
background.setTextDatum(TR_DATUM);
background.setTextSize(1);
background.setTextColor(0xDEDB, TFT_BLACK);
background.drawString(data.btcPrice.c_str(), 300, 58, GFXFF);
// Push prepared background to screen
background.pushSprite(0, 0);
}
void tDisplay_LoadingScreen(void)
{
tft.fillScreen(TFT_BLACK);
@ -216,7 +259,7 @@ void tDisplay_DoLedStuff(unsigned long frame)
{
}
CyclicScreenFunction tDisplayCyclicScreens[] = {tDisplay_MinerScreen, tDisplay_ClockScreen, tDisplay_GlobalHashScreen};
CyclicScreenFunction tDisplayCyclicScreens[] = {tDisplay_MinerScreen, tDisplay_ClockScreen, tDisplay_GlobalHashScreen, tDisplay_BTCprice};
DisplayDriver tDisplayDriver = {
tDisplay_Init,

View File

@ -195,6 +195,44 @@ void tDisplay_GlobalHashScreen(unsigned long mElapsed)
background.pushSprite(0, 0);
}
void tDisplay_BTCprice(unsigned long mElapsed)
{
clock_data data = getClockData(mElapsed);
// Print background screen
background.pushImage(0, 0, priceScreenWidth, priceScreenHeight, priceScreen);
Serial.printf(">>> Completed %s share(s), %s Khashes, avg. hashrate %s KH/s\n",
data.completedShares.c_str(), data.totalKHashes.c_str(), data.currentHashRate.c_str());
// Hashrate
render.setFontSize(25);
render.setCursor(19, 122);
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), 70, 103, TFT_BLACK);
// Print BlockHeight
render.setFontSize(18);
render.rdrawString(data.blockHeight.c_str(), 190, 110, TFT_WHITE);
// Print Hour
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.currentTime.c_str(), 148, 1, GFXFF);
// Print BTC Price
background.setFreeFont(FF24);
background.setTextDatum(TR_DATUM);
background.setTextSize(1);
background.setTextColor(0xDEDB, TFT_BLACK);
background.drawString(data.btcPrice.c_str(), 70, 25, GFXFF);
// Push prepared background to screen
background.pushSprite(0, 0);
}
void tDisplay_LoadingScreen(void)
{
tft.fillScreen(TFT_BLACK);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,8 +4,8 @@
#include <esp_task_wdt.h>
#include <nvs_flash.h>
#include <nvs.h>
#include "ShaTests/nerdSHA256.h"
//#include "ShaTests/nerdSHA256plus.h"
//#include "ShaTests/nerdSHA256.h"
#include "ShaTests/nerdSHA256plus.h"
#include "stratum.h"
#include "mining.h"
#include "utils.h"
@ -133,26 +133,12 @@ void runStratumWorker(void *name) {
continue;
}
//Test vars:
//************
//Nerdminerpool
// strcpy(poolString, "nerdminerPool");
// portNumber = 3002;
// strcpy(btcString,"test");
//Braiins
//strcpy(poolString, "eu.stratum.braiins.com");
//portNumber = 3333;
//strcpy(btcString,"Bitmaker.01");
//CKpool
//strcpy(poolString, "solo.ckpool.org");
//portNumber = 3333;
//strcpy(btcString,"test");
if(!checkPoolConnection())
if(!checkPoolConnection()){
//If server is not reachable add random delay for connection retries
srand(millis());
//Generate value between 1 and 15 secs
vTaskDelay(((1 + rand() % 15) * 1000) / portTICK_PERIOD_MS);
//Generate value between 1 and 120 secs
vTaskDelay(((1 + rand() % 120) * 1000) / portTICK_PERIOD_MS);
}
if(!isMinerSuscribed){
@ -256,14 +242,12 @@ void runMiner(void * task_id) {
mMonitor.NerdStatus = NM_hashing;
//Prepare Premining data
nerd_sha256 nerdMidstate;
//nerdSHA256_context nerdMidstate; //NerdShaplus
nerdSHA256_context nerdMidstate; //NerdShaplus
uint8_t hash[32];
//Calcular midstate
nerd_midstate(&nerdMidstate, mMiner.bytearray_blockheader, 64);
//nerd_mids(&nerdMidstate, mMiner.bytearray_blockheader); //NerdShaplus
nerd_mids(&nerdMidstate, mMiner.bytearray_blockheader); //NerdShaplus
// search a valid nonce
@ -290,8 +274,8 @@ void runMiner(void * task_id) {
memcpy(mMiner.bytearray_blockheader2 + 76, &nonce, 4);
nerd_double_sha2(&nerdMidstate, header64, hash);
//is16BitShare=nerd_sha256d(&nerdMidstate, header64, hash); //Boosted 80Khs sha
//nerd_double_sha2(&nerdMidstate, header64, hash);
is16BitShare=nerd_sha256d(&nerdMidstate, header64, hash); //Boosted 80Khs sha
/*Serial.print("hash1: ");
for (size_t i = 0; i < 32; i++)

View File

@ -152,7 +152,7 @@ String getBTCprice(void){
DynamicJsonDocument doc(1024);
deserializeJson(doc, payload);
if (doc.containsKey("bitcoin")) bitcoin_price = doc["last_trade_price"];
if (doc.containsKey("last_trade_price")) bitcoin_price = doc["last_trade_price"];
doc.clear();
@ -193,6 +193,24 @@ void getTime(unsigned long* currentHours, unsigned long* currentMinutes, unsigne
*currentSeconds = currentTime % 60;
}
String getDate(){
unsigned long elapsedTime = (millis() - mTriggerUpdate) / 1000; // Tiempo transcurrido en segundos
unsigned long currentTime = initialTime + elapsedTime; // La hora actual
// Convierte la hora actual (epoch time) en una estructura tm
struct tm *tm = localtime((time_t *)&currentTime);
int year = tm->tm_year + 1900; // tm_year es el número de años desde 1900
int month = tm->tm_mon + 1; // tm_mon es el mes del año desde 0 (enero) hasta 11 (diciembre)
int day = tm->tm_mday; // tm_mday es el día del mes
char currentDate[20];
sprintf(currentDate, "%02d/%02d/%04d", tm->tm_mday, tm->tm_mon + 1, tm->tm_year + 1900);
return String(currentDate);
}
String getTime(void){
unsigned long currentHours, currentMinutes, currentSeconds;
getTime(&currentHours, &currentMinutes, &currentSeconds);
@ -248,6 +266,7 @@ clock_data getClockData(unsigned long mElapsed)
data.btcPrice = getBTCprice();
data.blockHeight = getBlockHeight();
data.currentTime = getTime();
data.currentDate = getDate();
return data;
}

View File

@ -76,6 +76,7 @@ typedef struct {
String btcPrice;
String blockHeight;
String currentTime;
String currentDate;
}clock_data;
typedef struct {

View File

@ -1,6 +1,6 @@
#ifndef VERSION_H
#define VERSION_H
#define CURRENT_VERSION "V1.6.2"
#define CURRENT_VERSION "V1.6.3"
#endif // VERSION_H

View File

@ -134,9 +134,6 @@ void init_WifiManager()
// Text box (Number) - 7 characters maximum
WiFiManagerParameter port_text_box_num("Poolport", "Pool port", convertedValue, 7);
// Text box (String) - 80 characters maximum
WiFiManagerParameter password_text_box("Poolpassword", "Pool password", Settings.PoolPassword, 80);
// Text box (String) - 80 characters maximum
WiFiManagerParameter addr_text_box("btcAddress", "Your BTC address", Settings.BtcWallet, 80);
@ -153,6 +150,8 @@ void init_WifiManager()
strcat(checkboxParams, " checked");
}
WiFiManagerParameter save_stats_to_nvs("SaveStatsToNVS", "Track Uptime, Best Diff, Total Hashes in device Flash memory. (Experimental)", "T", 2, checkboxParams, WFM_LABEL_AFTER);
// Text box (String) - 80 characters maximum
WiFiManagerParameter password_text_box("Poolpassword - Optionl", "Pool password", Settings.PoolPassword, 80);
// Add all defined parameters
wm.addParameter(&pool_text_box);