Legacy selftest fixes (#346)

* make sure to VCORE_init() and VCORE_set_voltage() no matter what hw version.

* added "PRESS RESET" to selftest endscreen. pulled out magic numbers to #defines

* oops, cleanup

* update 402 power target

* 403+support

---------

Co-authored-by: Benjamin Wilson <admin@opensourceminer.com>
This commit is contained in:
Skot 2024-09-23 15:11:53 -05:00 committed by GitHub
parent 7b5e3ef2eb
commit 8b22bb2762
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 50 additions and 31 deletions

View File

@ -13,6 +13,11 @@
#include "string.h"
#include "TPS546.h"
#define POWER_CONSUMPTION_TARGET_SUB_402 12 //watts
#define POWER_CONSUMPTION_TARGET_402 5 //watts
#define POWER_CONSUMPTION_TARGET_GAMMA 11 //watts
#define POWER_CONSUMPTION_MARGIN 3 //+/- watts
static const char * TAG = "self_test";
static void display_msg(char * msg, GlobalState * GLOBAL_STATE) {
@ -33,6 +38,24 @@ static void display_msg(char * msg, GlobalState * GLOBAL_STATE) {
}
}
static void display_end_screen(GlobalState * GLOBAL_STATE) {
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
case DEVICE_GAMMA:
if (OLED_status()) {
OLED_clearLine(2);
OLED_writeString(0, 2, " PASS");
OLED_clearLine(3);
OLED_writeString(0, 3, "PRESS RESET");
}
break;
default:
}
}
static bool fan_sense_pass(GlobalState * GLOBAL_STATE)
{
uint16_t fan_speed = 0;
@ -147,35 +170,30 @@ void self_test(void * pvParameters)
default:
}
uint8_t result = VCORE_init(GLOBAL_STATE);
VCORE_set_voltage(nvs_config_get_u16(NVS_CONFIG_ASIC_VOLTAGE, CONFIG_ASIC_VOLTAGE) / 1000.0, GLOBAL_STATE);
// VCore regulator testing
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
if(GLOBAL_STATE->board_version != 402){
if(!DS4432U_test()){
ESP_LOGE(TAG, "DS4432 test failed!");
display_msg("DS4432U:FAIL", GLOBAL_STATE);
return;
}
}else{
uint8_t result = VCORE_init(GLOBAL_STATE);
VCORE_set_voltage(nvs_config_get_u16(NVS_CONFIG_ASIC_VOLTAGE, CONFIG_ASIC_VOLTAGE) / 1000.0, GLOBAL_STATE);
if(result != 0){
if (GLOBAL_STATE->board_version >= 402 && GLOBAL_STATE->board_version <= 499){
if (result != 0) {
ESP_LOGE(TAG, "TPS546 test failed!");
display_msg("TPS546:FAIL", GLOBAL_STATE);
return;
}
} else {
if(!DS4432U_test()) {
ESP_LOGE(TAG, "DS4432 test failed!");
display_msg("DS4432U:FAIL", GLOBAL_STATE);
return;
}
}
break;
case DEVICE_GAMMA:
uint8_t result = VCORE_init(GLOBAL_STATE);
VCORE_set_voltage(nvs_config_get_u16(NVS_CONFIG_ASIC_VOLTAGE, CONFIG_ASIC_VOLTAGE) / 1000.0, GLOBAL_STATE);
if(result != 0){
if (result != 0) {
ESP_LOGE(TAG, "TPS546 test failed!");
display_msg("TPS546:FAIL", GLOBAL_STATE);
return;
@ -273,23 +291,23 @@ void self_test(void * pvParameters)
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
if(GLOBAL_STATE->board_version != 402){
if (!INA260_power_consumption_pass(12, 3)) {
ESP_LOGE(TAG, "INA260 Power Draw Failed");
if(GLOBAL_STATE->board_version >= 402 && GLOBAL_STATE->board_version <= 499){
if (!TPS546_power_consumption_pass(POWER_CONSUMPTION_TARGET_402, POWER_CONSUMPTION_MARGIN)) {
ESP_LOGE(TAG, "TPS546 Power Draw Failed, target %.2f", (float)POWER_CONSUMPTION_TARGET_402);
display_msg("POWER: FAIL", GLOBAL_STATE);
return;
}
} else {
if (!TPS546_power_consumption_pass(8, 3)) {
ESP_LOGE(TAG, "TPS546 Power Draw Failed, target %f", 8.0);
if (!INA260_power_consumption_pass(POWER_CONSUMPTION_TARGET_SUB_402, POWER_CONSUMPTION_MARGIN)) {
ESP_LOGE(TAG, "INA260 Power Draw Failed, target %.2f", (float)POWER_CONSUMPTION_TARGET_SUB_402);
display_msg("POWER: FAIL", GLOBAL_STATE);
return;
}
}
break;
case DEVICE_GAMMA:
if (!TPS546_power_consumption_pass(11, 3)) {
ESP_LOGE(TAG, "TPS546 Power Draw Failed, target %f", 11.0);
if (!TPS546_power_consumption_pass(POWER_CONSUMPTION_TARGET_GAMMA, POWER_CONSUMPTION_MARGIN)) {
ESP_LOGE(TAG, "TPS546 Power Draw Failed, target %.2f", (float)POWER_CONSUMPTION_TARGET_GAMMA);
display_msg("POWER: FAIL", GLOBAL_STATE);
return;
}
@ -303,6 +321,7 @@ void self_test(void * pvParameters)
}
display_msg(" PASS", GLOBAL_STATE);
ESP_LOGI(TAG, "SELF TESTS PASS -- Press RESET to continue");
display_end_screen(GLOBAL_STATE);
nvs_config_set_u16(NVS_CONFIG_SELF_TEST, 0);
}

View File

@ -94,7 +94,7 @@ void POWER_MANAGEMENT_task(void * pvParameters)
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
if (GLOBAL_STATE->board_version != 402) {
if (GLOBAL_STATE->board_version < 402 || GLOBAL_STATE->board_version > 499) {
// Configure GPIO12 as input(barrel jack) 1 is plugged in
gpio_config_t barrel_jack_conf = {
.pin_bit_mask = (1ULL << GPIO_NUM_12),
@ -128,7 +128,7 @@ void POWER_MANAGEMENT_task(void * pvParameters)
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
if (GLOBAL_STATE->board_version == 402) {
if (GLOBAL_STATE->board_version >= 402 && GLOBAL_STATE->board_version <= 499) {
power_management->voltage = TPS546_get_vin() * 1000;
power_management->current = TPS546_get_iout() * 1000;
// calculate regulator power (in milliwatts)
@ -177,7 +177,7 @@ void POWER_MANAGEMENT_task(void * pvParameters)
case DEVICE_ULTRA:
case DEVICE_SUPRA:
if (GLOBAL_STATE->board_version == 402) {
if (GLOBAL_STATE->board_version >= 402 && GLOBAL_STATE->board_version <= 499) {
power_management->chip_temp_avg = GLOBAL_STATE->ASIC_initalized ? EMC2101_get_external_temp() : -1;
power_management->vr_temp = (float)TPS546_get_temperature();
} else {
@ -196,7 +196,7 @@ void POWER_MANAGEMENT_task(void * pvParameters)
ESP_LOGE(TAG, "OVERHEAT! VR: %fC ASIC %fC", power_management->vr_temp, power_management->chip_temp_avg );
EMC2101_set_fan_speed(1);
if (GLOBAL_STATE->board_version == 402) {
if (GLOBAL_STATE->board_version >= 402 && GLOBAL_STATE->board_version <= 499) {
// Turn off core voltage
VCORE_set_voltage(0.0, GLOBAL_STATE);
} else if (power_management->HAS_POWER_EN) {

View File

@ -27,7 +27,7 @@ uint8_t VCORE_init(GlobalState * global_state) {
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
if (global_state->board_version == 402) {
if (global_state->board_version >= 402 && global_state->board_version <= 499) {
result = TPS546_init();
}
break;
@ -75,7 +75,7 @@ bool VCORE_set_voltage(float core_voltage, GlobalState * global_state)
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
if (global_state->board_version == 402) {
if (global_state->board_version >= 402 && global_state->board_version <= 499) {
ESP_LOGI(TAG, "Set ASIC voltage = %.3fV", core_voltage);
TPS546_set_vout(core_voltage * (float)global_state->voltage_domain);
} else {