Getting Hard fault in MKV31F512 with following status for system control registers

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Getting Hard fault in MKV31F512 with following status for system control registers

1,122 Views
sangameshvandal
Contributor I

Hi

Getting Hard fault in MKV31F512 with following status for system control registers

PRECISEERR bit set in CFSR register

BFARVALID bit set with BFAR address 0x35323134.

Refre attached disassembly code

Help me in finding the exact reason for hardfault

0 Kudos
Reply
2 Replies

927 Views
colin
Contributor III

So the value 0x35323134 is an invalid address to read.  And the instruction ldrb r3, [r3, #0] at 0x140ec is trying to read it.  This invalid value 0x35323134 in r3 came from the previous instruction which loaded it from r7+4, which is 0x20006318 + 4 = 0x2000631B.  So you should inspect that memory and see what is there.  The most interesting thing that jumps out at me is that this is the ASCII value for the digits "4125" (little-endian order).

So probably there is some bad pointer arithmetic that is using ASCII text as if it were a pointer value.  Perhaps a buffer overrun or stack smashing issue.

0 Kudos
Reply

927 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Sangamesh Vandal:

As shown by the value of the register r3 and the address you mentioned from BFAR, the reason is that the CPU is trying to store data at address 0x35323134, which is not implemented in the KV31.

Defining the actual reason for that invalid access is not straightforward, you would need to inspect the register operations at the assembly level while debugging your code. In your pictures it seems that you are using an RTOS and the offending function is OSQPost, so I would start by checking that the queues send to the API are valid and also that no pointer corruption happens in the middle of such call.


Best Regards!,
Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply