Skip to main content
sne_123
Associate III
November 14, 2019
Solved

EEPROM EMULATION in STM32F103RB. Not able to save data in flash once code size exceeds 64Kb

  • November 14, 2019
  • 5 replies
  • 1131 views

Hello everyone,

I am doing EEPROM EMULATION On STM32F103RB Series which has 128kb flash. I am able to erase and write the contents into flash. But when my code size exceeds 64KB, the content is not being written properly into the flash. Can anyone tell me why such happens and what is the solution so as to solve the issue???

This topic has been closed for replies.
Best answer by waclawek.jan

You need to observe the size of block your STM32 model erases in one erase step. I don't use STM32F1, so you need to look it up in RM0008.

Maybe you want to set it to the highest possible part of the FLASH, to leave way for potential future code extension?

JW

5 replies

Ozone
Principal
November 14, 2019

Perhaps because the EEPROM emulation uses the last 64k sector, while the first is used for your code. Check your map file.

Using the first sector also would destroy the code.

> Can anyone tell me why such happens and what is the solution so as to solve the issue???

Use real EEPROM, or a variant with more Flash.

sne_123
sne_123Author
Associate III
November 14, 2019

Ok thank you Sir, I am new to flash programming. I am saving my data into flash from address "0x0800FC00" . If I change the starting address from "0x0800FC00" to

"0x0800FD00" , will it solve the issue??

waclawek.jan
waclawek.janBest answer
Super User
November 14, 2019

You need to observe the size of block your STM32 model erases in one erase step. I don't use STM32F1, so you need to look it up in RM0008.

Maybe you want to set it to the highest possible part of the FLASH, to leave way for potential future code extension?

JW

Ozone
Principal
November 14, 2019

And perhaps need to synchronize the EEPROM emulation settings with the linker file.

I don't know F103FB either, buf if the size required for your code is smaller, you could perhaps free more blocks (sectors) at higher addresses for the emulation.

sne_123
sne_123Author
Associate III
November 14, 2019

@Ozone​  @Community member​  Thanks a lot for your support. I shifted the starting address to the end page of the main memory and that solved the issue. Previously the code size exceeded 64k and at the same time I was trying to save data on flash . But using end page ( 0x0801 FC00 - 0x0801 FFFF) solved the issue. Thanks a lot :)