Skip to main content
Associate II
April 11, 2025
Solved

EEPROM Emulation not working in code >64K

  • April 11, 2025
  • 5 replies
  • 742 views

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?

Best answer by MM..1

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

5 replies

Andrew Neil
Super User
April 11, 2025

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.
Technical Moderator
April 14, 2025

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.

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question.Saket_Om"
OldSTManAuthor
Associate II
April 14, 2025

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?

MM..1
Chief III
April 14, 2025

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.

 

OldSTManAuthor
Associate II
April 15, 2025

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.

Andrew Neil
Super User
April 15, 2025
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.
OldSTManAuthor
Associate II
April 17, 2025

Thanks , the last hint solved all my problems !