cancel
Showing results for 
Search instead for 
Did you mean: 

EEPROM Emulation not working in code >64K

OldSTMan
Associate II

Split from EEPROM Emulation: meaning of the VirtAddVarTab as this is a new question.


The eeprom emulation in my simple trial sofware is working fine. The code is quite small.

I tried to use this software inside a more complex program, larger than 64K, and the system hangs.

From what I have understood only the first 16K are available for program with the suggested setup.

It is possile to have a setup for eeprom that allows to use more flash program memory?

1 ACCEPTED SOLUTION

Accepted Solutions

Your defines seems ok , but too is required linker file changes for spare this space.

MEMORY
{
  FLASH0 (rx)      : ORIGIN = 0x08000000, LENGTH = 16K	/* FL0 only isr */
  CCMRAM    (xrw)    : ORIGIN = 0x10000000,   LENGTH = 64K
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 320K
  FLASH    (rx)    : ORIGIN = 0x8010000,   LENGTH = 1984K /* reserve EEPROM sec 1 2 3 used only 2 3*/
}

...

  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >FLASH0

View solution in original post

8 REPLIES 8

If your previous question is now resolved, please mark the solution in that thread:

https://community.st.com/t5/community-guidelines/help-others-to-solve-their-issues/ta-p/575256

 


@OldSTMan wrote:

I tried to use this software inside a more complex program, larger than 64K


What STM32 are you using?

Does it have enough Flash for both your code and your emulated EEPROM to be in separate pages?

Have you made sure that they are in separate pages?

 


@OldSTMan wrote:

the system hangs.


So where, exactly, does it hang?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Saket_Om
ST Employee

Hello @OldSTMan 

What is the MCU you are using please? 

Did you check the examples on X-Cube EEPROM library please? 

Try to modify the linker script to allocate the good flash memory size for your Emulation.

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar
OldSTMan
Associate II

The project is for stm32f401re and includes SD card and CDC. Using the examples I was able to run the eeprom emulation in a small sample project. I would now undestand how to run it in alarger project (more than 64K).

I was playing with the configuration file with bad results (target not detected..). Can someone help me to understand what to do with programs larger than 16K? How can I  configure to have the program in separate pages?

For emulation is requiredd knowledge about flash sectors for F4

MM1_0-1744633325839.png

your code for emulate require arange into little sectors, or you waste big when not used, your choice your job.

 

OldSTMan
Associate II

I used sectors 2 and 3 (16K) as in the example  and in large program it is not working:

/* EEPROM start address in Flash */
#define EEPROM_START_ADDRESS ((uint32_t)0x08008000) /* EEPROM emulation start address:

from sector2 : after 16KByte of used

Flash memory */

/* Pages 0 and 1 base and end addresses */
#define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x0000))
#define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))
#define PAGE0_ID FLASH_SECTOR_2

#define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x4000))
#define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1))-1)
#define PAGE1_ID FLASH_SECTOR_3

Source Code formatting applied - please see How to insert source code for future reference.

Please see How to insert source code.

Note that X-CUBE-EEPROM is not for STM32F4 - you need STSW-STM32066 (AN3969)instead:

https://community.st.com/t5/stm32-mcus-embedded-software/x-cube-eeprom-not-for-stm32f0/m-p/684685/highlight/true#M48486:~:text=STM32F4%20%2D%20see%20AN3969%20instead%3B

 

But you still have to choose your Flash pages.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Your defines seems ok , but too is required linker file changes for spare this space.

MEMORY
{
  FLASH0 (rx)      : ORIGIN = 0x08000000, LENGTH = 16K	/* FL0 only isr */
  CCMRAM    (xrw)    : ORIGIN = 0x10000000,   LENGTH = 64K
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 320K
  FLASH    (rx)    : ORIGIN = 0x8010000,   LENGTH = 1984K /* reserve EEPROM sec 1 2 3 used only 2 3*/
}

...

  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >FLASH0
OldSTMan
Associate II

Thanks , the last hint solved all my problems !