Hard fault when erasing internal flash memory

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Hard fault when erasing internal flash memory

1,270 Views
yash_bhatt1
Contributor III

Hi,

We are using FRDMK64F and are trying to erase 4096 bytes of internal flash memory from address 0xFD000.

We are facing hard fault when executing the code 

"callFtfxRunCommand((FTFx_REG8_ACCESS_TYPE)(&FTFx->FSTAT));"

inside the "ftfx_command_sequence" function.

The fault shown on debug is "BFARVALID" i.e bus fault Address Register Vaild flag and "PRECISERR" Precise data bus error.

The weird thing is that we are able to erase this same sector from other part of code (handling different functionality).

We have tried disabling cache as suggested in forums but could not resolve the issue.

To disable the cache we did:

FMC->PFB0CR &= 0xFFFFFFE0;
FMC->PFB1CR &= 0xFFFFFFE0;

It might be useful to know that we are using a bootloader and the application starts from address 0x28000.

Any help will be appreciated.

Labels (1)
0 Kudos
2 Replies

1,173 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello yash.bhatt1

 

Wich functions are you using to erase the flash sector? I suggest you use the function:

FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key)

This function erases the appropriate number of flash sectors based on the desired start address and length in bytes. I tested it by my side with the values you provided and functioned well.

 

I suggest you to first verify the status of the Flash, it is recommended that the flash is unsecured to erase the sector.

 

Let me know if this is helpful, if you have more questions do not hesitate to ask me.

Best regards,

Omar

0 Kudos

1,173 Views
yash_bhatt1
Contributor III

Hi nxf54944‌,

We were able to resolve this issue. We had to disable the interrupts before the erase and write on internal flash and then enable the interrupts.

Got this from one of the NXP threads.

Regards,

Yash

0 Kudos