FreeRTOS Task getting created but not executing


I am trying to intigrate FreeRTOS with an evk board that freertos does not have a support for(Alif ensemble E7). The processor used in it is CORTEX M55. I am facing the problem where get the prints the task has been created but i dont find it executing.

I have added the rtos kernel files tasks.c,list.c,queue.c. Also for porting freertos I have added port.c , portasm.c for the GCC compiler and ARM cortex M55 processor.

In the application code I am just trying to blink the leds in while(1) creating some delay using xtaskDelay.

The compiler i am using is GCC.

The following are the macros that I am using in FreeRTOSConfig.h


#define configUSE_PREEMPTION                    1
#define configUSE_TICKLESS_IDLE                 0
#define configCPU_CLOCK_HZ                      400000000
#define configSYSTICK_CLOCK_HZ                  400000
#define configTICK_RATE_HZ                      1000
#define configMAX_PRIORITIES                    5
#define configMINIMAL_SECURE_STACK_SIZE         1024  //my
#define configMINIMAL_STACK_SIZE                128  //my
#define configMAX_TASK_NAME_LEN                 16
#define configUSE_16_BIT_TICKS                  0
#define configIDLE_SHOULD_YIELD                 1
#define configUSE_TASK_NOTIFICATIONS            1
#define configUSE_MUTEXES                       0
#define configUSE_RECURSIVE_MUTEXES             0
#define configUSE_COUNTING_SEMAPHORES           0
#define configUSE_ALTERNATIVE_API               0 /* Deprecated! */
#define configQUEUE_REGISTRY_SIZE               10

#define configSTACK_DEPTH_TYPE                  uint32_t
#define configMESSAGE_BUFFER_LENGTH_TYPE        uint8_t
#define configHEAP_CLEAR_MEMORY_ON_FREE         1

/* Memory allocation related definitions. */
#define configSUPPORT_STATIC_ALLOCATION             0
#define configSUPPORT_DYNAMIC_ALLOCATION            1
#define configTOTAL_HEAP_SIZE                       20000
#define configAPPLICATION_ALLOCATED_HEAP            0

/* Software timer related definitions. */
#define configUSE_TIMERS                        1
#define configTIMER_TASK_PRIORITY               1
#define configTIMER_QUEUE_LENGTH                10
#define configTIMER_TASK_STACK_DEPTH            configMINIMAL_STACK_SIZE

/* ARMv8-M secure side port related definitions. */
#define secureconfigMAX_SECURE_CONTEXTS         5

/* Optional functions - most linkers will remove unused functions anyway. */
#define INCLUDE_vTaskPrioritySet                1
#define INCLUDE_uxTaskPriorityGet               1
#define INCLUDE_vTaskDelete                     1
#define INCLUDE_vTaskSuspend                    1
#define INCLUDE_xResumeFromISR                  1
#define INCLUDE_vTaskDelayUntil                 1
#define INCLUDE_vTaskDelay                      1
#define INCLUDE_xTaskGetSchedulerState          1
#define INCLUDE_xTaskGetCurrentTaskHandle       1
#define INCLUDE_uxTaskGetStackHighWaterMark     0
#define INCLUDE_uxTaskGetStackHighWaterMark2    0
#define INCLUDE_xTaskGetIdleTaskHandle          0
#define INCLUDE_eTaskGetState                   0
#define INCLUDE_xEventGroupSetBitFromISR        1
#define INCLUDE_xTimerPendFunctionCall          0
#define INCLUDE_xTaskAbortDelay                 0
#define INCLUDE_xTaskGetHandle                  0
#define INCLUDE_xTaskResumeFromISR              1
#define INCLUDE_xTimerCreateTimerTask           1


#define INCLUDE_vTaskStartScheduler             1
#define INCLUDE_xTaskCreate                     1

/* A header file that defines trace macro can be included here. */

#define configENABLE_MPU 0
#define configENABLE_FPU 0
#define configENABLE_TRUSTZONE 0
#define configENABLE_MVE 0

#define configUSE_IDLE_HOOK         0
#define configUSE_TICK_HOOK         0

/* Interrupt nesting behaviour configuration. */
//#define configKERNEL_INTERRUPT_PRIORITY         1

#define configCHECK_FOR_STACK_OVERFLOW          1

#define configUSE_COUNTING_SEMAPHORES    1


please can someone help me on why the task is not being executed.

Thank you.

