psram size log set

This commit is contained in:
2025-09-12 14:57:04 +08:00
parent 68d6539130
commit f763ae05dc

View File

@@ -8,6 +8,8 @@
#include "application.h" #include "application.h"
#include "system_info.h" #include "system_info.h"
#include <esp_psram.h>
#define TAG "main" #define TAG "main"
extern "C" void app_main(void) extern "C" void app_main(void)
@@ -17,7 +19,8 @@ extern "C" void app_main(void)
// Initialize NVS flash for WiFi configuration // Initialize NVS flash for WiFi configuration
esp_err_t ret = nvs_flash_init(); esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
{
ESP_LOGW(TAG, "Erasing NVS flash to fix corruption"); ESP_LOGW(TAG, "Erasing NVS flash to fix corruption");
ESP_ERROR_CHECK(nvs_flash_erase()); ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init(); ret = nvs_flash_init();
@@ -25,9 +28,13 @@ extern "C" void app_main(void)
ESP_ERROR_CHECK(ret); ESP_ERROR_CHECK(ret);
// Detecting PSRAM // Detecting PSRAM
if (esp_spiram_is_initialized()) { if (esp_psram_is_initialized())
ESP_LOGI("PSRAM", "PSRAM is available and initialized."); {
} else { size_t psram_size = esp_psram_get_size();
ESP_LOGI("PSRAM", "PSRAM is available and initialized. Total size: %zu bytes", psram_size);
}
else
{
ESP_LOGE("PSRAM", "PSRAM not found or not initialized."); ESP_LOGE("PSRAM", "PSRAM not found or not initialized.");
} }