Hard fault from xQuesend

joe_her wrote on Tuesday, November 04, 2014:

I get a HardFault that is generated from xQsend, looking at the call stack, the top of the stack is vListInsert().
Is it because no space on the queu? I thought that if no space then xQueuSend will just return with an error code.
What could be the reason for the fault?
Thnaks

davedoors wrote on Tuesday, November 04, 2014:

I think we can be sure it is not because the queue is full.

This is the place to start http://www.freertos.org/FAQHelp.html

joe_her wrote on Wednesday, November 05, 2014:

Just before the crash I can see this comment:
//---------------------------------
If you find your application is crashing here then likely causes are:
1) Stack overflow -
see http://www.freertos.org/Stacks-and-stack-overflow-checking.html
2) Incorrect interrupt priority assignment, especially on Cortex-M3
parts where numerically high priority values denote low actual
interrupt priories, which can seem counter intuitive. See
configMAX_SYSCALL_INTERRUPT_PRIORITY on http://www.freertos.org/a00110.html
3) Calling an API function from within a critical section or when
the scheduler is suspended, or calling an API function that does
not end in “FromISR” from an interrupt.
4) Using a queue or semaphore before it has been initialised or
before the scheduler has been started (are interrupts firing
before vTaskStartScheduler() has been called?).
See http://www.freertos.org/FAQHelp.html for more tips, and ensure
configASSERT() is defined! http://www.freertos.org/a00110.html#configASSERT

//------------------------
So i tested for stack overflow using method #2 - not a stack overflow, I checked uxCriticalNesting - it is 0 so it is not an API during critical code, and it happens about 250 times after calling the same queue - it is created for sure.
What is left is that it is some interrupt priority problem, which I find not easy to debug, no assertion ishttps://sourceforge.net/p/freertos/discussion/382005/thread/5daa4e7f/# triggered ( configASSERT() is enabled of-course)

Any tips?

Thanks

joe_her wrote on Saturday, November 08, 2014:

Hi, I wonder why I have the last post waiting for moderation (3 days now).
have I done wrong?
thanks

rtel wrote on Saturday, November 08, 2014:

Hi, I wonder why I have the last post waiting for
moderation (3 days now). have I done wrong?
thanks

Sorry about that. We just didn’t notice it. No posts should go into moderation, but about once every three months or so for some reason one does, but we don’t get a notification to say this has happened so unfortunately your post just got overlooked.

What is left is that it is some interrupt priority problem,
which I find not easy to debug, no assertion is

Whether the assertion would get triggered or not depends on the version of FreeRTOS you are using. Which version are you using?

Regards.

joe_her wrote on Sunday, November 09, 2014:

I am using FreeRTOS 8.0.1

Regards

rtel wrote on Sunday, November 09, 2014:

In which case the configASSERT() should trap a bad interrupt priority.

Could it be just a data corruption? Something writing over the data
structures used by the kernel.

Please post the code that creates, writes to and reads from the queue.

Regards.

joe_her wrote on Sunday, November 09, 2014:

I moved the code (FatFS on USB host, f_open() ) to a later time in the program execution, so that it will run at a user button press. Just to see what will happen, and it works. I will need some time to investigate this.
Should I find the reason, I will share. I suspect it has to do with the USB host state machine (it has a few states like IDLE, attached, connected etc.).
Thanks
Johanan