diff --git a/Changelog.md b/Changelog.md index 1b63fa03..ad2a08fa 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,8 @@ +<<<<<<< HEAD ## [15.2.0] - 2023-04-23 +======= +## [15.1.1] - 2023-03-23 +>>>>>>> master ### Update Procedure @@ -6,6 +10,7 @@ Update Procedure see [online documentation](https://jomjol.github.io/AI-on-the-e ### Changes +<<<<<<< HEAD For a full list of changes see [Full list of changes](https://github.com/jomjol/AI-on-the-edge-device/compare/v15.1.1...v15.2.0) #### Added @@ -43,6 +48,12 @@ For a full list of changes see [Full list of changes](https://github.com/jomjol/ #### Added +======= +For a full list of changes see [Full list of changes](https://github.com/jomjol/AI-on-the-edge-device/compare/v15.1.0...v15.1.1) + +#### Added + +>>>>>>> master - [#2206](https://github.com/jomjol/AI-on-the-edge-device/pull/2206) Log PSRAM usage - [#2216](https://github.com/jomjol/AI-on-the-edge-device/pull/2216) Log MQTT connection refused reasons @@ -966,7 +977,10 @@ External Illumination - Initial Version +<<<<<<< HEAD [15.2.0]: https://github.com/jomjol/AI-on-the-edge-device/compare/v15.1.1...v15.1.2 +======= +>>>>>>> master [15.1.1]: https://github.com/jomjol/AI-on-the-edge-device/compare/v15.1.0...v15.1.1 [15.1.0]: https://github.com/jomjol/AI-on-the-edge-device/compare/v15.0.3...v15.1.0 [15.0.3]: https://github.com/jomjol/AI-on-the-edge-device/compare/v14.0.3...v15.0.3 diff --git a/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp b/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp index f7ff40d2..8d6f7600 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp @@ -190,7 +190,11 @@ bool ClassFlowAlignment::doFlow(string time) if (!ImageTMP) { +<<<<<<< HEAD ImageTMP = new CImageBasis("tmpImage", ImageBasis); // Make sure the name does not get change, it is relevant for the PSRAM allocation! +======= + ImageTMP = new CImageBasis("ImageTMP", ImageBasis); +>>>>>>> master if (!ImageTMP) { LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Can't allocate tmpImage -> Exec this round aborted!"); diff --git a/code/components/jomjol_helper/psram.cpp b/code/components/jomjol_helper/psram.cpp index 8c7dcabb..d762f241 100644 --- a/code/components/jomjol_helper/psram.cpp +++ b/code/components/jomjol_helper/psram.cpp @@ -1,12 +1,17 @@ #include "ClassLogFile.h" +<<<<<<< HEAD #include "../../include/defines.h" #include "psram.h" +======= +#include "esp_heap_caps.h" +>>>>>>> master static const char* TAG = "PSRAM"; using namespace std; +<<<<<<< HEAD void *shared_region = NULL; uint32_t allocatedBytesForSTBI = 0; @@ -123,6 +128,8 @@ void psram_free_shared_tensor_arena_and_model_memory(void) { /******************************************************************* * General *******************************************************************/ +======= +>>>>>>> master void *malloc_psram_heap(std::string name, size_t size, uint32_t caps) { void *ptr; @@ -138,6 +145,7 @@ void *malloc_psram_heap(std::string name, size_t size, uint32_t caps) { } +<<<<<<< HEAD void *realloc_psram_heap(std::string name, void *ptr, size_t size, uint32_t caps) { ptr = heap_caps_realloc(ptr, size, caps); if (ptr != NULL) { @@ -151,12 +159,18 @@ void *realloc_psram_heap(std::string name, void *ptr, size_t size, uint32_t caps } +======= +>>>>>>> master void *calloc_psram_heap(std::string name, size_t n, size_t size, uint32_t caps) { void *ptr; ptr = heap_caps_calloc(n, size, caps); if (ptr != NULL) { +<<<<<<< HEAD LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Allocated " + to_string(size) + " bytes in PSRAM for '" + name + "'"); +======= + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Allocated " + to_string(size) + " bytes in PSRAM for '" + name + "'"); +>>>>>>> master } else { LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to allocate " + to_string(size) + " bytes in PSRAM for '" + name + "'!"); @@ -169,4 +183,8 @@ void *calloc_psram_heap(std::string name, size_t n, size_t size, uint32_t caps) void free_psram_heap(std::string name, void *ptr) { LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Freeing memory in PSRAM used for '" + name + "'..."); heap_caps_free(ptr); +<<<<<<< HEAD } +======= +} +>>>>>>> master diff --git a/code/components/jomjol_helper/psram.h b/code/components/jomjol_helper/psram.h index 4c85bf26..cf95f202 100644 --- a/code/components/jomjol_helper/psram.h +++ b/code/components/jomjol_helper/psram.h @@ -1,3 +1,4 @@ +<<<<<<< HEAD #pragma once #ifndef PSRAM_h #define PSRAM_h @@ -32,3 +33,12 @@ void *calloc_psram_heap(std::string name, size_t n, size_t size, uint32_t caps); void free_psram_heap(std::string name, void *ptr); #endif // PSRAM_h +======= + +#include "esp_heap_caps.h" + +void *malloc_psram_heap(std::string name, size_t size, uint32_t caps); +void *calloc_psram_heap(std::string name, size_t n, size_t size, uint32_t caps); + +void free_psram_heap(std::string name, void *ptr); +>>>>>>> master diff --git a/code/components/jomjol_image_proc/CImageBasis.cpp b/code/components/jomjol_image_proc/CImageBasis.cpp index a61ca7cd..dc080224 100644 --- a/code/components/jomjol_image_proc/CImageBasis.cpp +++ b/code/components/jomjol_image_proc/CImageBasis.cpp @@ -477,6 +477,7 @@ CImageBasis::CImageBasis(string _name, CImageBasis *_copyfrom) memsize = width * height * channels; +<<<<<<< HEAD if (name == "tmpImage") { rgb_image = (unsigned char*)psram_reserve_shared_tmp_image_memory(); @@ -484,6 +485,9 @@ CImageBasis::CImageBasis(string _name, CImageBasis *_copyfrom) else { rgb_image = (unsigned char*)malloc_psram_heap(std::string(TAG) + "->CImageBasis (" + name + ")", memsize, MALLOC_CAP_SPIRAM); } +======= + rgb_image = (unsigned char*)malloc_psram_heap(std::string(TAG) + "->CImageBasis (" + name + ")", memsize, MALLOC_CAP_SPIRAM); +>>>>>>> master if (rgb_image == NULL) { @@ -624,6 +628,7 @@ CImageBasis::~CImageBasis() { RGBImageLock(); +<<<<<<< HEAD if (!externalImage) { if (name == "tmpImage") { // This image should be placed in the shared part of PSRAM @@ -638,6 +643,11 @@ CImageBasis::~CImageBasis() free_psram_heap(std::string(TAG) + "->CImageBasis (" + name + ", " + to_string(memsize) + ")", rgb_image); } } +======= + if (!externalImage) { + //stbi_image_free(rgb_image); + free_psram_heap(std::string(TAG) + "->CImageBasis (" + name + ", " + to_string(memsize) + ")", rgb_image); +>>>>>>> master } RGBImageRelease(); diff --git a/code/components/jomjol_mqtt/interface_mqtt.cpp b/code/components/jomjol_mqtt/interface_mqtt.cpp index 1ab8f03f..0a2267a8 100644 --- a/code/components/jomjol_mqtt/interface_mqtt.cpp +++ b/code/components/jomjol_mqtt/interface_mqtt.cpp @@ -248,6 +248,7 @@ int MQTT_Init() { LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Init"); MQTTdestroy_client(false); +<<<<<<< HEAD esp_mqtt_client_config_t mqtt_cfg = { }; mqtt_cfg.broker.address.uri = uri.c_str(); @@ -262,6 +263,22 @@ int MQTT_Init() { mqtt_cfg.session.last_will.msg_len = (int)(lwt_disconnected.length()); mqtt_cfg.session.keepalive = keepalive; mqtt_cfg.buffer.size = 1536; // size of MQTT send/receive buffer (Default: 1024) +======= + esp_mqtt_client_config_t mqtt_cfg = { + .uri = uri.c_str(), + .client_id = client_id.c_str(), + .lwt_topic = lwt_topic.c_str(), + .lwt_msg = lwt_disconnected.c_str(), + .lwt_retain = 1, + .lwt_msg_len = (int)(lwt_disconnected.length()), + .keepalive = keepalive, + .disable_auto_reconnect = false, // Reconnection routine active (Default: false) + .buffer_size = 1536, // size of MQTT send/receive buffer (Default: 1024) + .reconnect_timeout_ms = 15000, // Try to reconnect to broker (Default: 10000ms) + .network_timeout_ms = 20000, // Network Timeout (Default: 10000ms) + .message_retransmit_timeout = 3000 // Time after message resent when broker not acknowledged (QoS1, QoS2) + }; +>>>>>>> master if (user.length() && password.length()){ mqtt_cfg.credentials.username = user.c_str(); diff --git a/code/components/jomjol_tfliteclass/CTfLiteClass.cpp b/code/components/jomjol_tfliteclass/CTfLiteClass.cpp index 1f8d1daf..1d3dcc31 100644 --- a/code/components/jomjol_tfliteclass/CTfLiteClass.cpp +++ b/code/components/jomjol_tfliteclass/CTfLiteClass.cpp @@ -258,7 +258,11 @@ bool CTfLiteClass::ReadFileToModel(std::string _fn) LogFile.WriteHeapInfo("CTLiteClass::Alloc modelfile start"); #endif +<<<<<<< HEAD modelfile = (unsigned char*)psram_get_shared_model_memory(); +======= + modelfile = (unsigned char*)malloc_psram_heap(std::string(TAG) + "->modelfile", size, MALLOC_CAP_SPIRAM); +>>>>>>> master if(modelfile != NULL) { @@ -311,9 +315,15 @@ CTfLiteClass::CTfLiteClass() this->modelfile = NULL; this->interpreter = nullptr; this->input = nullptr; +<<<<<<< HEAD this->output = nullptr; this->kTensorArenaSize = TENSOR_ARENA_SIZE; this->tensor_arena = (uint8_t*)psram_get_shared_tensor_arena_memory(); +======= + this->output = nullptr; + this->kTensorArenaSize = 800 * 1024; /// according to testfile: 108000 - so far 600;; 2021-09-11: 200 * 1024 + this->tensor_arena = (uint8_t*)malloc_psram_heap(std::string(TAG) + "->tensor_arena", kTensorArenaSize, MALLOC_CAP_SPIRAM); +>>>>>>> master } @@ -322,7 +332,12 @@ CTfLiteClass::~CTfLiteClass() delete this->interpreter; delete this->error_reporter; +<<<<<<< HEAD psram_free_shared_tensor_arena_and_model_memory(); +======= + free_psram_heap(std::string(TAG) + "->modelfile", modelfile); + free_psram_heap(std::string(TAG) + "->tensor_arena", this->tensor_arena); +>>>>>>> master } diff --git a/code/sdkconfig.defaults b/code/sdkconfig.defaults index d7e142f3..4ef6266d 100644 --- a/code/sdkconfig.defaults +++ b/code/sdkconfig.defaults @@ -101,9 +101,14 @@ CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384 CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=40960 CONFIG_SPIRAM_CACHE_WORKAROUND=y CONFIG_SPIRAM_IGNORE_NOTFOUND=y +<<<<<<< HEAD CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y +======= +#CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y => Leads to memory fragmentation, see https://github.com/jomjol/AI-on-the-edge-device/issues/2200 +#CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y => Leads to memory fragmentation, see https://github.com/jomjol/AI-on-the-edge-device/issues/2200 +>>>>>>> master CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 @@ -125,7 +130,7 @@ CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED=y CONFIG_MQTT_USE_CORE_0=y CONFIG_MQTT_USE_CUSTOM_CONFIG=y #CONFIG_MQTT_OUTBOX_EXPIRED_TIMEOUT_MS=5000 -CONFIG_MQTT_CUSTOM_OUTBOX=y +#CONFIG_MQTT_CUSTOM_OUTBOX=y # -> Use custom outbox in components/jomjol_mqtt/mqtt_outbox.h/cpp. If USE_PSRAM is enabled in there, it will save 10 kBytes of internal RAM. How ever it also leads to memory fragmentation, see https://github.com/jomjol/AI-on-the-edge-device/issues/2200 CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=n