cancel
Showing results for 
Search instead for 
Did you mean: 

EEPROM Emulation Start Address Question

colecago
Associate II
Posted on December 21, 2011 at 19:06

I've been using the STM32F100C6 on a project at my work.  We had no experience in ARM before so we contracted a associate of one of our engineers to write the start up code (just initializing all I/O, setting up timers, PWM, EEPROM, etc).  Well everything is looking good, project is getting closer to being finished and I was trying to figure out a way to initialize the Fake EEPROM (I'll call it FEEPROM) to a known value, or erase the micro and if I see all 0xFFFF when I look through my stored vars to initialize them.  Anyways, I was using the ST-Link GUI and I could not find the darn things.  Digging around led me to look at the EEPROM.h file where start address is

EEPROM_START_ADDRESS    ((uint32_t)0x08010000)

and I only have a 32KB part, and it works.  So I adjusted the memory size ST-Link was looking at and sure enough there it was.

I assume more than one micro uses the same core but only certain parts of the memories are tested and such, so I'd rather not use that part of the memory if I can't guarantee it works long-term, but when looking through the example code written by ST they take in account the micro type for page size but don't do anything about the start address based on micro, and the example is supposed to work on low density/medium density/high density/connectivity products.  Some of those micros may include memory in the range that overlaps that.  Are you supposed to change that start address to wherever you want in your memory, or is this a protected range?  Should I keep it that way for my 32KB micro?  Is that range safe for me even though its beyond the sold capacity of the micro?

#stm32f10x #eeprom
4 REPLIES 4
Posted on December 21, 2011 at 19:45

No I think they use different die for some of the different parts. Assuming things are there will likely result in a Hard Fault.

You should set the address to reflect a region in the available memory which you have set aside for the EEPROM data, and conforms to the page sizes, or boundaries expected. You should also modify the memory available to the compiler via the linker script, scatter file, or GUI, so your code isn't placed there.

You'd normally you'd place it just under the FLASH top address to minimize it's impact on other code.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
colecago
Associate II
Posted on December 21, 2011 at 19:54

It's working, in fact its been working for like 3-4 months before I noticed this. You'd think they'd put something inside the eeprom.h file regarding this,

/* Define the STM32F10Xxx Flash page size depending on the used STM32 device */

#if defined (STM32F10X_LD) || defined (STM32F10X_MD)

#define PAGE_SIZE (uint16_t)0x400 /* Page size = 1KByte */

#elif defined (STM32F10X_HD) || defined (STM32F10X_CL)

#define PAGE_SIZE (uint16_t)0x800 /* Page size = 2KByte */

#endif

/* EEPROM start address in Flash */

#define EEPROM_START_ADDRESS ((uint32_t)0x08010000) /* EEPROM emulation start address:

after 64KByte of used Flash memory */

That's exactly what's in the file. Also, not sure how to limit my code size in IAR, I have the device selected and this added to the compiler

STM32F10X_LD_VL

so it knows what it is. But when building and such it never gives me any indication of what my final file size is. I finally saw it when uploading the hex to the ST-Link utility, and I'll be fine size-wise. This all came about for 2 reasons, I wanted to find command line programming of our devices so we can use batch files in production so I found the ST-Link utility, and I wanted to get rid of the button held routine during start up to initialize the values.

________________

Attachments :

STMemProblem.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtUH&d=%2Fa%2F0X0000000aQi%2FbkBl.Er4RWcc0Ar9PY7MkJPW.97IE4SdDu1ZmsiwzPc&asPdf=false
Posted on December 21, 2011 at 20:28

IAR should permit you to change the ROM range under the options for the CPU or linker.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
colecago
Associate II
Posted on December 21, 2011 at 21:36

Indeed it does, under linker and config, the person who wrote up the startupcode must have done this because there is an override file in there with the specs of this micro.  I'll set it to slightly below where I am going to put the new FEEPROM