Hardfault error while writing to EEPROM(Flash) in STM32WLE5 module
Hi,
I’m working on STM32WLE5 module for storing values in EEPROM. I want to use the last page of flash for storing configuration values of lora.
I have used EE library from GITHUB which uses HAL functions.
I followed 2 sequences for writing into flash:
- Erasing the page 127(which I use for writing the values), read and write worked perfectly. Values are being stored correctly in flash.
- Read the values from page 127 and then erasing the page and writing to it. I get hardfault error everytime.
if I erase the page 1st and write to it, then there is no use of storing in it. So, If I read the flash, I’m not able to write to it.
I have also moved all the functions used for writing into flash to RAM by adding __attribute__((section(“.RamFunc”))) in function definition so that there won’t be stalling of CPU. I have checked in disassembly while debugging that all the related code is running from RAM.


I get hardfault error while HAL_FLASH_Unlock() after erasing the page. Is there any other configuration I need to do for using flash as eeprom.
I want to do the procedure as follows:
Read EEPROM → Erase&update the new values in Flash.
