Skip to main content
MGami.1
Associate III
September 3, 2020
Solved

After erasing internal flash using st link utility when i will start storing sum data into internal flash it is going to be in hard-fault.

  • September 3, 2020
  • 4 replies
  • 1130 views

Hello Everyone,

We are working on STM32F413RH. We are storing sum data into internal flash at some interval of time. Simple mechanism is used, first we are erasing sector and then we are writing our data into internal flash.

But when we are erasing chip via ST link utility and try to store our data, we are getting hard-fault.

Please help us regarding the same.

Thanks and Regards

Milan

This topic has been closed for replies.
Best answer by waclawek.jan

Try to debug hardfault as usually, i.e. observe stacked values of registers, mainly PC; observe code in disasm/mixed with source, in vicinity (previously to) the address in the stacked PC; observing registers content estimate which instruction caused the problem and trace it back to C source variables content.

JW

4 replies

waclawek.jan
Super User
September 3, 2020

I don't understand - fault is result of program running, but when you're programming using STLink, program does not run, so how comes the fault?

JW

MGami.1
MGami.1Author
Associate III
September 3, 2020

We are doing below steps.

1) Load working program and check all the things that it is working properly or not. At the time of writing into internal Flash no error we are found.

2) After checking first step, we checked by connecting on st-link utility that whatever data we are writing into internal flash is stored or not? We successfully got our data and confirm that.

3) After second step we are erasing chip from ST-Link utility. and disconnect from st link utility.

4) Now again we start from first step (by loading same program) but we are getting hard-fault.

Thanks for your reply.

ErVaibhavS
Associate II
September 3, 2020

Kindly Share your code in which you are facing Problem !!!

MGami.1
MGami.1Author
Associate III
September 3, 2020

Sorry I can't share code because it is in system where i can not share anything.

We are doing below steps for your information.

1) Load working program and check all the things that it is working properly or not. At the time of writing into internal Flash no error we are found.

2) After checking first step, we checked by connecting on st-link utility that whatever data we are writing into internal flash is stored or not? We successfully got our data and confirm that.

3) After second step we are erasing chip from ST-Link utility. and disconnect from st link utility.

4) Now again we start from first step (by loading same program) but we are getting hard-fault.

Thanks for your reply.

waclawek.jan
waclawek.janBest answer
Super User
September 3, 2020

Try to debug hardfault as usually, i.e. observe stacked values of registers, mainly PC; observe code in disasm/mixed with source, in vicinity (previously to) the address in the stacked PC; observing registers content estimate which instruction caused the problem and trace it back to C source variables content.

JW

MGami.1
MGami.1Author
Associate III
September 9, 2020

Thanks for your reply.

As per your suggestion we have checked on dis-assembly window. And we found that due to UART peripheral we are accessing NULL address.

That is the reason we are getting hard-fault.

Thanks

Tesla DeLorean
Guru
September 3, 2020

You'll have to debug your own code.

Sanity check pointers, that you aren't accessing 0xFFFFFFFF.

Make sure you're not erasing running code.

Have a Hard Fault Handler that outputs actionable data, reports the registers and inspect the disassembly at the fault.​

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