From e01006cd49e5cb4159bb976a883a33885e782d07 Mon Sep 17 00:00:00 2001 From: Peter Siegmund Date: Sun, 25 Jan 2026 00:28:00 +0100 Subject: [PATCH] remove PSRAM usage Signed-off-by: Peter Siegmund --- .../components/api-server/src/api_handlers.c | 26 +++++++++---------- .../components/simulator/src/simulator.cpp | 7 +++-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/firmware/components/api-server/src/api_handlers.c b/firmware/components/api-server/src/api_handlers.c index eb9b619..d358fc0 100644 --- a/firmware/components/api-server/src/api_handlers.c +++ b/firmware/components/api-server/src/api_handlers.c @@ -64,7 +64,7 @@ esp_err_t api_capabilities_get_handler(httpd_req_t *req) { ESP_LOGI(TAG, "GET /api/capabilities"); - // Thread nur für esp32c6 oder esp32h2 verfügbar + // Thread only available for esp32c6 or esp32h2 bool thread = false; #if defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32H2) thread = true; @@ -95,7 +95,7 @@ esp_err_t api_wifi_scan_handler(httpd_req_t *req) uint16_t ap_num = 0; esp_wifi_scan_get_ap_num(&ap_num); - wifi_ap_record_t *ap_list = heap_caps_calloc(ap_num, sizeof(wifi_ap_record_t), MALLOC_CAP_SPIRAM); + wifi_ap_record_t *ap_list = heap_caps_calloc(ap_num, sizeof(wifi_ap_record_t), MALLOC_CAP_DEFAULT); if (!ap_list) { return send_error_response(req, 500, "Memory allocation failed"); @@ -164,7 +164,7 @@ esp_err_t api_wifi_config_handler(httpd_req_t *req) if (is_valid(pw)) { size_t pwlen = strlen(pw->valuestring); - char *masked = heap_caps_malloc(pwlen + 1, MALLOC_CAP_SPIRAM); + char *masked = heap_caps_malloc(pwlen + 1, MALLOC_CAP_DEFAULT); if (masked) { memset(masked, '*', pwlen); @@ -338,7 +338,7 @@ esp_err_t api_light_mode_handler(httpd_req_t *req) } else { - msg.data.settings.value.int_value = -1; // Unbekannter Modus + msg.data.settings.value.int_value = -1; // Unknown mode } message_manager_post(&msg, pdMS_TO_TICKS(100)); } @@ -445,7 +445,7 @@ esp_err_t api_wled_config_post_handler(httpd_req_t *req) { ESP_LOGI(TAG, "POST /api/wled/config"); - char *buf = heap_caps_malloc(MAX_BODY_SIZE, MALLOC_CAP_SPIRAM); + char *buf = heap_caps_malloc(MAX_BODY_SIZE, MALLOC_CAP_DEFAULT); if (!buf) return send_error_response(req, 500, "Memory allocation failed"); int total = 0, ret; @@ -545,7 +545,7 @@ esp_err_t api_schema_get_handler(httpd_req_t *req) ESP_LOGI(TAG, "Requested schema: %s", filename); - // Schema-Datei lesen + // Read schema file char path[128]; snprintf(path, sizeof(path), "%s", filename); @@ -560,11 +560,11 @@ esp_err_t api_schema_get_handler(httpd_req_t *req) return httpd_resp_sendstr(req, ""); } - // Gesamtlänge berechnen + // Calculate total length size_t total_len = 0; for (int i = 0; i < line_count; ++i) total_len += strlen(lines[i]) + 1; - char *csv = heap_caps_malloc(total_len + 1, MALLOC_CAP_SPIRAM); + char *csv = heap_caps_malloc(total_len + 1, MALLOC_CAP_DEFAULT); char *p = csv; for (int i = 0; i < line_count; ++i) { @@ -607,7 +607,7 @@ esp_err_t api_schema_post_handler(httpd_req_t *req) ESP_LOGI(TAG, "Extracted filename: %s", filename); // Dynamically read POST body (like api_wled_config_post_handler) - char *buf = heap_caps_malloc(MAX_BODY_SIZE, MALLOC_CAP_SPIRAM); + char *buf = heap_caps_malloc(MAX_BODY_SIZE, MALLOC_CAP_DEFAULT); if (!buf) { ESP_LOGE(TAG, "Memory allocation failed for POST body"); @@ -634,7 +634,7 @@ esp_err_t api_schema_post_handler(httpd_req_t *req) if (total > 0 && buf[total - 1] != '\n') line_count++; // last line without \n - char **lines = (char **)heap_caps_malloc(line_count * sizeof(char *), MALLOC_CAP_SPIRAM); + char **lines = (char **)heap_caps_malloc(line_count * sizeof(char *), MALLOC_CAP_DEFAULT); int idx = 0; char *saveptr = NULL; char *line = strtok_r(buf, "\n", &saveptr); @@ -642,7 +642,7 @@ esp_err_t api_schema_post_handler(httpd_req_t *req) { // Ignore empty lines if (line[0] != '\0') - lines[idx++] = heap_caps_strdup(line, MALLOC_CAP_SPIRAM); + lines[idx++] = heap_caps_strdup(line, MALLOC_CAP_DEFAULT); line = strtok_r(NULL, "\n", &saveptr); } int actual_count = idx; @@ -961,7 +961,7 @@ esp_err_t api_captive_portal_handler(httpd_req_t *req) { ESP_LOGI(TAG, "Captive portal detection: %s", req->uri); - // captive.html direkt ausliefern (Status 200, text/html) + // Serve captive.html directly (status 200, text/html) const char *base_path = CONFIG_API_SERVER_STATIC_FILES_PATH; char filepath[256]; snprintf(filepath, sizeof(filepath), "%s/captive.html", base_path); @@ -970,7 +970,7 @@ esp_err_t api_captive_portal_handler(httpd_req_t *req) { ESP_LOGE(TAG, "captive.html not found: %s", filepath); httpd_resp_set_status(req, "500 Internal Server Error"); - httpd_resp_sendstr(req, "Captive Portal nicht verfügbar"); + httpd_resp_sendstr(req, "Captive portal not available"); return ESP_FAIL; } httpd_resp_set_type(req, "text/html"); diff --git a/firmware/components/simulator/src/simulator.cpp b/firmware/components/simulator/src/simulator.cpp index e556ecc..ebe2115 100644 --- a/firmware/components/simulator/src/simulator.cpp +++ b/firmware/components/simulator/src/simulator.cpp @@ -82,10 +82,10 @@ esp_err_t add_light_item(const char time[5], uint8_t red, uint8_t green, uint8_t uint8_t brightness, uint8_t saturation) { // Allocate memory for a new node in PSRAM. - light_item_node_t *new_node = (light_item_node_t *)heap_caps_malloc(sizeof(light_item_node_t), MALLOC_CAP_SPIRAM); + light_item_node_t *new_node = (light_item_node_t *)heap_caps_malloc(sizeof(light_item_node_t), MALLOC_CAP_DEFAULT); if (new_node == NULL) { - ESP_LOGE(TAG, "Failed to allocate memory in PSRAM for new light_item_node_t."); + ESP_LOGE(TAG, "Failed to allocate memory for new light_item_node_t."); return ESP_FAIL; } @@ -372,8 +372,7 @@ void start_simulation_task(void) { stop_simulation_task(); - simulation_config_t *config = - (simulation_config_t *)heap_caps_malloc(sizeof(simulation_config_t), MALLOC_CAP_SPIRAM); + simulation_config_t *config = (simulation_config_t *)heap_caps_malloc(sizeof(simulation_config_t), 0); if (config == NULL) { ESP_LOGE(TAG, "Failed to allocate memory for simulation config.");