nimaltd / ee

EEPROM emulation for stm32.
GNU General Public License v3.0
311 stars 74 forks source link

Reserve memory for EEPROM emulation #10

Closed rtek1000 closed 2 years ago

rtek1000 commented 2 years ago

Hello,

It is interesting to have some advice on how to make this memory reserve in the library description, to get more reliability in using this library and to avoid unnecessary rework after realizing that the program is using that memory space.

If the program is too big and the space is not enough, the compiler will return an error due to lack of memory, so the programmer can find another solution, perhaps using external memory, or another microcontroller with more memory capacity.

I found this post below, it might be interesting to reserve the memory so that the program is not written over the area where you intend to use EEPROM emulation:

You can reserve memory by modifying the linker script Source: https://www.eevblog.com/forum/microcontrollers/eeprom-emulation-stm32f4-flash-vs-external-flash-chip/

In your linker file (*.ld) Source: https://stackoverflow.com/questions/14666904/reserving-flash-location-for-eeprom-emulation-stm32f4

Maybe like this: (STM32F407VG: 16K reserve at the beginning of memory) (STM32CubeIDE file: STM32F407VGTX_FLASH.ld)

MEMORY
{
  CCMRAM    (xrw)    : ORIGIN = 0x10000000,   LENGTH = 64K
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 128K
  FLASH    (rx)    : ORIGIN = 0x8000000 + 16K,   LENGTH = 1024K - 16K
}

(STM32F407VG: 256K reserve at end of memory) (STM32CubeIDE file: STM32F407VGTX_FLASH.ld)

MEMORY
{
  CCMRAM    (xrw)    : ORIGIN = 0x10000000,   LENGTH = 64K
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 128K
  FLASH    (rx)    : ORIGIN = 0x8000000,   LENGTH = 1024K - 256K
}
nimaltd commented 2 years ago

thank you