This commit is contained in:
Ben 2023-12-10 00:43:11 -05:00
commit 75f59be131
5 changed files with 66 additions and 87 deletions

View File

@ -413,7 +413,6 @@ task_result *BM1397_proccess_work(void *pvParameters)
ESP_LOGI(TAG, "return null");
return NULL;
}
ESP_LOGI(TAG, "return not null");
uint8_t nonce_found = 0;
uint32_t first_nonce = 0;

View File

@ -65,7 +65,7 @@ void STRATUM_V1_free_mining_notify(mining_notify *params);
int STRATUM_V1_authenticate(int socket, const char *username);
void STRATUM_V1_configure_version_rolling(int socket);
void STRATUM_V1_configure_version_rolling(int socket, uint32_t * version_mask);
int STRATUM_V1_suggest_difficulty(int socket, uint32_t difficulty);

View File

@ -333,14 +333,26 @@ void STRATUM_V1_submit_share(int socket, const char *username, const char *jobid
write(socket, submit_msg, strlen(submit_msg));
}
void STRATUM_V1_configure_version_rolling(int socket)
void STRATUM_V1_configure_version_rolling(int socket, uint32_t * version_mask)
{
// Configure
char configure_msg[BUFFER_SIZE * 2];
sprintf(configure_msg, "{\"id\": %d, \"method\": \"mining.configure\", \"params\": [[\"version-rolling\"], {\"version-rolling.mask\": \"ffffffff\"}]}\n", send_uid++);
ESP_LOGI(TAG, "tx: %s", configure_msg);
write(socket, configure_msg, strlen(configure_msg));
char * line;
line = STRATUM_V1_receive_jsonrpc_line(socket);
ESP_LOGI(TAG, "Received result %s", line);
StratumApiV1Message stratum_api_v1_message;
STRATUM_V1_parse(&stratum_api_v1_message, line);
if (stratum_api_v1_message.method == MINING_SET_VERSION_MASK || stratum_api_v1_message.method == STRATUM_RESULT_VERSION_MASK) {
*version_mask = stratum_api_v1_message.version_mask;
ESP_LOGI(TAG, "Set version mask: %08lx", *version_mask);
}
free(line);
return;
}

View File

@ -93,11 +93,11 @@ void stratum_task(void *pvParameters)
break;
}
STRATUM_V1_configure_version_rolling(GLOBAL_STATE->sock, &GLOBAL_STATE->version_mask);
STRATUM_V1_subscribe(GLOBAL_STATE->sock, &GLOBAL_STATE->extranonce_str, &GLOBAL_STATE->extranonce_2_len,
GLOBAL_STATE->asic_model);
STRATUM_V1_configure_version_rolling(GLOBAL_STATE->sock);
char *username = nvs_config_get_string(NVS_CONFIG_STRATUM_USER, STRATUM_USER);
STRATUM_V1_authenticate(GLOBAL_STATE->sock, username);
free(username);

130
readme.md
View File

@ -1,99 +1,67 @@
[![](https://dcbadge.vercel.app/api/server/3E8ca2dkcC)](https://discord.gg/3E8ca2dkcC)
# ESP-Miner
| Supported Targets | ESP32-S3 (BitAxe v2+) |
| ----------------- | --------------------- |
## Requires Python3.4 or later and pip
## Requires ESP-IDF v5.1
Install bitaxetool from pip. pip is included with Python 3.4 but if you need to install it check <https://pip.pypa.io/en/stable/installation/>
You can chose between 2 methods of installations:
### Manual Installation
Follow the official [instructions](https://docs.espressif.com/projects/esp-idf/en/release-v5.1/esp32s3/get-started/index.html#manual-installation).
### ESP-IDF Visual Studio Code Extension
Install the "Espressif IDF" extension, it will automate the IDF installation for you.
```
pip install --upgrade bitaxetool
```
## Hardware Required
This firmware is designed to run on a BitAxe v2+
## Configure the project
If you do have a Bitaxe with no USB connectivity make sure to establish a serial connection with either a JTAG ESP-Prog device or a USB-to-UART bridge
Set the target
## Preconfiguration
Starting with v2.0.0, the ESP-Miner firmware requires some basic manufacturing data to be flashed in the NVS partition.
1. Download the esp-miner-factory-v2.0.3.bin file from the release tab.
Click [here](https://github.com/skot/ESP-Miner/releases) for the release tab
2. Copy `config.cvs.example` to `config.cvs` and modify `asicfrequency`, `asicvoltage`, `asicmodel`, `devicemodel`, and `boardversion`
The following are recommendations but it is necessary that you do have all values in your `config.cvs`file to flash properly.
- recommended values for the Bitaxe 1366 (ultra)
```
key,type,encoding,value
main,namespace,,
asicfrequency,data,u16,485
asicvoltage,data,u16,1320
asicmodel,data,string,BM1366
devicemodel,data,string,ultra
boardversion,data,string,0.11
```
- recomended values for the Bitaxe 1397 (MAX)
```
key,type,encoding,value
main,namespace,,
asicfrequency,data,u16,475
asicvoltage,data,u16,1400
asicmodel,data,string,BM1397
devicemodel,data,string,max
boardversion,data,string,2.2
```
## Flash
The bitaxetool includes all necessary library for flashing the binary file to the Bitaxe Hardware.
The bitaxetool requires a config.cvs preloaded file and the appropiate firmware.bin file in it's executed directory.
3. Flash with the bitaxetool
```
idf.py set-target esp32s3
```
Use menuconfig to set the stratum server address/port and WiFi SSID/Password
```
idf.py menuconfig
```
Set following parameters under Stratum Configuration Options, these will define the stratum server you connect to:
* Set `Stratum Address` to the stratum pool domain name. example "public-pool.io"
* Set `Stratum Port` to the stratum pool port. example "21496"
* Set `Stratum username` to the stratum pool username. example "<my_BTC_address>.bitaxe"
* Set `Stratum password` to the stratum pool password. example "x"
Set following parameters under Example Connection Configuration Options:
* Set `WiFi SSID` to your target wifi network SSID.
* Set `Wifi Password` to the password for your target SSID.
For more information about the example_connect() method used here, check out <https://github.com/espressif/esp-idf/blob/master/examples/protocols/README.md>.
## Build website
To build the website for viewing and OTA updates open the Angular project found in
```
ESP-Miner\main\http_server\axe-os
```
Then install dependencies and build.
```
npm i
npm run build
```
When the esp-idf project is built it will bundle the website in www.bin
## Build and Flash
Build the project and flash it to the board, then run monitor tool to view serial output:
```
idf.py -p PORT flash monitor
```
(To exit the serial monitor, type ``Ctrl-]``.)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
## Run Unit tests
The unit tests for the project use the unity test framework and currently require actual esp32 hardware to run.
They are located at <https://github.com/johnny9/esp-miner/tree/master/components/stratum/test>
```
cd ./test/
idf.py set-target esp32s3
idf.py -p PORT flash monitor
bitaxetool --config ./config.cvs --firmware ./esp-miner-factory-v2.0.3.bin
```