HardFault during erasing Flash in debug mode

Started by ayoubt 5 months ago4 replieslatest reply 5 months ago70 views

I've written a custom bootloader using C to run on ARM cortex_M4 but I had a HardFault exception when using the debug mode. This exception appears just in debug mode, when I use release mode everithing works.

I've checked that the Flash/Erase code is loaded to RAM before the execution of erase command.

Thanks in advance.

[ - ]
Reply by MichaelKellettJuly 9, 2021

I think you need to tell us  a lot more before a good answer is possible.

What processor are you using, with which tools. Can you get a trace to see what caused the hard fault ?

You need to explain exactly how the processor is set up in your code, (ie is it running from RAM, are interrupts enabled  etc etc.)


[ - ]
Reply by DilbertoJuly 9, 2021

I completely agree with you.

It would be nice if every poster, independent of the aim of the question, ever provided some basic information about what he ( she ) is using, such as the core chip, the development tools with their versions and a clear description of the sequence of events that lead to the fail.

This would accelerate problem solving.


[ - ]
Reply by QLJuly 9, 2021

Most likely you still have some access to ROM, perhaps your code reads some constants in ROM (e.g., strings, etc.) Also, there might be still calls (perhaps indirect) to code in ROM.

[ - ]
Reply by waydanJuly 9, 2021

If you’re having trouble identifying the kind of hard fault, you might take a look at this article.