Skip to content

Commit

Permalink
fix self test functions, update example nvs configs with fallback str…
Browse files Browse the repository at this point in the history
…atum defaults (#405)
  • Loading branch information
skot authored Oct 10, 2024
1 parent 478b01d commit 0527084
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 37 deletions.
24 changes: 24 additions & 0 deletions config-202.cvs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
key,type,encoding,value
main,namespace,,
hostname,data,string,bitaxe
wifissid,data,string,myssid
wifipass,data,string,password
stratumurl,data,string,public-pool.io
stratumport,data,u16,21496
stratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
stratumpass,data,string,x
fbstratumurl,data,string,solo.ckpool.org
fbstratumport,data,u16,3333
fbstratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
fbstratumpass,data,string,x
asicfrequency,data,u16,485
asicvoltage,data,u16,1200
asicmodel,data,string,BM1366
devicemodel,data,string,ultra
boardversion,data,string,202
flipscreen,data,u16,1
invertfanpol,data,u16,1
autofanspeed,data,u16,1
fanspeed,data,u16,100
selftest,data,u16,0
overheat_mode,data,u16,0
7 changes: 6 additions & 1 deletion config-204.cvs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ stratumurl,data,string,public-pool.io
stratumport,data,u16,21496
stratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
stratumpass,data,string,x
fbstratumurl,data,string,solo.ckpool.org
fbstratumport,data,u16,3333
fbstratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
fbstratumpass,data,string,x
asicfrequency,data,u16,485
asicvoltage,data,u16,1200
asicmodel,data,string,BM1366
Expand All @@ -16,4 +20,5 @@ flipscreen,data,u16,1
invertfanpol,data,u16,1
autofanspeed,data,u16,1
fanspeed,data,u16,100
selftest,data,u16,0
selftest,data,u16,0
overheat_mode,data,u16,0
7 changes: 6 additions & 1 deletion config-401.cvs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ stratumurl,data,string,public-pool.io
stratumport,data,u16,21496
stratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
stratumpass,data,string,x
fbstratumurl,data,string,solo.ckpool.org
fbstratumport,data,u16,3333
fbstratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
fbstratumpass,data,string,x
asicfrequency,data,u16,490
asicvoltage,data,u16,1166
asicmodel,data,string,BM1368
Expand All @@ -16,4 +20,5 @@ flipscreen,data,u16,1
invertfanpol,data,u16,1
autofanspeed,data,u16,1
fanspeed,data,u16,100
selftest,data,u16,1
selftest,data,u16,1
overheat_mode,data,u16,0
7 changes: 6 additions & 1 deletion config-402.cvs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ stratumurl,data,string,public-pool.io
stratumport,data,u16,21496
stratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
stratumpass,data,string,x
fbstratumurl,data,string,solo.ckpool.org
fbstratumport,data,u16,3333
fbstratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
fbstratumpass,data,string,x
asicfrequency,data,u16,490
asicvoltage,data,u16,1166
asicmodel,data,string,BM1368
Expand All @@ -16,4 +20,5 @@ flipscreen,data,u16,1
invertfanpol,data,u16,1
autofanspeed,data,u16,1
fanspeed,data,u16,100
selftest,data,u16,1
selftest,data,u16,1
overheat_mode,data,u16,0
7 changes: 6 additions & 1 deletion config-403.cvs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ stratumurl,data,string,public-pool.io
stratumport,data,u16,21496
stratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
stratumpass,data,string,x
fbstratumurl,data,string,solo.ckpool.org
fbstratumport,data,u16,3333
fbstratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
fbstratumpass,data,string,x
asicfrequency,data,u16,490
asicvoltage,data,u16,1166
asicmodel,data,string,BM1368
Expand All @@ -16,4 +20,5 @@ flipscreen,data,u16,1
invertfanpol,data,u16,1
autofanspeed,data,u16,1
fanspeed,data,u16,100
selftest,data,u16,1
selftest,data,u16,1
overheat_mode,data,u16,0
7 changes: 6 additions & 1 deletion config-601.cvs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ stratumurl,data,string,public-pool.io
stratumport,data,u16,21496
stratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
stratumpass,data,string,x
fbstratumurl,data,string,solo.ckpool.org
fbstratumport,data,u16,3333
fbstratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
fbstratumpass,data,string,x
asicfrequency,data,u16,525
asicvoltage,data,u16,1150
asicmodel,data,string,BM1370
Expand All @@ -16,4 +20,5 @@ flipscreen,data,u16,1
invertfanpol,data,u16,1
autofanspeed,data,u16,1
fanspeed,data,u16,100
selftest,data,u16,1
selftest,data,u16,1
overheat_mode,data,u16,0
87 changes: 55 additions & 32 deletions main/self_test/self_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ static void display_end_screen(GlobalState * GLOBAL_STATE) {
case DEVICE_GAMMA:
if (OLED_status()) {
OLED_clearLine(2);
OLED_writeString(0, 2, " PASS");
OLED_writeString(0, 2, "TESTS PASS!");
OLED_clearLine(3);
OLED_writeString(0, 3, "PRESS RESET");
OLED_writeString(0, 3, " PRESS RESET");
}
break;
default:
Expand Down Expand Up @@ -120,10 +120,27 @@ static bool core_voltage_pass(GlobalState * GLOBAL_STATE)

void self_test(void * pvParameters)
{
GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters;

ESP_LOGI(TAG, "Running Self Tests");

GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters;
// Display testing
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
case DEVICE_GAMMA:
if (!OLED_init()) {
ESP_LOGE(TAG, "OLED init failed!");
} else {
ESP_LOGI(TAG, "OLED init success!");
// clear the oled screen
OLED_fill(0);
OLED_writeString(0, 0, "BITAXE SELF TESTING");
}
break;
default:
}

GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs = malloc(sizeof(bm_job *) * 128);
GLOBAL_STATE->valid_jobs = malloc(sizeof(uint8_t) * 128);
Expand All @@ -146,11 +163,6 @@ void self_test(void * pvParameters)
default:
}

// Init I2C
ESP_ERROR_CHECK(i2c_bitaxe_init());
ESP_LOGI(TAG, "I2C initialized successfully");


switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
Expand All @@ -162,24 +174,6 @@ void self_test(void * pvParameters)
default:
}

