# FreeRTOS Task getting created but not executing

**URL:** <https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578>\
**Category:** ARM\
**Tags:** debug\
**Created:** [January 18, 2023, 10:43am UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578 "2023-01-18T10:43:02Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![haihi](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@haihi](https://forums.freertos.org/u/haihi)\
**Post date:** [January 18, 2023, 10:43am UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/1 "2023-01-18T10:43:02Z")

</div>

Hi

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

```auto
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H

#define configUSE_PREEMPTION 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#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 configTASK_NOTIFICATION_ARRAY_ENTRIES 3
#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
#define configSTACK_ALLOCATION_FROM_SEPARATE_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

///////////testing

#define INCLUDE_vTaskStartScheduler 1
#define INCLUDE_xTaskCreate 1

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

////////////////testing///////////////////////////
#define configENABLE_MPU 0
#define configENABLE_FPU 0
#define configENABLE_TRUSTZONE 0
#define configENABLE_MVE 0
#define configRUN_FREERTOS_SECURE_ONLY 0

#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0

/* Interrupt nesting behaviour configuration. */
//#define configKERNEL_INTERRUPT_PRIORITY 1
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 2
//#define configMAX_API_CALL_INTERRUPT_PRIORITY 4

#define configCHECK_FOR_STACK_OVERFLOW 1

#define configUSE_COUNTING_SEMAPHORES 1

#endif

```

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

Thank you.

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [January 18, 2023, 11:13am UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/2 "2023-01-18T11:13:01Z")

</div>

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](https://www.freertos.org/Stacks-and-stack-overflow-checking.html) and properly define configASSERT during development.  
BTW I’d also recommend to enable  
`#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1`  
if you don’t have more than 32 tasks. It’s much more efficient.

---

<div class="post-metadata">

**Author:** ![haihi](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@haihi](https://forums.freertos.org/u/haihi)\
**Post date:** [January 18, 2023, 11:51am UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/3 "2023-01-18T11:51:17Z")

</div>

Hi

This the part where the task is getting created…

```auto
int main (void) {

    // System Initialization
    SystemCoreClockUpdate();

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

    ei_printf("started freeRTOS\n");

    vParTestInitialise();
        vParTestSetLED();

    BaseType_t xReturned = 0;

    if((xReturned = xTaskCreate( led_blink_app, "blink_led",2000, 1, 5, NULL )) != pdPASS)        
        {
            printf("task Not created\n");
            return;
        }
    
    #if 0
    /* Start the FreeRTOS IP task */
       FreeRTOS_IPInit(
        ucIPAddress,
        ucNetMask,
        ucGatewayAddress,
        ucDNSServerAddress,
        ucMACAddress );
        #endif

    /* Start the FreeRTOS Scheduler */
    vTaskStartScheduler();

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

```

and this is the task definition:

```auto
void led_blink_app(void *pvParameters)
{
   ei_printf("led_blink_app\n");
    while(1)
    {
    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)) {
            ei_printf("ERROR\n");
            error_power_off();
        }
        vTaskDelay(1000);
    }
}

```

> [@hs2](#):
>
> if you don’t have more than 32 tasks

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

---

<div class="post-metadata">

**Author:** ![haihi](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@haihi](https://forums.freertos.org/u/haihi)\
**Post date:** [January 18, 2023, 11:52am UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/4 "2023-01-18T11:52:42Z")

</div>

> [@hs2](#):
>
> if you don’t have more than 32 tasks. It’s much more efficient.

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

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [January 18, 2023, 12:34pm UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/5 "2023-01-18T12:34:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [January 18, 2023, 12:39pm UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/6 "2023-01-18T12:39:28Z")

</div>

stupid q: Do you start the scheduler?..

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [January 18, 2023, 12:42pm UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/7 "2023-01-18T12:42:40Z")

</div>

Yes, it’s started properly

> [@haihi](#):
>
> ```auto
> /* Start the FreeRTOS Scheduler */
> vTaskStartScheduler();
> 
> ```

---

<div class="post-metadata">

**Author:** ![haihi](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@haihi](https://forums.freertos.org/u/haihi)\
**Post date:** [January 18, 2023, 2:51pm UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/8 "2023-01-18T14:51:39Z")

</div>

Hi

> [@hs2](#):
>
> Do you get the “led\_blink\_app” ei\_printf output ?

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.

> [@hs2](#):
>
> Do you have a debugger attached ?

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.

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [January 18, 2023, 3:15pm UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/9 "2023-01-18T15:15:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [January 18, 2023, 3:22pm UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/10 "2023-01-18T15:22:01Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![urutva](https://avatars.discourse-cdn.com/v4/letter/u/65b543/32.png) [@urutva](https://forums.freertos.org/u/urutva)\
**Post date:** [January 18, 2023, 3:40pm UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/11 "2023-01-18T15:40:36Z")

</div>

> [@haihi](#):
>
> ```auto
> #define configENABLE_MPU 0
> #define configENABLE_FPU 0
> #define configENABLE_TRUSTZONE 0
> #define configENABLE_MVE 0
> #define configRUN_FREERTOS_SECURE_ONLY 0
> 
> ```

Hi,

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 [https://github.com/FreeRTOS/FreeRTOS-Kernel/tree/bb6071e1df3168a64dc2ce79de8aa91b7995ba23/portable/GCC/ARM\_CM55\_NTZ/non\_secure](https://github.com/FreeRTOS/FreeRTOS-Kernel/tree/bb6071e1df3168a64dc2ce79de8aa91b7995ba23/portable/GCC/ARM_CM55_NTZ/non_secure).

Please refer to [Using FreeRTOS on ARMv8-M Microcontrollers - FreeRTOS](https://www.freertos.org/2020/04/using-freertos-on-armv8-m-microcontrollers.html) for more information.

---

<div class="post-metadata">

**Author:** ![haihi](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@haihi](https://forums.freertos.org/u/haihi)\
**Post date:** [February 16, 2023, 9:46am UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/12 "2023-02-16T09:46:02Z")

</div>

First of all…I am sorry for late reply…

> [@urutva](#):
>
> Hi,
> 
> 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?

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.

---

<div class="post-metadata">

**Author:** ![haihi](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@haihi](https://forums.freertos.org/u/haihi)\
**Post date:** [February 16, 2023, 9:55am UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/13 "2023-02-16T09:55:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![haihi](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@haihi](https://forums.freertos.org/u/haihi)\
**Post date:** [February 17, 2023, 11:38am UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/14 "2023-02-17T11:38:15Z")

</div>

Please can someone reply for this question…

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [February 17, 2023, 10:27pm UTC](https://forums.freertos.org/t/freertos-task-getting-created-but-not-executing/16578/15 "2023-02-17T22:27:32Z")

</div>

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: [https://freertos.org/FAQHelp.html](https://freertos.org/FAQHelp.html)

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.
