cbgigahertz wrote on Wednesday, September 26, 2012:
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)
{
CMD_CMD* ncmd=pvPortMalloc(sizeof(CMD_CMD));
if (ncmd!=NULL){
(*ncmd).cmd=cmd;
(*ncmd).tag=tag;
(*ncmd).next=next;
if (tag==0) (*ncmd).cmdqueue=xQueueCreate(20,sizeof(CMD_LINE));
else {
(*ncmd).cmdqueue=0; //Damit irgendwas drin steht
if (next!=NULL) (*ncmd).cmdqueue=(*next).cmdqueue;
}
return ncmd;
} else return next;
}
//This is where the sheduler crashes
void cmd_newinterpreter(CMD_CMD* caller, CMD_CMD* commands)
{
CMD_PARAM* parm=pvPortMalloc(sizeof(CMD_PARAM));
(*parm).cmdqueue=(*caller).cmdqueue;
(*parm).cmdlist=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_newinterpreter(demo_mehr,demo_mehr_nochwas);
* CMD_CMD* demo_irgendwas =cmd_newcommand("irgendwas",demo_mehr);
* cmd_newinterpreter(demo,demo_irgendwas);
*/
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.