vApplicationStackOverflowHook

ftsi wrote on Sunday, May 26, 2019:

Hi
i would like to create just 2 tasks. But i gor error of vApplicationStackOverflowHook.

#include "stm32f30x.h"
#include "FreeRTOS.h"
#include "task.h"
//Task functions prototypes
void vTask1_handlder(void *params);
void vTask2_handlder(void *params);

TaskHandle_t xTaskHandle1 = NULL;
TaskHandle_t xTaskHandle2 = NULL;

int main(void)
{
	//1. Reset the RCC clock configuration to the default reset state
	//HSI ON,PLL OFF, HSE OFF, system clock = 8 MHz
	RCC_DeInit();

	//2. update the SystemCoreClock variable
	SystemCoreClockUpdate();

	xTaskCreate(vTask1_handlder, "Task-1",configMINIMAL_STACK_SIZE,NULL,2,&xTaskHandle1);

	xTaskCreate(vTask2_handlder, "Task-2",configMINIMAL_STACK_SIZE,NULL,2,&xTaskHandle2);
	for(;;);
}

void vTask1_handlder(void *params)
{
while(1);
}

void vTask2_handlder(void *params)
{
while(1);
}

as far as I know, this kind of error are connected with FreeRTOSConfig.h. I search something in the forum but changing some parameters value like configUSE_MALLOC_FAILED_HOOK, configCHECK_FOR_STACK_OVERFLOW, i have never solved the issues.
The compiler gives me:

d:/openstm32/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.17.0.201812190825/tools/compiler/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: STM32_HelloWorld.elf section `.bss' will not fit in region `RAM'
d:/openstm32/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.17.0.201812190825/tools/compiler/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 13736 bytes
Third-Party/FreeRTOS/ong/Source/tasks.o: In function `vTaskSwitchContext':
D:\Workspace\RTOS_workspace\STM32_HelloWorld\Debug/../Third-Party/FreeRTOS/ong/Source/tasks.c:2988: undefined reference to `vApplicationStackOverflowHook'
collect2.exe: error: ld returned 1 exit status
makefile:38: recipe for target 'STM32_HelloWorld.elf' failed
make: *** [STM32_HelloWorld.elf] Error 1

My Config file is:

....
#include "stm32f30x.h"
extern uint32_t SystemCoreClock;

#define configUSE_PREEMPTION				1
#define configUSE_IDLE_HOOK				0
#define configUSE_TICK_HOOK				0// it was 1
#define configCPU_CLOCK_HZ				(SystemCoreClock)
#define configTICK_RATE_HZ				((portTickType) 1000)
#define configMAX_PRIORITIES				(5) //it was ((unsigned portBASE_TYPE) 5)
#define configMINIMAL_STACK_SIZE			((unsigned short) 130)
#define configTOTAL_HEAP_SIZE				((size_t) (75 * 1024))
#define configMAX_TASK_NAME_LEN				(10)
#define configUSE_TRACE_FACILITY			1
#define configUSE_16_BIT_TICKS				0
#define configIDLE_SHOULD_YIELD				1
#define configUSE_MUTEXES				1
#define configQUEUE_REGISTRY_SIZE			8
#define configCHECK_FOR_STACK_OVERFLOW			2 // it was 2
#define configUSE_RECURSIVE_MUTEXES			1
#define configUSE_MALLOC_FAILED_HOOK			0
#define configUSE_APPLICATION_TASK_TAG			0
#define configUSE_COUNTING_SEMAPHORES			1
#define configGENERATE_RUN_TIME_STATS			0

/* Co-routine definitions. */
#define configUSE_CO_ROUTINES				0
#define configMAX_CO_ROUTINE_PRIORITIES			(2)

/* Software timer definitions. */
#define configUSE_TIMERS				1
#define configTIMER_TASK_PRIORITY			(2)
#define configTIMER_QUEUE_LENGTH			10
#define configTIMER_TASK_STACK_DEPTH			(configMINIMAL_STACK_SIZE * 2)

/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet			1
#define INCLUDE_uxTaskPriorityGet			1
#define INCLUDE_vTaskDelete				1
#define INCLUDE_vTaskCleanUpResources			1
#define INCLUDE_vTaskSuspend				1
#define INCLUDE_vTaskDelayUntil				1
#define INCLUDE_vTaskDelay				1
...

thanks in advance
Fausto

rtel wrote on Sunday, May 26, 2019:

I would definitely not expect a stack overflow with those settings as your tasks do not allocate any stack variables or call any functions. When does the stack overflow occur? Do the tasks ever start? Which compiler are you using and what is the optimization set to?

richarddamon wrote on Sunday, May 26, 2019:

You are getting a link error saying you haven;t defined vApplicationStackOverflowHook but you have configured FreeRTOS to call it because you have set configCHECK_FOR_STACK_OVERFLOW to 2.

You need to define the function vApplicationStackOverflowHook.

If you program is being written in C++, it also needs to be declared inside an extern “C” block, or it won’t have the right name.

ftsi wrote on Sunday, May 26, 2019:

Hi
I m using System Workbench of ST. The compiler is Ac6 STM32 MCU GCC.
As you can understand, i’m new with FreeRTOS and for me some names are unknown.

ftsi wrote on Sunday, May 26, 2019:

the appear in the file task,c in the void vTaskSwitchContext( void ) when the fucntion calls the function taskCHECK_FOR_STACK_OVERFLOW()
compiler : undefined reference to vApplicationStackOverflowHook’.
if i set configCHECK_FOR_STACK_OVERFLOW to 0, i have error of RAM:

d:/openstm32/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.17.0.201812190825/tools/compiler/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: STM32_HelloWorld.elf section `.bss' will not fit in region `RAM'
d:/openstm32/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.17.0.201812190825/tools/compiler/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 13736 bytes
collect2.exe: error: ld returned 1 exit status
makefile:38: recipe for target 'STM32_HelloWorld.elf' failed
make: *** [STM32_HelloWorld.elf] Error 1

rtel wrote on Sunday, May 26, 2019:

As Richard D said, if you want to use stack overflowing (which you
definitely should during development) then YOU need to implement
vApplicationStackOverflowHook(). Anything that starts “Application” is
the responsibility of the application writer. First link:

https://www.google.com/search?q=vApplicationStackOverflowHook

Also as Richard D says, the second error you are getting is that you are
trying to allocate 13KBytes more RAM than the linker script part says
you have available - so you need to reduce the RAM (this is nothing to
do with FreeRTOS by the way, but reducing the size of the heap allocated
to FreeRTOS may be all you need to do).

https://www.freertos.org/Documentation/RTOS_book.html