[SOLVED] Need Help with EEPROM Emulation

alexandros
Sat Jan 13, 2018 4:02 pm
Hello guys!

i have encounterd a wierd behavior i am using this library
https://github.com/rogerclarkmelbourne/ … OM_example

#include <EEPROM.h>
int AddressWrite,DataWrite;
void setup()
{
// initialize the digital pin as an output:
Serial1.begin(115200);
uint16 Status;
uint16 Data;

EEPROM.init();
EEPROM.PageBase0 = 0x801F000;
EEPROM.PageBase1 = 0x801F800;
EEPROM.PageSize = 0x400;

EEPROM.write(0, 1);

for (int i = 0; i < 255; i++)
{

Serial1.print( i);
Serial1.print( "= ");
Serial1.println( EEPROM.read(i));

}

}

void loop()
{
}


mrburnette
Sat Jan 13, 2018 5:11 pm
EEPROM emulation has been tested successfully:
viewtopic.php?t=1576#p20405

However, I personally have not tested.

AN2594 is the authority documentation.

However, I never recommend use of this technique; rather implementing external storage is easy.

http://stm32duino.com/viewtopic.php?f=13&p=39136
and
viewtopic.php?t=586#p6075

Here is the pertinent note on emulation:

3.4 Cycling capability
A program/erase cycle consists of one or more write accesses and one page erase
operation.
When the EEPROM technology is used, each byte can be programmed and erased a finite
number of times, typically in the range of 10 000 to 100 000.
However, in embedded Flash memory, the minimum erase size is the page and the number
of program/erase cycles applied to a page is the number of possible erase cycles. The
STM32F10xxx’s electrical characteristics guarantee 10 000 program/erase cycles per page.
The maximum lifetime of the emulated EEPROM is thereby limited by the update rate of the
most frequently written parameter.
The cycling capability is dependent of the amount/size of data that the user wants to handle.

Ray


alexandros
Sat Jan 13, 2018 5:17 pm
Thanks for the response ;)

I am sure everything is fine with my code, I can live with 10.000 limited read writes, the question is why if I power reboot the board the eeprom is empty


mrburnette
Sat Jan 13, 2018 5:32 pm
Maple Mini & clones are “medium density” devices as defined by ST.

Here is Roger’s take on the Blue Pill:
viewtopic.php?t=1576#p20754

As I have not played with the emulation, maybe one of our members has and can chime in. I would suggest you change Title to “Need Help with EEPROM Emulation.”

Ray


fpiSTM
Sat Jan 13, 2018 5:38 pm
One though, have you check the flash size of your board?
if you have only 64k it could not fit at 0x801F000

As mentioned in the topic provided by Ray:
For writing I use address 0x801F000 so that should be the “last” 4kB of the supposed 128kB flash on BP.


alexandros
Sat Jan 13, 2018 6:02 pm
128k

victor_pv
Sat Jan 13, 2018 9:56 pm
How are you uploading the sketch?
Is it possible that your upload method is erasing the whole memory at once?
Our bootloader should not do that, but if using the ROM bootloader, stlink or any other jtag probe, it’s possible that’s erasing all memory before writing rather than erase indivual pages.

alexandros
Sat Jan 13, 2018 10:00 pm
[victor_pv – Sat Jan 13, 2018 9:56 pm] –
How are you uploading the sketch?
Is it possible that your upload method is erasing the whole memory at once?
Our bootloader should not do that, but if using the ROM bootloader, stlink or any other jtag probe, it’s possible that’s erasing all memory before writing rather than erase indivual pages.

Yeap , i use st link


zmemw16
Sun Jan 14, 2018 12:52 am
excuse me people, if the documentation says the’declared size’ is XXk, then that is the size you need to work with.
if it went into a product, would you use 64k or 128k ?

it shouldn’t a) be done in first place :!: b) get past the first code review :!:
apols too much aircraft stuff.

more than 64k is happenstance, it could 68k, 72k, 76k or 96k or any 4k block boundary, but not less then 64k.
actually as you’re outside the spec it could be 85356 or any number over 64k and less than 128k or maybe not.

stephen


stevestrong
Sun Jan 14, 2018 9:19 am
Maybe the STLink will clear all the flash content by uploading?

Pito
Sun Jan 14, 2018 11:04 am
Run the sketch with writing to the EEPROM address 0 and then power it off, and then READ the memory with the STLink. You should see 0 there, I would guess. Then PROGRAM the sketch with writing to the EEPROM commented out, and then READ it with the STLink. You will see FF there most probably.

alexandros
Tue Jan 16, 2018 7:11 am
[Pito – Sun Jan 14, 2018 11:04 am] –
Run the sketch with writing to the EEPROM address 0 and then power it off, and then READ the memory with the STLink. You should see 0 there, I would guess. Then PROGRAM the sketch with writing to the EEPROM commented out, and then READ it with the STLink. You will see FF there most probably.

OK now i am very confused , Pito is that possible? , So can i use it to store some data or not? :(
Is it storing values as long as the program is alive? i dont get it, is there any other way except putting an eeprom external chip?


victor_pv
Wed Jan 17, 2018 7:51 pm
As pointed out before, the problem is most likely that you are wiping the whole flash when uploading with St-Link.

You must use a method that doesn’t wipe the whole flash (you can do so if using the ST_link GUI tool, has an option to select whether you want to completely erase the mcu or only the required pages). Our bootloader also only clear individual pages.
The ROM serial bootloader, as st-link can do it either way, you have to use the GUI to select what you want to do.


alexandros
Wed Jan 17, 2018 8:39 pm
Thanks for your replies guys

Actually i made it work.

When i used This


EEPROM.PageBase0 = 0x801F000;
EEPROM.PageBase1 = 0x801F800;
EEPROM.PageSize = 0x800;


Leave a Reply

Your email address will not be published. Required fields are marked *