mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-10-11 03:32:45 +02:00
* Verify CHIP_ID response Fixes #740 * Log warning on CHIP_ID mismatch * Fix CHIP_ID checksum calculation * On BM1397, CORE_NUM should be 0x18 * CORE_NUM and ADDR log only and early exit when no chips are detected * Fix compile error * Refactored out duplicated code Moved count_asic_chips and receive_work functions to common.c Moved asic_response_buffer to local scope Unified preamble and crc check on serial rx Fixed typo in proccess_work Moved CRC5_MASK define to proper location * Change receive_work read timeout log to debug * Changed wrong log to debug * Fix merge * Fix length check for bm1397 * add ASIC TX dubugging on BM1397 (crap, does this fix the ticket mask?!) --------- Co-authored-by: Skot <skot@bitnet.cx>
69 lines
2.4 KiB
C
69 lines
2.4 KiB
C
#include <lwip/tcpip.h>
|
|
|
|
#include "system.h"
|
|
#include "work_queue.h"
|
|
#include "serial.h"
|
|
#include "bm1397.h"
|
|
#include <string.h>
|
|
#include "esp_log.h"
|
|
#include "nvs_config.h"
|
|
#include "utils.h"
|
|
#include "stratum_task.h"
|
|
#include "asic.h"
|
|
|
|
static const char *TAG = "asic_result";
|
|
|
|
void ASIC_result_task(void *pvParameters)
|
|
{
|
|
GlobalState *GLOBAL_STATE = (GlobalState *)pvParameters;
|
|
|
|
while (1)
|
|
{
|
|
//task_result *asic_result = (*GLOBAL_STATE->ASIC_functions.receive_result_fn)(GLOBAL_STATE);
|
|
task_result *asic_result = ASIC_process_work(GLOBAL_STATE);
|
|
|
|
if (asic_result == NULL)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
uint8_t job_id = asic_result->job_id;
|
|
|
|
if (GLOBAL_STATE->valid_jobs[job_id] == 0)
|
|
{
|
|
ESP_LOGW(TAG, "Invalid job nonce found, 0x%02X", job_id);
|
|
continue;
|
|
}
|
|
|
|
// check the nonce difficulty
|
|
double nonce_diff = test_nonce_value(
|
|
GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id],
|
|
asic_result->nonce,
|
|
asic_result->rolled_version);
|
|
|
|
//log the ASIC response
|
|
ESP_LOGI(TAG, "Ver: %08" PRIX32 " Nonce %08" PRIX32 " diff %.1f of %ld.", asic_result->rolled_version, asic_result->nonce, nonce_diff, GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->pool_diff);
|
|
|
|
if (nonce_diff >= GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->pool_diff)
|
|
{
|
|
char * user = GLOBAL_STATE->SYSTEM_MODULE.is_using_fallback ? GLOBAL_STATE->SYSTEM_MODULE.fallback_pool_user : GLOBAL_STATE->SYSTEM_MODULE.pool_user;
|
|
int ret = STRATUM_V1_submit_share(
|
|
GLOBAL_STATE->sock,
|
|
GLOBAL_STATE->send_uid++,
|
|
user,
|
|
GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->jobid,
|
|
GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->extranonce2,
|
|
GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->ntime,
|
|
asic_result->nonce,
|
|
asic_result->rolled_version ^ GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->version);
|
|
|
|
if (ret < 0) {
|
|
ESP_LOGI(TAG, "Unable to write share to socket. Closing connection. Ret: %d (errno %d: %s)", ret, errno, strerror(errno));
|
|
stratum_close_connection(GLOBAL_STATE);
|
|
}
|
|
}
|
|
|
|
SYSTEM_notify_found_nonce(GLOBAL_STATE, nonce_diff, job_id);
|
|
}
|
|
}
|