mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-09 04:56:53 +03:00
merge conflicts
This commit is contained in:
@@ -190,11 +190,7 @@ bool ClassFlowAlignment::doFlow(string time)
|
|||||||
|
|
||||||
if (!ImageTMP)
|
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("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)
|
if (!ImageTMP)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Can't allocate tmpImage -> Exec this round aborted!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Can't allocate tmpImage -> Exec this round aborted!");
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
<<<<<<< HEAD
|
|
||||||
#include "../../include/defines.h"
|
#include "../../include/defines.h"
|
||||||
#include "psram.h"
|
#include "psram.h"
|
||||||
=======
|
|
||||||
#include "esp_heap_caps.h"
|
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
static const char* TAG = "PSRAM";
|
static const char* TAG = "PSRAM";
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
void *shared_region = NULL;
|
void *shared_region = NULL;
|
||||||
uint32_t allocatedBytesForSTBI = 0;
|
uint32_t allocatedBytesForSTBI = 0;
|
||||||
|
|
||||||
@@ -128,8 +123,6 @@ void psram_free_shared_tensor_arena_and_model_memory(void) {
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
* General
|
* General
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
=======
|
|
||||||
>>>>>>> master
|
|
||||||
void *malloc_psram_heap(std::string name, size_t size, uint32_t caps) {
|
void *malloc_psram_heap(std::string name, size_t size, uint32_t caps) {
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
@@ -145,7 +138,6 @@ 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) {
|
void *realloc_psram_heap(std::string name, void *ptr, size_t size, uint32_t caps) {
|
||||||
ptr = heap_caps_realloc(ptr, size, caps);
|
ptr = heap_caps_realloc(ptr, size, caps);
|
||||||
if (ptr != NULL) {
|
if (ptr != NULL) {
|
||||||
@@ -159,18 +151,12 @@ 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 *calloc_psram_heap(std::string name, size_t n, size_t size, uint32_t caps) {
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
ptr = heap_caps_calloc(n, size, caps);
|
ptr = heap_caps_calloc(n, size, caps);
|
||||||
if (ptr != NULL) {
|
if (ptr != NULL) {
|
||||||
<<<<<<< HEAD
|
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Allocated " + to_string(size) + " bytes in PSRAM for '" + name + "'");
|
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 {
|
else {
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to allocate " + to_string(size) + " bytes in PSRAM for '" + name + "'!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to allocate " + to_string(size) + " bytes in PSRAM for '" + name + "'!");
|
||||||
@@ -183,8 +169,4 @@ 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) {
|
void free_psram_heap(std::string name, void *ptr) {
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Freeing memory in PSRAM used for '" + name + "'...");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Freeing memory in PSRAM used for '" + name + "'...");
|
||||||
heap_caps_free(ptr);
|
heap_caps_free(ptr);
|
||||||
<<<<<<< HEAD
|
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
}
|
|
||||||
>>>>>>> master
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
<<<<<<< HEAD
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef PSRAM_h
|
#ifndef PSRAM_h
|
||||||
#define PSRAM_h
|
#define PSRAM_h
|
||||||
@@ -33,12 +32,3 @@ 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);
|
void free_psram_heap(std::string name, void *ptr);
|
||||||
|
|
||||||
#endif // PSRAM_h
|
#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
|
|
||||||
|
|||||||
@@ -477,7 +477,6 @@ CImageBasis::CImageBasis(string _name, CImageBasis *_copyfrom)
|
|||||||
|
|
||||||
memsize = width * height * channels;
|
memsize = width * height * channels;
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
if (name == "tmpImage") {
|
if (name == "tmpImage") {
|
||||||
rgb_image = (unsigned char*)psram_reserve_shared_tmp_image_memory();
|
rgb_image = (unsigned char*)psram_reserve_shared_tmp_image_memory();
|
||||||
@@ -485,9 +484,6 @@ CImageBasis::CImageBasis(string _name, CImageBasis *_copyfrom)
|
|||||||
else {
|
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);
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
rgb_image = (unsigned char*)malloc_psram_heap(std::string(TAG) + "->CImageBasis (" + name + ")", memsize, MALLOC_CAP_SPIRAM);
|
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
if (rgb_image == NULL)
|
if (rgb_image == NULL)
|
||||||
{
|
{
|
||||||
@@ -628,7 +624,6 @@ CImageBasis::~CImageBasis()
|
|||||||
{
|
{
|
||||||
RGBImageLock();
|
RGBImageLock();
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
if (!externalImage) {
|
if (!externalImage) {
|
||||||
if (name == "tmpImage") { // This image should be placed in the shared part of PSRAM
|
if (name == "tmpImage") { // This image should be placed in the shared part of PSRAM
|
||||||
@@ -643,11 +638,6 @@ CImageBasis::~CImageBasis()
|
|||||||
free_psram_heap(std::string(TAG) + "->CImageBasis (" + name + ", " + to_string(memsize) + ")", rgb_image);
|
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();
|
RGBImageRelease();
|
||||||
|
|||||||
@@ -248,7 +248,6 @@ int MQTT_Init() {
|
|||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Init");
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Init");
|
||||||
MQTTdestroy_client(false);
|
MQTTdestroy_client(false);
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
esp_mqtt_client_config_t mqtt_cfg = { };
|
esp_mqtt_client_config_t mqtt_cfg = { };
|
||||||
|
|
||||||
mqtt_cfg.broker.address.uri = uri.c_str();
|
mqtt_cfg.broker.address.uri = uri.c_str();
|
||||||
@@ -263,22 +262,6 @@ int MQTT_Init() {
|
|||||||
mqtt_cfg.session.last_will.msg_len = (int)(lwt_disconnected.length());
|
mqtt_cfg.session.last_will.msg_len = (int)(lwt_disconnected.length());
|
||||||
mqtt_cfg.session.keepalive = keepalive;
|
mqtt_cfg.session.keepalive = keepalive;
|
||||||
mqtt_cfg.buffer.size = 1536; // size of MQTT send/receive buffer (Default: 1024)
|
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()){
|
if (user.length() && password.length()){
|
||||||
mqtt_cfg.credentials.username = user.c_str();
|
mqtt_cfg.credentials.username = user.c_str();
|
||||||
|
|||||||
@@ -258,11 +258,7 @@ bool CTfLiteClass::ReadFileToModel(std::string _fn)
|
|||||||
LogFile.WriteHeapInfo("CTLiteClass::Alloc modelfile start");
|
LogFile.WriteHeapInfo("CTLiteClass::Alloc modelfile start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
modelfile = (unsigned char*)psram_get_shared_model_memory();
|
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)
|
if(modelfile != NULL)
|
||||||
{
|
{
|
||||||
@@ -315,15 +311,9 @@ CTfLiteClass::CTfLiteClass()
|
|||||||
this->modelfile = NULL;
|
this->modelfile = NULL;
|
||||||
this->interpreter = nullptr;
|
this->interpreter = nullptr;
|
||||||
this->input = nullptr;
|
this->input = nullptr;
|
||||||
<<<<<<< HEAD
|
|
||||||
this->output = nullptr;
|
this->output = nullptr;
|
||||||
this->kTensorArenaSize = TENSOR_ARENA_SIZE;
|
this->kTensorArenaSize = TENSOR_ARENA_SIZE;
|
||||||
this->tensor_arena = (uint8_t*)psram_get_shared_tensor_arena_memory();
|
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -332,12 +322,7 @@ CTfLiteClass::~CTfLiteClass()
|
|||||||
delete this->interpreter;
|
delete this->interpreter;
|
||||||
delete this->error_reporter;
|
delete this->error_reporter;
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
psram_free_shared_tensor_arena_and_model_memory();
|
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -101,14 +101,9 @@ CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384
|
|||||||
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=40960
|
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=40960
|
||||||
CONFIG_SPIRAM_CACHE_WORKAROUND=y
|
CONFIG_SPIRAM_CACHE_WORKAROUND=y
|
||||||
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
|
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
|
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
|
||||||
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=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
|
CONFIG_ESP_INT_WDT_TIMEOUT_MS=300
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user