Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug when setting baudrate that can prevent the ASIC from working #503

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

eandersson
Copy link
Collaborator

@eandersson eandersson commented Nov 20, 2024

When setting the baud rate, we need to ensure that all serial communication is transmitted; otherwise, the ASIC may not be initialized properly. As a result, the device would be unable to hash anything until the next reboot.

The easiest way to reproduce this issue is by disabling logging. However, it can occur with any device at any time due to a bit of bad luck during startup.

diff --git a/main/main.c b/main/main.c
index dbc467b..8e7fb4e 100644
--- a/main/main.c
+++ b/main/main.c
@@ -35,6 +35,8 @@ void app_main(void)
 {
     ESP_LOGI(TAG, "Welcome to the bitaxe - hack the planet!");
 
+    esp_log_level_set("*", ESP_LOG_WARN);
+
     // Init I2C
     ESP_ERROR_CHECK(i2c_bitaxe_init());
     ESP_LOGI(TAG, "I2C initialized successfully");

@eandersson eandersson changed the title Fix bug when setting baudrate that prevents the ASIC from working Fix bug when setting baudrate that can prevent the ASIC from working Nov 20, 2024
Copy link
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

@WantClue WantClue added bug Something isn't working enhancement New feature or request labels Nov 20, 2024
@benjamin-wilson
Copy link
Collaborator

1 second is way too long

@eandersson
Copy link
Collaborator Author

1 second is way too long

It does not actually wait for 1 second, that is just the longest it would possibly wait for tx to finish.

Copy link
Owner

@skot skot left a comment

Choose a reason for hiding this comment

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

LGTM, nice catch.

@skot skot merged commit b912691 into master Nov 20, 2024
2 checks passed
@eandersson eandersson deleted the fix_set_baudrate branch November 29, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants