Skip to content

Refactor self-test#1615

Merged
WantClue merged 7 commits intobitaxeorg:masterfrom
mutatrum:self-test-refactor
Mar 23, 2026
Merged

Refactor self-test#1615
WantClue merged 7 commits intobitaxeorg:masterfrom
mutatrum:self-test-refactor

Conversation

@mutatrum
Copy link
Copy Markdown
Collaborator

@mutatrum mutatrum commented Mar 16, 2026

This refactors self-test to use the normal startup code of the firmware, minus Wi-Fi, fan controller and stratum task.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 16, 2026

Test Results

49 tests  ±0   49 ✅ ±0   0s ⏱️ ±0s
 1 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit ea4c6d4. ± Comparison against base commit 139c979.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Collaborator

@WantClue WantClue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, i'll do some testing and report back before merging

if (GLOBAL_STATE->DEVICE_CONFIG.DS4432U && DS4432U_test() != ESP_OK) {
ESP_LOGE(TAG, "DS4432 test failed!");
self_test_show_message(GLOBAL_STATE, "DS4432U:FAIL");
tests_done(GLOBAL_STATE, false);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're missing a return here

snprintf(error_buf, 20, "VCORE:PWR FAULT");
display_msg(error_buf, GLOBAL_STATE);
self_test_show_message(GLOBAL_STATE, "VCORE:PWR FAULT");
tests_done(GLOBAL_STATE, false);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing return here as well

snprintf(error_buf, 20, "ASIC:FAIL %d CHIPS", chips_detected);
display_msg(error_buf, GLOBAL_STATE);
self_test_show_message(GLOBAL_STATE, "VOLTAGE:FAIL");
tests_done(GLOBAL_STATE, false);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing return here as well

}

static void display_msg(char * msg, GlobalState * GLOBAL_STATE)
void self_test_show_message(void * pvParameters, char * msg)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function stores msg directly in GLOBAL_STATE->SELF_TEST_MODULE.message. Throughout the code, this is called with stack-allocated buffers like logString (lines 316, 327, 348) and error_buf (line 382). Once the buffer is reused or goes out of scope, the stored pointer becomes invalid.

+static char self_test_message_buf[64];
+
 void self_test_show_message(void * pvParameters, char * msg)
 {
     GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters;

     if (GLOBAL_STATE->SELF_TEST_MODULE.is_active) {
-        GLOBAL_STATE->SELF_TEST_MODULE.message = msg;
+        strncpy(self_test_message_buf, msg, sizeof(self_test_message_buf) - 1);
+        self_test_message_buf[sizeof(self_test_message_buf) - 1] = '\0';
+        GLOBAL_STATE->SELF_TEST_MODULE.message = self_test_message_buf;
         vTaskDelay(10 / portTICK_PERIOD_MS);
     }
 }

{
ESP_LOGI(TAG, "Long press detected...");
// Give the semaphore back
xSemaphoreGive(longPressSemaphore);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a NULL check or initialize the semaphore earlier in self_test_init

{
GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters;

esp_vfs_spiffs_conf_t conf = {.base_path = "", .partition_label = NULL, .max_files = 5, .format_if_mount_failed = false};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik ESP-IDF does require a non empty path starting with "/" e.g. "/spiffs"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is just moved out of http_server.c, unchanged?

@WantClue WantClue merged commit 43aa4eb into bitaxeorg:master Mar 23, 2026
3 checks passed
mutatrum added a commit to mutatrum/ESP-Miner that referenced this pull request Mar 25, 2026
@mutatrum mutatrum mentioned this pull request Mar 26, 2026
WantClue pushed a commit that referenced this pull request Mar 26, 2026
* Fix recovery mode and enable web if system init fails

Follow-up of #1615

* Fix main.c

* Add countdown on display
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants