Hello,
i want to extract the data logged into the Fault Status, and i perform the following code in the default_handler to extract the data that im looking for. However, the live register data gets extracted instead (topright) and not bottom left's Fault Status register data.
How can i extract the Fault Status' register values during runtime?
In general, the hard fault registers are the HFSR, MMFSR, BFSR, UFSR, SFSR registers
When a hard fault occurs, the fault status property shows the reason of your fault, by ticking any of the blank boxes below:
Ιf you need more information for the HFSR, MMFSR, BFSR, UFSR, SFSR registers ,take a look on the link below :
https://developer.arm.com/documentation/dui0552/a/cortex-m3-peripherals/system-control-block/configurable-fault-status-register
Regards,
AL_Renesas
There seem to be 2 misconceptions here,
1. from my understanding the RA2E1 is based on the cortex M23, this core does not have HFSR/MMFSR/BFSR/UFSR/SFSR register support:
2. I wish to log the data in the "Fault Status" window during runtime, so when there is no debugger attached. I know i can see the registers in the window, but i wish to extract this data via code.
And as previously mentioned, the data in R0, R1, R2, R3, R12, LR, PC and PSR are not the same anymore when i take the values during runtime with the previously mentioned calls.
To me it seems like the data the Fault Status window is showing is stored somewhere in RAM memory, i just don't know where to find it.
I wasn't aware of that you are using ra2e1 device.
There isn't any relationship between the R0-R15, which are the CPU general purpose registers, program counter, link register and program stack counter and the fault status window that you refer.
These registers (R0, R1, R2, R3, R12, LR, PC and PSR) don't have some specific address on RAM memory and MCU has access to them using CPU instructions.
Yes, you can see them on Expressions tab and watching to be updated between breakpoints on your program, but you can't have direct access to them:
Regards
What confuses me then is, how am i supposed to get the LR address of the location where the fault occured? Im forcing a fault to test, and i know it occurs at address 0x2818, however at the time the code reaches the hardfault handler, the LR/PC values have already updated and are no longer pointing to the correct 0x2818 address.
However i do note that the Status Fault window has the correct value's in it's snapshot PC and LR registers. Is it possible to get a hold of the correct LR / PC values before theyre lost via code (runtime) only?
Please check the exception handling app note below, it also includes infromation for RA2E1:
Renesas RA Family Exception Handling
This document mentions in chapter 4.1 that there are 3 methods to determine the factor, location, and history of the exception event, but all of them include a person using some view to then manually check the registers to see the origin of the fault.
Please reread my previous question, is there no possibility to get the LR value of the hardault location, as seen in the Fault Status, during runtime without the use of any external tool. E.g. a device running in the field wants to log the LR pointing to the address where the hardfault occured without any tools attached
It seems i found an answer in an older community post, using this construction and redirecting the hardfault handler from the default handler to this custom assembly wrapper, which in turn calls the hardfault_handler with an uint32_t pointer as argument. The correct stack pointer needs to be set to R0 in order for the argument uint32_t pointer to make sense:
https://community.arm.com/support-forums/f/architectures-and-processors-forum/52210/cortex-m23-dumping-values-on-the-stack
Now the value in variable PC is equal to the value seen in the Fault Status window
I think that you can implement something like the below, using assembly instructions in C, in order to have access to the LR register and storing it to a global variable:
Please inform me , if this matches with your request.