cancel
Showing results for 
Search instead for 
Did you mean: 

Hard Fault when reading flash

sivaram
Associate III

I am working to generate the CRC for the flash memory, During this I am facing hard fault when the CRC module tries to read from certain flash locations, to debug it I made a small loop which assigns the value of each 4 byte. I found that reading at certain locations results in hardfault.

I tried with different starting address, I found that

when starting address is 0x08000000 hardfault occurred at 0x08000440

when starting address is 0x08001000 hardfault occurred at 0x0800144c

when starting address is 0x08004000 hardfault occurred at 0x080044cc

uint32_t *d1 = 0x08000000;
while(length){
      uint32_t temp = *d1;
      d1++;
      length -= 4;
}

Any Idea of what is causing this issue?

22 REPLIES 22
Ozone
Lead

MPU enabled ?

Or another unhandled/escalated fault ?

I would check the SCB registers for fault reason & location.

Although, I don't have specific experience with the H7.

MPU is not enabled.

Unaligned bit is set in UFSR register.

Uwe Bonnes
Principal II

I do not find a hit when searching for UFSR in RM0399.

It is in programmers manual PM0253.

Custom board? Which H7 specifically?

Check clock speeds.

Check supplies and VCAP pins/caps.

Check Flash wait states.

Check length a multiple of 4.

Keil, IAR or GCC?​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AB.17
Associate II

I have STM32H750VB on desk and I have dumped flash with 0 issues:

volatile uint32_t *d1 = 0x08000000;
do{
volatile uint32_t temp = *d1;
d1++;
}while(d1<0x080FFFFF);

Used keil, no HAL, clock is 400 MHz. Afaik STMH7s have sane default setting of flash latency, so it runs with highest clock without touching.

As I understand OT has some other soft already running so it wouldn't matter.

At what exactly instruction it breaks?

HAL usage?

sivaram
Associate III

Nucleo-h743zi

gcc.

Length and address increments is always a multiple of 4.

The processor runs at 64mHz, with a flash latency set to 0. Changed the flash latency to 4. Still the result is same.

Just copy pasted this code,

The hardfault occurs at

volatile uint32_t temp = *d1;

The address in d1 is 0x80029d0 at the time of hardfault, another time is 0x800332c... I have no other code other than this after the initialization.