Storing Hard Fault information from hard fault handler in flash

Hi,

we are developing custom hard fault handler to get its information during non-debug mode. In order to collect the information in non-debug mode we are trying to store hard fault information in the flash.
If I try to use flash operations, Control is not coming out of their flash functions. I have tried to flash read as well as flash write both are not supporting.

Does it not possible to store Hard fault information in flash?

Thank you

Shreya,

Parents
  • Hi Shreya,

    Writing to flash from the hardfault handler will not always be possible depending on the type of hardfault, so I would suggest a different approach that is more robust.

    While the RAM content is not guaranteed to be intact during a reset, most of it will most of the time, so another approach could be to sererve an area in the RAM and write your debug inormation to that area, together with a checksum before resetting in your hardfault handler. Upon reset, check if this area has content, and if it does, validate it against the cheksum. if it is valid, you can now log it to flash or do what you want to do with it. Now clear this memory region. This way you can have a very simple hardfault handler, while still being able to get the debug information you want for a hardfault.

    Einar

Reply
  • Hi Shreya,

    Writing to flash from the hardfault handler will not always be possible depending on the type of hardfault, so I would suggest a different approach that is more robust.

    While the RAM content is not guaranteed to be intact during a reset, most of it will most of the time, so another approach could be to sererve an area in the RAM and write your debug inormation to that area, together with a checksum before resetting in your hardfault handler. Upon reset, check if this area has content, and if it does, validate it against the cheksum. if it is valid, you can now log it to flash or do what you want to do with it. Now clear this memory region. This way you can have a very simple hardfault handler, while still being able to get the debug information you want for a hardfault.

    Einar

Children
Related