// Display testing
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
case DEVICE_GAMMA:
if (!OLED_init()) {
ESP_LOGE(TAG, "OLED init failed!");
} else {
ESP_LOGI(TAG, "OLED init success!");
// clear the oled screen
OLED_fill(0);
display_msg("SELF TEST...", GLOBAL_STATE);
}
break;
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);

Expand Down Expand Up @@ -284,7 +278,7 @@ void self_test(void * pvParameters)
if (chips_detected < 1) {
ESP_LOGE(TAG, "SELF TEST FAIL, NO CHIPS DETECTED");
// ESP_LOGE(TAG, "SELF TEST FAIL, INCORRECT NONCE DIFF");
display_msg("ASIC:FAIL NO CHIPS", GLOBAL_STATE);
display_msg("ASIC:FAIL 0 CHIPS", GLOBAL_STATE);
return;
}

Expand All @@ -293,7 +287,7 @@ void self_test(void * pvParameters)

if (!core_voltage_pass(GLOBAL_STATE)) {
ESP_LOGE(TAG, "SELF TEST FAIL, INCORRECT CORE VOLTAGE");
display_msg("VCORE: FAIL", GLOBAL_STATE);
display_msg("VCORE:FAIL", GLOBAL_STATE);
return;
}

Expand All @@ -304,21 +298,21 @@ void self_test(void * pvParameters)
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);
display_msg("POWER:FAIL", GLOBAL_STATE);
return;
}
} else {
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);
display_msg("POWER:FAIL", GLOBAL_STATE);
return;
}
}
break;
case DEVICE_GAMMA:
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);
display_msg("POWER:FAIL", GLOBAL_STATE);
return;
}
break;
Expand All @@ -327,11 +321,40 @@ void self_test(void * pvParameters)

if (!fan_sense_pass(GLOBAL_STATE)) {
ESP_LOGE(TAG, "FAN test failed!");
display_msg("FAN: WARN", GLOBAL_STATE);
display_msg("FAN:WARN", 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);

//blink tests pass screen
while (1) {
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
case DEVICE_GAMMA:
if (OLED_status()) {
OLED_clearLine(3);
OLED_writeString(0, 3, " PRESS RESET");
}
break;
default:
}
vTaskDelay(500 / portTICK_PERIOD_MS);
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
case DEVICE_GAMMA:
if (OLED_status()) {
OLED_clearLine(3);
}
break;
default:
}
vTaskDelay(500 / portTICK_PERIOD_MS);
}
}

0 comments on commit 0527084

Please sign in to comment.