Need Help with EEPROM Emulation

Post here first, or if you can't find a relevant section!
alexandros
Posts: 47
Joined: Mon Oct 02, 2017 6:51 pm

Need Help with EEPROM Emulation

Post by 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

Code: Select all

#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()
{
}
This gives me this result

0= 1
1= 65535
2= 65535
3= 65535
4= 65535
5= 65535
6= 65535
7= 65535
...............
254= 65535


If i upload the same code without this line
EEPROM.write(0, 1);

the result is

0= 65535
1= 65535
2= 65535
3= 65535
4= 65535
5= 65535
6= 65535
7= 65535
...............
254= 65535


is this possible?? it doesnt save it !!
Last edited by alexandros on Sat Jan 13, 2018 5:34 pm, edited 2 times in total.

User avatar
mrburnette
Posts: 2013
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: EEPROM

Post by 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
Posts: 47
Joined: Mon Oct 02, 2017 6:51 pm

Re: EEPROM

Post by 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

User avatar
mrburnette
Posts: 2013
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: EEPROM

Post by 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
Posts: 268
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: Need Help with EEPROM Emulation

Post by 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
Posts: 47
Joined: Mon Oct 02, 2017 6:51 pm

Re: Need Help with EEPROM Emulation

Post by alexandros » Sat Jan 13, 2018 6:02 pm

128k

victor_pv
Posts: 1781
Joined: Mon Apr 27, 2015 12:12 pm

Re: Need Help with EEPROM Emulation

Post by 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
Posts: 47
Joined: Mon Oct 02, 2017 6:51 pm

Re: Need Help with EEPROM Emulation

Post by alexandros » Sat Jan 13, 2018 10:00 pm

victor_pv wrote:
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
Posts: 1578
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Need Help with EEPROM Emulation

Post by 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
Posts: 1928
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: Need Help with EEPROM Emulation

Post by stevestrong » Sun Jan 14, 2018 9:19 am

Maybe the STLink will clear all the flash content by uploading?

Post Reply