While Configuring FreeRTOS in STMCubeide an error occurs

arm-none-eabi-gcc -o “001Tasks_CM4.elf” @“objects.list” -mcpu=cortex-m4 -T"G:\WorkSpace\RTOS_Workspace\001Tasks\CM4\STM32MP157DACX_RAM.ld" --specs=nosys.specs -Wl,-Map=“001Tasks_CM4.map” -Wl,–gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,–start-group -lc -lm -Wl,–end-group

C:/ST/STM32CubeIDE_1.16.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.200.202406191623/tools/bin/…/lib/gcc/arm-none-eabi/12.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: ./Third_Party/FreeRTOS/tasks.o: in function `vTaskStartScheduler’:

G:/WorkSpace/RTOS_Workspace/001Tasks/CM4/Debug/…/Third_Party/FreeRTOS/tasks.c:1967: undefined reference to `vApplicationGetIdleTaskMemory’

C:/ST/STM32CubeIDE_1.16.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.200.202406191623/tools/bin/…/lib/gcc/arm-none-eabi/12.3.1/…/…/…/…/arm-none-eabi/bin/ld.exe: ./Third_Party/FreeRTOS/timers.o: in function `xTimerCreateTimerTask’:

G:/WorkSpace/RTOS_Workspace/001Tasks/CM4/Debug/…/Third_Party/FreeRTOS/timers.c:251: undefined reference to `vApplicationGetTimerTaskMemory’

collect2.exe: error: ld returned 1 exit status

make: *** [makefile:68: 001Tasks_CM4.elf] Error 1

“make -j4 all” terminated with exit code 2. Build might be incomplete.

21:15:55 Build Failed. 3 errors, 4 warnings. (took 4s.476ms)

The above error occurs and not able to solve Please help to resolve it.

Looks like you configures Static Task creations, and then didn’t define the function vApplicationGetTimerTaskMemory or the define (configKERNEL_PROVIDED_STATIC_MEMORY) to make the system provide that function.

I have define configKERNEL_PROVIDED_STATIC_MEMORY in freeRTOSconfig file. still have this error. I have given the freeRTOSconfig file contain. please verify it.

/* USER CODE BEGIN Header /
/

  • FreeRTOS Kernel V10.0.1

  • Permission is hereby granted, free of charge, to any person obtaining a copy of

  • this software and associated documentation files (the “Software”), to deal in

  • the Software without restriction, including without limitation the rights to

  • use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of

  • the Software, and to permit persons to whom the Software is furnished to do so,

  • subject to the following conditions:

  • The above copyright notice and this permission notice shall be included in all

  • copies or substantial portions of the Software.

  • THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

  • IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS

  • FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR

  • COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER

  • IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN

  • CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

  • 1 tab == 4 spaces!
    /
    /
    USER CODE END Header */

#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H

/*-----------------------------------------------------------

  • Application specific definitions.
  • These definitions should be adjusted for your particular hardware and
  • application requirements.
  • These parameters and more are described within the ‘configuration’ section of the
  • FreeRTOS API documentation available on the FreeRTOS web site.

----------------------------------------------------------/

/* USER CODE BEGIN Includes /
/
Section where include file can be added /
/
USER CODE END Includes */

/* Ensure definitions are only used by the compiler, and not by the assembler. */
#if defined(ICCARM) || defined(__CC_ARM) || defined(GNUC)
#include <stdint.h>
extern uint32_t SystemCoreClock;
#endif
#define configUSE_PREEMPTION 1
#define configSUPPORT_STATIC_ALLOCATION 1
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( SystemCoreClock )
#define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES ( 56 )
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
#define configTOTAL_HEAP_SIZE ((size_t)3072)
#define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
#define configUSE_MUTEXES 1
#define configQUEUE_REGISTRY_SIZE 8
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#define configKERNEL_PROVIDED_STATIC_MEMORY 1 //Added by me

/* 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 256

/* 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 0
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_xTimerPendFunctionCall 1
#define INCLUDE_xQueueGetMutexHolder 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1
#define INCLUDE_eTaskGetState 1

/*

  • The CMSIS-RTOS V2 FreeRTOS wrapper is dependent on the heap implementation used
  • by the application thus the correct define need to be enabled below
    */
    #define USE_FreeRTOS_HEAP_4

/* Cortex-M specific definitions. /
#ifdef __NVIC_PRIO_BITS
/
__BVIC_PRIO_BITS will be specified when CMSIS is being used. */
#define configPRIO_BITS __NVIC_PRIO_BITS
#else
#define configPRIO_BITS 4
#endif

/* The lowest interrupt priority that can be used in a call to a “set priority”
function. */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15

/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5

/* Interrupt priorities used by the kernel port layer itself. These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

/* Normal assert() semantics without relying on the provision of an assert.h
header file. /
/
USER CODE BEGIN 1 /
#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}
/
USER CODE END 1 */

/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
standard names. */
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler

/* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick,
to prevent overwriting SysTick_Handler defined within STM32Cube HAL */
#define xPortSysTickHandler SysTick_Handler

/* USER CODE BEGIN Defines /
/
USER CODE END Defines */

#endif /* FREERTOS_CONFIG_H */

I would check if that function was supported in that version. You might need a newer version to get that support, or you need to write the function yourself.

I was using new version of FreeRTOS. Can you please help me what exactly i can do to solve.

Your config file says 10.0.1, which might be too old to have that function. Check the end of tasks.c to see if they are there in your code base (STM may still be using older versions of FreeRTOS).

Also, if you are using the MPU, the option doesn’t work, and you need to define the functions yourself to put the stacks at appropriate memory addresses. It looks like it was added to the kernel in sept 2023 which puts it into V10.6.2, so if your version of the kernel isn’t that new, you need to either upgrade it (and possible work around STM cubes version) or add the functions to your own code.

configKERNEL_PROVIDED_STATIC_MEMORY was added in FreeRTOS V11.0.0 , so you need to verify if you are using this version of FreeRTOS-Kernel, or implement those functions yourself for them to be available. You can use this as a reference for implementing these functions.

As @karahulx mentioned, copy the following to one of your c files:

void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
                                    StackType_t ** ppxIdleTaskStackBuffer,
                                    configSTACK_DEPTH_TYPE * puxIdleTaskStackSize )
{
    static StaticTask_t xIdleTaskTCB;
    static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];

    *ppxIdleTaskTCBBuffer = &( xIdleTaskTCB );
    *ppxIdleTaskStackBuffer = &( uxIdleTaskStack[ 0 ] );
    *puxIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}

void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
                                     StackType_t ** ppxTimerTaskStackBuffer,
                                     configSTACK_DEPTH_TYPE * puxTimerTaskStackSize )
{
    static StaticTask_t xTimerTaskTCB;
    static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];

    *ppxTimerTaskTCBBuffer = &( xTimerTaskTCB );
    *ppxTimerTaskStackBuffer = &( uxTimerTaskStack[ 0 ] );
    *puxTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}

Hello guys,
As I have try to configure FreeRTOSConfig.c file according to customization document give in FrreRTOS website and the above given error is not coming now. But new problem occurs, the task that I was creating usings xTaskCreate() was created but as soon as start kernel using vTaskStartScheduler() , It got stuck in this function after/within bellow this given point.
(if( xReturn == pdPASS )
{
xReturn = xTimerCreateTimerTask();
})

Can you break the code in the debugger and see what it is doing when it appears hang?
Do you have configASSERT defined and stack overflow check enabled?
Also it would be helpful if you share the entire code.

My first guess is that if xTimerCreateTimerTask is hanging, it is because it ran out of memory to create the timer task.

Knowing where in there is halts would answer that better.