mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 12:36:52 +03:00
Modify stack sizes + max open files (SD) , add REST handler for heap/(stack) infos (#1751)
* Modify stack sizes+max open files,add rest handler * Update
This commit is contained in:
@@ -250,7 +250,7 @@ void GpioHandler::init()
|
||||
|
||||
if (xHandleTaskGpio == NULL) {
|
||||
gpio_queue_handle = xQueueCreate(10,sizeof(GpioResult));
|
||||
BaseType_t xReturned = xTaskCreate(&gpioHandlerTask, "gpio_int", configMINIMAL_STACK_SIZE * 8, (void *)this, tskIDLE_PRIORITY + 2, &xHandleTaskGpio);
|
||||
BaseType_t xReturned = xTaskCreate(&gpioHandlerTask, "gpio_int", 3 * 1024, (void *)this, tskIDLE_PRIORITY + 4, &xHandleTaskGpio);
|
||||
if(xReturned == pdPASS ) {
|
||||
ESP_LOGD(TAG, "xHandletaskGpioHandler started");
|
||||
} else {
|
||||
|
||||
@@ -134,6 +134,45 @@ bool doflow(void)
|
||||
}
|
||||
|
||||
|
||||
esp_err_t handler_get_heap(httpd_req_t *req)
|
||||
{
|
||||
#ifdef DEBUG_DETAIL_ON
|
||||
LogFile.WriteHeapInfo("handler_get_heap - Start");
|
||||
ESP_LOGD(TAG, "handler_get_heap uri: %s", req->uri);
|
||||
#endif
|
||||
|
||||
std::string zw = "Heap info:<br>" + getESPHeapInfo();
|
||||
|
||||
#ifdef TASK_ANALYSIS_ON
|
||||
char* pcTaskList = (char*) heap_caps_calloc(1, sizeof(char) * 768, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
|
||||
if (pcTaskList) {
|
||||
vTaskList(pcTaskList);
|
||||
zw = zw + "<br><br>Task info:<br><pre>Name | State | Prio | Lowest stacksize | Creation order | CPU (-1=NoAffinity)<br>"
|
||||
+ std::string(pcTaskList) + "</pre>";
|
||||
heap_caps_free(pcTaskList);
|
||||
}
|
||||
else {
|
||||
zw = zw + "<br><br>Task info:<br>ERROR - Allocation of TaskList buffer in PSRAM failed";
|
||||
}
|
||||
#endif
|
||||
|
||||
if (zw.length() > 0)
|
||||
{
|
||||
httpd_resp_send(req, zw.c_str(), zw.length());
|
||||
}
|
||||
else
|
||||
{
|
||||
httpd_resp_send(req, NULL, 0);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DETAIL_ON
|
||||
LogFile.WriteHeapInfo("handler_get_heap - Done");
|
||||
#endif
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
esp_err_t handler_init(httpd_req_t *req)
|
||||
{
|
||||
#ifdef DEBUG_DETAIL_ON
|
||||
@@ -875,15 +914,12 @@ void TFliteDoAutoStart()
|
||||
{
|
||||
BaseType_t xReturned;
|
||||
|
||||
int _i = configMINIMAL_STACK_SIZE;
|
||||
|
||||
ESP_LOGD(TAG, "task_autodoFlow configMINIMAL_STACK_SIZE: %d", _i);
|
||||
ESP_LOGD(TAG, "getESPHeapInfo: %s", getESPHeapInfo().c_str());
|
||||
|
||||
xReturned = xTaskCreate(&task_autodoFlow, "task_autodoFlow", configMINIMAL_STACK_SIZE * 35, NULL, tskIDLE_PRIORITY+1, &xHandletask_autodoFlow);
|
||||
xReturned = xTaskCreatePinnedToCore(&task_autodoFlow, "task_autodoFlow", 16 * 1024, NULL, tskIDLE_PRIORITY+2, &xHandletask_autodoFlow, 0);
|
||||
//xReturned = xTaskCreate(&task_autodoFlow, "task_autodoFlow", 16 * 1024, NULL, tskIDLE_PRIORITY+2, &xHandletask_autodoFlow);
|
||||
if( xReturned != pdPASS )
|
||||
{
|
||||
//Memory: 64 --> 48 --> 35 --> 25
|
||||
ESP_LOGD(TAG, "ERROR task_autodoFlow konnte nicht erzeugt werden!");
|
||||
}
|
||||
ESP_LOGD(TAG, "getESPHeapInfo: %s", getESPHeapInfo().c_str());
|
||||
@@ -989,4 +1025,9 @@ void register_server_tflite_uri(httpd_handle_t server)
|
||||
camuri.handler = handler_json;
|
||||
camuri.user_ctx = (void*) "JSON";
|
||||
httpd_register_uri_handler(server, &camuri);
|
||||
|
||||
camuri.uri = "/heap";
|
||||
camuri.handler = handler_get_heap;
|
||||
camuri.user_ctx = (void*) "Heap";
|
||||
httpd_register_uri_handler(server, &camuri);
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ void LEDBlinkTask(int _dauer, int _anz, bool _off)
|
||||
BlinkAnzahl = _anz;
|
||||
BlinkOff = _off;
|
||||
|
||||
xTaskCreate(&task_doBlink, "task_doBlink", configMINIMAL_STACK_SIZE * 8, NULL, tskIDLE_PRIORITY+1, NULL);
|
||||
xTaskCreate(&task_doBlink, "task_doBlink", 4 * 1024, NULL, tskIDLE_PRIORITY+1, NULL);
|
||||
}
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -6,6 +6,18 @@
|
||||
//// Global definitions ////
|
||||
/////////////////////////////////////////////
|
||||
|
||||
/* Uncomment this to generate task list with stack sizes using the /heap handler
|
||||
PLEASE BE AWARE: The following CONFIG parameters have to to be set in
|
||||
sdkconfig.defaults before use of this function is possible!!
|
||||
|
||||
CONFIG_FREERTOS_USE_TRACE_FACILITY=1
|
||||
CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y
|
||||
CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y
|
||||
*/
|
||||
// server_tflite.cpp
|
||||
//#define TASK_ANALYSIS_ON
|
||||
|
||||
|
||||
/* Uncomment this to keep the logfile open for appending.
|
||||
* If commented out, the logfile gets opened/closed for each log measage (old behaviour) */
|
||||
// ClassLogFile
|
||||
|
||||
@@ -92,7 +92,7 @@ bool Init_NVS_SDCard()
|
||||
// formatted in case when mounting fails.
|
||||
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
|
||||
.format_if_mount_failed = false,
|
||||
.max_files = 7, // anstatt 5 (2022-09-21)
|
||||
.max_files = 12, // previously -> 2022-09-21: 5, 2023-01-02: 7
|
||||
.allocation_unit_size = 16 * 1024
|
||||
};
|
||||
|
||||
|
||||
@@ -451,13 +451,13 @@ httpd_handle_t start_webserver(void)
|
||||
httpd_handle_t server = NULL;
|
||||
httpd_config_t config = { };
|
||||
|
||||
config.task_priority = tskIDLE_PRIORITY+3; //20221211: before: tskIDLE_PRIORITY+1; // 20210924 --> before +5
|
||||
config.stack_size = 32768; //20210921 --> before 32768 // at 32k the programme crashes when taking pictures
|
||||
config.core_id = 0; //20221211 --> force all not flow related tasks to CPU0, before: tskNO_AFFINITY;
|
||||
config.task_priority = tskIDLE_PRIORITY+3; // previously -> 2022-12-11: tskIDLE_PRIORITY+1; 2021-09-24: tskIDLE_PRIORITY+5
|
||||
config.stack_size = 12288; // previously -> 2023-01-02: 32768
|
||||
config.core_id = 1; // previously -> 2023-01-02: 0, 2022-12-11: tskNO_AFFINITY;
|
||||
config.server_port = 80;
|
||||
config.ctrl_port = 32768;
|
||||
config.max_open_sockets = 5; //20210921 --> previously 7
|
||||
config.max_uri_handlers = 38; // previously 24, 20220511: 35, 20221220: 37
|
||||
config.max_uri_handlers = 38; // previously 24, 20220511: 35, 20221220: 37, 2023-01-02:38
|
||||
config.max_resp_headers = 8;
|
||||
config.backlog_conn = 5;
|
||||
config.lru_purge_enable = true; // this cuts old connections if new ones are needed.
|
||||
|
||||
@@ -132,3 +132,8 @@ CONFIG_GC2145_SUPPORT=n
|
||||
CONFIG_GC032A_SUPPORT=n
|
||||
CONFIG_GC0308_SUPPORT=n
|
||||
CONFIG_BF3005_SUPPORT=n
|
||||
|
||||
#only necessary for task analysis (include/defines -> TASK_ANALYSIS_ON)
|
||||
#CONFIG_FREERTOS_USE_TRACE_FACILITY=1
|
||||
#CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y
|
||||
#CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y
|
||||
|
||||
Reference in New Issue
Block a user