I have a hard fault after xTaskCreate which vanishes when putting a vTaskDelay(1) right after it.
The paramter of the TaskCreate is a malloced struct containing pointers to other malloced structs. The task created just parses the messages given to it, then distributes it to other queues.
//This is where the parameters come from.
CMD_CMD* cmd_newcommand(char cmd, uint32_t tag, CMD_CMD* next)
if (tag==0) (*ncmd).cmdqueue=xQueueCreate(20,sizeof(CMD_LINE));
(*ncmd).cmdqueue=0; //Damit irgendwas drin steht
if (next!=NULL) (*ncmd).cmdqueue=(*next).cmdqueue;
} else return next;
//This is where the sheduler crashes
void cmd_newinterpreter(CMD_CMD* caller, CMD_CMD* commands)
xTaskCreate(cmd_commandtask,NULL,75,parm,2,NULL); //setting the stack size to 7500 won't help
vTaskDelay(1); //Removing this will make it crash
/* This is how it's typically used
* CMD_CMD* demo_dings = cmd_newcommand("dings",0,NULL);
* CMD_CMD* demo_bumms = cmd_newcommand("bumms",0,demo_dings);
* CMD_CMD* demo_mehr = cmd_newcommand("mehr",0,demo_bumms);
* CMD_CMD* demo_mehr_nochwas = cmd_newcommand("nochwas",0,NULL);
* CMD_CMD* demo_irgendwas =cmd_newcommand("irgendwas",demo_mehr);
This is running on an STM32F4 on the gcc. As far as I can tell, all Interrupt priorities are set to 0xf via the libraries.
Is cmd_newinterpreter() called when when the kernel is already running? I presume so if you are calling vTaskDelay(1).
The effect calling vTaskDelay( 1 ) has will depend on the priority of the task you are calling cmd_newinterpreter() from. The task you are creating is priority 2, so if you are calling cmd_newinterpreter() from a task of priority 3 or higher, then the vTaskDelay() will allow cmd_commandtask() to run before cmd_newinterpreter() returns. If you are calling cmd_newinterpreter() from a task of priority 2 or lower, then cmd_commandtask() will run before cmd_newinterpreter() returned with or without the vTaskDelay( 1 ).
Does it crash inside xTaskCreate(), or inside cmd_commandtask()? What is it doing (or trying to do) to make it crash?
Do you create a new queue for every command? Do you check the queue was created before trying to use it (that is not shown in the code you have posted).
Plus the usual help links: http://www.freertos.org/FAQHelp.html