diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 0faff7cd..3fd0ec9a 100755 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -44,6 +44,7 @@ PRIV_REQUIRES "esp_event" "esp_http_server" "esp_netif" + "esp_psram" "esp_timer" "esp_wifi" "json" diff --git a/main/global_state.h b/main/global_state.h index 5c48649e..744171cf 100644 --- a/main/global_state.h +++ b/main/global_state.h @@ -123,6 +123,7 @@ typedef struct int sock; bool ASIC_initalized; + bool psram_is_available; } GlobalState; #endif /* GLOBAL_STATE_H_ */ diff --git a/main/http_server/http_server.c b/main/http_server/http_server.c index 1371814e..cc1bbd6e 100644 --- a/main/http_server/http_server.c +++ b/main/http_server/http_server.c @@ -381,6 +381,8 @@ static esp_err_t GET_system_info(httpd_req_t * req) cJSON_AddNumberToObject(root, "isUsingFallbackStratum", GLOBAL_STATE->SYSTEM_MODULE.is_using_fallback); + cJSON_AddNumberToObject(root, "isPSRAMAvailable", GLOBAL_STATE->psram_is_available); + cJSON_AddNumberToObject(root, "freeHeap", esp_get_free_heap_size()); cJSON_AddNumberToObject(root, "coreVoltage", nvs_config_get_u16(NVS_CONFIG_ASIC_VOLTAGE, CONFIG_ASIC_VOLTAGE)); cJSON_AddNumberToObject(root, "coreVoltageActual", VCORE_get_voltage_mv(GLOBAL_STATE)); diff --git a/main/main.c b/main/main.c index eeff4dc0..f0e0fda7 100644 --- a/main/main.c +++ b/main/main.c @@ -1,6 +1,7 @@ #include "esp_event.h" #include "esp_log.h" +#include "esp_psram.h" #include "nvs_flash.h" // #include "protocol_examples_common.h" @@ -34,6 +35,13 @@ void app_main(void) { ESP_LOGI(TAG, "Welcome to the bitaxe - hack the planet!"); + if (!esp_psram_is_initialized()) { + ESP_LOGE(TAG, "No PSRAM available on ESP32 device!"); + GLOBAL_STATE.psram_is_available = false; + } else { + GLOBAL_STATE.psram_is_available = true; + } + // Init I2C ESP_ERROR_CHECK(i2c_bitaxe_init()); ESP_LOGI(TAG, "I2C initialized successfully");