STM32 L0 Flash Writing issues.
Hi ST Community,
I have inherited a product that runs on a stm32L051k8 mcu, and I am having difficulty with using the onboard flash memory. On boot, the product checks a certain location in flash to see if there are some configuration settings stored there, and if the flash storage is in an erased state, the mcu saves some default values to that configuration settings location.
What is happening is that sometimes after the first boot, those default configuration settings are not getting saved correctly, which causes the product itself to malfunction.
The only things we have found to fix a board that had a bad first time boot would be to re-flash the board with the UART boot-loader (we do not program the board using ST-LINK). Unfortunately, this is not a guaranteed fix as the board might have another faulty first time boot and still have corrupted config settings. Something else that we have tried that helps mitigate (but not solve) this issue is to add a ~100ms delay between power up and when we try to write to flash, to let the voltage to the micro-controller rise to the right value. But even with this delay, we are still seeing around 15% of all the boards we program have corrupted configuration settings.
Any help would be greatly appreciated.
Best,
Matthew Cocke.
