FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [September 2012 Threads]
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.
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
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.