call of prvInitialiseTaskLists

tymokhin wrote on Saturday, November 18, 2017:

Hi. this is my first post.

I try to use FreeRTOS with Oryx-Embedded Cyclone TCP.

In this library present function like TRACEINFO. I try to use them on start of main() sub and got a Hard Fault Interrupt. When I start to investigate code, I found that in macro TRACEINFO used vTaskSuspendAll() and xTaskResumeAll(). If beteen calling of this function appear a system tick interrupt, the handler try to switch to next ready task, but before adding first task don’t call prvInitialiseTaskLists(), so the pxDelayedTaskList is NULL, but handler try to use this NULL as pointer to correct struct and this call a Hard Fault Interrupt.

So maybe should to add an init fuction for check list in handler? or some another decision of this problem.

simple example of code:

int main() {

//during executing printf apear system tick interrupt and appear a Hard fault interrupt

xTaskCreate("",vTask0,NULL, configMINIMAL_STACK_SIZE, configMAX_PRIORITIES);    


Best regards, Tymokhin Oleksandr

rtel wrote on Tuesday, November 21, 2017:

Sorry for the delay in replying - somehow missed this one. However, in this case it sounds like you are reporting a problem in somebody elses code, rather than ours, if indeed there is a problem at all. It just sounds like you are performing an operation before the scheduler has started that is intended to be used after the scheduler has started as it is using the FreeRTOS API.

tymokhin wrote on Thursday, November 23, 2017:

Yes. this problem is occure before scheduler is started, or when its started before any tasks was added. Its of course not normal sitation, but in some cases can be expected. For example in case when tasks added by condition from main(), or using exernal libraries with for example with trace definition. And it come to Hard Fault. May be useful to check pxCurrentTCB to NULL. Its just a proposition. May be I don’t anderstand in FreeRTOS architecture.

In my case I have next problem. I use Nucleo-144 with stm32f767 chip

  1. I init system clock and start it at 216MHz
  2. route standard file to ITM for output debug info
  3. before starting scheduler use printf to ITM some debug information
  4. printf to long and systick event raise during printf before executing vTaskStartScheduler(), but pxCurrentTCB in this moment is null and pxReadyTasksLists[ pxCurrentTCB->uxPriority ] raise hard fault (line 2615 in tasks.c FreeRTOS v9.0.0)

May be it’s correct behavior. I don’t now.

Best regards, Tymokhin Oleksandr

sergossv wrote on Thursday, November 23, 2017:

Oryx-Embedded Cyclone TCP use in macro TRACEINFO NOT vTaskSuspendAll() and xTaskResumeAll(). In this macro, this function is actually used

void osSuspendAllTasks(void)
//Make sure the operating system is running
if(xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED)
//Suspend all tasks

You should use this function.

rtel wrote on Thursday, November 23, 2017:

Where? Why?

tymokhin wrote on Friday, November 24, 2017:


Yes, I Use TRACEINFO. And the problem in next. May be it’s not for thisd topic.

I use not clear FreeRTOS. I Use cmsis_os2 lib.

TRACE_PRINTF(…) osSuspendAllTasks(), fprintf(stderr, VA_ARGS), osResumeAllTasks()

So, when call osSuspendAllTasks() - it call osKernelLock()

int32_t osKernelLock (void) {
int32_t lock;

if (IS_IRQ()) {
lock = (int32_t)osErrorISR;
else {
switch (xTaskGetSchedulerState()) {
lock = 1;

    lock = 0;

    lock = (int32_t)osError;


return (lock);

The scheduler is not running and in this case xTaskGetSchedulerState() return taskSCHEDULER_NOT_STARTED
and in this case vTaskSuspendAll() is not calling and systick interrupt is raise. So appear situation from above message.

Best regards, Oleksandr