cancel
Showing results for 
Search instead for 
Did you mean: 

Bus fault when running ARM DSP functions

nalostta
Associate

1. I am implementing a custom extended kalman filter function. The program on running hits HardFault handler on the 4th iteration (prediction function).

2. Cortex-M4->CFSR = 0x8200 (BFARVALID=1)

3. BFAR holds : 0xa5a5a5a5

I am not able to understand where the issue lies. Whether this issue is caused by using the ARM's CMSIS-DSP module or whether it is a program logic issue, though I am inclined that the latter is more likely the issue.

How do I proceed to debug this?

Board details: STM32F429ZiT6-Discovery board with STMCUBEide running with FreeRTOS.

Since there is a lot of code, I am proceeding with adding a snippet, please ping me for more details.

typedef struct
{
    arm_matrix_instance_f32 QV;
    arm_matrix_instance_f32 RV;
    arm_matrix_instance_f32 P;
    arm_matrix_instance_f32 Q;
    arm_matrix_instance_f32 R1;
    arm_matrix_instance_f32 poseUpdate;
    arm_matrix_instance_f32 posePred;
    
    float32_t _QV[3];
    float32_t _RV[3];

    float32_t _P[3][3];
    float32_t _Q[3][3];
    float32_t _R1[3][3];

    float32_t _poseUpdate[3];
    float32_t _posePred[3];
    float32_t imu_theta;

    int32_t   isInitialized;
    float32_t wheel_radius;
    float32_t wheel_base;
} KalmanFilter_t;

typedef struct
{
	float32_t left_omega;
	float32_t right_omega;
} sensor_data_t;

sensor_data_t testData[40] = {...};

void ekfTestFn(void *args)
{
	float32_t dt = 10.0f;
	KalmanFilter_t k;
	ekf_init(&k);
	for(int i=0; i<40; i++)
	{
		ekf_predict(&k, dt, &testData[i]);
		ekf_update(&k, dt, testDataIMU[i], &op_estimate[i]);
	}
	while(1) //test complete!
	{
		HAL_GPIO_TogglePin(GPIOG, GPIO_PIN_13);
		osDelay(150);
	}
}

 

3 REPLIES 3
STOne-32
ST Employee

Dear @nalostta ,

Here is a link on how to debug and understand Cortex-M faults:

https://www.keil.com/appnotes/files/apnt209.pdf

it might me a pointer issue or non initialized buffer, you need to debug that precise fault with address . Hope it helps .

Ciao,

STOne-32

>>How do I proceed to debug this?

Dump the registers (ALL) and disassemble the code identified as faulting. Narrow it down a bit, not just stare at the top-level code.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
GLASS
Senior

Hi.

Look like you overflow a freertos task stack.With embedded SW you MUST avoid to allocate big data on local stack.

On your partial piece of code, may be you can move some var from local function to more global or instantiate it as static.

Good one to try:

KalmanFilter_t k;

You must also check that stack for each freertos task are enough sized for the worstest case of call stack of the considered task...