EEPROM STM32 is now read only

Post here first, or if you can't find a relevant section!
Post Reply
aurel_mrn
Posts: 4
Joined: Sat Apr 09, 2022 7:05 pm

EEPROM STM32 is now read only

Post by aurel_mrn »

hi, i'm working on a project based on an STM32. i've flashed the STM32 for using it in arduino ide. All was working find until now.
today i made a function to reset all the parameters stored in EEPROM :

Code: Select all

for (int i = 0; i < 512 ; i++)
    {
      EEPROM.write(i,0);
    }
i've run the function once and now EEPROM.write() does not work anymore. when i try to write somyhing in internal eeprom as i used to, everything seems working normaly, but when i read the data it alwaise return 0.
i can upload new sketch, but the EEPROM is alwais protected and i cant writre anymore.

can you help me to solve this problem ?

thank you
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: EEPROM STM32 is now read only

Post by GonzoG »

There is no EEPROM on STM32 MCUs.
Flash memory is used to emulate EEPROM.
If you've your program made much EEPROM writes you might have damaged flash.
aurel_mrn
Posts: 4
Joined: Sat Apr 09, 2022 7:05 pm

Re: EEPROM STM32 is now read only

Post by aurel_mrn »

hi, i don't think i've made too much write on the MCU flash. i was very careful with that.
also, as i said, i'm able to update new sketch (including big sketches) without any issue and the sketches run normaly. i think that one way or an other i'v enabled an option like write protection or anything like that. i know theses MCU have options like that.
i would like to connect the bluepill to STM32cube programmer but i can't with this bootloader.
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: EEPROM STM32 is now read only

Post by GonzoG »

I don't think that this is a problem with write protect of flash memory. It cannot be done by mistake.
To check if flash is protected you need to connect to MCU with STM32CubeProgrammer. It can be done with ST-Link or TTL-USB converter. There is no DFU on STM32F103 so USB cannot be used.

Also, using standard EEPROM library, there are only 256B of usable EEPROM storage on STM32F103C8/CB.
aurel_mrn
Posts: 4
Joined: Sat Apr 09, 2022 7:05 pm

Re: EEPROM STM32 is now read only

Post by aurel_mrn »

ok, thank you for your fast reply. i will check that.
i've just seen that if i read all bytes from 0 to 512, only the 256 first bytes return 0.
can i connect the stm32 with STM32cube programmer with the USB bootloader though ftdi to usb board ?
have i to re-upload the originla bootloader ?
thank you
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: EEPROM STM32 is now read only

Post by GonzoG »

You don't need any additional bootloader for UART or ST-Link.
And there is no "original" bootloader for STMs to flash. They all have hardware bootloader.
aurel_mrn
Posts: 4
Joined: Sat Apr 09, 2022 7:05 pm

Re: EEPROM STM32 is now read only

Post by aurel_mrn »

ok, so ! i've connected my stm32 to the stm32cubeprogrammer and i've seen that all the flash was not protected. so as you said, the problem dont come from this point.
after that i tried to re upload the same bootloader (just in case) but it not changed nothing. finaly, i found this video :https://www.youtube.com/watch?v=Myon8H111PQ

and after uploading this bootloader, the flash memory comme back again !
every thing work just fin now :D
thank you !


ps: the repository for the boars as changed from this guy made the video. the new repository is :

Code: Select all

https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
Post Reply

Return to “General discussion”