mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-03-26 17:51:45 +01:00
Improved when to run self test and fail messages
This commit is contained in:
parent
75d5643c76
commit
493dbccfe5
@ -106,6 +106,16 @@ static esp_err_t register_write_byte(uint8_t reg_addr, uint8_t data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DS4432U_test(void)
|
||||
{
|
||||
uint8_t data[3];
|
||||
|
||||
/* Read the DS4432U+ WHO_AM_I register, on power up the register should have the value 0x00 */
|
||||
esp_err_t register_result = register_read(DS4432U_OUT0_REG, data, 1);
|
||||
ESP_LOGI(TAG, "DS4432U+ OUT1 = 0x%02X", data[0]);
|
||||
return register_result == ESP_OK;
|
||||
}
|
||||
|
||||
void DS4432U_read(void)
|
||||
{
|
||||
uint8_t data[3];
|
||||
|
@ -6,7 +6,7 @@
|
||||
esp_err_t i2c_master_init(void);
|
||||
esp_err_t i2c_master_delete(void);
|
||||
void DS4432U_read(void);
|
||||
|
||||
bool DS4432U_test(void);
|
||||
bool DS4432U_set_vcore(float);
|
||||
|
||||
#endif /* DS4432U_H_ */
|
@ -73,9 +73,12 @@ void app_main(void)
|
||||
GLOBAL_STATE.ASIC_functions = ASIC_functions;
|
||||
}
|
||||
|
||||
bool is_max = strcmp(GLOBAL_STATE.asic_model, "BM1397") == 0;
|
||||
uint64_t best_diff = nvs_config_get_u64(NVS_CONFIG_BEST_DIFF, 0);
|
||||
uint16_t should_self_test = nvs_config_get_u16(NVS_CONFIG_SELF_TEST, 1);
|
||||
if (should_self_test == 1) {
|
||||
if (should_self_test == 1 && !is_max && best_diff < 1) {
|
||||
self_test((void *) &GLOBAL_STATE);
|
||||
vTaskDelay(60 * 60 * 1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
xTaskCreate(SYSTEM_task, "SYSTEM_task", 4096, (void *) &GLOBAL_STATE, 3, NULL);
|
||||
@ -151,4 +154,3 @@ void MINER_set_wifi_status(wifi_status_t status, uint16_t retry_count)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,8 +45,7 @@ static bool core_voltage_pass()
|
||||
|
||||
void self_test(void * pvParameters)
|
||||
{
|
||||
bool ASIC_PASS = false;
|
||||
bool POWER_PASS = false;
|
||||
|
||||
GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters;
|
||||
SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE;
|
||||
|
||||
@ -86,20 +85,17 @@ void self_test(void * pvParameters)
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "SELF TEST...");
|
||||
OLED_writeString(0, 0, module->oled_buf);
|
||||
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "ASIC:");
|
||||
OLED_writeString(0, 1, module->oled_buf);
|
||||
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "POWER:");
|
||||
OLED_writeString(0, 2, module->oled_buf);
|
||||
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "FAN:");
|
||||
OLED_writeString(0, 3, module->oled_buf);
|
||||
}
|
||||
|
||||
if(!DS4432U_test()){
|
||||
if (OLED_status()) {
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "DS4432U:FAIL");
|
||||
OLED_writeString(0, 2, module->oled_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SERIAL_init();
|
||||
uint8_t chips_detected = (GLOBAL_STATE->ASIC_functions.init_fn)(GLOBAL_STATE->POWER_MANAGEMENT_MODULE.frequency_value);
|
||||
ESP_LOGI(TAG, "%u chips detected", chips_detected);
|
||||
@ -168,79 +164,48 @@ void self_test(void * pvParameters)
|
||||
// ESP_LOGI(TAG, "Nonce %lu Nonce difficulty %.32f.", asic_result->nonce, nonce_diff);
|
||||
|
||||
// if (asic_result->nonce == 4054974794) {
|
||||
if (chips_detected > 0) {
|
||||
ESP_LOGI(TAG, "SELF TEST PASS");
|
||||
ASIC_PASS = true;
|
||||
if (chips_detected < 1) {
|
||||
ESP_LOGE(TAG, "SELF TEST FAIL, NO CHIPS DETECTED");
|
||||
// ESP_LOGE(TAG, "SELF TEST FAIL, INCORRECT NONCE DIFF");
|
||||
if (OLED_status()) {
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "ASIC: PASS");
|
||||
OLED_writeString(0, 1, module->oled_buf);
|
||||
}
|
||||
} else {
|
||||
ESP_LOGE(TAG, "SELF TEST FAIL, INCORRECT NONCE DIFF");
|
||||
if (OLED_status()) {
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "ASIC: FAIL");
|
||||
OLED_writeString(0, 1, module->oled_buf);
|
||||
snprintf(module->oled_buf, 20, "ASIC:FAIL NO CHIPS");
|
||||
OLED_writeString(0, 2, module->oled_buf);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// } else {
|
||||
// ESP_LOGE(TAG, "SELF TEST FAIL, NO NONCE DIFF");
|
||||
// if (OLED_status()) {
|
||||
// memset(module->oled_buf, 0, 20);
|
||||
// snprintf(module->oled_buf, 20, "ASIC: FAIL");
|
||||
// OLED_writeString(0, 1, module->oled_buf);
|
||||
// }
|
||||
// }
|
||||
|
||||
free(GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs);
|
||||
free(GLOBAL_STATE->valid_jobs);
|
||||
|
||||
|
||||
if (INA260_installed()) {
|
||||
if (power_consumption_pass() && core_voltage_pass()) {
|
||||
POWER_PASS = true;
|
||||
if (OLED_status()) {
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "POWER: PASS");
|
||||
OLED_writeString(0, 2, module->oled_buf);
|
||||
}
|
||||
} else {
|
||||
if (OLED_status()) {
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "POWER: FAIL");
|
||||
OLED_writeString(0, 2, module->oled_buf);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (core_voltage_pass()) {
|
||||
POWER_PASS = true;
|
||||
if (OLED_status()) {
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "POWER: PASS");
|
||||
OLED_writeString(0, 2, module->oled_buf);
|
||||
}
|
||||
} else {
|
||||
if (OLED_status()) {
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "POWER: FAIL");
|
||||
OLED_writeString(0, 2, module->oled_buf);
|
||||
}
|
||||
if (!core_voltage_pass()) {
|
||||
if (OLED_status()) {
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "POWER: FAIL");
|
||||
OLED_writeString(0, 2, module->oled_buf);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (fan_sense_pass()) {
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "FAN: PASS");
|
||||
OLED_writeString(0, 3, module->oled_buf);
|
||||
} else {
|
||||
if (INA260_installed() && !power_consumption_pass()) {
|
||||
if (OLED_status()) {
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "POWER: FAIL");
|
||||
OLED_writeString(0, 2, module->oled_buf);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fan_sense_pass()) {
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, "FAN: WARN");
|
||||
OLED_writeString(0, 3, module->oled_buf);
|
||||
OLED_writeString(0, 1, module->oled_buf);
|
||||
}
|
||||
|
||||
if (POWER_PASS && ASIC_PASS) {
|
||||
nvs_config_set_u16(NVS_CONFIG_SELF_TEST, 0);
|
||||
}
|
||||
vTaskDelay(60 * 60 * 1000 / portTICK_PERIOD_MS);
|
||||
|
||||
memset(module->oled_buf, 0, 20);
|
||||
snprintf(module->oled_buf, 20, " PASS");
|
||||
OLED_writeString(0, 2, module->oled_buf);
|
||||
nvs_config_set_u16(NVS_CONFIG_SELF_TEST, 0);
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user