You should post the code creating the tasks and the task function. Otherwise it’s impossible to guess the problem.
It’s important that you enable stack checking and properly define configASSERT during development.
BTW I’d also recommend to enable
if you don’t have more than 32 tasks. It’s much more efficient.


This the part where the task is getting created…

int main (void) {

    // System Initialization

    if (UartStdOutInit())
        // non zero return on uart init
        while (1);

    ei_printf("started freeRTOS\n");


    BaseType_t xReturned = 0;

    if((xReturned = xTaskCreate( led_blink_app, "blink_led",2000, 1, 5, NULL )) != pdPASS)        
            printf("task Not created\n");
    #if 0
    /* Start the FreeRTOS IP task */
        ucMACAddress );

    /* Start the FreeRTOS Scheduler */

    /* Should never get here! */
    return 0;

and this is the task definition:

void led_blink_app(void *pvParameters)
    ret1 = ptrDrv->SetValue(led_ds2, GPIO_PIN_OUTPUT_STATE_TOGGLE);
      //  ei_printf("done\n");
    ret2 = ptrDrv->SetValue(led_ds1, GPIO_PIN_OUTPUT_STATE_TOGGLE);

        if ((ret1 != ARM_DRIVER_OK) || (ret2 != ARM_DRIVER_OK)) {

Thank you for your quick reply…I will be trying out the other suggestions that you have given.

Right now i only have this one task apart from the idle task being created for testing purpose.

Your code seems ok so far… Do you get the “led_blink_app” ei_printf output ?
(Is ei_printf is thread-safe and can be used in multiple tasks in case you’re adding more tasks later on ?)
Do you have a debugger attached ? Then you can put a breakpoint to the led_blink_app function and run the program (using a debug build).
The target should be halted there right after the scheduler was started. Then step through the task code to see what’s going on.
Oh yes … please enclose code blocks with 3 tildes ‘~’ or backticks ‘`’ for better readability.

stupid q: Do you start the scheduler?..

Yes, it’s started properly


No,I am not getting this print. Also even if i don’t put any any ei_printf statements in the task code I dont see the leds blinking.

No, i dont,t have a debugger.Is there any other way I can check that what is happening after the scheduler has started.

Thank you.

Without debugger you’ll have a very, vey hard time to develop something a bit more complex than a blinking LED application…
However, if you only have ei_printf and maybe some LEDs then these are the debug tools you have.
So given that ei_printf is really working create a configASSERT macro using it to see when and where an assertion fails. That should provide some valueable information why the task couldn’t be started as expected.

to see if your system works at all, you can toggle the LEDs before you start the scheduler (to ensure that they work correctly), then toggle them on every 100th or so invocation of your sys tick handler…


Both configENABLE_TRUSTZONE and configRUN_FREERTOS_SECURE_ONLY are set to 0. This implies that Trustzone support is disabled and FreeRTOS is configured to run on the non-secure side. Does the hardware boots to non-secure? If not, then can you try setting configRUN_FREERTOS_SECURE_ONLY to 1 so that FreeRTOS runs on the secure side?

In this case, you need to use port.c and portasm.c from FreeRTOS-Kernel/portable/GCC/ARM_CM55_NTZ/non_secure at bb6071e1df3168a64dc2ce79de8aa91b7995ba23 · FreeRTOS/FreeRTOS-Kernel · GitHub.

Please refer to Using FreeRTOS on ARMv8-M Microcontrollers - FreeRTOS for more information.

1 Like

First of all…I am sorry for late reply…

I have tried it both the ways…this means

  1. By setting both configENABLE_TRUSTZONE = 0 configRUN_FREERTOS_SECURE_ONLY = 0.
    2 . By setting configENABLE_TRUSTZONE = 0 configRUN_FREERTOS_SECURE_ONLY = 1.
    Carried out the second step as suggested by you that is by changing the port.c and portasm.c files with NTZ files from the given link but I am still not finding any change.

This question might sound stupid but have never done freertos integration before so want to ask
—does this the task execution have anything to do with system clock settings or SysTick_Handler definition.

Please can someone reply for this question…

The system tick interrupt must call xPortSysTickHandler(). Otherwise the tick count won’t increment. Some tools automatically define the SystTick handler to call SysTick_Handler, in which case you need to #define xPortSysTickHandler() to SysTick_Hander() to ensure it gets called. This page describes how to do that:

If the clock setting doesn’t match configTICK_RATE_HZ then the tick interrupt will execute at the wrong frequency, but the system should still run, it will just measure time incorrectly.