diff --git a/main/agent/agent_loop.c b/main/agent/agent_loop.c index 7e5eae6..7ce5d36 100644 --- a/main/agent/agent_loop.c +++ b/main/agent/agent_loop.c @@ -172,13 +172,12 @@ static void agent_loop_task(void *arg) { ESP_LOGI(TAG, "Agent loop started on core %d", xPortGetCoreID()); - /* Allocate large buffers from PSRAM */ - char *system_prompt = heap_caps_calloc(1, MIMI_CONTEXT_BUF_SIZE, MALLOC_CAP_SPIRAM); - char *history_json = heap_caps_calloc(1, MIMI_LLM_STREAM_BUF_SIZE, MALLOC_CAP_SPIRAM); - char *tool_output = heap_caps_calloc(1, TOOL_OUTPUT_SIZE, MALLOC_CAP_SPIRAM); + char *system_prompt = calloc(1, MIMI_CONTEXT_BUF_SIZE); + char *history_json = calloc(1, MIMI_LLM_STREAM_BUF_SIZE); + char *tool_output = calloc(1, TOOL_OUTPUT_SIZE); if (!system_prompt || !history_json || !tool_output) { - ESP_LOGE(TAG, "Failed to allocate PSRAM buffers"); + ESP_LOGE(TAG, "Failed to allocate runtime buffers"); vTaskDelete(NULL); return; } @@ -318,8 +317,8 @@ static void agent_loop_task(void *arg) free(msg.content); /* Log memory status */ - ESP_LOGI(TAG, "Free PSRAM: %d bytes", - (int)heap_caps_get_free_size(MALLOC_CAP_SPIRAM)); + ESP_LOGI(TAG, "Free internal heap: %d bytes", + (int)heap_caps_get_free_size(MALLOC_CAP_INTERNAL)); } } diff --git a/main/cli/serial_cli.c b/main/cli/serial_cli.c index d2315c4..6758bd1 100644 --- a/main/cli/serial_cli.c +++ b/main/cli/serial_cli.c @@ -195,8 +195,6 @@ static int cmd_heap_info(int argc, char **argv) { printf("Internal free: %d bytes\n", (int)heap_caps_get_free_size(MALLOC_CAP_INTERNAL)); - printf("PSRAM free: %d bytes\n", - (int)heap_caps_get_free_size(MALLOC_CAP_SPIRAM)); printf("Total free: %d bytes\n", (int)esp_get_free_heap_size()); return 0; diff --git a/main/llm/llm_proxy.c b/main/llm/llm_proxy.c index dba2961..86febc6 100644 --- a/main/llm/llm_proxy.c +++ b/main/llm/llm_proxy.c @@ -7,7 +7,6 @@ #include "esp_log.h" #include "esp_http_client.h" #include "esp_crt_bundle.h" -#include "esp_heap_caps.h" #include "nvs.h" #include "cJSON.h" @@ -91,7 +90,7 @@ typedef struct { static esp_err_t resp_buf_init(resp_buf_t *rb, size_t initial_cap) { - rb->data = heap_caps_calloc(1, initial_cap, MALLOC_CAP_SPIRAM); + rb->data = calloc(1, initial_cap); if (!rb->data) return ESP_ERR_NO_MEM; rb->len = 0; rb->cap = initial_cap; @@ -102,7 +101,7 @@ static esp_err_t resp_buf_append(resp_buf_t *rb, const char *data, size_t len) { while (rb->len + len >= rb->cap) { size_t new_cap = rb->cap * 2; - char *tmp = heap_caps_realloc(rb->data, new_cap, MALLOC_CAP_SPIRAM); + char *tmp = realloc(rb->data, new_cap); if (!tmp) return ESP_ERR_NO_MEM; rb->data = tmp; rb->cap = new_cap; diff --git a/main/mimi.c b/main/mimi.c index 2bded17..65151b3 100644 --- a/main/mimi.c +++ b/main/mimi.c @@ -108,8 +108,6 @@ void app_main(void) /* Print memory info */ ESP_LOGI(TAG, "Internal free: %d bytes", (int)heap_caps_get_free_size(MALLOC_CAP_INTERNAL)); - ESP_LOGI(TAG, "PSRAM free: %d bytes", - (int)heap_caps_get_free_size(MALLOC_CAP_SPIRAM)); /* Input */ button_Init(); diff --git a/main/tools/tool_web_search.c b/main/tools/tool_web_search.c index d1b8ecf..4daaa34 100644 --- a/main/tools/tool_web_search.c +++ b/main/tools/tool_web_search.c @@ -7,7 +7,6 @@ #include "esp_log.h" #include "esp_http_client.h" #include "esp_crt_bundle.h" -#include "esp_heap_caps.h" #include "nvs.h" #include "cJSON.h" @@ -256,9 +255,8 @@ esp_err_t tool_web_search_execute(const char *input_json, char *output, size_t o snprintf(path, sizeof(path), "/res/v1/web/search?q=%s&count=%d", encoded_query, SEARCH_RESULT_COUNT); - /* Allocate response buffer from PSRAM */ search_buf_t sb = {0}; - sb.data = heap_caps_calloc(1, SEARCH_BUF_SIZE, MALLOC_CAP_SPIRAM); + sb.data = calloc(1, SEARCH_BUF_SIZE); if (!sb.data) { snprintf(output, output_size, "Error: Out of memory"); return ESP_ERR_NO_MEM;