cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to disable the automatic default task creation in CubeMx ?

MEber.10
Associate

We are using CubeMX (incl. FreeRtos) to update our settings.

The problem is that CubeMX will always create a default task in the main. We also tried to remove the following line from the ioc file "FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL" but it will automatically rewrite it.

Is there a way to disable the default task code generation ?

Thanks

18 REPLIES 18
Khouloud GARSI
Lead II

Hello @MEber.10​ ,

I will highlight this point internally and one of our STM32CubeMX experts will answer you ASAP. Meanwhile, could you please precise which STM32CubeMX version you're using.

Khouloud.

WBOUG
Senior

Hi @MEber.10​ 

I want to know the CubeMX version you are using as well as the ioc file that generated this problem.

Best Regards,

Wael.

WBOUG
Senior

Hi @MEber.10​ 

I tried with an STM32F4 MCU. I noticed that you're right

Your request has been redirected to the development team. it will be corrected in the next release.

Best Regards.

Wael.

SAnde.12
Associate

Hi, I just updated to STM32CubeMX V5.0.1 /2-January-2019 and issue is still there. Not possible to delete defaultTask using GUI and it is re-added if manually removed from ioc.

In which release is this planned to be corrected?

Best regards

/Stefan

WBOUG
Senior

Hi @SAnde.12​ 

Your request has been redirected to the development team. it will be corrected in the release 5.2.0 of CubeMX .

Best Regards,

Wael

Jordi Becares
Associate II

Hi all,

I "fixed" this problem, renaming the defaultTask to another task used in my application, and this works.

It is not a "final" solution, but I can kept RAM free.

I will wait for oficial soution.

Regards

Jordi

david.s.keck
Associate II

I am having a similar issue. When I remove the code generated for the DefaultTask, I am met with a hard fault. What is depending on this default task being around and how do I break that dependency?

char_array
Associate III

My workaround is to simply add a return statement inside MX_FREERTOS_Init() user code section.

void MX_FREERTOS_Init(void) {
  /* USER CODE BEGIN Init */
    startMyTask(); // create and start your own task here
    return; //return to avoid creation of default task
  /* USER CODE END Init */
 
  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */
 
  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */
 
  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */
 
  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */
 
  /* Create the thread(s) */
  /* creation of defaultTask */
  defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
 
  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */
 
  /* USER CODE BEGIN RTOS_EVENTS */
  /* add events, ... */
  /* USER CODE END RTOS_EVENTS */
}

The default task will never start this way. The compiler should be smart enough to optimize out the function as it is an empty function and only referenced by dead code.

PR.10
Associate III

The problem still exists in 1.10.1. The task creation is in main now so the workaround with return does not work. All application tasks are created elsewhere using freertos API. In my project the default task is empty only taking memory and cannot be used to anything else. I was considering deleting it by that won't help when full static allocation is used.

Is there any plan to fix that? It would be nice for processors with just few kB of ram not not waste it. Just add a user section around so we can use #if 0 or add checkbox to mx ui