From 06b5e2d080840be28139ea37f27dc2f98e25cc9d Mon Sep 17 00:00:00 2001 From: Ryan Srichai Date: Mon, 18 Nov 2024 11:50:55 -0600 Subject: [PATCH] added stack overflow message and fixed memory problem with stats printing. Stats seem to be broken also --- sdk/freertos_app_cpu0/src/FreeRTOSConfig.h | 5 ++++- sdk/freertos_app_cpu0/src/main.c | 4 ++++ sdk/freertos_app_cpu0/src/usr/vsiApp/task_vsiApp.c | 2 +- sdk/shared/sys/commands.c | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sdk/freertos_app_cpu0/src/FreeRTOSConfig.h b/sdk/freertos_app_cpu0/src/FreeRTOSConfig.h index d575b590..040b0a68 100644 --- a/sdk/freertos_app_cpu0/src/FreeRTOSConfig.h +++ b/sdk/freertos_app_cpu0/src/FreeRTOSConfig.h @@ -95,7 +95,7 @@ #define configIDLE_SHOULD_YIELD 1 #define configUSE_MUTEXES 1 #define configQUEUE_REGISTRY_SIZE 8 -#define configCHECK_FOR_STACK_OVERFLOW 0 +#define configCHECK_FOR_STACK_OVERFLOW 1 #define configUSE_RECURSIVE_MUTEXES 1 #define configUSE_MALLOC_FAILED_HOOK 0 #define configUSE_APPLICATION_TASK_TAG 0 @@ -160,6 +160,9 @@ extern void vInitialiseTimerForRunTimeStats(void); #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vInitialiseTimerForRunTimeStats() #define portGET_RUN_TIME_COUNTER_VALUE() ((0xffffffffUL - XScuWdt_ReadReg(xTimerStats.Config.BaseAddr, XSCUWDT_COUNTER_OFFSET)) >> 1) +/* https://forums.freertos.org/t/run-time-statistics-overrun/12928 */ +#define configRUN_TIME_COUNTER_TYPE uint64_t + /* The size of the global output buffer that is available for use when there are multiple command interpreters running at once (for example, one on a UART diff --git a/sdk/freertos_app_cpu0/src/main.c b/sdk/freertos_app_cpu0/src/main.c index 0802aecf..11a7f944 100644 --- a/sdk/freertos_app_cpu0/src/main.c +++ b/sdk/freertos_app_cpu0/src/main.c @@ -233,6 +233,10 @@ void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer, StackT *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; } +void vApplicationStackOverflowHook(TaskHandle_t xTask, char * pcTaskName) { + xil_printf("STACK OVERRFLOW ON TASK %s\n", pcTaskName); +} + /*******************************************************************************/ /* S E T U P I N T E R R U P T S Y S T E M */ /*******************************************************************************/ diff --git a/sdk/freertos_app_cpu0/src/usr/vsiApp/task_vsiApp.c b/sdk/freertos_app_cpu0/src/usr/vsiApp/task_vsiApp.c index 9630b1c8..88951e2d 100644 --- a/sdk/freertos_app_cpu0/src/usr/vsiApp/task_vsiApp.c +++ b/sdk/freertos_app_cpu0/src/usr/vsiApp/task_vsiApp.c @@ -126,7 +126,7 @@ void task_vsiApp(void *arg) // Read in values sampled on the AMDS (plugged into your GPIO port) from all channels: int err; err = amds_get_data(amds_port, AMDS_CH_1, &out_ch_1); - amds_current_a = out_ch_1; + amds_current_a = 0.00125 * out_ch_1; // Now, "out" variables contain the sign-extended 16-bit // sample value for each channel } diff --git a/sdk/shared/sys/commands.c b/sdk/shared/sys/commands.c index fb9b3f3f..6e02df31 100644 --- a/sdk/shared/sys/commands.c +++ b/sdk/shared/sys/commands.c @@ -139,14 +139,14 @@ void commands_init(void) printf("CMD:\tInitializing command tasks...\n"); // Command parse & exec task (UART) if (uartTaskExists == 0) { - xTaskCreate(commands_uart, (const char *) "command_uart", 1024, + xTaskCreate(commands_uart, (const char *) "command_uart", 2048, NULL, tskIDLE_PRIORITY, &tcb_uart); uartTaskExists = 1; } // Command parse task (ETH) if (ethTaskExists == 0) { - xTaskCreate(commands_eth, (const char *) "command_eth", 1024, + xTaskCreate(commands_eth, (const char *) "command_eth", 2048, NULL, tskIDLE_PRIORITY, &tcb_eth); ethTaskExists = 1; }