mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-03-18 05:42:16 +01:00
try to explain nonce space duration from paramters (#228)
* try to explain nonce space duration from paramters * Fix Nonce Space duration for BM1397 (no version-rolling) * fixed issue with version mask on 1397. added easy serial debugging on 1397 * cleanup jobID debugs --------- Co-authored-by: Skot <skot@bitnet.cx>
This commit is contained in:
parent
e760af7831
commit
9dc8c8cad3
@ -684,7 +684,7 @@ task_result * BM1366_proccess_work(void * pvParameters)
|
||||
|
||||
uint8_t job_id = asic_result->job_id;
|
||||
uint8_t rx_job_id = job_id & 0xf8;
|
||||
ESP_LOGI(TAG, "RX Job ID: %02X", rx_job_id);
|
||||
ESP_LOGI(TAG, "Job ID: %02X, RX: %02X", job_id, rx_job_id);
|
||||
|
||||
GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters;
|
||||
|
||||
|
@ -525,9 +525,8 @@ task_result * BM1368_proccess_work(void * pvParameters)
|
||||
}
|
||||
|
||||
uint8_t job_id = asic_result->job_id;
|
||||
ESP_LOGI(TAG, "Job ID: %02X", job_id);
|
||||
uint8_t rx_job_id = ((int8_t)job_id & 0xf0) >> 1;
|
||||
ESP_LOGI(TAG, "RX Job ID: %02X", rx_job_id);
|
||||
ESP_LOGI(TAG, "Job ID: %02X, RX: %02X", job_id, rx_job_id);
|
||||
|
||||
GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters;
|
||||
|
||||
|
@ -108,7 +108,7 @@ static void _send_read_address(void)
|
||||
{
|
||||
unsigned char read_address[2] = {0x00, 0x00};
|
||||
// send serial data
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_READ), read_address, 2, false);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_READ), read_address, 2, BM1937_SERIALTX_DEBUG);
|
||||
}
|
||||
|
||||
static void _send_chain_inactive(void)
|
||||
@ -116,7 +116,7 @@ static void _send_chain_inactive(void)
|
||||
|
||||
unsigned char read_address[2] = {0x00, 0x00};
|
||||
// send serial data
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_INACTIVE), read_address, 2, false);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_INACTIVE), read_address, 2, BM1937_SERIALTX_DEBUG);
|
||||
}
|
||||
|
||||
static void _set_chip_address(uint8_t chipAddr)
|
||||
@ -124,7 +124,7 @@ static void _set_chip_address(uint8_t chipAddr)
|
||||
|
||||
unsigned char read_address[2] = {chipAddr, 0x00};
|
||||
// send serial data
|
||||
_send_BM1397((TYPE_CMD | GROUP_SINGLE | CMD_SETADDRESS), read_address, 2, false);
|
||||
_send_BM1397((TYPE_CMD | GROUP_SINGLE | CMD_SETADDRESS), read_address, 2, BM1937_SERIALTX_DEBUG);
|
||||
}
|
||||
|
||||
// borrowed from cgminer driver-gekko.c calc_gsf_freq()
|
||||
@ -203,12 +203,12 @@ void BM1397_send_hash_frequency(float frequency)
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), prefreq1, 6, false);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), prefreq1, 6, BM1937_SERIALTX_DEBUG);
|
||||
}
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), freqbuf, 6, false);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), freqbuf, 6, BM1937_SERIALTX_DEBUG);
|
||||
}
|
||||
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
@ -241,24 +241,24 @@ static void _send_init(uint64_t frequency, uint16_t asic_count)
|
||||
}
|
||||
|
||||
unsigned char init[6] = {0x00, CLOCK_ORDER_CONTROL_0, 0x00, 0x00, 0x00, 0x00}; // init1 - clock_order_control0
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init, 6, false);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init, 6, BM1937_SERIALTX_DEBUG);
|
||||
|
||||
unsigned char init2[6] = {0x00, CLOCK_ORDER_CONTROL_1, 0x00, 0x00, 0x00, 0x00}; // init2 - clock_order_control1
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init2, 6, false);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init2, 6, BM1937_SERIALTX_DEBUG);
|
||||
|
||||
unsigned char init3[9] = {0x00, ORDERED_CLOCK_ENABLE, 0x00, 0x00, 0x00, 0x01}; // init3 - ordered_clock_enable
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init3, 6, false);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init3, 6, BM1937_SERIALTX_DEBUG);
|
||||
|
||||
unsigned char init4[9] = {0x00, CORE_REGISTER_CONTROL, 0x80, 0x00, 0x80, 0x74}; // init4 - init_4_?
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init4, 6, false);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init4, 6, BM1937_SERIALTX_DEBUG);
|
||||
|
||||
BM1397_set_job_difficulty_mask(256);
|
||||
|
||||
unsigned char init5[9] = {0x00, PLL3_PARAMETER, 0xC0, 0x70, 0x01, 0x11}; // init5 - pll3_parameter
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init5, 6, false);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init5, 6, BM1937_SERIALTX_DEBUG);
|
||||
|
||||
unsigned char init6[9] = {0x00, FAST_UART_CONFIGURATION, 0x06, 0x00, 0x00, 0x0F}; // init6 - fast_uart_configuration
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init6, 6, false);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init6, 6, BM1937_SERIALTX_DEBUG);
|
||||
|
||||
BM1397_set_default_baud();
|
||||
|
||||
@ -301,7 +301,7 @@ int BM1397_set_default_baud(void)
|
||||
{
|
||||
// default divider of 26 (11010) for 115,749
|
||||
unsigned char baudrate[9] = {0x00, MISC_CONTROL, 0x00, 0x00, 0b01111010, 0b00110001}; // baudrate - misc_control
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), baudrate, 6, false);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), baudrate, 6, BM1937_SERIALTX_DEBUG);
|
||||
return 115749;
|
||||
}
|
||||
|
||||
@ -311,7 +311,7 @@ int BM1397_set_max_baud(void)
|
||||
ESP_LOGI(TAG, "Setting max baud of 3125000");
|
||||
unsigned char baudrate[9] = {0x00, MISC_CONTROL, 0x00, 0x00, 0b01100000, 0b00110001};
|
||||
; // baudrate - misc_control
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), baudrate, 6, false);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), baudrate, 6, BM1937_SERIALTX_DEBUG);
|
||||
return 3125000;
|
||||
}
|
||||
|
||||
@ -341,7 +341,7 @@ void BM1397_set_job_difficulty_mask(int difficulty)
|
||||
|
||||
ESP_LOGI(TAG, "Setting job ASIC mask to %d", difficulty);
|
||||
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), job_difficulty_mask, 6, false);
|
||||
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), job_difficulty_mask, 6, BM1937_SERIALTX_DEBUG);
|
||||
}
|
||||
|
||||
static uint8_t id = 0;
|
||||
@ -384,7 +384,7 @@ void BM1397_send_work(void *pvParameters, bm_job *next_bm_job)
|
||||
// ESP_LOGI(TAG, "Added Job: %i", job.job_id);
|
||||
pthread_mutex_unlock(&GLOBAL_STATE->valid_jobs_lock);
|
||||
|
||||
_send_BM1397((TYPE_JOB | GROUP_SINGLE | CMD_WRITE), &job, sizeof(job_packet), false);
|
||||
_send_BM1397((TYPE_JOB | GROUP_SINGLE | CMD_WRITE), &job, sizeof(job_packet), BM1397_DEBUG_WORK);
|
||||
}
|
||||
|
||||
asic_result *BM1397_receive_work(void)
|
||||
|
@ -8,12 +8,8 @@
|
||||
#define CRC5_MASK 0x1F
|
||||
#define BM1366_INITIAL_DIFFICULTY 256
|
||||
|
||||
// static const uint64_t BM1366_FREQUENCY = CONFIG_ASIC_FREQUENCY;
|
||||
static const uint64_t BM1366_CORE_COUNT = 672;
|
||||
// static const uint64_t BM1366_HASHRATE_S = BM1366_FREQUENCY * BM1366_CORE_COUNT * 1000000;
|
||||
// 2^32
|
||||
// static const uint64_t NONCE_SPACE = 4294967296;
|
||||
static const double BM1366_FULLSCAN_MS = 2140;
|
||||
static const uint64_t BM1366_CORE_COUNT = 112;
|
||||
static const uint64_t BM1366_SMALL_CORE_COUNT = 894;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -9,12 +9,8 @@
|
||||
|
||||
#define BM1368_INITIAL_DIFFICULTY 256
|
||||
|
||||
// static const uint64_t BM1368_FREQUENCY = CONFIG_ASIC_FREQUENCY;
|
||||
static const uint64_t BM1368_CORE_COUNT = 672;
|
||||
// static const uint64_t BM1368_HASHRATE_S = BM1368_FREQUENCY * BM1368_CORE_COUNT * 1000000;
|
||||
// 2^32
|
||||
// static const uint64_t NONCE_SPACE = 4294967296;
|
||||
static const double BM1368_FULLSCAN_MS = 2140;
|
||||
static const uint64_t BM1368_CORE_COUNT = 80;
|
||||
static const uint64_t BM1368_SMALL_CORE_COUNT = 1276;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -8,12 +8,12 @@
|
||||
#define CRC5_MASK 0x1F
|
||||
#define BM1397_INITIAL_DIFFICULTY 256
|
||||
|
||||
// static const uint64_t ASIC_FREQUENCY = CONFIG_ASIC_FREQUENCY;
|
||||
static const uint64_t BM1397_CORE_COUNT = 672;
|
||||
// static const uint64_t BM1397_HASHRATE_S = ASIC_FREQUENCY * BM1397_CORE_COUNT * 1000000;
|
||||
// 2^32
|
||||
static const uint64_t NONCE_SPACE = 4294967296;
|
||||
// static const double BM1397_FULLSCAN_MS = ((double) NONCE_SPACE / (double) BM1397_HASHRATE_S) * 1000;
|
||||
#define BM1937_SERIALTX_DEBUG false
|
||||
#define BM1937_SERIALRX_DEBUG false
|
||||
#define BM1397_DEBUG_WORK false //causes insane amount of debug output
|
||||
|
||||
static const uint64_t BM1397_CORE_COUNT = 168;
|
||||
static const uint64_t BM1397_SMALL_CORE_COUNT = 672;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ int SERIAL_send(uint8_t *data, int len, bool debug)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
printf("->");
|
||||
printf("tx: ");
|
||||
prettyHex((unsigned char *)data, len);
|
||||
printf("\n");
|
||||
}
|
||||
@ -67,11 +67,15 @@ int SERIAL_send(uint8_t *data, int len, bool debug)
|
||||
int16_t SERIAL_rx(uint8_t *buf, uint16_t size, uint16_t timeout_ms)
|
||||
{
|
||||
int16_t bytes_read = uart_read_bytes(UART_NUM_1, buf, size, timeout_ms / portTICK_PERIOD_MS);
|
||||
// if (bytes_read > 0) {
|
||||
// printf("rx: ");
|
||||
// prettyHex((unsigned char*) buf, bytes_read);
|
||||
// printf("\n");
|
||||
// }
|
||||
|
||||
#if BM1937_SERIALRX_DEBUG
|
||||
if (bytes_read > 0) {
|
||||
printf("rx: ");
|
||||
prettyHex((unsigned char*) buf, bytes_read);
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ export class HomeComponent {
|
||||
);
|
||||
|
||||
this.expectedHashRate$ = this.info$.pipe(map(info => {
|
||||
return Math.floor(info.frequency * ((info.coreCount * info.asicCount) / 1000))
|
||||
return Math.floor(info.frequency * ((info.smallCoreCount * info.asicCount) / 1000))
|
||||
}))
|
||||
|
||||
this.quickLink$ = this.info$.pipe(
|
||||
|
@ -41,7 +41,7 @@ export class SystemService {
|
||||
sharesRejected: 0,
|
||||
uptimeSeconds: 38,
|
||||
asicCount: 1,
|
||||
coreCount: 672,
|
||||
smallCoreCount: 672,
|
||||
ASICModel: eASICModel.BM1366,
|
||||
stratumURL: "public-pool.io",
|
||||
stratumPort: 21496,
|
||||
|
@ -22,7 +22,7 @@ export interface ISystemInfo {
|
||||
sharesRejected: number,
|
||||
uptimeSeconds: number,
|
||||
asicCount: number,
|
||||
coreCount: number,
|
||||
smallCoreCount: number,
|
||||
ASICModel: eASICModel,
|
||||
stratumURL: string,
|
||||
stratumPort: number,
|
||||
|
@ -378,23 +378,23 @@ static esp_err_t GET_system_info(httpd_req_t * req)
|
||||
cJSON_AddNumberToObject(root, "sharesRejected", GLOBAL_STATE->SYSTEM_MODULE.shares_rejected);
|
||||
cJSON_AddNumberToObject(root, "uptimeSeconds", (esp_timer_get_time() - GLOBAL_STATE->SYSTEM_MODULE.start_time) / 1000000);
|
||||
cJSON_AddNumberToObject(root, "asicCount", GLOBAL_STATE->asic_count);
|
||||
uint16_t core_count = 0;
|
||||
uint16_t small_core_count = 0;
|
||||
switch (GLOBAL_STATE->asic_model){
|
||||
case ASIC_BM1397:
|
||||
core_count = BM1397_CORE_COUNT;
|
||||
small_core_count = BM1397_SMALL_CORE_COUNT;
|
||||
break;
|
||||
case ASIC_BM1366:
|
||||
core_count = BM1366_CORE_COUNT;
|
||||
small_core_count = BM1366_SMALL_CORE_COUNT;
|
||||
break;
|
||||
case ASIC_BM1368:
|
||||
core_count = BM1368_CORE_COUNT;
|
||||
small_core_count = BM1368_SMALL_CORE_COUNT;
|
||||
break;
|
||||
case ASIC_UNKNOWN:
|
||||
default:
|
||||
core_count = -1;
|
||||
small_core_count = -1;
|
||||
break;
|
||||
}
|
||||
cJSON_AddNumberToObject(root, "coreCount", core_count);
|
||||
cJSON_AddNumberToObject(root, "smallCoreCount", small_core_count);
|
||||
cJSON_AddStringToObject(root, "ASICModel", GLOBAL_STATE->asic_model_str);
|
||||
cJSON_AddStringToObject(root, "stratumURL", stratumURL);
|
||||
cJSON_AddNumberToObject(root, "stratumPort", nvs_config_get_u16(NVS_CONFIG_STRATUM_PORT, CONFIG_STRATUM_PORT));
|
||||
|
11
main/main.c
11
main/main.c
@ -20,6 +20,7 @@
|
||||
static GlobalState GLOBAL_STATE = {.extranonce_str = NULL, .extranonce_2_len = 0, .abandon_work = 0, .version_mask = 0};
|
||||
|
||||
static const char * TAG = "miner";
|
||||
static const double NONCE_SPACE = 4294967296.0; // 2^32
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
@ -65,7 +66,7 @@ void app_main(void)
|
||||
.set_max_baud_fn = BM1366_set_max_baud,
|
||||
.set_difficulty_mask_fn = BM1366_set_job_difficulty_mask,
|
||||
.send_work_fn = BM1366_send_work};
|
||||
GLOBAL_STATE.asic_job_frequency_ms = BM1366_FULLSCAN_MS / (double) GLOBAL_STATE.asic_count;
|
||||
GLOBAL_STATE.asic_job_frequency_ms = (NONCE_SPACE / (double) (GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value * BM1366_CORE_COUNT * 1000)) / (double) GLOBAL_STATE.asic_count; // version-rolling so Small Cores have different Nonce Space
|
||||
GLOBAL_STATE.initial_ASIC_difficulty = BM1366_INITIAL_DIFFICULTY;
|
||||
|
||||
GLOBAL_STATE.ASIC_functions = ASIC_functions;
|
||||
@ -77,9 +78,7 @@ void app_main(void)
|
||||
.set_max_baud_fn = BM1368_set_max_baud,
|
||||
.set_difficulty_mask_fn = BM1368_set_job_difficulty_mask,
|
||||
.send_work_fn = BM1368_send_work};
|
||||
|
||||
uint64_t bm1368_hashrate = GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value * BM1368_CORE_COUNT * 1000000;
|
||||
GLOBAL_STATE.asic_job_frequency_ms = (((double) NONCE_SPACE / (double) bm1368_hashrate) * 1000) / (double) GLOBAL_STATE.asic_count;
|
||||
GLOBAL_STATE.asic_job_frequency_ms = (NONCE_SPACE / (double) (GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value * BM1368_CORE_COUNT * 1000)) / (double) GLOBAL_STATE.asic_count; // version-rolling so Small Cores have different Nonce Space
|
||||
GLOBAL_STATE.initial_ASIC_difficulty = BM1368_INITIAL_DIFFICULTY;
|
||||
|
||||
GLOBAL_STATE.ASIC_functions = ASIC_functions;
|
||||
@ -91,9 +90,7 @@ void app_main(void)
|
||||
.set_max_baud_fn = BM1397_set_max_baud,
|
||||
.set_difficulty_mask_fn = BM1397_set_job_difficulty_mask,
|
||||
.send_work_fn = BM1397_send_work};
|
||||
|
||||
uint64_t bm1397_hashrate = GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value * BM1397_CORE_COUNT * 1000000;
|
||||
GLOBAL_STATE.asic_job_frequency_ms = (((double) NONCE_SPACE / (double) bm1397_hashrate) * 1000) / (double) GLOBAL_STATE.asic_count;
|
||||
GLOBAL_STATE.asic_job_frequency_ms = (NONCE_SPACE / (double) (GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value * BM1397_SMALL_CORE_COUNT * 1000)) / (double) GLOBAL_STATE.asic_count; // no version-rolling so same Nonce Space is splitted between Small Cores
|
||||
GLOBAL_STATE.initial_ASIC_difficulty = BM1397_INITIAL_DIFFICULTY;
|
||||
|
||||
GLOBAL_STATE.ASIC_functions = ASIC_functions;
|
||||
|
@ -43,7 +43,6 @@ void ASIC_task(void *pvParameters)
|
||||
(*GLOBAL_STATE->ASIC_functions.send_work_fn)(GLOBAL_STATE, next_bm_job); // send the job to the ASIC
|
||||
|
||||
// Time to execute the above code is ~0.3ms
|
||||
// vTaskDelay((BM1397_FULLSCAN_MS - 0.3 ) / portTICK_PERIOD_MS);
|
||||
vTaskDelay((GLOBAL_STATE->asic_job_frequency_ms - 0.3) / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
@ -145,75 +145,36 @@ void POWER_MANAGEMENT_task(void * pvParameters)
|
||||
case DEVICE_ULTRA:
|
||||
case DEVICE_SUPRA:
|
||||
power_management->chip_temp_avg = EMC2101_get_external_temp();
|
||||
|
||||
if ((power_management->chip_temp_avg > THROTTLE_TEMP) &&
|
||||
(power_management->frequency_value > 50 || power_management->voltage > 1000)) {
|
||||
ESP_LOGE(TAG, "OVERHEAT");
|
||||
|
||||
EMC2101_set_fan_speed(1);
|
||||
if (power_management->HAS_POWER_EN) {
|
||||
gpio_set_level(GPIO_NUM_10, 1);
|
||||
}
|
||||
nvs_config_set_u16(NVS_CONFIG_ASIC_VOLTAGE, 990);
|
||||
nvs_config_set_u16(NVS_CONFIG_ASIC_FREQ, 50);
|
||||
nvs_config_set_u16(NVS_CONFIG_FAN_SPEED, 100);
|
||||
nvs_config_set_u16(NVS_CONFIG_AUTO_FAN_SPEED, 0);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
|
||||
// Voltage
|
||||
// We'll throttle between 4.9v and 3.5v
|
||||
float voltage_multiplier =
|
||||
_fbound((power_management->voltage - VOLTAGE_MIN_THROTTLE) * (1 / (float) VOLTAGE_RANGE), 0, 1);
|
||||
|
||||
// Temperature
|
||||
float temperature_multiplier = 1;
|
||||
float over_temp = -(THROTTLE_TEMP - power_management->chip_temp_avg);
|
||||
if (over_temp > 0) {
|
||||
temperature_multiplier = (THROTTLE_TEMP_RANGE - over_temp) / THROTTLE_TEMP_RANGE;
|
||||
}
|
||||
|
||||
float lowest_multiplier = 1;
|
||||
float multipliers[2] = {voltage_multiplier, temperature_multiplier};
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (multipliers[i] < lowest_multiplier) {
|
||||
lowest_multiplier = multipliers[i];
|
||||
}
|
||||
}
|
||||
|
||||
power_management->frequency_multiplier = lowest_multiplier;
|
||||
|
||||
float target_frequency = _fbound(power_management->frequency_multiplier * frequency_target, 0, frequency_target);
|
||||
|
||||
if (target_frequency < 50) {
|
||||
// TODO: Turn the chip off
|
||||
}
|
||||
|
||||
// chip is coming back from a low/no voltage event
|
||||
if (power_management->frequency_value < 50 && target_frequency > 50) {
|
||||
// TODO recover gracefully?
|
||||
ESP_LOGE(TAG, "Freq %f", power_management->frequency_value);
|
||||
ESP_LOGI(TAG, "Restarting System because of ERROR: low/no voltage event");
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
if (power_management->frequency_value > target_frequency) {
|
||||
power_management->frequency_value = target_frequency;
|
||||
last_frequency_increase = 0;
|
||||
BM1397_send_hash_frequency(power_management->frequency_value);
|
||||
ESP_LOGI(TAG, "target %f, Freq %f, Temp %f, Power %f", target_frequency, power_management->frequency_value,
|
||||
power_management->chip_temp_avg, power_management->power);
|
||||
} else {
|
||||
if (last_frequency_increase > 120 && power_management->frequency_value != frequency_target) {
|
||||
float add = (target_frequency + power_management->frequency_value) / 2;
|
||||
power_management->frequency_value += _fbound(add, 2, 20);
|
||||
BM1397_send_hash_frequency(power_management->frequency_value);
|
||||
ESP_LOGI(TAG, "target %f, Freq %f, Temp %f, Power %f", target_frequency, power_management->frequency_value,
|
||||
power_management->chip_temp_avg, power_management->power);
|
||||
last_frequency_increase = 60;
|
||||
} else {
|
||||
last_frequency_increase++;
|
||||
}
|
||||
}
|
||||
} else if (GLOBAL_STATE->asic_model == ASIC_BM1366 || GLOBAL_STATE->asic_model == ASIC_BM1368) {
|
||||
switch (GLOBAL_STATE->device_model) {
|
||||
case DEVICE_MAX:
|
||||
case DEVICE_ULTRA:
|
||||
case DEVICE_SUPRA:
|
||||
power_management->chip_temp_avg = EMC2101_get_internal_temp() + 5;
|
||||
|
||||
if (GLOBAL_STATE->board_version == 402) {
|
||||
power_management->chip_temp_avg = EMC2101_get_external_temp();
|
||||
power_management->vr_temp = (float)TPS546_get_temperature();
|
||||
} else {
|
||||
power_management->chip_temp_avg = EMC2101_get_internal_temp() + 5;
|
||||
power_management->vr_temp = 0.0;
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ void stratum_task(void * pvParameters)
|
||||
ESP_LOGI(TAG, "Set stratum difficulty: %ld", SYSTEM_TASK_MODULE.stratum_difficulty);
|
||||
}
|
||||
} else if (stratum_api_v1_message.method == MINING_SET_VERSION_MASK ||
|
||||
stratum_api_v1_message.method == .0) {
|
||||
stratum_api_v1_message.method == STRATUM_RESULT_VERSION_MASK) {
|
||||
// 1fffe000
|
||||
ESP_LOGI(TAG, "Set version mask: %08lx", stratum_api_v1_message.version_mask);
|
||||
GLOBAL_STATE->version_mask = stratum_api_v1_message.version_mask;
|
||||
|
Loading…
x
Reference in New Issue
Block a user