2022-03-11 01:06 PM
I am encountering a HardFault in the System Timer Thread which I am struggling to understand and resolve.
I have 2 threads with the same priority. Each thread also has a queue. The first thing I did when I encountered the Hardfault is check the stack usage and also increase the stack usage for each thread.
One thread is sleeping and the other thread is suspended waiting for a message from a queue.
Here is my thread initialization:
//Cellular Service Task ThreadX resources
/* Allocate the stack for Cellular Service Task. */
if (tx_byte_allocate(byte_pool, (VOID **) &pointer, CST_QUEUE_SIZE*sizeof(ULONG), TX_NO_WAIT) != TX_SUCCESS)
{
Error_Handler();
}
if(tx_queue_create(&cst_queue_id, "Cell Service Task queue", TX_1_ULONG,
pointer, CST_QUEUE_SIZE * sizeof(ULONG)) != TX_SUCCESS)
{
Error_Handler();
}
//Allocate stack for Cellular Service Thread
if (tx_byte_allocate(byte_pool, (VOID **) &pointer, CELLULAR_SERVICE_THREAD_STACK_SIZE, TX_NO_WAIT) != TX_SUCCESS)
{
Error_Handler();
}
/* Create CST (Cellular Service Task) Thread. */
if (tx_thread_create(&cst_cellular_service_thread_id, "CellularService", CST_cellular_service_task, 0, pointer, CELLULAR_SERVICE_THREAD_STACK_SIZE, CELLULAR_SERVICE_THREAD_PRIO,
CELLULAR_SERVICE_THREAD_PREEMPTION_THRESHOLD, DEFAULT_TIME_SLICE, TX_AUTO_START) != TX_SUCCESS)
{
Error_Handler();
}
//AT Core Task ThreadX resources
if (tx_byte_allocate(byte_pool, (VOID **) &pointer, MSG_IPC_RECEIVED_SIZE*sizeof(ULONG), TX_NO_WAIT) != TX_SUCCESS)
{
Error_Handler();
}
if(tx_queue_create(&q_msg_IPC_received_Id, "IPC_MSG_RCV", TX_1_ULONG,
pointer, MSG_IPC_RECEIVED_SIZE * sizeof(ULONG)) != TX_SUCCESS)
{
Error_Handler();
}
//Allocate stack for AT Core Thread
if (tx_byte_allocate(byte_pool, (VOID **) &pointer, ATCORE_THREAD_STACK_SIZE, TX_NO_WAIT) != TX_SUCCESS)
{
Error_Handler();
}
/* Create AT Core Thread. */
if (tx_thread_create(&atcoreTaskId, "AtCore", ATCoreTaskBody, 0, pointer, ATCORE_THREAD_STACK_SIZE, ATCORE_THREAD_STACK_PRIO,
ATCORE_THREAD_PREEMTION_THRESHOLD, DEFAULT_TIME_SLICE, TX_AUTO_START) != TX_SUCCESS)
{
Error_Handler();
}
Using the Fault Analyzer view in STM32CubeIDE I see an IMPRECISERR. I look at the register content at the fault exception and the PSP (Process stack pointer) is 0x2000b848 which is in the System Timer Thread stack.
When I exit my Hard Fault hander I see that the function the code was running when the error occurred is:
#ifndef TX_TIMER_PROCESS_IN_ISR
VOID _tx_timer_thread_entry(ULONG timer_thread_input)
Since all the stack sizes appears to be more than what is being used and the location of the cause of the exception I'm stuck on how to proceed.
I have tried also increasing the size of the system Timer Thread from 512 to 768 but the same fault occurs
2022-04-13 03:56 AM
Hello @MD'Si.1 ,
You can refer to this example provided under x-cube-azrtos-h7 package.
This may help you.
BeST Regards,
Walid
2022-07-20 08:01 AM
Thanks @Walid ZRELLI
The issue is closed as ST released x-cube-cellular 7.0.0 so I have abandoned this work